i965: Avoid redundant call to brw_merge_inputs() in brw_try_draw_prims()
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 8 May 2014 11:29:20 +0000 (13:29 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Tue, 13 May 2014 08:09:35 +0000 (10:09 +0200)
We always call brw_merge_inputs() right before looping over the primitives but
this can be called inside the loop for each primitive too. In the case we do it
for the first primitive the call is redundant and can be skipped.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_draw.c

index fef1c063e156ae72110fa5e37373ae55b3a4eb01..ac21656012a9991ca94e19955232b9baa7b619b3 100644 (file)
@@ -458,15 +458,14 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
       intel_batchbuffer_require_space(brw, estimated_max_prim_size, RENDER_RING);
       intel_batchbuffer_save_state(brw);
 
-      if (brw->num_instances != prims[i].num_instances) {
+      if (brw->num_instances != prims[i].num_instances ||
+          brw->basevertex != prims[i].basevertex) {
          brw->num_instances = prims[i].num_instances;
-         brw->state.dirty.brw |= BRW_NEW_VERTICES;
-         brw_merge_inputs(brw, arrays);
-      }
-      if (brw->basevertex != prims[i].basevertex) {
          brw->basevertex = prims[i].basevertex;
-         brw->state.dirty.brw |= BRW_NEW_VERTICES;
-         brw_merge_inputs(brw, arrays);
+         if (i > 0) { /* For i == 0 we just did this before the loop */
+            brw->state.dirty.brw |= BRW_NEW_VERTICES;
+            brw_merge_inputs(brw, arrays);
+         }
       }
       if (brw->gen < 6)
         brw_set_prim(brw, &prims[i]);