[Mesa-dev] [PATCH 07/13] mesa: Minor clean ups in set_combiner_mode

Ian Romanick idr at freedesktop.org
Wed Aug 24 18:46:15 UTC 2016


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/texenv.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index c7403d9..1ab4708 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -106,9 +106,9 @@ set_env_color(struct gl_context *ctx,
 static void
 set_combiner_mode(struct gl_context *ctx,
                   struct gl_texture_unit *texUnit,
-                  GLenum pname, GLenum mode)
+                  bool is_rgb, GLenum mode)
 {
-   GLboolean legal;
+   bool legal;
 
    switch (mode) {
    case GL_REPLACE:
@@ -116,28 +116,26 @@ set_combiner_mode(struct gl_context *ctx,
    case GL_ADD:
    case GL_ADD_SIGNED:
    case GL_INTERPOLATE:
-      legal = GL_TRUE;
+      legal = true;
       break;
    case GL_SUBTRACT:
       legal = ctx->Extensions.ARB_texture_env_combine;
       break;
    case GL_DOT3_RGB_EXT:
    case GL_DOT3_RGBA_EXT:
-      legal = _mesa_has_EXT_texture_env_dot3(ctx) && pname == GL_COMBINE_RGB;
+      legal = _mesa_has_EXT_texture_env_dot3(ctx) && is_rgb;
       break;
    case GL_DOT3_RGB:
    case GL_DOT3_RGBA:
-      legal = (ctx->Extensions.ARB_texture_env_dot3 &&
-               pname == GL_COMBINE_RGB);
+      legal = ctx->Extensions.ARB_texture_env_dot3 && is_rgb;
       break;
    case GL_MODULATE_ADD_ATI:
    case GL_MODULATE_SIGNED_ADD_ATI:
    case GL_MODULATE_SUBTRACT_ATI:
-      legal = (ctx->API == API_OPENGL_COMPAT &&
-               ctx->Extensions.ATI_texture_env_combine3);
+      legal = _mesa_has_ATI_texture_env_combine3(ctx);
       break;
    default:
-      legal = GL_FALSE;
+      legal = false;
    }
 
    if (!legal) {
@@ -145,22 +143,16 @@ set_combiner_mode(struct gl_context *ctx,
       return;
    }
 
-   switch (pname) {
-   case GL_COMBINE_RGB:
+   if (is_rgb) {
       if (texUnit->Combine.ModeRGB == mode)
          return;
       FLUSH_VERTICES(ctx, _NEW_TEXTURE);
       texUnit->Combine.ModeRGB = mode;
-      break;
-
-   case GL_COMBINE_ALPHA:
+   } else {
       if (texUnit->Combine.ModeA == mode)
          return;
       FLUSH_VERTICES(ctx, _NEW_TEXTURE);
       texUnit->Combine.ModeA = mode;
-      break;
-   default:
-      TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
    }
 }
 
@@ -407,7 +399,8 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
          break;
       case GL_COMBINE_RGB:
       case GL_COMBINE_ALPHA:
-         set_combiner_mode(ctx, texUnit, pname, (GLenum) iparam0);
+         set_combiner_mode(ctx, texUnit, pname == GL_COMBINE_RGB,
+                           (GLenum) iparam0);
 	 break;
       case GL_SOURCE0_RGB:
       case GL_SOURCE1_RGB:
-- 
2.5.5



More information about the mesa-dev mailing list