mesa/i965: remove _mesa_prim::indirect_offset
authorMarek Olšák <marek.olsak@amd.com>
Tue, 11 Feb 2020 01:19:37 +0000 (20:19 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 28 Feb 2020 00:53:45 +0000 (00:53 +0000)
Only i965 was using it.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3990>

src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_primitive_restart.c
src/mesa/main/draw.h
src/mesa/vbo/vbo.h
src/mesa/vbo/vbo_primitive_restart.c

index ecd40afc567c34d7520b52f0852b4d8330e4e08b..95463c68d27d99551f1dc5ec3f56ca2f9ac8a9a3 100644 (file)
@@ -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;
 
index a8dd1572bac804fe765197e360cfa6fdc849f241..48c1b10d51a0973e0f128419536cf03c3d7b89d3 100644 (file)
@@ -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;
    }
 
index dfb9735ef29c694ce8b8448cf3f47602d2dc3323..158f94779397830f951bbf57f0bd17abcf91406e 100644 (file)
@@ -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;
index 528696de60f0e094de70558dcd07fb14ab3c4c8c..47d02f575b169426fb65ac73160d88fb2a6d4bf1 100644 (file)
@@ -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
index 17d668e386f8418423dc05fbe5bd1124f36ba9dd..a03a4cec70b4f25af5dc816a427a16f287f12690 100644 (file)
@@ -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*
index 4f380b6dcbabfce5d258fa26b9f9a23ad61cf566..b4b3cdf8d4c2337c280b40f7e8fc54690d7ac752 100644 (file)
@@ -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];