Merge pull request #5090 from unknownbrackets/gpu-minor

Double colors only when texturing, and after test
This commit is contained in:
Henrik Rydgård 2014-01-12 12:33:12 -08:00
commit 762643c7dd
2 changed files with 16 additions and 17 deletions

View File

@ -364,7 +364,7 @@ void GenerateFragmentShader(char *buffer) {
bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear();
bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !gstate.isModeClear() && !g_Config.bDisableAlphaTest;
bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue() && !gstate.isModeClear();
bool enableColorDoubling = gstate.isColorDoublingEnabled();
bool enableColorDoubling = gstate.isColorDoublingEnabled() && gstate.isTextureMapEnabled();
// This isn't really correct, but it's a hack to get doubled blend modes to work more correctly.
bool enableAlphaDoubling = CanDoubleSrcBlendMode();
bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX;
@ -515,16 +515,7 @@ void GenerateFragmentShader(char *buffer) {
}
}
}
// TODO: Before or after the color test?
if (enableColorDoubling && enableAlphaDoubling) {
WRITE(p, " v = v * 2.0;\n");
} else if (enableColorDoubling) {
WRITE(p, " v.rgb = v.rgb * 2.0;\n");
} else if (enableAlphaDoubling) {
WRITE(p, " v.a = v.a * 2.0;\n");
}
if (enableColorTest) {
GEComparison colorTestFunc = gstate.getColorTestFunction();
const char *colorTestFuncs[] = { "#", "#", " != ", " == " }; // never/always don't make sense
@ -538,6 +529,15 @@ void GenerateFragmentShader(char *buffer) {
}
}
// Color doubling happens after the color test.
if (enableColorDoubling && enableAlphaDoubling) {
WRITE(p, " v = v * 2.0;\n");
} else if (enableColorDoubling) {
WRITE(p, " v.rgb = v.rgb * 2.0;\n");
} else if (enableAlphaDoubling) {
WRITE(p, " v.a = v.a * 2.0;\n");
}
if (enableFog) {
WRITE(p, " float fogCoef = clamp(v_fogdepth, 0.0, 1.0);\n");
WRITE(p, " v = mix(vec4(u_fogcolor, v.a), v, fogCoef);\n");

View File

@ -1007,12 +1007,6 @@ void DrawTriangleSlice(
prim_color_a = out.a();
}
if (gstate.isColorDoublingEnabled() && !clearMode) {
// TODO: Do we need to clamp here?
prim_color_rgb *= 2;
sec_color *= 2;
}
if (!clearMode)
prim_color_rgb += sec_color;
@ -1071,6 +1065,11 @@ void DrawTriangleSlice(
Vec4<int> dst = Vec4<int>::FromRGBA(GetPixelColor(p.x, p.y));
prim_color_rgb = AlphaBlendingResult(prim_color_rgb, prim_color_a, dst);
}
if (gstate.isTextureMapEnabled() && gstate.isColorDoublingEnabled() && !clearMode) {
prim_color_rgb *= 2;
}
if (!clearMode)
prim_color_rgb = prim_color_rgb.Clamp(0, 255);