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:
parent
99d7bf724d
commit
47a16da49a
|
@ -70,17 +70,21 @@ bool PixelShaderCache::SetShader(bool dstAlpha)
|
||||||
{
|
{
|
||||||
iter->second.frameCount = frameCount;
|
iter->second.frameCount = frameCount;
|
||||||
const PSCacheEntry &entry = iter->second;
|
const PSCacheEntry &entry = iter->second;
|
||||||
D3D::dev->SetPixelShader(entry.shader);
|
|
||||||
last_entry = &entry;
|
last_entry = &entry;
|
||||||
DEBUGGER_PAUSE_COUNT_N(NEXT_PIXEL_SHADER_CHANGE);
|
DEBUGGER_PAUSE_COUNT_N(NEXT_PIXEL_SHADER_CHANGE);
|
||||||
|
|
||||||
|
if (entry.shader)
|
||||||
|
{
|
||||||
|
D3D::dev->SetPixelShader(entry.shader);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const char *code = GeneratePixelShader(PixelShaderManager::GetTextureMask(), dstAlpha, true);
|
const char *code = GeneratePixelShader(PixelShaderManager::GetTextureMask(), dstAlpha, true);
|
||||||
LPDIRECT3DPIXELSHADER9 shader = D3D::CompilePixelShader(code, (int)strlen(code));
|
LPDIRECT3DPIXELSHADER9 shader = D3D::CompilePixelShader(code, (int)strlen(code));
|
||||||
|
|
||||||
if (shader)
|
|
||||||
{
|
|
||||||
// Make an entry in the table
|
// Make an entry in the table
|
||||||
PSCacheEntry newentry;
|
PSCacheEntry newentry;
|
||||||
newentry.shader = shader;
|
newentry.shader = shader;
|
||||||
|
@ -91,13 +95,16 @@ bool PixelShaderCache::SetShader(bool dstAlpha)
|
||||||
PixelShaders[uid] = newentry;
|
PixelShaders[uid] = newentry;
|
||||||
last_entry = &PixelShaders[uid];
|
last_entry = &PixelShaders[uid];
|
||||||
|
|
||||||
D3D::dev->SetPixelShader(shader);
|
|
||||||
|
|
||||||
INCSTAT(stats.numPixelShadersCreated);
|
INCSTAT(stats.numPixelShadersCreated);
|
||||||
SETSTAT(stats.numPixelShadersAlive, (int)PixelShaders.size());
|
SETSTAT(stats.numPixelShadersAlive, (int)PixelShaders.size());
|
||||||
|
|
||||||
|
if (shader)
|
||||||
|
{
|
||||||
|
D3D::dev->SetPixelShader(shader);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (g_Config.bShowShaderErrors)
|
|
||||||
|
if (g_Config.bShowShaderErrors)
|
||||||
{
|
{
|
||||||
PanicAlert("Failed to compile Pixel Shader:\n\n%s", code);
|
PanicAlert("Failed to compile Pixel Shader:\n\n%s", code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,17 +70,21 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||||
{
|
{
|
||||||
iter->second.frameCount = frameCount;
|
iter->second.frameCount = frameCount;
|
||||||
const VSCacheEntry &entry = iter->second;
|
const VSCacheEntry &entry = iter->second;
|
||||||
D3D::dev->SetVertexShader(entry.shader);
|
|
||||||
last_entry = &entry;
|
last_entry = &entry;
|
||||||
|
|
||||||
DEBUGGER_PAUSE_COUNT_N(NEXT_VERTEX_SHADER_CHANGE);
|
DEBUGGER_PAUSE_COUNT_N(NEXT_VERTEX_SHADER_CHANGE);
|
||||||
|
if (entry.shader)
|
||||||
|
{
|
||||||
|
D3D::dev->SetVertexShader(entry.shader);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const char *code = GenerateVertexShader(components, true);
|
const char *code = GenerateVertexShader(components, true);
|
||||||
LPDIRECT3DVERTEXSHADER9 shader = D3D::CompileVertexShader(code, (int)strlen(code));
|
LPDIRECT3DVERTEXSHADER9 shader = D3D::CompileVertexShader(code, (int)strlen(code));
|
||||||
|
|
||||||
if (shader)
|
|
||||||
{
|
|
||||||
// Make an entry in the table
|
// Make an entry in the table
|
||||||
VSCacheEntry entry;
|
VSCacheEntry entry;
|
||||||
entry.shader = shader;
|
entry.shader = shader;
|
||||||
|
@ -90,14 +94,15 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||||
#endif
|
#endif
|
||||||
vshaders[uid] = entry;
|
vshaders[uid] = entry;
|
||||||
last_entry = &vshaders[uid];
|
last_entry = &vshaders[uid];
|
||||||
|
|
||||||
D3D::dev->SetVertexShader(shader);
|
|
||||||
|
|
||||||
INCSTAT(stats.numVertexShadersCreated);
|
INCSTAT(stats.numVertexShadersCreated);
|
||||||
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
||||||
|
if (shader)
|
||||||
|
{
|
||||||
|
D3D::dev->SetVertexShader(shader);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (g_Config.bShowShaderErrors)
|
|
||||||
|
if (g_Config.bShowShaderErrors)
|
||||||
{
|
{
|
||||||
PanicAlert("Failed to compile Vertex Shader:\n\n%s", code);
|
PanicAlert("Failed to compile Vertex Shader:\n\n%s", code);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue