From b8236b1b1c161bcff368eab1ae88eebbeee0da3d Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Fri, 18 Feb 2022 22:09:58 +0100 Subject: [PATCH] GS-hw: Partially revert #5540 Allow to wrap on colclip. For real tho, ideal solution is sw blend, doing any clamp/wrap is wrong on blend mix. --- bin/resources/shaders/dx11/tfx.fx | 2 +- bin/resources/shaders/opengl/tfx_fs.glsl | 2 +- bin/resources/shaders/vulkan/tfx.glsl | 2 +- pcsx2/GS/Renderers/HW/GSRendererNew.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/resources/shaders/dx11/tfx.fx b/bin/resources/shaders/dx11/tfx.fx index e2c9cfebbc9a9..7a533840ed060 100644 --- a/bin/resources/shaders/dx11/tfx.fx +++ b/bin/resources/shaders/dx11/tfx.fx @@ -717,7 +717,7 @@ void ps_color_clamp_wrap(inout float3 C) C = clamp(C, (float3)0.0f, (float3)255.0f); // In 16 bits format, only 5 bits of color are used. It impacts shadows computation of Castlevania - if (PS_DFMT == FMT_16 && PS_BLEND_MIX == 0) + if (PS_DFMT == FMT_16 && (PS_HDR == 1 || PS_BLEND_MIX == 0)) C = (float3)((int3)C & (int3)0xF8); else if (PS_COLCLIP == 1 && PS_HDR == 0) C = (float3)((int3)C & (int3)0xFF); diff --git a/bin/resources/shaders/opengl/tfx_fs.glsl b/bin/resources/shaders/opengl/tfx_fs.glsl index 33695049a91c9..212526bcd50f1 100644 --- a/bin/resources/shaders/opengl/tfx_fs.glsl +++ b/bin/resources/shaders/opengl/tfx_fs.glsl @@ -638,7 +638,7 @@ void ps_color_clamp_wrap(inout vec3 C) // Warning: normally blending equation is mult(A, B) = A * B >> 7. GPU have the full accuracy // GS: Color = 1, Alpha = 255 => output 1 // GPU: Color = 1/255, Alpha = 255/255 * 255/128 => output 1.9921875 -#if PS_DFMT == FMT_16 && PS_BLEND_MIX == 0 +#if PS_DFMT == FMT_16 && (PS_HDR == 1 || PS_BLEND_MIX == 0) // In 16 bits format, only 5 bits of colors are used. It impacts shadows computation of Castlevania C = vec3(ivec3(C) & ivec3(0xF8)); #elif PS_COLCLIP == 1 && PS_HDR == 0 diff --git a/bin/resources/shaders/vulkan/tfx.glsl b/bin/resources/shaders/vulkan/tfx.glsl index 86156c0875f13..f6d3668983af3 100644 --- a/bin/resources/shaders/vulkan/tfx.glsl +++ b/bin/resources/shaders/vulkan/tfx.glsl @@ -973,7 +973,7 @@ void ps_color_clamp_wrap(inout vec3 C) // Warning: normally blending equation is mult(A, B) = A * B >> 7. GPU have the full accuracy // GS: Color = 1, Alpha = 255 => output 1 // GPU: Color = 1/255, Alpha = 255/255 * 255/128 => output 1.9921875 -#if PS_DFMT == FMT_16 && PS_BLEND_MIX == 0 +#if PS_DFMT == FMT_16 && (PS_HDR == 1 || PS_BLEND_MIX == 0) // In 16 bits format, only 5 bits of colors are used. It impacts shadows computation of Castlevania C = vec3(ivec3(C) & ivec3(0xF8)); #elif PS_COLCLIP == 1 && PS_HDR == 0 diff --git a/pcsx2/GS/Renderers/HW/GSRendererNew.cpp b/pcsx2/GS/Renderers/HW/GSRendererNew.cpp index f6cf244690775..80fa3d9546633 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererNew.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererNew.cpp @@ -706,7 +706,7 @@ void GSRendererNew::EmulateBlending(bool& DATE_PRIMID, bool& DATE_BARRIER) accumulation_blend = false; blend_mix = false; } - else if (accumulation_blend) + else if (accumulation_blend || blend_mix) { // A fast algo that requires 2 passes GL_INS("COLCLIP Fast HDR mode ENABLED");