From 231c13d6cec11c1326ab21f567ab6a58a521043d Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sun, 4 Sep 2011 00:47:45 +0200 Subject: [PATCH] Added safe vertex shader UIDs for debugging purposes. --- .../Core/VideoCommon/Src/VertexShaderGen.cpp | 21 +++++++++++++++++++ Source/Core/VideoCommon/Src/VertexShaderGen.h | 21 ++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index 7a1d5eb555..d15cef0c70 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -69,6 +69,27 @@ void GetVertexShaderId(VERTEXSHADERUID *uid, u32 components) } } +void GetSafeVertexShaderId(VERTEXSHADERUIDSAFE *uid, u32 components) +{ + // Just store all used registers here without caring whether we need all bits or less. + u32* ptr = uid->values; + *ptr++ = components; + *ptr++ = xfregs.numTexGen.hex; + *ptr++ = xfregs.numChan.hex; + *ptr++ = xfregs.dualTexTrans.hex; + + for (int i = 0; i < 2; ++i) { + *ptr++ = xfregs.color[i].hex; + *ptr++ = xfregs.alpha[i].hex; + } + *ptr++ = g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting; + for (unsigned int i = 0; i < 8; ++i) { + *ptr++ = xfregs.texMtxInfo[i].hex; + *ptr++ = xfregs.postMtxInfo[i].hex; + } + _assert_((ptr - uid->values) == uid->GetNumValues()); +} + static char text[16384]; #define WRITE p+=sprintf diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h index d7bf362213..50e9c5fc3b 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.h +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h @@ -48,17 +48,19 @@ #define C_DEPTHPARAMS (C_POSTTRANSFORMMATRICES + 64) #define C_VENVCONST_END (C_DEPTHPARAMS + 4) -class VERTEXSHADERUID +template +class _VERTEXSHADERUID { +#define NUM_VSUID_VALUES_SAFE 25 public: - u32 values[9]; + u32 values[safe ? NUM_VSUID_VALUES_SAFE : 9]; - VERTEXSHADERUID() + _VERTEXSHADERUID() { memset(values, 0, sizeof(values)); } - VERTEXSHADERUID(const VERTEXSHADERUID& r) + _VERTEXSHADERUID(const _VERTEXSHADERUID& r) { for (size_t i = 0; i < sizeof(values) / sizeof(u32); ++i) values[i] = r.values[i]; @@ -66,10 +68,11 @@ public: int GetNumValues() const { - return (((values[0] >> 23) & 0xf) * 3 + 3) / 4 + 3; // numTexGens*3/4+1 + if (safe) return NUM_VSUID_VALUES_SAFE; + else return (((values[0] >> 23) & 0xf) * 3 + 3) / 4 + 3; // numTexGens*3/4+1 } - bool operator <(const VERTEXSHADERUID& _Right) const + bool operator <(const _VERTEXSHADERUID& _Right) const { if (values[0] < _Right.values[0]) return true; @@ -86,7 +89,7 @@ public: return false; } - bool operator ==(const VERTEXSHADERUID& _Right) const + bool operator ==(const _VERTEXSHADERUID& _Right) const { if (values[0] != _Right.values[0]) return false; @@ -99,13 +102,15 @@ public: return true; } }; - +typedef _VERTEXSHADERUID VERTEXSHADERUID; +typedef _VERTEXSHADERUID VERTEXSHADERUIDSAFE; // components is included in the uid. char* GenerateVSOutputStruct(char* p, u32 components, API_TYPE api_type); const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type); void GetVertexShaderId(VERTEXSHADERUID *uid, u32 components); +void GetSafeVertexShaderId(VERTEXSHADERUIDSAFE *uid, u32 components); extern VERTEXSHADERUID last_vertex_shader_uid;