From 9556805ac4d149d370de97e6a409e99250b94ebc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 10 Feb 2020 19:54:44 -0500 Subject: [PATCH] i965: stop using "indirect" parameter from Driver.Draw (non-indirect) The parameter will be removed. v2: added UNUSED, removed "!!" Reviewed-by: Ian Romanick Part-of: --- src/mesa/drivers/dri/i965/brw_context.h | 5 +++++ src/mesa/drivers/dri/i965/brw_draw.c | 21 +++++++++++-------- src/mesa/drivers/dri/i965/brw_draw.h | 3 +-- .../drivers/dri/i965/brw_primitive_restart.c | 12 +++++++---- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 754d651d190..ecd40afc567 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -907,6 +907,11 @@ struct brw_context */ struct brw_bo *draw_params_count_bo; uint32_t draw_params_count_offset; + + /** + * Draw indirect buffer. + */ + struct gl_buffer_object *draw_indirect_data; } draw; struct { diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 3f705bce6ac..92c57742d75 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -956,12 +956,12 @@ brw_draw_single_prim(struct gl_context *ctx, const struct _mesa_prim *prim, unsigned prim_id, struct brw_transform_feedback_object *xfb_obj, - unsigned stream, - struct gl_buffer_object *indirect) + unsigned stream) { struct brw_context *brw = brw_context(ctx); const struct gen_device_info *devinfo = &brw->screen->devinfo; bool fail_next; + bool is_indirect = brw->draw.draw_indirect_data != NULL; /* Flag BRW_NEW_DRAW_CALL on every draw. This allows us to have * atoms that happen on every draw call. @@ -1003,7 +1003,7 @@ brw_draw_single_prim(struct gl_context *ctx, vs_prog_data->uses_firstvertex || vs_prog_data->uses_baseinstance; - if ((uses_draw_parameters && indirect) || + if ((uses_draw_parameters && is_indirect) || (vs_prog_data->uses_firstvertex && brw->draw.params.firstvertex != new_firstvertex) || (vs_prog_data->uses_baseinstance && @@ -1015,7 +1015,7 @@ brw_draw_single_prim(struct gl_context *ctx, brw->draw.params.gl_baseinstance = new_baseinstance; brw_bo_unreference(brw->draw.draw_params_bo); - if (indirect) { + if (is_indirect) { /* Point draw_params_bo at the indirect buffer. */ brw->draw.draw_params_bo = intel_buffer_object(ctx->DrawIndirectBuffer)->buffer; @@ -1066,7 +1066,7 @@ retry: if (devinfo->gen == 9) gen9_emit_preempt_wa(brw, prim); - brw_emit_prim(brw, prim, brw->primitive, xfb_obj, stream, !!indirect); + brw_emit_prim(brw, prim, brw->primitive, xfb_obj, stream, is_indirect); brw->batch.no_wrap = false; @@ -1105,7 +1105,7 @@ brw_draw_prims(struct gl_context *ctx, GLuint max_index, struct gl_transform_feedback_object *gl_xfb_obj, unsigned stream, - struct gl_buffer_object *indirect) + UNUSED struct gl_buffer_object *unused_indirect) { unsigned i; struct brw_context *brw = brw_context(ctx); @@ -1117,7 +1117,7 @@ brw_draw_prims(struct gl_context *ctx, return; /* Handle primitive restart if needed */ - if (brw_handle_primitive_restart(ctx, prims, nr_prims, ib, indirect)) { + if (brw_handle_primitive_restart(ctx, prims, nr_prims, ib)) { /* The draw was handled, so we can exit now */ return; } @@ -1183,7 +1183,7 @@ brw_draw_prims(struct gl_context *ctx, brw->predicate.state = BRW_PREDICATE_STATE_USE_BIT; } - brw_draw_single_prim(ctx, &prims[i], i, xfb_obj, stream, indirect); + brw_draw_single_prim(ctx, &prims[i], i, xfb_obj, stream); } brw_finish_drawing(ctx); @@ -1230,11 +1230,14 @@ brw_draw_indirect_prims(struct gl_context *ctx, brw->draw.draw_params_count_offset = indirect_params_offset; } + brw->draw.draw_indirect_data = indirect_data; + brw_draw_prims(ctx, prim, draw_count, ib, false, 0, ~0, NULL, 0, - indirect_data); + NULL); + brw->draw.draw_indirect_data = NULL; free(prim); } diff --git a/src/mesa/drivers/dri/i965/brw_draw.h b/src/mesa/drivers/dri/i965/brw_draw.h index c74a2536aa1..1e111fe7431 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.h +++ b/src/mesa/drivers/dri/i965/brw_draw.h @@ -66,8 +66,7 @@ GLboolean brw_handle_primitive_restart(struct gl_context *ctx, const struct _mesa_prim *prims, GLuint nr_prims, - const struct _mesa_index_buffer *ib, - struct gl_buffer_object *indirect); + const struct _mesa_index_buffer *ib); void brw_draw_indirect_prims(struct gl_context *ctx, diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c b/src/mesa/drivers/dri/i965/brw_primitive_restart.c index 3b696aa9cbc..4e4aeeb0a80 100644 --- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c +++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c @@ -130,8 +130,7 @@ GLboolean brw_handle_primitive_restart(struct gl_context *ctx, const struct _mesa_prim *prims, GLuint nr_prims, - const struct _mesa_index_buffer *ib, - struct gl_buffer_object *indirect) + const struct _mesa_index_buffer *ib) { struct brw_context *brw = brw_context(ctx); @@ -164,13 +163,18 @@ brw_handle_primitive_restart(struct gl_context *ctx, */ brw->prim_restart.enable_cut_index = true; brw_draw_prims(ctx, prims, nr_prims, ib, GL_FALSE, -1, -1, NULL, 0, - indirect); + NULL); brw->prim_restart.enable_cut_index = false; } else { /* Not all the primitive draw modes are supported by the cut index, * so take the software path */ - vbo_sw_primitive_restart(ctx, prims, nr_prims, ib, indirect); + struct gl_buffer_object *indirect_data = brw->draw.draw_indirect_data; + + /* Clear this to make the draw direct. */ + brw->draw.draw_indirect_data = NULL; + + vbo_sw_primitive_restart(ctx, prims, nr_prims, ib, indirect_data); } brw->prim_restart.in_progress = false; -- 2.30.2