PixelShaderGen: Some cleanups.

This commit is contained in:
NeoBrainX 2013-03-29 20:59:03 +01:00
parent 3c02f227db
commit 9eccd56ef0
3 changed files with 26 additions and 27 deletions

View File

@ -157,6 +157,11 @@
#define TEVALPHAARG_KONST 6
#define TEVALPHAARG_ZERO 7
#define GX_TEVPREV 0
#define GX_TEVREG0 1
#define GX_TEVREG1 2
#define GX_TEVREG2 3
#define ALPHACMP_NEVER 0
#define ALPHACMP_LESS 1
#define ALPHACMP_EQUAL 2

View File

@ -269,7 +269,9 @@ const char *WriteLocation(API_TYPE ApiType)
template<class T>
void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
{
// TODO: Where does this TODO belong again...?
// TODO: Can be optimized if using alpha pass
#define SetUidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name = value; };
#define OR_UidField(name, value) if (&out.GetUidData() != NULL) {out.GetUidData().name |= value; };
out.SetBuffer(text);
@ -915,7 +917,6 @@ static void WriteStage(T& out, int n, API_TYPE ApiType)
|| cc.c == TEVCOLORARG_C0 || cc.c == TEVCOLORARG_A0
|| ac.a == TEVALPHAARG_A0 || ac.b == TEVALPHAARG_A0 || ac.c == TEVALPHAARG_A0)
{
// TODO: WTF?
out.SetConstantsUsed(C_COLORS+1,C_COLORS+1);
if(RegisterStates[1].AlphaNeedOverflowControl || RegisterStates[1].ColorNeedOverflowControl)
{
@ -971,26 +972,19 @@ static void WriteStage(T& out, int n, API_TYPE ApiType)
RegisterStates[cc.dest].ColorNeedOverflowControl = (cc.clamp == 0);
RegisterStates[cc.dest].AuxStored = false;
/* if (cc.d == TEVCOLORARG_C0 || cc.d == TEVCOLORARG_A0 || ac.d == TEVALPHAARG_A0)
{
if (cc.d == TEVCOLORARG_C0 || cc.d == TEVCOLORARG_A0 || ac.d == TEVALPHAARG_A0)
out.SetConstantsUsed(C_COLORS+1,C_COLORS+1);
// TODO: 11 bit signed overflow..
}
if (cc.d == TEVCOLORARG_C1 || cc.d == TEVCOLORARG_A1 || ac.d == TEVALPHAARG_A1)
{
out.SetConstantsUsed(C_COLORS+2,C_COLORS+2);
// TODO: 11 bit signed overflow..
}
if (cc.d == TEVCOLORARG_C2 || cc.d == TEVCOLORARG_A2 || ac.d == TEVALPHAARG_A2)
{
out.SetConstantsUsed(C_COLORS+3,C_COLORS+3);
// TODO: 11 bit signed overflow..
}*/
// TODO: Are there enums for this?
if (cc.dest >= 1 && cc.dest <= 3)
if (cc.d == TEVCOLORARG_C1 || cc.d == TEVCOLORARG_A1 || ac.d == TEVALPHAARG_A1)
out.SetConstantsUsed(C_COLORS+2,C_COLORS+2);
if (cc.d == TEVCOLORARG_C2 || cc.d == TEVCOLORARG_A2 || ac.d == TEVALPHAARG_A2)
out.SetConstantsUsed(C_COLORS+3,C_COLORS+3);
if (cc.dest >= GX_TEVREG0 && cc.dest <= GX_TEVREG2)
out.SetConstantsUsed(C_COLORS+cc.dest, C_COLORS+cc.dest);
if (ac.dest >= 1 && ac.dest <= 3)
if (ac.dest >= GX_TEVREG0 && ac.dest <= GX_TEVREG2)
out.SetConstantsUsed(C_COLORS+ac.dest, C_COLORS+ac.dest);
out.Write("// color combine\n");
@ -1103,14 +1097,14 @@ void SampleTexture(T& out, const char *destination, const char *texcoords, const
static const char *tevAlphaFuncsTable[] =
{
"(false)", //ALPHACMP_NEVER 0, TODO: Not safe?
"(prev.a <= %s - (0.25f/255.0f))", //ALPHACMP_LESS 1
"(abs( prev.a - %s ) < (0.5f/255.0f))", //ALPHACMP_EQUAL 2
"(prev.a < %s + (0.25f/255.0f))", //ALPHACMP_LEQUAL 3
"(prev.a >= %s + (0.25f/255.0f))", //ALPHACMP_GREATER 4
"(abs( prev.a - %s ) >= (0.5f/255.0f))", //ALPHACMP_NEQUAL 5
"(prev.a > %s - (0.25f/255.0f))", //ALPHACMP_GEQUAL 6
"(true)" //ALPHACMP_ALWAYS 7
"(false)", // NEVER
"(prev.a <= %s - (0.25f/255.0f))", // LESS
"(abs( prev.a - %s ) < (0.5f/255.0f))", // EQUAL
"(prev.a < %s + (0.25f/255.0f))", // LEQUAL
"(prev.a >= %s + (0.25f/255.0f))", // GREATER
"(abs( prev.a - %s ) >= (0.5f/255.0f))", // NEQUAL
"(prev.a > %s - (0.25f/255.0f))", // GEQUAL
"(true)" // ALWAYS
};
static const char *tevAlphaFunclogicTable[] =
@ -1132,7 +1126,6 @@ static void WriteAlphaTest(T& out, API_TYPE ApiType, DSTALPHA_MODE dstAlphaMode,
out.SetConstantsUsed(C_ALPHA, C_ALPHA);
// using discard then return works the same in cg and dx9 but not in dx11
out.Write("\tif(!( ");

View File

@ -419,6 +419,7 @@ void PixelShaderManager::SetPSTextureDims(int texid)
// This one is high in profiles (0.5%).
// TODO: Move conversion out, only store the raw color value
// and update it when the shader constant is set, only.
// TODO: Conversion should be checked in the context of tev_fixes..
void PixelShaderManager::SetColorChanged(int type, int num, bool high)
{
float *pf = &lastRGBAfull[type][num][0];