Skip to content
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: 12 additions & 12 deletions bin/resources/shaders/dx11/tfx.fx
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,14 @@ float4x4 sample_4p(uint4 u)
return c;
}

int fetch_raw_depth(int2 xy)
uint fetch_raw_depth(int2 xy)
{
#if PS_TEX_IS_FB == 1
float4 col = RtTexture.Load(int3(xy, 0));
#else
float4 col = Texture.Load(int3(xy, 0));
#endif
return (int)(col.r * exp2(32.0f));
return (uint)(col.r * exp2(32.0f));
}

float4 fetch_raw_color(int2 xy)
Expand Down Expand Up @@ -466,10 +466,10 @@ float4 sample_depth(float2 st, float2 pos)
if (PS_TALES_OF_ABYSS_HLE == 1)
{
// Warning: UV can't be used in channel effect
int depth = fetch_raw_depth(pos);
uint depth = fetch_raw_depth(pos);

// Convert msb based on the palette
t = Palette.Load(int3((depth >> 8) & 0xFF, 0, 0)) * 255.0f;
t = Palette.Load(int3((depth >> 8u) & 0xFFu, 0, 0)) * 255.0f;
}
else if (PS_URBAN_CHAOS_HLE == 1)
{
Expand All @@ -480,13 +480,13 @@ float4 sample_depth(float2 st, float2 pos)
// To be faster both steps (msb&lsb) are done in a single pass.

// Warning: UV can't be used in channel effect
int depth = fetch_raw_depth(pos);
uint depth = fetch_raw_depth(pos);

// Convert lsb based on the palette
t = Palette.Load(int3(depth & 0xFF, 0, 0)) * 255.0f;
t = Palette.Load(int3(depth & 0xFFu, 0, 0)) * 255.0f;

// Msb is easier
float green = (float)((depth >> 8) & 0xFF) * 36.0f;
float green = (float)((depth >> 8u) & 0xFFu) * 36.0f;
green = min(green, 255.0f);
t.g += green;
}
Expand Down Expand Up @@ -538,7 +538,7 @@ float4 fetch_red(int2 xy)

if ((PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2))
{
int depth = (fetch_raw_depth(xy)) & 0xFF;
uint depth = (fetch_raw_depth(xy)) & 0xFFu;
rt = (float4)(depth) / 255.0f;
}
else
Expand All @@ -555,7 +555,7 @@ float4 fetch_green(int2 xy)

if ((PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2))
{
int depth = (fetch_raw_depth(xy) >> 8) & 0xFF;
uint depth = (fetch_raw_depth(xy) >> 8u) & 0xFFu;
rt = (float4)(depth) / 255.0f;
}
else
Expand All @@ -572,7 +572,7 @@ float4 fetch_blue(int2 xy)

if ((PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2))
{
int depth = (fetch_raw_depth(xy) >> 16) & 0xFF;
uint depth = (fetch_raw_depth(xy) >> 16u) & 0xFFu;
rt = (float4)(depth) / 255.0f;
}
else
Expand Down Expand Up @@ -600,8 +600,8 @@ float4 fetch_gXbY(int2 xy)
{
if ((PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2))
{
int depth = fetch_raw_depth(xy);
int bg = (depth >> (8 + ChannelShuffle.w)) & 0xFF;
uint depth = fetch_raw_depth(xy);
uint bg = (depth >> (8u + uint(ChannelShuffle.w))) & 0xFFu;
return (float4)(bg);
}
else
Expand Down
26 changes: 13 additions & 13 deletions bin/resources/shaders/opengl/tfx_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,14 @@ mat4 sample_4p(uvec4 u)
return c;
}

int fetch_raw_depth()
uint fetch_raw_depth()
{
float multiplier = exp2(32.0f);

#if PS_TEX_IS_FB == 1
return int(sample_from_rt().r * multiplier);
return uint(sample_from_rt().r * multiplier);
#else
return int(texelFetch(TextureSampler, ivec2(gl_FragCoord.xy + ChannelShuffleOffset), 0).r * multiplier);
return uint(texelFetch(TextureSampler, ivec2(gl_FragCoord.xy + ChannelShuffleOffset), 0).r * multiplier);
#endif
}

Expand Down Expand Up @@ -393,10 +393,10 @@ vec4 sample_depth(vec2 st)

#if PS_TALES_OF_ABYSS_HLE == 1
// Warning: UV can't be used in channel effect
int depth = fetch_raw_depth();
uint depth = fetch_raw_depth();

// Convert msb based on the palette
t = texelFetch(PaletteSampler, ivec2((depth >> 8) & 0xFF, 0), 0) * 255.0f;
t = texelFetch(PaletteSampler, ivec2((depth >> 8u) & 0xFFu, 0), 0) * 255.0f;

#elif PS_URBAN_CHAOS_HLE == 1
// Depth buffer is read as a RGB5A1 texture. The game try to extract the green channel.
Expand All @@ -406,13 +406,13 @@ vec4 sample_depth(vec2 st)
// To be faster both steps (msb&lsb) are done in a single pass.

// Warning: UV can't be used in channel effect
int depth = fetch_raw_depth();
uint depth = fetch_raw_depth();

// Convert lsb based on the palette
t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0) * 255.0f;
t = texelFetch(PaletteSampler, ivec2((depth & 0xFFu), 0), 0) * 255.0f;

// Msb is easier
float green = float((depth >> 8) & 0xFF) * 36.0f;
float green = float((depth >> 8u) & 0xFFu) * 36.0f;
green = min(green, 255.0f);

