diff options
| author | Anthony <Helios747@users.noreply.github.com> | 2017-09-03 19:26:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-03 19:26:50 -0700 |
| commit | ee6930a231a7ff1b25750deb84f613bddee90379 (patch) | |
| tree | 5cfee129760ba3d4747f029cd47872c0b92a7aa6 /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | 26e777d80bb125e12a4a93e0e727c804a0facd34 (diff) | |
| parent | 90051536bf53f66ca0e4c46105e481e08f1642f3 (diff) | |
Merge pull request #6013 from stenzek/d3d-logic-op
D3D: Implement logic op support
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index d503b21176..5e561456ab 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -175,6 +175,7 @@ PixelShaderUid GetPixelShaderUid() uid_data->rgba6_format = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24 && !g_ActiveConfig.bForceTrueColor; uid_data->dither = bpmem.blendmode.dither && uid_data->rgba6_format; + uid_data->uint_output = bpmem.blendmode.UseLogicOp(); u32 numStages = uid_data->genMode_numtevstages + 1; @@ -434,7 +435,7 @@ static void SampleTexture(ShaderCode& out, const char* texcoords, const char* te static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_data, APIType ApiType, bool per_pixel_depth, bool use_dual_source); static void WriteFog(ShaderCode& out, const pixel_shader_uid_data* uid_data); -static void WriteColor(ShaderCode& out, const pixel_shader_uid_data* uid_data, +static void WriteColor(ShaderCode& out, APIType api_type, const pixel_shader_uid_data* uid_data, bool use_dual_source); ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host_config, @@ -568,8 +569,12 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host else // D3D { out.Write("void main(\n"); - out.Write(" out float4 ocol0 : SV_Target0,\n" - " out float4 ocol1 : SV_Target1,\n%s" + if (uid_data->uint_output) + out.Write(" out uint4 ocol0 : SV_Target,\n"); + else + out.Write(" out float4 ocol0 : SV_Target0,\n" + " out float4 ocol1 : SV_Target1,\n"); + out.Write("%s" " in float4 rawpos : SV_Position,\n", uid_data->per_pixel_depth ? " out float depth : SV_Depth,\n" : ""); @@ -778,7 +783,7 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host WriteFog(out, uid_data); // Write the color and alpha values to the framebuffer - WriteColor(out, uid_data, use_dual_source); + WriteColor(out, ApiType, uid_data, use_dual_source); if (uid_data->bounding_box) { @@ -1302,8 +1307,19 @@ static void WriteFog(ShaderCode& out, const pixel_shader_uid_data* uid_data) out.Write("\tprev.rgb = (prev.rgb * (256 - ifog) + " I_FOGCOLOR ".rgb * ifog) >> 8;\n"); } -static void WriteColor(ShaderCode& out, const pixel_shader_uid_data* uid_data, bool use_dual_source) +static void WriteColor(ShaderCode& out, APIType api_type, const pixel_shader_uid_data* uid_data, + bool use_dual_source) { + // D3D requires that the shader outputs be uint when writing to a uint render target for logic op. + if (api_type == APIType::D3D && uid_data->uint_output) + { + if (uid_data->rgba6_format) + out.Write("\tocol0 = uint4(prev & 0xFC);\n"); + else + out.Write("\tocol0 = uint4(prev);\n"); + return; + } + if (uid_data->rgba6_format) out.Write("\tocol0.rgb = float3(prev.rgb >> 2) / 63.0;\n"); else |
