From c63c8f51358e47383aa0f447b6882070a6d509a1 Mon Sep 17 00:00:00 2001 From: Plamena Manolova Date: Mon, 2 Oct 2017 23:58:24 +0300 Subject: [PATCH] i965: Introduce brw_prepare_drawing. 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 Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_draw.c | 46 ++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 06c6ed72c98..1e93cb67c67 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -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 -- 2.30.2