summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2016-12-28 01:37:41 +0100
committerdegasus <wickmarkus@web.de>2017-01-04 20:02:31 +0100
commit41b0c74e3056ec0d0b354896684debb2d82320f3 (patch)
treefb2b3f0b624a4dc275100633e6a251fa1944e5e6 /Source/Core/VideoCommon/PixelShaderGen.cpp
parentb7d8bd13a6c44eecf5c5e59ea60796e3018785f9 (diff)
VideoCommon: Make dst_alpha state implicit.
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index 6d10d82202..7a718c8f38 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -156,13 +156,15 @@ static const char* tevAOutputTable[] = {"prev.a", "c0.a", "c1.a", "c2.a"};
// leak
// into this UID; This is really unhelpful if these UIDs ever move from one machine to
// another.
-PixelShaderUid GetPixelShaderUid(DSTALPHA_MODE dstAlphaMode)
+PixelShaderUid GetPixelShaderUid()
{
PixelShaderUid out;
pixel_shader_uid_data* uid_data = out.GetUidData<pixel_shader_uid_data>();
memset(uid_data, 0, sizeof(*uid_data));
- uid_data->dstAlphaMode = dstAlphaMode;
+ uid_data->useDstAlpha = bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate &&
+ bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
+
uid_data->genMode_numindstages = bpmem.genMode.numindstages;
uid_data->genMode_numtevstages = bpmem.genMode.numtevstages;
uid_data->genMode_numtexgens = bpmem.genMode.numtexgens;
@@ -327,13 +329,9 @@ PixelShaderUid GetPixelShaderUid(DSTALPHA_MODE dstAlphaMode)
uid_data->ztex_op = bpmem.ztex2.op;
uid_data->early_ztest = bpmem.UseEarlyDepthTest();
uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel;
-
- if (dstAlphaMode != DSTALPHA_ALPHA_PASS)
- {
- uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel;
- uid_data->fog_proj = bpmem.fog.c_proj_fsel.proj;
- uid_data->fog_RangeBaseEnabled = bpmem.fogRange.Base.Enabled;
- }
+ uid_data->fog_fsel = bpmem.fog.c_proj_fsel.fsel;
+ uid_data->fog_proj = bpmem.fog.c_proj_fsel.proj;
+ uid_data->fog_RangeBaseEnabled = bpmem.fogRange.Base.Enabled;
return out;
}
@@ -510,7 +508,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data*
const bool use_dual_source =
g_ActiveConfig.backend_info.bSupportsDualSourceBlend &&
(!DriverDetails::HasBug(DriverDetails::BUG_BROKEN_DUAL_SOURCE_BLENDING) ||
- uid_data->dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND);
+ uid_data->useDstAlpha);
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
{
@@ -795,8 +793,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data*
out.Write("\tprev.rgb = (prev.rgb - (prev.rgb >> 6)) + abs(dither.y * 3 - dither.x * 2);\n");
}
- if (uid_data->dstAlphaMode != DSTALPHA_ALPHA_PASS)
- WriteFog(out, uid_data);
+ WriteFog(out, uid_data);
// Write the color and alpha values to the framebuffer
WriteColor(out, uid_data, use_dual_source);
@@ -1308,7 +1305,7 @@ static void WriteColor(ShaderCode& out, const pixel_shader_uid_data* uid_data, b
// Colors will be blended against the 8-bit alpha from ocol1 and
// the 6-bit alpha from ocol0 will be written to the framebuffer
- if (uid_data->dstAlphaMode == DSTALPHA_NONE)
+ if (!uid_data->useDstAlpha)
{
out.Write("\tocol0.a = float(prev.a >> 2) / 63.0;\n");
if (use_dual_source)
@@ -1322,7 +1319,7 @@ static void WriteColor(ShaderCode& out, const pixel_shader_uid_data* uid_data, b
// Use dual-source color blending to perform dst alpha in a single pass
if (use_dual_source)
{
- if (uid_data->dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
+ if (uid_data->useDstAlpha)
out.Write("\tocol1.a = float(prev.a) / 255.0;\n");
else
out.Write("\tocol1.a = float(" I_ALPHA ".a) / 255.0;\n");