//-------------------------------------------------------------------------------------- // Name: SetVertexShader() // Desc: Overloaded function to avoid redundant calls to D3D //-------------------------------------------------------------------------------------- D3DVOID WINAPI D3DDevice::SetVertexShader( D3DVertexShader* pShader ) { static D3DVertexShader* g_pShader = NULL; // Synchronize with current D3D device state, to catch subsystems that do not go // through this codepath D3DVertexShader* pCurrentVS = NULL; D3DDevice_GetVertexShader( this, &pCurrentVS ); g_pShader = pCurrentVS; if( pCurrentVS != NULL ) pCurrentVS->Release(); // Only update shader if it has changed if( g_pShader != pShader ) { D3DDevice_SetVertexShader( this, pShader ); g_pShader = pShader; } D3DVOIDRETURN; }
Burger::Effect::~Effect() { D3DPixelShader *pPixelShader = m_pPixelShader; if (pPixelShader != NULL) { IDirect3DDevice9 *pDevice; pPixelShader->GetDevice(&pDevice); if (pDevice) { pDevice->SetPixelShader(0); } pPixelShader->Release(); m_pPixelShader = NULL; } D3DVertexShader *pVertexShader = m_pVertexShader; if (pVertexShader != NULL) { IDirect3DDevice9 *pDevice; pVertexShader->GetDevice(&pDevice); if (pDevice) { pDevice->SetVertexShader(0); } pVertexShader->Release(); m_pVertexShader = NULL; } }