t.g += green;
Expand Down Expand Up @@ -454,7 +454,7 @@ vec4 sample_depth(vec2 st)
vec4 fetch_red()
{
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
int depth = (fetch_raw_depth()) & 0xFF;
uint depth = (fetch_raw_depth()) & 0xFFu;
vec4 rt = vec4(depth) / 255.0f;
#else
vec4 rt = fetch_raw_color();
Expand All @@ -465,7 +465,7 @@ vec4 fetch_red()
vec4 fetch_green()
{
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
int depth = (fetch_raw_depth() >> 8) & 0xFF;
uint depth = (fetch_raw_depth() >> 8u) & 0xFFu;
vec4 rt = vec4(depth) / 255.0f;
#else
vec4 rt = fetch_raw_color();
Expand All @@ -476,7 +476,7 @@ vec4 fetch_green()
vec4 fetch_blue()
{
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
int depth = (fetch_raw_depth() >> 16) & 0xFF;
uint depth = (fetch_raw_depth() >> 16u) & 0xFFu;
vec4 rt = vec4(depth) / 255.0f;
#else
vec4 rt = fetch_raw_color();
Expand All @@ -500,8 +500,8 @@ vec4 fetch_rgb()
vec4 fetch_gXbY()
{
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
int depth = fetch_raw_depth();
int bg = (depth >> (8 + ChannelShuffle.w)) & 0xFF;
uint depth = fetch_raw_depth();
uint bg = (depth >> (8u + uint(ChannelShuffle.w))) & 0xFFu;
return vec4(bg);
#else
ivec4 rt = ivec4(fetch_raw_color() * 255.0f);
Expand Down
24 changes: 12 additions & 12 deletions bin/resources/shaders/vulkan/tfx.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,14 @@ mat4 sample_4p(uvec4 u)
return c;
}

int fetch_raw_depth(ivec2 xy)
uint fetch_raw_depth(ivec2 xy)
{
#if PS_TEX_IS_FB
vec4 col = sample_from_rt();
#else
vec4 col = texelFetch(Texture, xy, 0);
#endif
return int(col.r * exp2(32.0f));
return uint(col.r * exp2(32.0f));
}

vec4 fetch_raw_color(ivec2 xy)
Expand Down Expand Up @@ -642,10 +642,10 @@ vec4 sample_depth(vec2 st, ivec2 pos)
#if (PS_TALES_OF_ABYSS_HLE == 1)
{
// Warning: UV can't be used in channel effect
int depth = fetch_raw_depth(pos);
uint depth = fetch_raw_depth(pos);

// Convert msb based on the palette
t = texelFetch(Palette, ivec2((depth >> 8) & 0xFF, 0), 0) * 255.0f;
t = texelFetch(Palette, ivec2((depth >> 8u) & 0xFFu, 0), 0) * 255.0f;
}
#elif (PS_URBAN_CHAOS_HLE == 1)
{
Expand All @@ -656,13 +656,13 @@ vec4 sample_depth(vec2 st, ivec2 pos)
// To be faster both steps (msb&lsb) are done in a single pass.

// Warning: UV can't be used in channel effect
int depth = fetch_raw_depth(pos);
uint depth = fetch_raw_depth(pos);

// Convert lsb based on the palette
t = texelFetch(Palette, ivec2(depth & 0xFF, 0), 0) * 255.0f;
t = texelFetch(Palette, ivec2(depth & 0xFFu, 0), 0) * 255.0f;

// Msb is easier
float green = float(((depth >> 8) & 0xFF) * 36.0f);
float green = float(((depth >> 8u) & 0xFFu) * 36.0f);
green = min(green, 255.0f);
t.g += green;
}
Expand Down Expand Up @@ -715,7 +715,7 @@ vec4 fetch_red(ivec2 xy)
vec4 rt;

#if (PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2)
int depth = (fetch_raw_depth(xy)) & 0xFF;
uint depth = (fetch_raw_depth(xy)) & 0xFFu;
rt = vec4(float(depth) / 255.0f);
#else
rt = fetch_raw_color(xy);
Expand All @@ -729,7 +729,7 @@ vec4 fetch_green(ivec2 xy)
vec4 rt;

#if (PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2)
int depth = (fetch_raw_depth(xy) >> 8) & 0xFF;
uint depth = (fetch_raw_depth(xy) >> 8u) & 0xFFu;
rt = vec4(float(depth) / 255.0f);
#else
rt = fetch_raw_color(xy);
Expand All @@ -743,7 +743,7 @@ vec4 fetch_blue(ivec2 xy)
vec4 rt;

#if (PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2)
int depth = (fetch_raw_depth(xy) >> 16) & 0xFF;
uint depth = (fetch_raw_depth(xy) >> 16u) & 0xFFu;
rt = vec4(float(depth) / 255.0f);
#else
rt = fetch_raw_color(xy);
Expand All @@ -768,8 +768,8 @@ vec4 fetch_rgb(ivec2 xy)
vec4 fetch_gXbY(ivec2 xy)
{
#if (PS_DEPTH_FMT == 1) || (PS_DEPTH_FMT == 2)
int depth = fetch_raw_depth(xy);
int bg = (depth >> (8 + ChannelShuffle.w)) & 0xFF;
uint depth = fetch_raw_depth(xy);
uint bg = (depth >> (8u + uint(ChannelShuffle.w))) & 0xFFu;
return vec4(bg);
#else
ivec4 rt = ivec4(fetch_raw_color(xy) * 255.0);
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 = 82;
static constexpr u32 SHADER_CACHE_VERSION = 83;