Mesa (master): mesa: Properly set the fog scale (gl_Fog.scale) to +INF when fog start and end are equal.

Henri Verbeet hverbeet at kemper.freedesktop.org
Tue Sep 10 21:01:27 UTC 2013


Module: Mesa
Branch: master
Commit: bd77f517585baa1dba70e7cf260828f0d772e61a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bd77f517585baa1dba70e7cf260828f0d772e61a

Author: Henri Verbeet <hverbeet at gmail.com>
Date:   Sat Aug 31 11:50:16 2013 +0200

mesa: Properly set the fog scale (gl_Fog.scale) to +INF when fog start and end are equal.

This was originally introduced by commit
ba47aabc9868b410cdfe3bc8b6d25a44a598cba2, but unfortunately the commit message
doesn't go into much detail about why +INF would be a problem here.

A similar issue exists for STATE_FOG_PARAMS_OPTIMIZED, but allowing infinity
there would potentially introduce NaNs where they shouldn't exist, depending
on the values of fog end and the fog coord. Since STATE_FOG_PARAMS_OPTIMIZED
is only used for fixed function (including ARB_fragment_program with fog
option), and the calculation there probably isn't very stable to begin with
when fog start and end are close together, it seems best to just leave it
alone.

This fixes piglit glsl-fs-fogscale, and a couple of Wine D3D tests. No piglit
regressions on Cayman.

Signed-off-by: Henri Verbeet <hverbeet at gmail.com>
Tested-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/program/prog_statevars.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index f6073be..145c07c 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -256,8 +256,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
       value[0] = ctx->Fog.Density;
       value[1] = ctx->Fog.Start;
       value[2] = ctx->Fog.End;
-      value[3] = (ctx->Fog.End == ctx->Fog.Start)
-         ? 1.0f : (GLfloat)(1.0 / (ctx->Fog.End - ctx->Fog.Start));
+      value[3] = 1.0f / (ctx->Fog.End - ctx->Fog.Start);
       return;
    case STATE_CLIPPLANE:
       {




More information about the mesa-commit mailing list