Skip to content

Commit 6f0ec4d

Browse files
GS: Clamp pow conColor to always be positive.
Fixes warning: warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
1 parent 21876ff commit 6f0ec4d

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

bin/resources/shaders/dx11/shadeboost.fx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ float4 ContrastSaturationBrightness(float4 color) // Ported to HLSL
3737
float3 conColor = lerp(AvgLumin, satColor, con);
3838

3939
float3 csb = conColor;
40-
csb = pow(csb, 1.0 / gam);
40+
csb = pow(max(csb, 0.0), 1.0 / gam);
4141
color.rgb = csb;
4242
return color;
4343
}

bin/resources/shaders/opengl/shadeboost.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ vec4 ContrastSaturationBrightness(vec4 color)
4747
vec3 conColor = mix(AvgLumin, satColor, con);
4848

4949
vec3 csb = conColor;
50-
csb = pow(csb, vec3(1.0 / gam));
50+
csb = pow(max(csb, 0.0), vec3(1.0 / gam));
5151
color.rgb = csb;
5252

5353
return color;

bin/resources/shaders/vulkan/shadeboost.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ vec4 ContrastSaturationBrightness(vec4 color)
6161
vec3 conColor = mix(AvgLumin, satColor, con);
6262

6363
vec3 csb = conColor;
64-
csb = pow(csb, vec3(1.0 / gam));
64+
csb = pow(max(csb, 0.0), vec3(1.0 / gam));
6565
color.rgb = csb;
6666
return color;
6767
}

pcsx2/GS/Renderers/Metal/convert.metal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fragment float4 ps_shadeboost(float4 p [[position]], DirectReadTextureIn<float>
547547
float3 satColor = mix(intensity, brtColor, sat);
548548
float3 conColor = mix(AvgLumin, satColor, con);
549549

550-
float3 csb = pow(conColor, float3(1.0 / gam));
550+
float3 csb = pow(max(conColor, 0.0), 1.0 / gam);
551551

552552
return float4(csb, 1);
553553
}

pcsx2/ShaderCacheVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
/// Version number for GS and other shaders. Increment whenever any of the contents of the
55
/// shaders change, to invalidate the cache.
6-
static constexpr u32 SHADER_CACHE_VERSION = 72;
6+
static constexpr u32 SHADER_CACHE_VERSION = 73;

0 commit comments

Comments
 (0)