//////////////////////////////////////////////////////////////// // // CRenderItemManager::OnDeviceCreate // // // //////////////////////////////////////////////////////////////// void CRenderItemManager::OnDeviceCreate ( IDirect3DDevice9* pDevice, float fViewportSizeX, float fViewportSizeY ) { m_pDevice = pDevice; m_uiDefaultViewportSizeX = fViewportSizeX; m_uiDefaultViewportSizeY = fViewportSizeY; m_pRenderWare = CCore::GetSingleton ().GetGame ()->GetRenderWare (); // Get some stats m_strVideoCardName = (const char*)g_pDeviceState->AdapterState.Name; m_iVideoCardMemoryKBTotal = g_pDeviceState->AdapterState.InstalledMemoryKB; m_iVideoCardMemoryKBForMTATotal = ( m_iVideoCardMemoryKBTotal - ( 64 * 1024 ) ) * 4 / 5; m_iVideoCardMemoryKBForMTATotal = std::max ( 0, m_iVideoCardMemoryKBForMTATotal ); D3DCAPS9 caps; pDevice->GetDeviceCaps ( &caps ); int iMinor = caps.PixelShaderVersion & 0xFF; int iMajor = ( caps.PixelShaderVersion & 0xFF00 ) >> 8; m_strVideoCardPSVersion = SString ( "%d", iMajor ); if ( iMinor ) m_strVideoCardPSVersion += SString ( ".%d", iMinor ); UpdateMemoryUsage (); // Check if using SwiftShader dll SLibVersionInfo libVersionInfo; if ( GetLibVersionInfo( "d3d9.dll", &libVersionInfo ) ) { if ( libVersionInfo.strProductName.ContainsI( "Swift" ) ) m_bIsSwiftShader = true; } }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::OnResetDevice // // Recreate device stuff // //////////////////////////////////////////////////////////////// void CRenderItemManager::OnResetDevice ( void ) { for ( std::set < CRenderItem* >::iterator iter = m_CreatedItemList.begin () ; iter != m_CreatedItemList.end () ; iter++ ) (*iter)->OnResetDevice (); UpdateMemoryUsage (); }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::NotifyDestructRenderItem // // Remove from managers list // //////////////////////////////////////////////////////////////// void CRenderItemManager::NotifyDestructRenderItem(CRenderItem* pItem) { assert(MapContains(m_CreatedItemList, pItem)); MapRemove(m_CreatedItemList, pItem); if (CScreenSourceItem* pScreenSourceItem = DynamicCast<CScreenSourceItem>(pItem)) m_bBackBufferCopyMaybeNeedsResize = true; else if (CShaderItem* pShaderItem = DynamicCast<CShaderItem>(pItem)) RemoveShaderItemFromWatchLists(pShaderItem); UpdateMemoryUsage(); }
QmitkMemoryUsageIndicatorView::QmitkMemoryUsageIndicatorView(QWidget * /*parent*/, Qt::WindowFlags /*f*/) { this->setupUi(this); auto timer = new QTimer(this); QObject::connect(timer, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage())); timer->start(1000); m_LEDGreen = QPixmap(QmitkMemoryUsageIndicatorImagesGreen_xpm); m_LEDYellow = QPixmap(QmitkMemoryUsageIndicatorImagesYellow_xpm); m_LEDOrange = QPixmap(QmitkMemoryUsageIndicatorImagesOrange_xpm); m_LEDRed = QPixmap(QmitkMemoryUsageIndicatorImagesRed_xpm); m_LED->setPixmap(m_LEDGreen); m_PreviousState = 0; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateTexture // // TODO: Make underlying data for textures shared // //////////////////////////////////////////////////////////////// CTextureItem* CRenderItemManager::CreateTexture ( const SString& strFullFilePath, const CPixels* pPixels, bool bMipMaps, uint uiSizeX, uint uiSizeY, ERenderFormat format, ETextureAddress textureAddress, ETextureType textureType, uint uiVolumeDepth ) { CFileTextureItem* pTextureItem = new CFileTextureItem (); pTextureItem->PostConstruct ( this, strFullFilePath, pPixels, bMipMaps, uiSizeX, uiSizeY, format, textureAddress, textureType, uiVolumeDepth ); if ( !pTextureItem->IsValid () ) { SAFE_RELEASE ( pTextureItem ); return NULL; } UpdateMemoryUsage (); return pTextureItem; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateGuiFont // // TODO: Make underlying data for fonts shared // //////////////////////////////////////////////////////////////// CGuiFontItem* CRenderItemManager::CreateGuiFont ( const SString& strFullFilePath, const SString& strFontName, uint uiSize ) { if ( !CanCreateRenderItem ( CGuiFontItem::GetClassId () ) ) return NULL; CGuiFontItem* pGuiFontItem = new CGuiFontItem (); pGuiFontItem->PostConstruct ( this, strFullFilePath, strFontName, uiSize ); if ( !pGuiFontItem->IsValid () ) { SAFE_RELEASE ( pGuiFontItem ); return NULL; } UpdateMemoryUsage (); return pGuiFontItem; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateDxFont // // TODO: Make underlying data for fonts shared // //////////////////////////////////////////////////////////////// CDxFontItem* CRenderItemManager::CreateDxFont ( const SString& strFullFilePath, uint uiSize, bool bBold, DWORD ulQuality ) { if ( !CanCreateRenderItem ( CDxFontItem::GetClassId () ) ) return NULL; CDxFontItem* pDxFontItem = new CDxFontItem (); pDxFontItem->PostConstruct ( this, strFullFilePath, uiSize, bBold, ulQuality ); if ( !pDxFontItem->IsValid () ) { SAFE_RELEASE ( pDxFontItem ); return NULL; } UpdateMemoryUsage (); return pDxFontItem; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateWebBrowser // // // //////////////////////////////////////////////////////////////// CWebBrowserItem* CRenderItemManager::CreateWebBrowser ( uint uiSizeX, uint uiSizeY ) { if ( !CanCreateRenderItem ( CWebBrowserItem::GetClassId () ) ) return NULL; CWebBrowserItem* pWebBrowserItem = new CWebBrowserItem; pWebBrowserItem->PostConstruct ( this, uiSizeX, uiSizeY ); if ( !pWebBrowserItem->IsValid () ) { SAFE_RELEASE ( pWebBrowserItem ); return NULL; } UpdateMemoryUsage (); return pWebBrowserItem; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateScreenSource // // // //////////////////////////////////////////////////////////////// CScreenSourceItem* CRenderItemManager::CreateScreenSource ( uint uiSizeX, uint uiSizeY ) { if ( !CanCreateRenderItem ( CScreenSourceItem::GetClassId () ) ) return NULL; CScreenSourceItem* pScreenSourceItem = new CScreenSourceItem (); pScreenSourceItem->PostConstruct ( this, uiSizeX, uiSizeY ); if ( !pScreenSourceItem->IsValid () ) { SAFE_RELEASE ( pScreenSourceItem ); return NULL; } UpdateMemoryUsage (); return pScreenSourceItem; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateRenderTarget // // // //////////////////////////////////////////////////////////////// CRenderTargetItem* CRenderItemManager::CreateRenderTarget ( uint uiSizeX, uint uiSizeY, bool bWithAlphaChannel, bool bForce ) { if ( !bForce && !CanCreateRenderItem ( CRenderTargetItem::GetClassId () ) ) return NULL; CRenderTargetItem* pRenderTargetItem = new CRenderTargetItem (); pRenderTargetItem->PostConstruct ( this, uiSizeX, uiSizeY, bWithAlphaChannel ); if ( !pRenderTargetItem->IsValid () ) { SAFE_RELEASE ( pRenderTargetItem ); return NULL; } UpdateMemoryUsage (); return pRenderTargetItem; }
//////////////////////////////////////////////////////////////// // // CRenderItemManager::CreateRenderTarget // // // //////////////////////////////////////////////////////////////// CRenderTargetItem* CRenderItemManager::CreateRenderTarget ( uint uiSizeX, uint uiSizeY, bool bWithAlphaChannel, bool bForce ) { if ( !bForce && !CanCreateRenderItem ( CRenderTargetItem::GetClassId () ) ) return NULL; // Include in memory stats only if render target is not for MTA internal use bool bIncludeInMemoryStats = (bForce == false); CRenderTargetItem* pRenderTargetItem = new CRenderTargetItem (); pRenderTargetItem->PostConstruct ( this, uiSizeX, uiSizeY, bWithAlphaChannel, bIncludeInMemoryStats ); if ( !pRenderTargetItem->IsValid () ) { SAFE_RELEASE ( pRenderTargetItem ); return NULL; } UpdateMemoryUsage (); return pRenderTargetItem; }