Revert "Partially revert revision d511b506120c."
This reverts commit 08e06b2293
.
This commit is contained in:
parent
8fed3b76c8
commit
bb8b5936c0
|
@ -487,6 +487,15 @@ static char swapModeTable[4][5];
|
|||
static char text[16384];
|
||||
static bool DepthTextureEnable;
|
||||
|
||||
struct RegisterState
|
||||
{
|
||||
bool ColorNeedOverflowControl;
|
||||
bool AlphaNeedOverflowControl;
|
||||
bool AuxStored;
|
||||
};
|
||||
|
||||
static RegisterState RegisterStates[4];
|
||||
|
||||
static void BuildSwapModeTable()
|
||||
{
|
||||
static const char *swapColors = "rgba";
|
||||
|
@ -717,6 +726,16 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
|||
}
|
||||
}
|
||||
|
||||
RegisterStates[0].AlphaNeedOverflowControl = false;
|
||||
RegisterStates[0].ColorNeedOverflowControl = false;
|
||||
RegisterStates[0].AuxStored = false;
|
||||
for(int i = 1; i < 4; i++)
|
||||
{
|
||||
RegisterStates[i].AlphaNeedOverflowControl = true;
|
||||
RegisterStates[i].ColorNeedOverflowControl = true;
|
||||
RegisterStates[i].AuxStored = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < numStages; i++)
|
||||
WriteStage(p, i, ApiType); //build the equation for this stage
|
||||
|
||||
|
@ -724,11 +743,22 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
|||
{
|
||||
// The results of the last texenv stage are put onto the screen,
|
||||
// regardless of the used destination register
|
||||
WRITE(p, "prev.rgb = %s;\n",tevCOutputTable[bpmem.combiners[numStages-1].colorC.dest]);
|
||||
WRITE(p, "prev.a = %s;\n",tevAOutputTable[bpmem.combiners[numStages-1].alphaC.dest]);
|
||||
if(bpmem.combiners[numStages - 1].colorC.dest != 0)
|
||||
{
|
||||
bool retrieveFromAuxRegister = !RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].ColorNeedOverflowControl && RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].AuxStored;
|
||||
WRITE(p, "prev.rgb = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevCOutputTable[bpmem.combiners[numStages - 1].colorC.dest]);
|
||||
RegisterStates[0].ColorNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].ColorNeedOverflowControl;
|
||||
}
|
||||
if(bpmem.combiners[numStages - 1].alphaC.dest != 0)
|
||||
{
|
||||
bool retrieveFromAuxRegister = !RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl && RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AuxStored;
|
||||
WRITE(p, "prev.a = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevAOutputTable[bpmem.combiners[numStages - 1].alphaC.dest]);
|
||||
RegisterStates[0].AlphaNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl;
|
||||
}
|
||||
}
|
||||
// emulation of unsigned 8 overflow when casting
|
||||
WRITE(p, "prev = frac(4.0f + prev * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
// emulation of unsigned 8 overflow when casting if needed
|
||||
if(RegisterStates[0].AlphaNeedOverflowControl || RegisterStates[0].ColorNeedOverflowControl)
|
||||
WRITE(p, "prev = frac(prev * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
|
||||
if(Pretest == -1)
|
||||
{
|
||||
|
@ -917,7 +947,6 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC;
|
||||
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC;
|
||||
|
||||
// blah1
|
||||
if(cc.a == TEVCOLORARG_RASA || cc.a == TEVCOLORARG_RASC
|
||||
|| cc.b == TEVCOLORARG_RASA || cc.b == TEVCOLORARG_RASC
|
||||
|| cc.c == TEVCOLORARG_RASA || cc.c == TEVCOLORARG_RASC
|
||||
|
@ -950,7 +979,6 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
WRITE(p, "textemp = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
|
||||
|
||||
|
||||
// blah2
|
||||
if (cc.a == TEVCOLORARG_KONST || cc.b == TEVCOLORARG_KONST || cc.c == TEVCOLORARG_KONST || cc.d == TEVCOLORARG_KONST
|
||||
|| ac.a == TEVALPHAARG_KONST || ac.b == TEVALPHAARG_KONST || ac.c == TEVALPHAARG_KONST || ac.d == TEVALPHAARG_KONST)
|
||||
{
|
||||
|
@ -971,30 +999,78 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
|| cc.b == TEVCOLORARG_CPREV || cc.b == TEVCOLORARG_APREV
|
||||
|| cc.c == TEVCOLORARG_CPREV || cc.c == TEVCOLORARG_APREV
|
||||
|| ac.a == TEVALPHAARG_APREV || ac.b == TEVALPHAARG_APREV || ac.c == TEVALPHAARG_APREV)
|
||||
WRITE(p, "cprev = frac(prev * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
|
||||
{
|
||||
if(RegisterStates[0].AlphaNeedOverflowControl || RegisterStates[0].ColorNeedOverflowControl)
|
||||
{
|
||||
WRITE(p, "cprev = frac(prev * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
RegisterStates[0].AlphaNeedOverflowControl = false;
|
||||
RegisterStates[0].ColorNeedOverflowControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, "cprev = prev;\n");
|
||||
}
|
||||
RegisterStates[0].AuxStored = true;
|
||||
}
|
||||
|
||||
if(cc.a == TEVCOLORARG_C0 || cc.a == TEVCOLORARG_A0
|
||||
|| cc.b == TEVCOLORARG_C0 || cc.b == TEVCOLORARG_A0
|
||||
|| cc.c == TEVCOLORARG_C0 || cc.c == TEVCOLORARG_A0
|
||||
|| ac.a == TEVALPHAARG_A0 || ac.b == TEVALPHAARG_A0 || ac.c == TEVALPHAARG_A0)
|
||||
WRITE(p, "cc0 = frac(c0 * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
|
||||
{
|
||||
if(RegisterStates[1].AlphaNeedOverflowControl || RegisterStates[1].ColorNeedOverflowControl)
|
||||
{
|
||||
WRITE(p, "cc0 = frac(c0 * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
RegisterStates[1].AlphaNeedOverflowControl = false;
|
||||
RegisterStates[1].ColorNeedOverflowControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, "cc0 = c0;\n");
|
||||
}
|
||||
RegisterStates[1].AuxStored = true;
|
||||
}
|
||||
|
||||
if(cc.a == TEVCOLORARG_C1 || cc.a == TEVCOLORARG_A1
|
||||
|| cc.b == TEVCOLORARG_C1 || cc.b == TEVCOLORARG_A1
|
||||
|| cc.c == TEVCOLORARG_C1 || cc.c == TEVCOLORARG_A1
|
||||
|| ac.a == TEVALPHAARG_A1 || ac.b == TEVALPHAARG_A1 || ac.c == TEVALPHAARG_A1)
|
||||
WRITE(p, "cc1 = frac(c1 * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
|
||||
{
|
||||
if(RegisterStates[2].AlphaNeedOverflowControl || RegisterStates[2].ColorNeedOverflowControl)
|
||||
{
|
||||
WRITE(p, "cc1 = frac(c1 * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
RegisterStates[2].AlphaNeedOverflowControl = false;
|
||||
RegisterStates[2].ColorNeedOverflowControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, "cc1 = c1;\n");
|
||||
}
|
||||
RegisterStates[2].AuxStored = true;
|
||||
}
|
||||
|
||||
if(cc.a == TEVCOLORARG_C2 || cc.a == TEVCOLORARG_A2
|
||||
|| cc.b == TEVCOLORARG_C2 || cc.b == TEVCOLORARG_A2
|
||||
|| cc.c == TEVCOLORARG_C2 || cc.c == TEVCOLORARG_A2
|
||||
|| ac.a == TEVALPHAARG_A2 || ac.b == TEVALPHAARG_A2 || ac.c == TEVALPHAARG_A2)
|
||||
{
|
||||
if(RegisterStates[3].AlphaNeedOverflowControl || RegisterStates[3].ColorNeedOverflowControl)
|
||||
{
|
||||
WRITE(p, "cc2 = frac(c2 * (255.0f/256.0f)) * (256.0f/255.0f);\n");
|
||||
RegisterStates[3].AlphaNeedOverflowControl = false;
|
||||
RegisterStates[3].ColorNeedOverflowControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, "cc2 = c2;\n");
|
||||
}
|
||||
RegisterStates[3].AuxStored = true;
|
||||
}
|
||||
|
||||
RegisterStates[cc.dest].ColorNeedOverflowControl = (cc.clamp == 0);
|
||||
RegisterStates[cc.dest].AuxStored = false;
|
||||
|
||||
// combine the color channel
|
||||
WRITE(p, "// color combine\n");
|
||||
if (cc.clamp)
|
||||
WRITE(p, "%s = saturate(", tevCOutputTable[cc.dest]);
|
||||
|
@ -1042,8 +1118,11 @@ static void WriteStage(char *&p, int n, API_TYPE ApiType)
|
|||
WRITE(p, ")");
|
||||
WRITE(p,";\n");
|
||||
|
||||
WRITE(p, "// alpha combine\n");
|
||||
RegisterStates[ac.dest].AlphaNeedOverflowControl = (ac.clamp == 0);
|
||||
RegisterStates[ac.dest].AuxStored = false;
|
||||
|
||||
// combine the alpha channel
|
||||
WRITE(p, "// alpha combine\n");
|
||||
if (ac.clamp)
|
||||
WRITE(p, "%s = saturate(", tevAOutputTable[ac.dest]);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue