Rework the logic for avoiding lerp() in shader code

This should give the exact same shader code except for the cases of
SELA == SELB and SELC == 1, the latter only for the color combinder.
In these two cases the results of the shader should not change in any way.

It would have been possible to optimize the SELC == HALF case too, if
the actual factor had been 0.5f instead of 0.4980392f.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5472 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
pierre 2010-05-23 22:46:13 +00:00
parent 88cf89e7fe
commit b73b77014f

View File

@ -761,18 +761,16 @@ static void WriteStage(char *&p, int n, u32 texture_mask, u32 HLSL)
if(!(cc.d == TEVCOLORARG_ZERO && cc.op == 0))
WRITE(p, "%s%s",tevCInputTable[cc.d],tevOpTable[cc.op]);
if (cc.a == TEVCOLORARG_ZERO && cc.b == TEVCOLORARG_ZERO)
WRITE(p, "float3(0.0f,0.0f,0.0f)");
else if (cc.a == TEVCOLORARG_ZERO && cc.c == TEVCOLORARG_ZERO)
WRITE(p, "float3(0.0f,0.0f,0.0f)");
else if (cc.b == TEVCOLORARG_ZERO && cc.c == TEVCOLORARG_ZERO)
if (cc.a == cc.b)
WRITE(p,"%s",tevCInputTable[cc.a]);
else if (cc.c == TEVCOLORARG_ZERO)
WRITE(p,"%s",tevCInputTable[cc.a]);
else if (cc.c == TEVCOLORARG_ONE)
WRITE(p,"%s",tevCInputTable[cc.b]);
else if (cc.a == TEVCOLORARG_ZERO)
WRITE(p,"%s*%s",tevCInputTable[cc.b],tevCInputTable[cc.c]);
else if (cc.b == TEVCOLORARG_ZERO)
WRITE(p,"%s*(float3(1.0f,1.0f,1.0f)-%s)",tevCInputTable[cc.a],tevCInputTable[cc.c]);
else if (cc.c == TEVCOLORARG_ZERO)
WRITE(p,"%s",tevCInputTable[cc.a]);
else
WRITE(p, "lerp(%s,%s,%s)",tevCInputTable[cc.a], tevCInputTable[cc.b],tevCInputTable[cc.c]);
@ -809,18 +807,14 @@ static void WriteStage(char *&p, int n, u32 texture_mask, u32 HLSL)
if(!(ac.d == TEVALPHAARG_ZERO && ac.op == 0))
WRITE(p, "%s%s",tevAInputTable[ac.d],tevOpTable[ac.op]);
if (ac.a == TEVALPHAARG_ZERO && ac.b == TEVALPHAARG_ZERO)
WRITE(p, "0.0f");
else if (ac.a == TEVALPHAARG_ZERO && ac.c == TEVALPHAARG_ZERO)
WRITE(p, "0.0f");
else if (ac.b == TEVALPHAARG_ZERO && ac.c == TEVALPHAARG_ZERO)
if (ac.a == ac.b)
WRITE(p,"%s",tevAInputTable[ac.a]);
else if (ac.c == TEVALPHAARG_ZERO)
WRITE(p,"%s",tevAInputTable[ac.a]);
else if (ac.a == TEVALPHAARG_ZERO)
WRITE(p,"%s*%s",tevAInputTable[ac.b],tevAInputTable[ac.c]);
else if (ac.b == TEVALPHAARG_ZERO)
WRITE(p,"%s*(1.0f-%s)",tevAInputTable[ac.a],tevAInputTable[ac.c]);
else if (ac.c == TEVALPHAARG_ZERO)
WRITE(p,"%s",tevAInputTable[ac.a]);
else
WRITE(p, "lerp(%s,%s,%s)",tevAInputTable[ac.a],tevAInputTable[ac.b],tevAInputTable[ac.c]);