GS/HW: Cleanup gl and vk shaders.

gl: Rename fetch_rt to sample_from_rt to match vk shaders, remove old atst call.

vk: Make sure shuffle values have correct unsigned type.
This commit is contained in:
lightningterror 2025-02-16 22:07:33 +01:00
parent 4a44d2668c
commit d3e288447f
3 changed files with 13 additions and 15 deletions

View File

@ -111,7 +111,7 @@ layout(binding = 3) uniform sampler2D img_prim_min;
//layout(pixel_center_integer) in vec4 gl_FragCoord; //layout(pixel_center_integer) in vec4 gl_FragCoord;
#endif #endif
vec4 fetch_rt() vec4 sample_from_rt()
{ {
#if !NEEDS_RT #if !NEEDS_RT
return vec4(0.0); return vec4(0.0);
@ -127,7 +127,7 @@ vec4 fetch_rt()
vec4 sample_c(vec2 uv) vec4 sample_c(vec2 uv)
{ {
#if PS_TEX_IS_FB == 1 #if PS_TEX_IS_FB == 1
return fetch_rt(); return sample_from_rt();
#elif PS_REGION_RECT #elif PS_REGION_RECT
return texelFetch(TextureSampler, ivec2(uv), 0); return texelFetch(TextureSampler, ivec2(uv), 0);
#else #else
@ -312,7 +312,7 @@ int fetch_raw_depth()
float multiplier = exp2(32.0f); float multiplier = exp2(32.0f);
#if PS_TEX_IS_FB == 1 #if PS_TEX_IS_FB == 1
return int(fetch_rt().r * multiplier); return int(sample_from_rt().r * multiplier);
#else #else
return int(texelFetch(TextureSampler, ivec2(gl_FragCoord.xy), 0).r * multiplier); return int(texelFetch(TextureSampler, ivec2(gl_FragCoord.xy), 0).r * multiplier);
#endif #endif
@ -321,7 +321,7 @@ int fetch_raw_depth()
vec4 fetch_raw_color() vec4 fetch_raw_color()
{ {
#if PS_TEX_IS_FB == 1 #if PS_TEX_IS_FB == 1
return fetch_rt(); return sample_from_rt();
#else #else
return texelFetch(TextureSampler, ivec2(gl_FragCoord.xy), 0); return texelFetch(TextureSampler, ivec2(gl_FragCoord.xy), 0);
#endif #endif
@ -697,8 +697,6 @@ vec4 ps_color()
vec4 C = tfx(T, PSin.c); vec4 C = tfx(T, PSin.c);
atst(C);
fog(C, PSin.t_float.z); fog(C, PSin.t_float.z);
return C; return C;
@ -709,9 +707,9 @@ void ps_fbmask(inout vec4 C)
// FIXME do I need special case for 16 bits // FIXME do I need special case for 16 bits
#if PS_FBMASK #if PS_FBMASK
#if PS_HDR == 1 #if PS_HDR == 1
vec4 RT = trunc(fetch_rt() * 65535.0f); vec4 RT = trunc(sample_from_rt() * 65535.0f);
#else #else
vec4 RT = trunc(fetch_rt() * 255.0f + 0.1f); vec4 RT = trunc(sample_from_rt() * 255.0f + 0.1f);
#endif #endif
C = vec4((uvec4(C) & ~FbMask) | (uvec4(RT) & FbMask)); C = vec4((uvec4(C) & ~FbMask) | (uvec4(RT) & FbMask));
#endif #endif
@ -799,7 +797,7 @@ float As = As_rgba.a;
#endif #endif
#if SW_BLEND_NEEDS_RT #if SW_BLEND_NEEDS_RT
vec4 RT = fetch_rt(); vec4 RT = sample_from_rt();
#else #else
// Not used, but we define it to make the selection below simpler. // Not used, but we define it to make the selection below simpler.
vec4 RT = vec4(0.0f); vec4 RT = vec4(0.0f);
@ -974,9 +972,9 @@ void ps_main()
#if PS_WRITE_RG == 1 #if PS_WRITE_RG == 1
// Pseudo 16 bits access. // Pseudo 16 bits access.
float rt_a = fetch_rt().g; float rt_a = sample_from_rt().g;
#else #else
float rt_a = fetch_rt().a; float rt_a = sample_from_rt().a;
#endif #endif
#if (PS_DATE & 3) == 1 #if (PS_DATE & 3) == 1
@ -1028,9 +1026,9 @@ void ps_main()
#if SW_AD_TO_HW #if SW_AD_TO_HW
#if PS_RTA_CORRECTION #if PS_RTA_CORRECTION
vec4 RT = trunc(fetch_rt() * 128.0f + 0.1f); vec4 RT = trunc(sample_from_rt() * 128.0f + 0.1f);
#else #else
vec4 RT = trunc(fetch_rt() * 255.0f + 0.1f); vec4 RT = trunc(sample_from_rt() * 255.0f + 0.1f);
#endif #endif
vec4 alpha_blend = vec4(RT.a / 128.0f); vec4 alpha_blend = vec4(RT.a / 128.0f);

View File

@ -954,7 +954,7 @@ vec4 ps_color()
T.a = float(denorm_c_before.a & 0x80u); T.a = float(denorm_c_before.a & 0x80u);
#else #else
T.r = float((denorm_c_before.r << 3) & 0xF8u); T.r = float((denorm_c_before.r << 3) & 0xF8u);
T.g = float(((denorm_c_before.r >> 2) & 0x38) | ((denorm_c_before.g << 6) & 0xC0u)); T.g = float(((denorm_c_before.r >> 2) & 0x38u) | ((denorm_c_before.g << 6) & 0xC0u));
T.b = float((denorm_c_before.g << 1) & 0xF8u); T.b = float((denorm_c_before.g << 1) & 0xF8u);
T.a = float(denorm_c_before.g & 0x80u); T.a = float(denorm_c_before.g & 0x80u);
#endif #endif

View File

@ -3,4 +3,4 @@
/// Version number for GS and other shaders. Increment whenever any of the contents of the /// Version number for GS and other shaders. Increment whenever any of the contents of the
/// shaders change, to invalidate the cache. /// shaders change, to invalidate the cache.
static constexpr u32 SHADER_CACHE_VERSION = 58; static constexpr u32 SHADER_CACHE_VERSION = 59;