[Mesa-dev] [PATCH 4/6] i965: Clarify that we only check one prim's type for cut index support.

Kenneth Graunke kenneth at whitecape.org
Wed Aug 28 16:49:12 PDT 2013


can_cut_index_handle_prims() was passed an array of _mesa_prim objects
and a count, and runs a loop for that many iterations.  However, it
treats the array like a pointer, repeatedly checking the first element.

This is wasteful and bizarre.

The VBO module will never call us with multiple primitives of different
topologies, so it's actually reasonable to just check the first element.

Once.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_primitive_restart.c | 37 +++++++++++------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
index 0dbc48f..ca2e6b7 100644
--- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c
+++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c
@@ -76,7 +76,6 @@ can_cut_index_handle_restart_index(struct gl_context *ctx,
 static bool
 can_cut_index_handle_prims(struct gl_context *ctx,
                            const struct _mesa_prim *prim,
-                           GLuint nr_prims,
                            const struct _mesa_index_buffer *ib)
 {
    struct brw_context *brw = brw_context(ctx);
@@ -92,24 +91,22 @@ can_cut_index_handle_prims(struct gl_context *ctx,
       return false;
    }
 
-   for ( ; nr_prims > 0; nr_prims--) {
-      switch(prim->mode) {
-      case GL_POINTS:
-      case GL_LINES:
-      case GL_LINE_STRIP:
-      case GL_TRIANGLES:
-      case GL_TRIANGLE_STRIP:
-         /* Cut index supports these primitive types */
-         break;
-      default:
-         /* Cut index does not support these primitive types */
-      //case GL_LINE_LOOP:
-      //case GL_TRIANGLE_FAN:
-      //case GL_QUADS:
-      //case GL_QUAD_STRIP:
-      //case GL_POLYGON:
-         return false;
-      }
+   switch (prim->mode) {
+   case GL_POINTS:
+   case GL_LINES:
+   case GL_LINE_STRIP:
+   case GL_TRIANGLES:
+   case GL_TRIANGLE_STRIP:
+      /* Cut index supports these primitive types */
+      break;
+   default:
+      /* Cut index does not support these primitive types */
+   //case GL_LINE_LOOP:
+   //case GL_TRIANGLE_FAN:
+   //case GL_QUADS:
+   //case GL_QUAD_STRIP:
+   //case GL_POLYGON:
+      return false;
    }
 
    return true;
@@ -161,7 +158,7 @@ brw_handle_primitive_restart(struct gl_context *ctx,
     */
    brw->prim_restart.in_progress = true;
 
-   if (can_cut_index_handle_prims(ctx, prim, nr_prims, ib)) {
+   if (can_cut_index_handle_prims(ctx, &prim[0], ib)) {
       /* Cut index should work for primitive restart, so use it
        */
       brw->prim_restart.enable_cut_index = true;
-- 
1.8.3.4



More information about the mesa-dev mailing list