diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp index a7200dd57e..4a7485fee9 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp @@ -70,34 +70,41 @@ bool PixelShaderCache::SetShader(bool dstAlpha) { iter->second.frameCount = frameCount; const PSCacheEntry &entry = iter->second; - D3D::dev->SetPixelShader(entry.shader); last_entry = &entry; DEBUGGER_PAUSE_COUNT_N(NEXT_PIXEL_SHADER_CHANGE); - return true; + + if (entry.shader) + { + D3D::dev->SetPixelShader(entry.shader); + return true; + } + else + return false; } const char *code = GeneratePixelShader(PixelShaderManager::GetTextureMask(), dstAlpha, true); LPDIRECT3DPIXELSHADER9 shader = D3D::CompilePixelShader(code, (int)strlen(code)); + // Make an entry in the table + PSCacheEntry newentry; + newentry.shader = shader; + newentry.frameCount = frameCount; +#if defined(_DEBUG) || defined(DEBUGFAST) + newentry.code = code; +#endif + PixelShaders[uid] = newentry; + last_entry = &PixelShaders[uid]; + + INCSTAT(stats.numPixelShadersCreated); + SETSTAT(stats.numPixelShadersAlive, (int)PixelShaders.size()); + if (shader) { - // Make an entry in the table - PSCacheEntry newentry; - newentry.shader = shader; - newentry.frameCount = frameCount; -#if defined(_DEBUG) || defined(DEBUGFAST) - newentry.code = code; -#endif - PixelShaders[uid] = newentry; - last_entry = &PixelShaders[uid]; - D3D::dev->SetPixelShader(shader); - - INCSTAT(stats.numPixelShadersCreated); - SETSTAT(stats.numPixelShadersAlive, (int)PixelShaders.size()); return true; } - else if (g_Config.bShowShaderErrors) + + if (g_Config.bShowShaderErrors) { PanicAlert("Failed to compile Pixel Shader:\n\n%s", code); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp index 798403b513..93adfb8e25 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp @@ -70,34 +70,39 @@ bool VertexShaderCache::SetShader(u32 components) { iter->second.frameCount = frameCount; const VSCacheEntry &entry = iter->second; - D3D::dev->SetVertexShader(entry.shader); last_entry = &entry; + DEBUGGER_PAUSE_COUNT_N(NEXT_VERTEX_SHADER_CHANGE); - return true; + if (entry.shader) + { + D3D::dev->SetVertexShader(entry.shader); + return true; + } + else + return false; } const char *code = GenerateVertexShader(components, true); LPDIRECT3DVERTEXSHADER9 shader = D3D::CompileVertexShader(code, (int)strlen(code)); + // Make an entry in the table + VSCacheEntry entry; + entry.shader = shader; + entry.frameCount = frameCount; +#if defined(_DEBUG) || defined(DEBUGFAST) + entry.code = code; +#endif + vshaders[uid] = entry; + last_entry = &vshaders[uid]; + INCSTAT(stats.numVertexShadersCreated); + SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size()); if (shader) { - // Make an entry in the table - VSCacheEntry entry; - entry.shader = shader; - entry.frameCount = frameCount; -#if defined(_DEBUG) || defined(DEBUGFAST) - entry.code = code; -#endif - vshaders[uid] = entry; - last_entry = &vshaders[uid]; - D3D::dev->SetVertexShader(shader); - - INCSTAT(stats.numVertexShadersCreated); - SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size()); return true; } - else if (g_Config.bShowShaderErrors) + + if (g_Config.bShowShaderErrors) { PanicAlert("Failed to compile Vertex Shader:\n\n%s", code); }