From 0c9850e55d11447d79bba1ad070f57ed52e85c96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 10 Feb 2020 20:19:37 -0500 Subject: [PATCH] mesa/i965: remove _mesa_prim::indirect_offset Only i965 was using it. Reviewed-by: Ian Romanick Part-of: --- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/brw_draw.c | 35 +++++++++++-------- .../drivers/dri/i965/brw_primitive_restart.c | 4 ++- src/mesa/main/draw.h | 2 -- src/mesa/vbo/vbo.h | 3 +- src/mesa/vbo/vbo_primitive_restart.c | 5 +-- 6 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index ecd40afc567..95463c68d27 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -911,6 +911,8 @@ struct brw_context /** * Draw indirect buffer. */ + unsigned draw_indirect_stride; + GLsizeiptr draw_indirect_offset; struct gl_buffer_object *draw_indirect_data; } draw; diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index a8dd1572bac..48c1b10d51a 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -161,7 +161,8 @@ brw_emit_prim(struct brw_context *brw, uint32_t hw_prim, struct brw_transform_feedback_object *xfb_obj, unsigned stream, - bool is_indirect) + bool is_indirect, + GLsizeiptr indirect_offset) { const struct gen_device_info *devinfo = &brw->screen->devinfo; int verts_per_instance; @@ -227,25 +228,25 @@ brw_emit_prim(struct brw_context *brw, struct gl_buffer_object *indirect_buffer = brw->ctx.DrawIndirectBuffer; struct brw_bo *bo = intel_bufferobj_buffer(brw, intel_buffer_object(indirect_buffer), - prim->indirect_offset, 5 * sizeof(GLuint), false); + indirect_offset, 5 * sizeof(GLuint), false); indirect_flag = GEN7_3DPRIM_INDIRECT_PARAMETER_ENABLE; brw_load_register_mem(brw, GEN7_3DPRIM_VERTEX_COUNT, bo, - prim->indirect_offset + 0); + indirect_offset + 0); brw_load_register_mem(brw, GEN7_3DPRIM_INSTANCE_COUNT, bo, - prim->indirect_offset + 4); + indirect_offset + 4); brw_load_register_mem(brw, GEN7_3DPRIM_START_VERTEX, bo, - prim->indirect_offset + 8); + indirect_offset + 8); if (prim->indexed) { brw_load_register_mem(brw, GEN7_3DPRIM_BASE_VERTEX, bo, - prim->indirect_offset + 12); + indirect_offset + 12); brw_load_register_mem(brw, GEN7_3DPRIM_START_INSTANCE, bo, - prim->indirect_offset + 16); + indirect_offset + 16); } else { brw_load_register_mem(brw, GEN7_3DPRIM_START_INSTANCE, bo, - prim->indirect_offset + 12); + indirect_offset + 12); brw_load_register_imm32(brw, GEN7_3DPRIM_BASE_VERTEX, 0); } } else { @@ -956,7 +957,8 @@ 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) + unsigned stream, + GLsizeiptr indirect_offset) { struct brw_context *brw = brw_context(ctx); const struct gen_device_info *devinfo = &brw->screen->devinfo; @@ -1021,7 +1023,7 @@ brw_draw_single_prim(struct gl_context *ctx, intel_buffer_object(ctx->DrawIndirectBuffer)->buffer; brw_bo_reference(brw->draw.draw_params_bo); brw->draw.draw_params_offset = - prim->indirect_offset + (prim->indexed ? 12 : 8); + indirect_offset + (prim->indexed ? 12 : 8); } else { /* Set draw_params_bo to NULL so brw_prepare_vertices knows it * has to upload gl_BaseVertex and such if they're needed. @@ -1066,7 +1068,8 @@ retry: if (devinfo->gen == 9) gen9_emit_preempt_wa(brw, prim); - brw_emit_prim(brw, prim, brw->primitive, xfb_obj, stream, is_indirect); + brw_emit_prim(brw, prim, brw->primitive, xfb_obj, stream, is_indirect, + indirect_offset); brw->batch.no_wrap = false; @@ -1182,7 +1185,9 @@ 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); + brw_draw_single_prim(ctx, &prims[i], i, xfb_obj, stream, + brw->draw.draw_indirect_offset + + brw->draw.draw_indirect_stride * i); } brw_finish_drawing(ctx); @@ -1213,12 +1218,14 @@ brw_draw_indirect_prims(struct gl_context *ctx, return; } + brw->draw.draw_indirect_stride = stride; + brw->draw.draw_indirect_offset = indirect_offset; + prim[0].begin = 1; prim[draw_count - 1].end = 1; - for (i = 0; i < draw_count; ++i, indirect_offset += stride) { + for (i = 0; i < draw_count; ++i) { prim[i].mode = mode; prim[i].indexed = ib != NULL; - prim[i].indirect_offset = indirect_offset; prim[i].draw_id = i; } diff --git a/src/mesa/drivers/dri/i965/brw_primitive_restart.c b/src/mesa/drivers/dri/i965/brw_primitive_restart.c index dfb9735ef29..158f9477939 100644 --- a/src/mesa/drivers/dri/i965/brw_primitive_restart.c +++ b/src/mesa/drivers/dri/i965/brw_primitive_restart.c @@ -173,7 +173,9 @@ brw_handle_primitive_restart(struct gl_context *ctx, /* Clear this to make the draw direct. */ brw->draw.draw_indirect_data = NULL; - vbo_sw_primitive_restart(ctx, prims, nr_prims, ib, indirect_data); + vbo_sw_primitive_restart(ctx, prims, nr_prims, ib, + indirect_data, + brw->draw.draw_indirect_offset); } brw->prim_restart.in_progress = false; diff --git a/src/mesa/main/draw.h b/src/mesa/main/draw.h index 528696de60f..47d02f575b1 100644 --- a/src/mesa/main/draw.h +++ b/src/mesa/main/draw.h @@ -65,8 +65,6 @@ struct _mesa_prim GLuint num_instances; GLuint base_instance; GLuint draw_id; - - GLsizeiptr indirect_offset; }; /* Would like to call this a "vbo_index_buffer", but this would be diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 17d668e386f..a03a4cec70b 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -97,7 +97,8 @@ vbo_sw_primitive_restart(struct gl_context *ctx, const struct _mesa_prim *prim, GLuint nr_prims, const struct _mesa_index_buffer *ib, - struct gl_buffer_object *indirect); + struct gl_buffer_object *indirect, + GLsizeiptr indirect_offset); const struct gl_array_attributes* diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c index 4f380b6dcba..b4b3cdf8d4c 100644 --- a/src/mesa/vbo/vbo_primitive_restart.c +++ b/src/mesa/vbo/vbo_primitive_restart.c @@ -164,7 +164,8 @@ vbo_sw_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) + struct gl_buffer_object *indirect, + GLsizeiptr indirect_offset) { GLuint prim_num; struct _mesa_prim new_prim; @@ -196,7 +197,7 @@ vbo_sw_primitive_restart(struct gl_context *ctx, new_prim = prims[0]; indirect_params = (const uint32_t *) ADD_POINTERS(indirect->Mappings[MAP_INTERNAL].Pointer, - new_prim.indirect_offset); + indirect_offset); new_prim.count = indirect_params[0]; new_prim.num_instances = indirect_params[1]; -- 2.30.2