diff options
| author | OatmealDome <OatmealDome@users.noreply.github.com> | 2023-01-31 01:55:55 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-31 01:55:55 -0500 |
| commit | 0f037a1af843300bd1e274487b3501384ef14df0 (patch) | |
| tree | 1afa1c95d21e436cdd8ace17020d367c3f611d8c /Source/Core/VideoCommon/PixelShaderGen.cpp | |
| parent | be8cbe3c667fafdf949f160f96ca68d3f48f2cfe (diff) | |
| parent | 600ad5f49832a69efe0ebd5ca7a19d3a82f7a319 (diff) | |
Merge pull request #10864 from TellowKrinkle/BetterLogicBlend
VideoCommon: Better logic op invert approximation
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/PixelShaderGen.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 7db650e431..8a34f1debf 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -744,6 +744,7 @@ static void WriteAlphaTest(ShaderCode& out, const pixel_shader_uid_data* uid_dat bool per_pixel_depth, bool use_dual_source); static void WriteFog(ShaderCode& out, const pixel_shader_uid_data* uid_data); static void WriteLogicOp(ShaderCode& out, const pixel_shader_uid_data* uid_data); +static void WriteLogicOpBlend(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); static void WriteBlend(ShaderCode& out, const pixel_shader_uid_data* uid_data); @@ -1148,6 +1149,8 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos if (uid_data->logic_op_enable) WriteLogicOp(out, uid_data); + else if (uid_data->emulate_logic_op_with_blend) + WriteLogicOpBlend(out, uid_data); // Write the color and alpha values to the framebuffer // If using shader blend, we still use the separate alpha @@ -1803,6 +1806,29 @@ static void WriteLogicOp(ShaderCode& out, const pixel_shader_uid_data* uid_data) out.Write("\tprev = ({}) & 0xff;\n", logic_op_mode[uid_data->logic_op_mode]); } +static void WriteLogicOpBlend(ShaderCode& out, const pixel_shader_uid_data* uid_data) +{ + switch (static_cast<LogicOp>(uid_data->logic_op_mode)) + { + case LogicOp::Clear: + case LogicOp::NoOp: + out.Write("\tprev = int4(0, 0, 0, 0);\n"); + break; + case LogicOp::Copy: + // Do nothing! + break; + case LogicOp::CopyInverted: + out.Write("\tprev ^= 255;\n"); + break; + case LogicOp::Set: + case LogicOp::Invert: // In cooperation with blend + out.Write("\tprev = int4(255, 255, 255, 255);\n"); + break; + default: + break; + } +} + static void WriteColor(ShaderCode& out, APIType api_type, const pixel_shader_uid_data* uid_data, bool use_dual_source) { |
