From c13a5c38e9ab997f21b84c2ce64772b66cc3cfc9 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Thu, 10 Oct 2013 20:36:55 +0200 Subject: [PATCH] PixelShaderGen: Change the "alpha" uniform to use integers. --- Source/Core/VideoCommon/ConstantManager.h | 2 +- Source/Core/VideoCommon/PixelShaderGen.cpp | 10 +++++----- Source/Core/VideoCommon/PixelShaderManager.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoCommon/ConstantManager.h b/Source/Core/VideoCommon/ConstantManager.h index 1b1aa79dc3..d4c17860f5 100644 --- a/Source/Core/VideoCommon/ConstantManager.h +++ b/Source/Core/VideoCommon/ConstantManager.h @@ -13,7 +13,7 @@ struct PixelShaderConstants { int4 colors[4]; int4 kcolors[4]; - float4 alpha; + int4 alpha; float4 texdims[8]; float4 zbias[2]; float4 indtexscale[2]; diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index e141168644..b59a1f99f9 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -285,7 +285,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T DeclareUniform(out, ApiType, C_COLORS, "int4", I_COLORS"[4]"); DeclareUniform(out, ApiType, C_KCOLORS, "int4", I_KCOLORS"[4]"); - DeclareUniform(out, ApiType, C_ALPHA, "float4", I_ALPHA"[1]"); // TODO: Why is this an array...-.- + DeclareUniform(out, ApiType, C_ALPHA, "int4", I_ALPHA"[1]"); // TODO: Why is this an array...-.- DeclareUniform(out, ApiType, C_TEXDIMS, "float4", I_TEXDIMS"[8]"); DeclareUniform(out, ApiType, C_ZBIAS, "float4", I_ZBIAS"[2]"); DeclareUniform(out, ApiType, C_INDTEXSCALE, "float4", I_INDTEXSCALE"[2]"); @@ -570,7 +570,7 @@ 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(float3(iprev.rgb) / 255.0, " I_ALPHA"[0].a);\n"); + out.Write("\tocol0 = float4(float3(iprev.rgb), float(" I_ALPHA".a)) / 255.0;\n"); } else { @@ -586,7 +586,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 = float4(iprev) / 255.0;\n"); - out.Write("\tocol0.a = " I_ALPHA"[0].a;\n"); + out.Write("\tocol0.a = float(" I_ALPHA".a) / 255.0;\n"); } out.Write("}\n"); @@ -962,8 +962,8 @@ static inline void WriteAlphaTest(T& out, pixel_shader_uid_data& uid_data, API_T { static const char *alphaRef[2] = { - "int(round(" I_ALPHA"[0].r * 255.0))", - "int(round(" I_ALPHA"[0].g * 255.0))" + I_ALPHA".r", + I_ALPHA".g" }; out.SetConstantsUsed(C_ALPHA, C_ALPHA); diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index 5d5850da5b..29e13dd717 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -164,14 +164,14 @@ void PixelShaderManager::SetColorChanged(int type, int num) void PixelShaderManager::SetAlpha() { - constants.alpha[0] = bpmem.alpha_test.ref0 / 255.0f; - constants.alpha[1] = bpmem.alpha_test.ref1 / 255.0f; + constants.alpha[0] = bpmem.alpha_test.ref0; + constants.alpha[1] = bpmem.alpha_test.ref1; dirty = true; } void PixelShaderManager::SetDestAlpha() { - constants.alpha[3] = bpmem.dstalpha.alpha / 255.0f; + constants.alpha[3] = bpmem.dstalpha.alpha; dirty = true; }