Some shader manager changes, to avoid a shader be re-generated / re-compiled again, and again, if it is failed at the first time. There used to be cases that a vertex shader was failed, and Dolphin tried to generate/compile it forever, and caused the entire game slow down. It maybe not the case anymore after recent changes.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4175 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
rice1964 2009-09-03 02:21:14 +00:00
parent 99d7bf724d
commit 47a16da49a
2 changed files with 44 additions and 32 deletions

View File

@ -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);
}

View File

@ -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);
}