[Mesa-dev] [PATCH 3/3] mesa/vbo: Remove vp_mode enum in favor of a boolean.

Kenneth Graunke kenneth at whitecape.org
Tue Oct 16 11:57:32 PDT 2012


Now that there are only two options, an enum seems unnecessary.
---
 src/mesa/vbo/vbo_context.h    | 17 +++++++----------
 src/mesa/vbo/vbo_exec.h       |  7 -------
 src/mesa/vbo/vbo_exec_array.c |  8 ++------
 src/mesa/vbo/vbo_exec_draw.c  | 10 +++-------
 src/mesa/vbo/vbo_save_draw.c  | 10 +++-------
 5 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index c896f11..cc04b99 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -51,6 +51,7 @@
 #ifndef _VBO_CONTEXT_H
 #define _VBO_CONTEXT_H
 
+#include <stdbool.h>
 #include "main/mfeatures.h"
 #include "vbo.h"
 #include "vbo_attrib.h"
@@ -96,18 +97,14 @@ static inline struct vbo_context *vbo_context(struct gl_context *ctx)
 
 
 /**
- * Return VP_x token to indicate whether we're running fixed-function
- * vertex transformation, an NV vertex program or ARB vertex program/shader.
+ * Return true if we're running an ARB vertex program/shader, or false
+ * for fixed-function vertex transformation.
  */
-static inline enum vp_mode
-get_program_mode( struct gl_context *ctx )
+static inline bool
+vertex_program_active(struct gl_context *ctx)
 {
-   if (!ctx->VertexProgram._Current)
-      return VP_NONE;
-   else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram)
-      return VP_NONE;
-   else
-      return VP_ARB;
+   return ctx->VertexProgram._Current &&
+          ctx->VertexProgram._Current != ctx->VertexProgram._TnlProgram;
 }
 
 
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index ef57a81..32acb5d 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -52,13 +52,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define VBO_VERT_BUFFER_SIZE (1024*64)	/* bytes */
 
 
-/** Current vertex program mode */
-enum vp_mode {
-   VP_NONE,   /**< fixed function */
-   VP_ARB     /**< ARB vertex program or GLSL vertex shader */
-};
-
-
 struct vbo_exec_eval1_map {
    struct gl_1d_map *map;
    GLuint sz;
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index d857ac3..14b5b36 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -409,8 +409,7 @@ recalculate_input_bindings(struct gl_context *ctx)
    GLbitfield64 const_inputs = 0x0;
    GLuint i;
 
-   switch (get_program_mode(ctx)) {
-   case VP_NONE:
+   if (!vertex_program_active(ctx)) {
       /* When no vertex program is active (or the vertex program is generated
        * from fixed-function state).  We put the material values into the
        * generic slots.  This is the only situation where material values
@@ -438,9 +437,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 	 inputs[VERT_ATTRIB_GENERIC(i)] = &vbo->currval[VBO_ATTRIB_GENERIC0+i];
          const_inputs |= VERT_BIT_GENERIC(i);
       }
-      break;
-
-   case VP_ARB:
+   } else {
       /* GL_ARB_vertex_program or GLSL vertex shader - Only the generic[0]
        * attribute array aliases and overrides the legacy position array.  
        *
@@ -476,7 +473,6 @@ recalculate_input_bindings(struct gl_context *ctx)
       }
 
       inputs[VERT_ATTRIB_GENERIC0] = inputs[0];
-      break;
    }
 
    _mesa_set_varying_vp_inputs( ctx, VERT_BIT_ALL & (~const_inputs) );
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 817af4d..0beb7c4 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -168,8 +168,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
    /* Install the default (ie Current) attributes first, then overlay
     * all active ones.
     */
-   switch (get_program_mode(exec->ctx)) {
-   case VP_NONE:
+   if (!vertex_program_active(exec->ctx)) {
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
          exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
@@ -179,8 +178,8 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
             &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
       }
       map = vbo->map_vp_none;
-      break;
-   case VP_ARB:
+   } else {
+      /* Vertex program active */
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
          exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
@@ -202,9 +201,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
          exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
          exec->vtx.attrsz[0] = 0;
       }
-      break;
-   default:
-      assert(0);
    }
 
    /* Make all active attributes (including edgeflag) available as
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 09b8b8a..9da16ae 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -141,8 +141,7 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
    /* Install the default (ie Current) attributes first, then overlay
     * all active ones.
     */
-   switch (get_program_mode(ctx)) {
-   case VP_NONE:
+   if (!vertex_program_active(ctx)) {
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
          save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
@@ -151,8 +150,8 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
             &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
       }
       map = vbo->map_vp_none;
-      break;
-   case VP_ARB:
+   } else {
+      /* Vertex program active */
       for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
          save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
       }
@@ -172,9 +171,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
          node_attrsz[VERT_ATTRIB_GENERIC0] = node_attrsz[0];
          node_attrsz[0] = 0;
       }
-      break;
-   default:
-      assert(0);
    }
 
    for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
-- 
1.7.12.3



More information about the mesa-dev mailing list