Added safe pixel shader UIDs for debugging purposes.
This commit is contained in:
parent
231c13d6ce
commit
4702de591e
|
@ -164,7 +164,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode)
|
|||
}
|
||||
|
||||
u32* ptr = &uid->values[2];
|
||||
for (unsigned int i = 0; i < bpmem.genMode.numtevstages+1; ++i)
|
||||
for (int i = 0; i < bpmem.genMode.numtevstages+1; ++i)
|
||||
{
|
||||
StageHash(i, ptr);
|
||||
ptr += 4; // max: ptr = &uid->values[66]
|
||||
|
@ -315,6 +315,46 @@ void _GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode)
|
|||
|
||||
}
|
||||
|
||||
void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode)
|
||||
{
|
||||
u32* ptr = uid->values;
|
||||
*ptr++ = dstAlphaMode;
|
||||
*ptr++ = bpmem.genMode.hex;
|
||||
*ptr++ = bpmem.ztex2.hex;
|
||||
*ptr++ = bpmem.zcontrol.hex;
|
||||
*ptr++ = bpmem.zmode.hex;
|
||||
*ptr++ = g_ActiveConfig.bEnablePerPixelDepth;
|
||||
*ptr++ = g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting;
|
||||
*ptr++ = xfregs.numTexGen.hex;
|
||||
|
||||
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
|
||||
{
|
||||
// TODO: Include register states for lighting shader
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i)
|
||||
*ptr++ = xfregs.texMtxInfo[i].hex;
|
||||
|
||||
for (unsigned int i = 0; i < 16; ++i)
|
||||
*ptr++ = bpmem.tevind[i].hex;
|
||||
|
||||
*ptr++ = bpmem.tevindref.hex;
|
||||
|
||||
for (int i = 0; i < bpmem.genMode.numtevstages+1; ++i)
|
||||
{
|
||||
// TODO ...
|
||||
StageHash(i, ptr);
|
||||
ptr += 4; // max: ptr = &uid->values[66]
|
||||
}
|
||||
|
||||
*ptr++ = bpmem.fog.c_proj_fsel.hex;
|
||||
|
||||
*ptr++ = bpmem.fogRange.Base.hex;
|
||||
|
||||
_assert_((ptr - uid->values) == uid->GetNumValues());
|
||||
}
|
||||
|
||||
|
||||
// old tev->pixelshader notes
|
||||
//
|
||||
// color for this stage (alpha, color) is given by bpmem.tevorders[0].colorchan0
|
||||
|
@ -539,8 +579,8 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
|||
|
||||
char *p = text;
|
||||
WRITE(p, "//Pixel Shader for TEV stages\n");
|
||||
WRITE(p, "//%i TEV stages, %i texgens, %i IND stages\n",
|
||||
numStages, numTexgen, bpmem.genMode.numindstages);
|
||||
WRITE(p, "//%i TEV stages, %i texgens, XXX IND stages\n",
|
||||
numStages, numTexgen/*, bpmem.genMode.numindstages*/);
|
||||
|
||||
int nIndirectStagesUsed = 0;
|
||||
if (bpmem.genMode.numindstages > 0)
|
||||
|
@ -876,7 +916,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
|
||||
if (bHasIndStage)
|
||||
{
|
||||
WRITE(p, "// indirect op\n", n);
|
||||
WRITE(p, "// indirect op\n");
|
||||
// perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords
|
||||
if (bpmem.tevind[n].bs != ITBA_OFF)
|
||||
{
|
||||
|
@ -1026,7 +1066,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
WRITE(p, "cc2 = frac(c2 * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
|
||||
|
||||
WRITE(p, "// color combine\n", n);
|
||||
WRITE(p, "// color combine\n");
|
||||
if (cc.clamp)
|
||||
WRITE(p, "%s = saturate(", tevCOutputTable[cc.dest]);
|
||||
else
|
||||
|
@ -1073,7 +1113,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
WRITE(p, ")");
|
||||
WRITE(p,";\n");
|
||||
|
||||
WRITE(p, "// alpha combine\n", n);
|
||||
WRITE(p, "// alpha combine\n");
|
||||
// combine the alpha channel
|
||||
if (ac.clamp)
|
||||
WRITE(p, "%s = saturate(", tevAOutputTable[ac.dest]);
|
||||
|
@ -1119,7 +1159,7 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
if (ac.clamp)
|
||||
WRITE(p, ")");
|
||||
WRITE(p, ";\n\n");
|
||||
WRITE(p, "// TEV done\n", n);
|
||||
WRITE(p, "// TEV done\n");
|
||||
}
|
||||
|
||||
void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, API_TYPE ApiType)
|
||||
|
|
|
@ -45,36 +45,39 @@
|
|||
#define C_PMATERIALS (C_PLIGHTS + 40)
|
||||
#define C_PENVCONST_END (C_PMATERIALS + 4)
|
||||
#define PIXELSHADERUID_MAX_VALUES 67
|
||||
#define PIXELSHADERUID_MAX_VALUES_SAFE 100
|
||||
|
||||
// DO NOT make anything in this class virtual.
|
||||
class PIXELSHADERUID
|
||||
template<bool safe>
|
||||
class _PIXELSHADERUID
|
||||
{
|
||||
public:
|
||||
u32 values[PIXELSHADERUID_MAX_VALUES];
|
||||
u32 values[safe ? PIXELSHADERUID_MAX_VALUES_SAFE : PIXELSHADERUID_MAX_VALUES];
|
||||
u16 tevstages, indstages;
|
||||
|
||||
PIXELSHADERUID()
|
||||
_PIXELSHADERUID()
|
||||
{
|
||||
memset(values, 0, PIXELSHADERUID_MAX_VALUES * 4);
|
||||
memset(values, 0, sizeof(values));
|
||||
tevstages = indstages = 0;
|
||||
}
|
||||
|
||||
PIXELSHADERUID(const PIXELSHADERUID& r)
|
||||
_PIXELSHADERUID(const _PIXELSHADERUID& r)
|
||||
{
|
||||
tevstages = r.tevstages;
|
||||
indstages = r.indstages;
|
||||
int N = GetNumValues();
|
||||
_assert_(N <= PIXELSHADERUID_MAX_VALUES);
|
||||
_assert_(N <= GetNumValues());
|
||||
for (int i = 0; i < N; ++i)
|
||||
values[i] = r.values[i];
|
||||
}
|
||||
|
||||
int GetNumValues() const
|
||||
{
|
||||
return tevstages;
|
||||
if (safe) return (sizeof(values) / sizeof(u32));
|
||||
else return tevstages;
|
||||
}
|
||||
|
||||
bool operator <(const PIXELSHADERUID& _Right) const
|
||||
bool operator <(const _PIXELSHADERUID& _Right) const
|
||||
{
|
||||
if (values[0] < _Right.values[0])
|
||||
return true;
|
||||
|
@ -91,7 +94,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
bool operator ==(const PIXELSHADERUID& _Right) const
|
||||
bool operator ==(const _PIXELSHADERUID& _Right) const
|
||||
{
|
||||
if (values[0] != _Right.values[0])
|
||||
return false;
|
||||
|
@ -104,6 +107,8 @@ public:
|
|||
return true;
|
||||
}
|
||||
};
|
||||
typedef _PIXELSHADERUID<false> PIXELSHADERUID;
|
||||
typedef _PIXELSHADERUID<true> PIXELSHADERUIDSAFE;
|
||||
|
||||
// Different ways to achieve rendering with destination alpha
|
||||
enum DSTALPHA_MODE
|
||||
|
@ -115,6 +120,7 @@ enum DSTALPHA_MODE
|
|||
|
||||
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components);
|
||||
void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode);
|
||||
void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode);
|
||||
|
||||
extern PIXELSHADERUID last_pixel_shader_uid;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
_VERTEXSHADERUID()
|
||||
{
|
||||
memset(values, 0, sizeof(values));
|
||||
memset(values, 0, sizeof(values));
|
||||
}
|
||||
|
||||
_VERTEXSHADERUID(const _VERTEXSHADERUID& r)
|
||||
|
|
Loading…
Reference in New Issue