Mesa (master): mesa/main: Maintain compressed fog mode.

Marek Olšák mareko at kemper.freedesktop.org
Sat Apr 8 20:08:03 UTC 2017


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

Author: Gustaw Smolarczyk <wielkiegie at gmail.com>
Date:   Thu Mar 30 20:09:29 2017 +0200

mesa/main: Maintain compressed fog mode.

Signed-off-by: Gustaw Smolarczyk <wielkiegie at gmail.com>
Signed-off-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/main/enable.c |  1 +
 src/mesa/main/fog.c    |  9 +++++++++
 src/mesa/main/mtypes.h | 14 ++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index d9d63a6b4b..ef278a318a 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -385,6 +385,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             return;
          FLUSH_VERTICES(ctx, _NEW_FOG);
          ctx->Fog.Enabled = state;
+         ctx->Fog._PackedEnabledMode = state ? ctx->Fog._PackedMode : FOG_NONE;
          break;
       case GL_LIGHT0:
       case GL_LIGHT1:
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index 1ad939cfde..76e65080b7 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -102,8 +102,13 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
          m = (GLenum) (GLint) *params;
 	 switch (m) {
 	 case GL_LINEAR:
+	    ctx->Fog._PackedMode = FOG_LINEAR;
+	    break;
 	 case GL_EXP:
+	    ctx->Fog._PackedMode = FOG_EXP;
+	    break;
 	 case GL_EXP2:
+	    ctx->Fog._PackedMode = FOG_EXP2;
 	    break;
 	 default:
 	    _mesa_error( ctx, GL_INVALID_ENUM, "glFog" );
@@ -113,6 +118,8 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
 	    return;
 	 FLUSH_VERTICES(ctx, _NEW_FOG);
 	 ctx->Fog.Mode = m;
+	 ctx->Fog._PackedEnabledMode = ctx->Fog.Enabled ?
+				       ctx->Fog._PackedMode : FOG_NONE;
 	 break;
       case GL_FOG_DENSITY:
 	 if (*params<0.0F) {
@@ -210,6 +217,8 @@ void _mesa_init_fog( struct gl_context * ctx )
    /* Fog group */
    ctx->Fog.Enabled = GL_FALSE;
    ctx->Fog.Mode = GL_EXP;
+   ctx->Fog._PackedMode = FOG_EXP;
+   ctx->Fog._PackedEnabledMode = FOG_NONE;
    ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 );
    ASSIGN_4V( ctx->Fog.ColorUnclamped, 0.0, 0.0, 0.0, 0.0 );
    ctx->Fog.Index = 0.0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d0fb6c7c26..4986e42d1b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -575,12 +575,26 @@ struct gl_eval_attrib
 
 
 /**
+ * Compressed fog mode.
+ */
+enum gl_fog_mode
+{
+   FOG_NONE,
+   FOG_LINEAR,
+   FOG_EXP,
+   FOG_EXP2,
+};
+
+
+/**
  * Fog attribute group (GL_FOG_BIT).
  */
 struct gl_fog_attrib
 {
    GLboolean Enabled;		/**< Fog enabled flag */
    GLboolean ColorSumEnabled;
+   uint8_t _PackedMode;		/**< Fog mode as 2 bits */
+   uint8_t _PackedEnabledMode;	/**< Masked CompressedMode */
    GLfloat ColorUnclamped[4];            /**< Fog color */
    GLfloat Color[4];		/**< Fog color */
    GLfloat Density;		/**< Density >= 0.0 */




More information about the mesa-commit mailing list