Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS/HW: Cleanup gl and vk shaders. #12316

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions bin/resources/shaders/opengl/tfx_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ layout(binding = 3) uniform sampler2D img_prim_min;
//layout(pixel_center_integer) in vec4 gl_FragCoord;
#endif

vec4 fetch_rt()
vec4 sample_from_rt()
{
#if !NEEDS_RT
return vec4(0.0);
Expand All @@ -127,7 +127,7 @@ vec4 fetch_rt()
vec4 sample_c(vec2 uv)
{
#if PS_TEX_IS_FB == 1
return fetch_rt();
return sample_from_rt();
#elif PS_REGION_RECT
return texelFetch(TextureSampler, ivec2(uv), 0);
#else
Expand Down Expand Up @@ -312,7 +312,7 @@ int fetch_raw_depth()
float multiplier = exp2(32.0f);

#if PS_TEX_IS_FB == 1
return int(fetch_rt().r * multiplier);
return int(sample_from_rt().r * multiplier);
#else
return int(texelFetch(TextureSampler, ivec2(gl_FragCoord.xy), 0).r * multiplier);
#endif
Expand All @@ -321,7 +321,7 @@ int fetch_raw_depth()
vec4 fetch_raw_color()
{
#if PS_TEX_IS_FB == 1
return fetch_rt();
return sample_from_rt();
#else
return texelFetch(TextureSampler, ivec2(gl_FragCoord.xy), 0);
#endif
Expand Down Expand Up @@ -697,8 +697,6 @@ vec4 ps_color()

vec4 C = tfx(T, PSin.c);

atst(C);

fog(C, PSin.t_float.z);

return C;
Expand All @@ -709,9 +707,9 @@ void ps_fbmask(inout vec4 C)
// FIXME do I need special case for 16 bits
#if PS_FBMASK
#if PS_HDR == 1
vec4 RT = trunc(fetch_rt() * 65535.0f);
vec4 RT = trunc(sample_from_rt() * 65535.0f);
#else
vec4 RT = trunc(fetch_rt() * 255.0f + 0.1f);
vec4 RT = trunc(sample_from_rt() * 255.0f + 0.1f);
#endif
C = vec4((uvec4(C) & ~FbMask) | (uvec4(RT) & FbMask));
#endif
Expand Down Expand Up @@ -799,7 +797,7 @@ float As = As_rgba.a;
#endif

#if SW_BLEND_NEEDS_RT
vec4 RT = fetch_rt();
vec4 RT = sample_from_rt();
#else
// Not used, but we define it to make the selection below simpler.
vec4 RT = vec4(0.0f);
Expand Down Expand Up @@ -974,9 +972,9 @@ void ps_main()

#if PS_WRITE_RG == 1
// Pseudo 16 bits access.
float rt_a = fetch_rt().g;
float rt_a = sample_from_rt().g;
#else
float rt_a = fetch_rt().a;
float rt_a = sample_from_rt().a;
#endif

#if (PS_DATE & 3) == 1
Expand Down Expand Up @@ -1028,9 +1026,9 @@ void ps_main()

#if SW_AD_TO_HW
#if PS_RTA_CORRECTION
vec4 RT = trunc(fetch_rt() * 128.0f + 0.1f);
vec4 RT = trunc(sample_from_rt() * 128.0f + 0.1f);
#else
vec4 RT = trunc(fetch_rt() * 255.0f + 0.1f);
vec4 RT = trunc(sample_from_rt() * 255.0f + 0.1f);
#endif

vec4 alpha_blend = vec4(RT.a / 128.0f);
Expand Down
2 changes: 1 addition & 1 deletion bin/resources/shaders/vulkan/tfx.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ vec4 ps_color()
T.a = float(denorm_c_before.a & 0x80u);
#else
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.a = float(denorm_c_before.g & 0x80u);
#endif
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/ShaderCacheVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

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