Make shader ID validation optional by adding a gfx setting called "EnableShaderDebugging".
Setting this to True will enable additional checks if the shader cache misses any relevant register changes.
This commit is contained in:
parent
b28348066e
commit
5c14a24ce1
|
@ -96,6 +96,8 @@ void VideoConfig::Load(const char *ini_file)
|
||||||
iniFile.Get("Settings", "EnableOpenCL", &bEnableOpenCL, false);
|
iniFile.Get("Settings", "EnableOpenCL", &bEnableOpenCL, false);
|
||||||
iniFile.Get("Settings", "OMPDecoder", &bOMPDecoder, false);
|
iniFile.Get("Settings", "OMPDecoder", &bOMPDecoder, false);
|
||||||
|
|
||||||
|
iniFile.Get("Settings", "EnableShaderDebugging", &bEnableShaderDebugging, false);
|
||||||
|
|
||||||
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
|
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
|
||||||
iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 0); // NOTE - this is x in (1 << x)
|
iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 0); // NOTE - this is x in (1 << x)
|
||||||
iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, "");
|
iniFile.Get("Enhancements", "PostProcessingShader", &sPostProcessingShader, "");
|
||||||
|
@ -231,6 +233,8 @@ void VideoConfig::Save(const char *ini_file)
|
||||||
iniFile.Set("Settings", "EnableOpenCL", bEnableOpenCL);
|
iniFile.Set("Settings", "EnableOpenCL", bEnableOpenCL);
|
||||||
iniFile.Set("Settings", "OMPDecoder", bOMPDecoder);
|
iniFile.Set("Settings", "OMPDecoder", bOMPDecoder);
|
||||||
|
|
||||||
|
iniFile.Set("Settings", "EnableShaderDebugging", bEnableShaderDebugging);
|
||||||
|
|
||||||
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
|
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
|
||||||
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
|
iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy);
|
||||||
iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader);
|
iniFile.Set("Enhancements", "PostProcessingShader", sPostProcessingShader);
|
||||||
|
|
|
@ -147,6 +147,9 @@ struct VideoConfig
|
||||||
// D3D only config, mostly to be merged into the above
|
// D3D only config, mostly to be merged into the above
|
||||||
int iAdapter;
|
int iAdapter;
|
||||||
|
|
||||||
|
// Debugging
|
||||||
|
bool bEnableShaderDebugging;
|
||||||
|
|
||||||
// Static config per API
|
// Static config per API
|
||||||
// TODO: Move this out of VideoConfig
|
// TODO: Move this out of VideoConfig
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -499,7 +499,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||||
bool success = InsertByteCode(uid, pbytecode->Data(), pbytecode->Size());
|
bool success = InsertByteCode(uid, pbytecode->Data(), pbytecode->Size());
|
||||||
pbytecode->Release();
|
pbytecode->Release();
|
||||||
|
|
||||||
if (success)
|
if (g_ActiveConfig.bEnableShaderDebugging && success)
|
||||||
{
|
{
|
||||||
PixelShaders[uid].code = code;
|
PixelShaders[uid].code = code;
|
||||||
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, dstAlphaMode);
|
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, dstAlphaMode);
|
||||||
|
|
|
@ -240,7 +240,7 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||||
bool success = InsertByteCode(uid, pbytecode);
|
bool success = InsertByteCode(uid, pbytecode);
|
||||||
pbytecode->Release();
|
pbytecode->Release();
|
||||||
|
|
||||||
if (success)
|
if (g_ActiveConfig.bEnableShaderDebugging && success)
|
||||||
{
|
{
|
||||||
vshaders[uid].code = code;
|
vshaders[uid].code = code;
|
||||||
GetSafeVertexShaderId(&vshaders[uid].safe_uid, components);
|
GetSafeVertexShaderId(&vshaders[uid].safe_uid, components);
|
||||||
|
|
|
@ -359,9 +359,12 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||||
// Need to compile a new shader
|
// Need to compile a new shader
|
||||||
const char *code = GeneratePixelShaderCode(dstAlphaMode, ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF) < 3 ? API_D3D9_SM20 : API_D3D9_SM30, components);
|
const char *code = GeneratePixelShaderCode(dstAlphaMode, ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF) < 3 ? API_D3D9_SM20 : API_D3D9_SM30, components);
|
||||||
|
|
||||||
|
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||||
|
{
|
||||||
u32 code_hash = HashAdler32((const u8 *)code, strlen(code));
|
u32 code_hash = HashAdler32((const u8 *)code, strlen(code));
|
||||||
unique_shaders.insert(code_hash);
|
unique_shaders.insert(code_hash);
|
||||||
SETSTAT(stats.numUniquePixelShaders, unique_shaders.size());
|
SETSTAT(stats.numUniquePixelShaders, unique_shaders.size());
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
||||||
|
@ -388,7 +391,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||||
bool success = InsertByteCode(uid, bytecode, bytecodelen, true);
|
bool success = InsertByteCode(uid, bytecode, bytecodelen, true);
|
||||||
delete [] bytecode;
|
delete [] bytecode;
|
||||||
|
|
||||||
if (success)
|
if (g_ActiveConfig.bEnableShaderDebugging && success)
|
||||||
{
|
{
|
||||||
PixelShaders[uid].code = code;
|
PixelShaders[uid].code = code;
|
||||||
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, dstAlphaMode);
|
GetSafePixelShaderId(&PixelShaders[uid].safe_uid, dstAlphaMode);
|
||||||
|
|
|
@ -218,7 +218,7 @@ bool VertexShaderCache::SetShader(u32 components)
|
||||||
g_vs_disk_cache.Sync();
|
g_vs_disk_cache.Sync();
|
||||||
|
|
||||||
bool success = InsertByteCode(uid, bytecode, bytecodelen, true);
|
bool success = InsertByteCode(uid, bytecode, bytecodelen, true);
|
||||||
if (success)
|
if (g_ActiveConfig.bEnableShaderDebugging && success)
|
||||||
{
|
{
|
||||||
vshaders[uid].code = code;
|
vshaders[uid].code = code;
|
||||||
GetSafeVertexShaderId(&vshaders[uid].safe_uid, components);
|
GetSafeVertexShaderId(&vshaders[uid].safe_uid, components);
|
||||||
|
|
|
@ -190,7 +190,7 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
|
||||||
if (uid == last_pixel_shader_uid && PixelShaders[uid].frameCount == frameCount)
|
if (uid == last_pixel_shader_uid && PixelShaders[uid].frameCount == frameCount)
|
||||||
{
|
{
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
||||||
ValidatePixelShaderIDs(API_OPENGL, PixelShaders[uid].safe_uid, PixelShaders[uid].code, dstAlphaMode, components);
|
ValidatePixelShaderIDs(API_OPENGL, PixelShaders[uid].safe_uid, PixelShaders[uid].shader.strprog, dstAlphaMode, components);
|
||||||
return pShaderLast;
|
return pShaderLast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
|
||||||
pShaderLast = &entry.shader;
|
pShaderLast = &entry.shader;
|
||||||
|
|
||||||
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE, true);
|
||||||
ValidatePixelShaderIDs(API_OPENGL, entry.safe_uid, entry.code, dstAlphaMode, components);
|
ValidatePixelShaderIDs(API_OPENGL, entry.safe_uid, entry.shader.strprog, dstAlphaMode, components);
|
||||||
return pShaderLast;
|
return pShaderLast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +215,12 @@ FRAGMENTSHADER* PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 comp
|
||||||
newentry.frameCount = frameCount;
|
newentry.frameCount = frameCount;
|
||||||
pShaderLast = &newentry.shader;
|
pShaderLast = &newentry.shader;
|
||||||
const char *code = GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, components);
|
const char *code = GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, components);
|
||||||
|
|
||||||
|
if (g_ActiveConfig.bEnableShaderDebugging && code)
|
||||||
|
{
|
||||||
GetSafePixelShaderId(&newentry.safe_uid, dstAlphaMode);
|
GetSafePixelShaderId(&newentry.safe_uid, dstAlphaMode);
|
||||||
newentry.code = code;
|
newentry.shader.strprog = code;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
||||||
|
@ -320,9 +324,6 @@ bool PixelShaderCache::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpr
|
||||||
cgDestroyProgram(tempprog);
|
cgDestroyProgram(tempprog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
||||||
ps.strprog = pstrprogram;
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,7 @@ struct FRAGMENTSHADER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GLuint glprogid; // opengl program id
|
GLuint glprogid; // opengl program id
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
||||||
std::string strprog;
|
std::string strprog;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PixelShaderCache
|
class PixelShaderCache
|
||||||
|
@ -57,7 +55,6 @@ class PixelShaderCache
|
||||||
shader.Destroy();
|
shader.Destroy();
|
||||||
}
|
}
|
||||||
PIXELSHADERUIDSAFE safe_uid;
|
PIXELSHADERUIDSAFE safe_uid;
|
||||||
std::string code;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<PIXELSHADERUID, PSCacheEntry> PSCache;
|
typedef std::map<PIXELSHADERUID, PSCacheEntry> PSCache;
|
||||||
|
|
|
@ -100,6 +100,7 @@ VERTEXSHADER* VertexShaderCache::SetShader(u32 components)
|
||||||
entry.frameCount = frameCount;
|
entry.frameCount = frameCount;
|
||||||
pShaderLast = &entry.shader;
|
pShaderLast = &entry.shader;
|
||||||
const char *code = GenerateVertexShaderCode(components, API_OPENGL);
|
const char *code = GenerateVertexShaderCode(components, API_OPENGL);
|
||||||
|
GetSafeVertexShaderId(&entry.safe_uid, components);
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
|
||||||
|
@ -183,9 +184,8 @@ bool VertexShaderCache::CompileVertexShader(VERTEXSHADER& vs, const char* pstrpr
|
||||||
cgDestroyProgram(tempprog);
|
cgDestroyProgram(tempprog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#if defined(_DEBUG) || defined(DEBUGFAST)
|
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||||
vs.strprog = pstrprogram;
|
vs.strprog = pstrprogram;
|
||||||
//#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue