mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-08 11:37:53 +03:00
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
2 changed files with 44 additions and 32 deletions
|
@ -70,34 +70,41 @@ 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);
|
||||||
return true;
|
|
||||||
|
if (entry.shader)
|
||||||
|
{
|
||||||
|
D3D::dev->SetPixelShader(entry.shader);
|
||||||
|
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));
|
||||||
|
|
||||||
|
// 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)
|
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);
|
D3D::dev->SetPixelShader(shader);
|
||||||
|
|
||||||
INCSTAT(stats.numPixelShadersCreated);
|
|
||||||
SETSTAT(stats.numPixelShadersAlive, (int)PixelShaders.size());
|
|
||||||
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,34 +70,39 @@ 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);
|
||||||
return true;
|
if (entry.shader)
|
||||||
|
{
|
||||||
|
D3D::dev->SetVertexShader(entry.shader);
|
||||||
|
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));
|
||||||
|
|
||||||
|
// 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)
|
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);
|
D3D::dev->SetVertexShader(shader);
|
||||||
|
|
||||||
INCSTAT(stats.numVertexShadersCreated);
|
|
||||||
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
|
||||||
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…
Add table
Add a link
Reference in a new issue