summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/UberShaderPixel.cpp
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2017-09-03 19:26:50 -0700
committerGitHub <noreply@github.com>2017-09-03 19:26:50 -0700
commitee6930a231a7ff1b25750deb84f613bddee90379 (patch)
tree5cfee129760ba3d4747f029cd47872c0b92a7aa6 /Source/Core/VideoCommon/UberShaderPixel.cpp
parent26e777d80bb125e12a4a93e0e727c804a0facd34 (diff)
parent90051536bf53f66ca0e4c46105e481e08f1642f3 (diff)
Merge pull request #6013 from stenzek/d3d-logic-op
D3D: Implement logic op support
Diffstat (limited to 'Source/Core/VideoCommon/UberShaderPixel.cpp')
-rw-r--r--Source/Core/VideoCommon/UberShaderPixel.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/UberShaderPixel.cpp b/Source/Core/VideoCommon/UberShaderPixel.cpp
index 01cca466cd..4e760408c5 100644
--- a/Source/Core/VideoCommon/UberShaderPixel.cpp
+++ b/Source/Core/VideoCommon/UberShaderPixel.cpp
@@ -25,6 +25,7 @@ PixelShaderUid GetPixelShaderUid()
(bpmem.ztex2.op != ZTEXTURE_DISABLE && bpmem.UseLateDepthTest()) ||
(!g_ActiveConfig.bFastDepthCalc && bpmem.zmode.testenable && !uid_data->early_depth) ||
(bpmem.zmode.testenable && bpmem.genMode.zfreeze);
+ uid_data->uint_output = bpmem.blendmode.UseLogicOp();
return out;
}
@@ -1163,18 +1164,29 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
" }\n"
"\n");
- // TODO: Do we still want to support two pass alpha blending?
- out.Write(" if (bpmem_rgba6_format)\n"
- " ocol0.rgb = float3(TevResult.rgb >> 2) / 63.0;\n"
- " else\n"
- " ocol0.rgb = float3(TevResult.rgb) / 255.0;\n"
- "\n"
- " if (bpmem_dstalpha != 0u)\n");
- out.Write(" ocol0.a = float(%s >> 2) / 63.0;\n",
- BitfieldExtract("bpmem_dstalpha", ConstantAlpha().alpha).c_str());
- out.Write(" else\n"
- " ocol0.a = float(TevResult.a >> 2) / 63.0;\n"
- " \n");
+ // D3D requires that the shader outputs be uint when writing to a uint render target for logic op.
+ if (ApiType == APIType::D3D && uid_data->uint_output)
+ {
+ out.Write(" if (bpmem_rgba6_format)\n"
+ " ocol0 = uint4(TevResult & 0xFC);\n"
+ " else\n"
+ " ocol0 = uint4(TevResult);\n"
+ "\n");
+ }
+ else
+ {
+ out.Write(" if (bpmem_rgba6_format)\n"
+ " ocol0.rgb = float3(TevResult.rgb >> 2) / 63.0;\n"
+ " else\n"
+ " ocol0.rgb = float3(TevResult.rgb) / 255.0;\n"
+ "\n"
+ " if (bpmem_dstalpha != 0u)\n");
+ out.Write(" ocol0.a = float(%s >> 2) / 63.0;\n",
+ BitfieldExtract("bpmem_dstalpha", ConstantAlpha().alpha).c_str());
+ out.Write(" else\n"
+ " ocol0.a = float(TevResult.a >> 2) / 63.0;\n"
+ " \n");
+ }
if (use_dual_source)
{
@@ -1259,7 +1271,11 @@ void EnumeratePixelShaderUids(const std::function<void(const PixelShaderUid&)>&
continue;
puid->per_pixel_depth = per_pixel_depth != 0;
- callback(uid);
+ for (u32 uint_output = 0; uint_output < 2; uint_output++)
+ {
+ puid->uint_output = uint_output;
+ callback(uid);
+ }
}
}
}