i965: Introduce brw_prepare_drawing.
authorPlamena Manolova <plamena.n.manolova@gmail.com>
Mon, 2 Oct 2017 20:58:24 +0000 (23:58 +0300)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 2 Oct 2017 23:25:36 +0000 (16:25 -0700)
In order to add our ARB_indirect_parameters implementation we
need to refactor brw_try_draw_prims so that it operates on a
per primitive basis and move the loop into brw_draw_prims.
This commit introduces the brw_prepare_drawing function where
we move the code that executes once before the loop.

Signed-off-by: Plamena Manolova <plamena.manolova@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_draw.c

index 06c6ed72c98e2d71c7bff68b84b1c138191b40da..1e93cb67c6726beab1337a2a068fbdd9b3137c68 100644 (file)
@@ -593,26 +593,15 @@ brw_postdraw_reconcile_align_wa_slices(struct brw_context *brw)
    }
 }
 
-/* May fail if out of video memory for texture or vbo upload, or on
- * fallback conditions.
- */
 static void
-brw_try_draw_prims(struct gl_context *ctx,
-                   const struct gl_vertex_array *arrays[],
-                   const struct _mesa_prim *prims,
-                   GLuint nr_prims,
-                   const struct _mesa_index_buffer *ib,
-                   bool index_bounds_valid,
-                   GLuint min_index,
-                   GLuint max_index,
-                   struct brw_transform_feedback_object *xfb_obj,
-                   unsigned stream,
-                   struct gl_buffer_object *indirect)
+brw_prepare_drawing(struct gl_context *ctx,
+                    const struct gl_vertex_array *arrays[],
+                    const struct _mesa_index_buffer *ib,
+                    bool index_bounds_valid,
+                    GLuint min_index,
+                    GLuint max_index)
 {
    struct brw_context *brw = brw_context(ctx);
-   const struct gen_device_info *devinfo = &brw->screen->devinfo;
-   GLuint i;
-   bool fail_next = false;
 
    if (ctx->NewState)
       _mesa_update_state(ctx);
@@ -667,6 +656,24 @@ brw_try_draw_prims(struct gl_context *ctx,
    brw->vb.min_index = min_index;
    brw->vb.max_index = max_index;
    brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
+}
+
+/* May fail if out of video memory for texture or vbo upload, or on
+ * fallback conditions.
+ */
+static void
+brw_try_draw_prims(struct gl_context *ctx,
+                   const struct gl_vertex_array *arrays[],
+                   const struct _mesa_prim *prims,
+                   GLuint nr_prims,
+                   struct brw_transform_feedback_object *xfb_obj,
+                   unsigned stream,
+                   struct gl_buffer_object *indirect)
+{
+   struct brw_context *brw = brw_context(ctx);
+   const struct gen_device_info *devinfo = &brw->screen->devinfo;
+   GLuint i;
+   bool fail_next = false;
 
    for (i = 0; i < nr_prims; i++) {
       /* Flag BRW_NEW_DRAW_CALL on every draw.  This allows us to have
@@ -849,12 +856,13 @@ brw_draw_prims(struct gl_context *ctx,
       index_bounds_valid = true;
    }
 
+   brw_prepare_drawing(ctx, arrays, ib, index_bounds_valid, min_index,
+                       max_index);
    /* Try drawing with the hardware, but don't do anything else if we can't
     * manage it.  swrast doesn't support our featureset, so we can't fall back
     * to it.
     */
-   brw_try_draw_prims(ctx, arrays, prims, nr_prims, ib, index_bounds_valid,
-                      min_index, max_index, xfb_obj, stream, indirect);
+   brw_try_draw_prims(ctx, arrays, prims, nr_prims, xfb_obj, stream, indirect);
 }
 
 void