mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Improve the shader UID debugging stuff and merge it to VideoCommon, effectively enabling it in D3D9 and D3D11 as well.
This commit is contained in:
@ -184,30 +184,13 @@ void PixelShaderCache::Shutdown()
|
||||
FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||
{
|
||||
PIXELSHADERUID uid;
|
||||
PIXELSHADERUIDSAFE safe_uid;
|
||||
GetPixelShaderId(&uid, dstAlphaMode);
|
||||
GetSafePixelShaderId(&safe_uid, dstAlphaMode);
|
||||
|
||||
|
||||
// Check if the shader is already set - TODO: Use pShaderLast instead of PixelShaders[uid]?
|
||||
if (uid == last_pixel_shader_uid && PixelShaders[uid].frameCount == frameCount)
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
||||
|
||||
if (!(safe_uid == PixelShaders[uid].safe_uid))
|
||||
{
|
||||
std::string code(GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, components));
|
||||
if (code != PixelShaders[uid].code)
|
||||
{
|
||||
char msg[4096];
|
||||
char* ptr = msg;
|
||||
ptr += sprintf(ptr, "Mismatch!\nUnique IDs:\n");
|
||||
for (int i = 0; i < PixelShaders[uid].safe_uid.GetNumValues()/2; ++i)
|
||||
ptr += sprintf(ptr, "%02d, %08X %08X | %08X %08X\n", 2*i, PixelShaders[uid].safe_uid.values[2*i], PixelShaders[uid].safe_uid.values[2*i+1],
|
||||
safe_uid.values[2*i], safe_uid.values[2*i+1]);
|
||||
PanicAlert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
ValidatePixelShaderIDs(API_OPENGL, PixelShaders[uid].safe_uid, PixelShaders[uid].code, dstAlphaMode, components);
|
||||
return pShaderLast;
|
||||
}
|
||||
|
||||
@ -220,35 +203,19 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
|
||||
iter->second.frameCount = frameCount;
|
||||
PSCacheEntry &entry = iter->second;
|
||||
if (&entry.shader != pShaderLast)
|
||||
{
|
||||
pShaderLast = &entry.shader;
|
||||
}
|
||||
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
||||
if (!(safe_uid == entry.safe_uid))
|
||||
{
|
||||
std::string code(GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, components));
|
||||
if (code != entry.code)
|
||||
{
|
||||
char msg[4096];
|
||||
char *ptr = msg;
|
||||
ptr += sprintf(ptr, "Mismatch!\nUnique IDs:\n");
|
||||
for (int i = 0; i < entry.safe_uid.GetNumValues()/2; ++i)
|
||||
ptr += sprintf(ptr, "%02d\t%08X %08X | %08X %08X\n", 2*i, entry.safe_uid.values[2*i], entry.safe_uid.values[2*i+1],
|
||||
safe_uid.values[2*i], safe_uid.values[2*i+1]);
|
||||
PanicAlert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
ValidatePixelShaderIDs(API_OPENGL, entry.safe_uid, entry.code, dstAlphaMode, components);
|
||||
return pShaderLast;
|
||||
}
|
||||
|
||||
// Make an entry in the table
|
||||
PSCacheEntry& newentry = PixelShaders[uid];
|
||||
newentry.frameCount = frameCount;
|
||||
newentry.safe_uid = safe_uid;
|
||||
pShaderLast = &newentry.shader;
|
||||
const char *code = GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, components);
|
||||
GetSafePixelShaderId(&newentry.safe_uid, dstAlphaMode);
|
||||
newentry.code = code;
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
|
@ -77,6 +77,7 @@ VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
|
||||
if (uid == last_vertex_shader_uid && vshaders[uid].frameCount == frameCount)
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_VERTEX_SHADER_CHANGE, true);
|
||||
ValidateVertexShaderIDs(API_OPENGL, vshaders[uid].safe_uid, vshaders[uid].shader.strprog, components);
|
||||
return pShaderLast;
|
||||
}
|
||||
memcpy(&last_vertex_shader_uid, &uid, sizeof(VERTEXSHADERUID));
|
||||
@ -86,11 +87,11 @@ VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
|
||||
{
|
||||
iter->second.frameCount = frameCount;
|
||||
VSCacheEntry &entry = iter->second;
|
||||
if (&entry.shader != pShaderLast) {
|
||||
if (&entry.shader != pShaderLast)
|
||||
pShaderLast = &entry.shader;
|
||||
}
|
||||
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_VERTEX_SHADER_CHANGE, true);
|
||||
ValidateVertexShaderIDs(API_OPENGL, entry.safe_uid, entry.shader.strprog, components);
|
||||
return pShaderLast;
|
||||
}
|
||||
|
||||
@ -182,9 +183,9 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
||||
cgDestroyProgram(tempprog);
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
//#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
vs.strprog = pstrprogram;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ struct VERTEXSHADER
|
||||
VERTEXSHADER() : glprogid(0) {}
|
||||
GLuint glprogid; // opengl program id
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
//#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
std::string strprog;
|
||||
#endif
|
||||
//#endif
|
||||
};
|
||||
|
||||
class VertexShaderCache
|
||||
@ -42,6 +42,7 @@ class VertexShaderCache
|
||||
struct VSCacheEntry
|
||||
{
|
||||
VERTEXSHADER shader;
|
||||
VERTEXSHADERUIDSAFE safe_uid;
|
||||
int frameCount;
|
||||
VSCacheEntry() : frameCount(0) {}
|
||||
void Destroy() {
|
||||
|
Reference in New Issue
Block a user