def SupportsHigherShaderModel(): shaderModel = trinity.GetShaderModel() maxSupported = trinity.GetMaxShaderModelSupported() if shaderModel == 'SM_2_0_LO' and maxSupported.startswith('SM_3'): return True return False
def SetDevice(self, device, tryAgain=1, fallback=0, keepSettings=1, hideTitle=None, userModified=False, muteExceptions=False, updateWindowPosition=True): if hideTitle is None: hideTitle = not device.Windowed self.LogInfo('SetDevice: tryAgain', tryAgain, 'fallback', fallback, 'keepSettings', keepSettings, 'hideTitle', hideTitle, 'deviceDict', device.__dict__) if not fallback: device = self.EnforceDeviceSettings(device) self.SanitizeDeviceTypes(device) change = self.CheckDeviceDifference(device, getChange=1) dev = trinity.device if not change and tryAgain and dev.DoesD3DDeviceExist(): return True sm.ChainEvent('ProcessDeviceChange') pr = [] for k, v in device.__dict__.items(): pr.append((k, v)) pr.sort() msg = 'SetDevice: Found a difference\n' for k, v in pr: extra = '' if k in change: extra = ' >> this one changed, it was ' + str(change[k][0]) msg += ' ' + str(k) + ': ' + str(v) + extra + '\n' self.LogInfo(msg) triapp = trinity.app if tryAgain: self.BackupSettings() try: triapp.hideTitle = hideTitle triapp.AdjustWindowForChange( device.Windowed, settings.public.device.Get('FixedWindow', False)) msg = 'SetDevice - trying again\n' msg += 'Before:\n' msg += repr(device.__dict__) + '\n' if device.Adapter not in self.adapters: device.Adapter = self.adapters[0] device.__dict__.update( self.FixupPresentation(device.Adapter, device.__dict__)) msg += 'After:\n' msg += repr(device.__dict__) + '\n' self.LogInfo(msg) dev = trinity.device dev.viewport.width = device.BackBufferWidth dev.viewport.height = device.BackBufferHeight while True: try: triapp.ChangeDevice(device.Adapter, 0, 0, device.__dict__) break except trinity.D3DERR_DEVICELOST: blue.pyos.synchro.SleepWallclock(1000) except Exception as e: import traceback self.LogInfo(traceback.format_exc()) self.LogInfo(repr(device.__dict__)) if trinity.device.GetRenderingPlatformID() == 2: if prefs.HasKey('trinityPreferredPlatform') and prefs.GetValue( 'trinityPreferredPlatform') == 'dx11': prefs.SetValue('trinityPreferredPlatform', 'dx9') log.Quit( 'Failed to create device under DX11 - setting preferred platform to DX9' ) else: log.Quit('Failed to create device under DX11') if tryAgain and self.settingsBackup: sys.exc_clear() self.LogInfo( 'SetDevice failed, trying again with backup settings') return self.SetDevice(self.settingsBackup, 0, keepSettings=keepSettings) if not fallback: sys.exc_clear() self.LogInfo( 'SetDevice with backup settings failed, falling back to savemode' ) set = self.GetSaveMode() return self.SetDevice(set, fallback=1, tryAgain=0, hideTitle=not set.Windowed, keepSettings=False) if muteExceptions: log.LogException() sys.exc_clear() self.LogInfo('SetDevice failed completely') return False if updateWindowPosition: self.UpdateWindowPosition(device) else: wr = triapp.GetWindowRect() triapp.SetWindowPos(wr.left, wr.top) sm.ScatterEvent('OnSetDevice') if uicore.desktop: uicore.desktop.UpdateSize() if keepSettings: set = self.GetSettings() keep = set.__dict__ del keep['hDeviceWindow'] gfxsettings.Set(gfxsettings.GFX_DEVICE_SETTINGS, keep, pending=False) self.settings.SaveSettings() self.LogInfo('Keeping device settings:', repr(keep)) if self.IsWindowed(set): val = (set.BackBufferWidth, set.BackBufferHeight) gfxsettings.Set(gfxsettings.GFX_RESOLUTION_WINDOWED, val, pending=False) else: val = (set.BackBufferWidth, set.BackBufferHeight) gfxsettings.Set(gfxsettings.GFX_RESOLUTION_FULLSCREEN, val, pending=False) if userModified and self.resolutionBackup and self.resolutionBackup != val: self.AskForConfirmation() sm.ScatterEvent('OnEndChangeDevice', change) unsupportedModels = ['SM_1_1', 'SM_2_0_LO', 'SM_2_0_HI'] maxCardModel = trinity.GetMaxShaderModelSupported() if maxCardModel in unsupportedModels: message = localization.GetByLabel( '/Carbon/UI/Service/Device/ShaderModelNotSupportedMessage') title = localization.GetByLabel( '/Carbon/UI/Service/Device/ShaderModelNotSupportedTitle') blue.os.ShowErrorMessageBox(title, message) bluepy.Terminate('Shader Model version check failed') return True
def GetDefaultDepthEffectsEnabled(self): return trinity.renderJobUtils.DeviceSupportsIntZ( ) and not trinity.GetMaxShaderModelSupported().startswith('SM_2')