diff options
| author | Tony Wasserka <NeoBrainX@gmail.com> | 2013-08-14 15:06:47 +0200 |
|---|---|---|
| committer | Tony Wasserka <NeoBrainX@gmail.com> | 2014-03-14 22:26:48 +0100 |
| commit | fa77e1d2b6a7e9a730b3e8b6fb8d95b68bf2a55c (patch) | |
| tree | e93b22c217d883222e19b67095c45425f4bcee16 /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | 22c989de9a067eb9b6f04d0c3fa8772e8412d4d8 (diff) | |
PixelShaderGen: Use integer math for alpha testing.
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index f9a3cb5d2f..5a051b894c 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -541,9 +541,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T RegisterStates[0].AlphaNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl; } } - // emulation of unsigned 8 overflow when casting if needed - if (RegisterStates[0].AlphaNeedOverflowControl || RegisterStates[0].ColorNeedOverflowControl) - out.Write("\tprev = frac(prev * (255.0/256.0)) * (256.0/255.0);\n"); + out.Write("\tint4 iprev = int4(round(prev * 255.0)) & 0xFF;\n"); AlphaTest::TEST_RESULT Pretest = bpmem.alpha_test.TestResult(); uid_data.Pretest = Pretest; @@ -602,12 +600,12 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T if (dstAlphaMode == DSTALPHA_ALPHA_PASS) { out.SetConstantsUsed(C_ALPHA, C_ALPHA); - out.Write("\tocol0 = float4(prev.rgb, " I_ALPHA"[0].a);\n"); + out.Write("\tocol0 = float4(float3(iprev.rgb) / 255.0, " I_ALPHA"[0].a);\n"); } else { WriteFog<T>(out, uid_data); - out.Write("\tocol0 = prev;\n"); + out.Write("\tocol0 = float4(iprev) / 255.0;\n"); } // Use dual-source color blending to perform dst alpha in a single pass @@ -617,7 +615,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T // Colors will be blended against the alpha from ocol1 and // the alpha from ocol0 will be written to the framebuffer. - out.Write("\tocol1 = prev;\n"); + out.Write("\tocol1 = float4(iprev) / 255.0;\n"); out.Write("\tocol0.a = " I_ALPHA"[0].a;\n"); } @@ -1065,14 +1063,14 @@ static inline void SampleTexture(T& out, const char *texcoords, const char *texs static const char *tevAlphaFuncsTable[] = { - "(false)", // NEVER - "(prev.a <= %s - (0.25/255.0))", // LESS - "(abs( prev.a - %s ) < (0.5/255.0))", // EQUAL - "(prev.a < %s + (0.25/255.0))", // LEQUAL - "(prev.a >= %s + (0.25/255.0))", // GREATER - "(abs( prev.a - %s ) >= (0.5/255.0))", // NEQUAL - "(prev.a > %s - (0.25/255.0))", // GEQUAL - "(true)" // ALWAYS + "(false)", // NEVER + "(iprev.a < %s)", // LESS + "(iprev.a == %s)", // EQUAL + "(iprev.a <= %s)", // LEQUAL + "(iprev.a > %s)", // GREATER + "(iprev.a != %s)", // NEQUAL + "(iprev.a >= %s)", // GEQUAL + "(true)" // ALWAYS }; static const char *tevAlphaFunclogicTable[] = @@ -1088,8 +1086,8 @@ static inline void WriteAlphaTest(T& out, pixel_shader_uid_data& uid_data, API_T { static const char *alphaRef[2] = { - I_ALPHA"[0].r", - I_ALPHA"[0].g" + "int(round(" I_ALPHA"[0].r * 255.0))", + "int(round(" I_ALPHA"[0].g * 255.0))" }; out.SetConstantsUsed(C_ALPHA, C_ALPHA); @@ -1200,7 +1198,7 @@ static inline void WriteFog(T& out, pixel_shader_uid_data& uid_data) WARN_LOG(VIDEO, "Unknown Fog Type! %08x", bpmem.fog.c_proj_fsel.fsel); } - out.Write("\tprev.rgb = lerp(prev.rgb, " I_FOG"[0].rgb, fog);\n"); + out.Write("\tiprev.rgb = int3(round(lerp(float3(iprev.rgb), " I_FOG"[0].rgb*255.0, fog)));\n"); } void GetPixelShaderUid(PixelShaderUid& object, DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components) |
