From 22d664b2102becdde07859f2ed799938c9273766 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 8 Apr 2021 03:05:08 +1000 Subject: [PATCH] GPU/ShaderGen: Move discard to end of shader Possible workaround for this PowerVR driver issue. --- src/core/gpu_hw_shadergen.cpp | 16 ++++++++-------- src/core/shader_cache_version.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 0420d643f..4484ab084 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -931,10 +931,6 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords) // Apply semitransparency. If not a semitransparent texel, destination alpha is ignored. if (semitransparent) { - #if TRANSPARENCY_ONLY_OPAQUE - discard; - #endif - #if USE_DUAL_SOURCE o_col0 = float4(color, oalpha); o_col1 = float4(0.0, 0.0, 0.0, u_dst_alpha_factor / ialpha); @@ -945,13 +941,13 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords) #if !PGXP_DEPTH o_depth = oalpha * v_pos.z; #endif + + #if TRANSPARENCY_ONLY_OPAQUE + discard; + #endif } else { - #if TRANSPARENCY_ONLY_TRANSPARENT - discard; - #endif - #if USE_DUAL_SOURCE o_col0 = float4(color, oalpha); o_col1 = float4(0.0, 0.0, 0.0, 1.0 - ialpha); @@ -962,6 +958,10 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords) #if !PGXP_DEPTH o_depth = oalpha * v_pos.z; #endif + + #if TRANSPARENCY_ONLY_TRANSPARENT + discard; + #endif } #else // Non-transparency won't enable blending so we can write the mask here regardless. diff --git a/src/core/shader_cache_version.h b/src/core/shader_cache_version.h index a4ed71231..0f774c29a 100644 --- a/src/core/shader_cache_version.h +++ b/src/core/shader_cache_version.h @@ -1,4 +1,4 @@ #pragma once #include "types.h" -static constexpr u32 SHADER_CACHE_VERSION = 3; \ No newline at end of file +static constexpr u32 SHADER_CACHE_VERSION = 4; \ No newline at end of file