mesa: clamp fog scale to -FLT_MAX instead of FLT_MIN

FLT_MIN is the smallest positive float, not the smallest negative float.

Fixes: 35ae5dce39 ("mesa: don't pass Infs to the shader via gl_Fog.scale")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11412

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37204>
(cherry picked from commit f47e4fee4c)
This commit is contained in:
Georg Lehmann 2025-09-05 11:48:33 +02:00 committed by Eric Engestrom
parent 770debce96
commit 50f967cde1
4 changed files with 2 additions and 10 deletions

View file

@ -8154,7 +8154,7 @@
"description": "mesa: clamp fog scale to -FLT_MAX instead of FLT_MIN",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "35ae5dce39cddb71f217b3f73c8e1244ff0c5b1e",
"notes": null

View file

@ -409,9 +409,5 @@ spec@nv_copy_depth_to_color@nv_copy_depth_to_color 1 0x223344ff,Fail
spec@nv_copy_depth_to_color@nv_copy_depth_to_color 1 0x76356278,Fail
wgl@wgl-multi-context-single-window,Fail
# Should've been fixed by https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/843
# but still seems to be failing.
spec@arb_vertex_program@arb_vertex_program-property-bindings,Fail
# This tests NaNs in a GLSL version where NaNs are undefined
shaders@glsl-fs-fogscale@vs and fs,Fail

View file

@ -584,10 +584,6 @@ spec@!opengl 1.1@line-smooth-stipple,Fail
# bookworm update
spec@ext_framebuffer_multisample@renderbufferstorage-samples,Fail
# remove this after https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/843
# is merged and piglit is updated
spec@glsl-1.10@execution@glsl-1.10-built-in-uniform-state,Fail
x11-dEQP-EGL.functional.wide_color.pbuffer_888_colorspace_srgb,Fail
x11-dEQP-EGL.functional.wide_color.window_888_colorspace_srgb,Fail

View file

@ -317,7 +317,7 @@ fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
* The division by 2 makes it less likely that ALU ops will generate
* Inf.
*/
scale = CLAMP(scale, FLT_MIN / 2, FLT_MAX / 2);
scale = CLAMP(scale, -FLT_MAX / 2, FLT_MAX / 2);
value[0] = ctx->Fog.Density;
value[1] = ctx->Fog.Start;
value[2] = ctx->Fog.End;