Added safe vertex shader UIDs for debugging purposes.

This commit is contained in:
NeoBrainX 2011-09-04 00:47:45 +02:00
parent bcb8d11c1b
commit 231c13d6ce
2 changed files with 34 additions and 8 deletions

View File

@ -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

View File

@ -48,17 +48,19 @@
#define C_DEPTHPARAMS (C_POSTTRANSFORMMATRICES + 64)
#define C_VENVCONST_END (C_DEPTHPARAMS + 4)
class VERTEXSHADERUID
template<bool safe>
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<false> VERTEXSHADERUID;
typedef _VERTEXSHADERUID<true> 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;