i965: Store per-stage push constant BO pointers.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 27 Jun 2017 21:38:13 +0000 (14:38 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 14 Jul 2017 02:56:49 +0000 (19:56 -0700)
Right now, we always upload new push constant data, and immediately
emit 3DSTATE_CONSTANT_* packets.  We call intel_upload_space and store
the resulting BO pointer in brw->curbe.curbe_bo.  We read that when
emitting the packets.  This works today, but is fragile - it depends on
upload and packet emission being interleaved.

If we instead were to upload all the data, then emit all the packets,
then upload BO wrapping will get us into trouble.  For example, the VS
constants may land in one upload BO, but the FS constants may not fit
and land in a second upload BO.  Uploading FS constants would overwrite
the brw->curbe.curbe_bo pointer, so when we emitted 3DSTATE_CONSTANT_VS,
we'd get the wrong BO.

I intend to separate out this code in a future commit, so I need to fix
this.  To fix it, we simply store a per-stage BO pointer.

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/gen6_constant_state.c
src/mesa/drivers/dri/i965/genX_state_upload.c

index 3a613ff63e6587629d39c438b2e924e4e3ea07a0..d7ea7fae31d18c9b5666aab2074012953fab820b 100644 (file)
@@ -552,7 +552,8 @@ struct brw_stage_state
    /** Offset in the batchbuffer to Gen4-5 pipelined state (VS/WM/GS_STATE). */
    uint32_t state_offset;
 
-   uint32_t push_const_offset; /* Offset in the batchbuffer */
+   struct brw_bo *push_const_bo; /* NULL if using the batchbuffer */
+   uint32_t push_const_offset; /* Offset in the push constant BO or batch */
    int push_const_size; /* in 256-bit register increments */
 
    /* Binding table: pointers to SURFACE_STATE entries. */
index f3927c5dba280bc72894b14bc3dc41ce793d0eb4..920f502ca37cccda3e284014747f91415f47209e 100644 (file)
@@ -65,7 +65,8 @@ gen6_upload_push_constants(struct brw_context *brw,
       const int size = prog_data->nr_params * sizeof(gl_constant_value);
       gl_constant_value *param;
       if (brw->gen >= 8 || brw->is_haswell) {
-         param = intel_upload_space(brw, size, 32, &brw->curbe.curbe_bo,
+         param = intel_upload_space(brw, size, 32,
+                                    &stage_state->push_const_bo,
                                     &stage_state->push_const_offset);
       } else {
          param = brw_state_batch(brw, size, 32,
index b6678ec69411021ade4baca07ec1cd191ae77b0f..e0b87b762d2820594b26bc3a4583118e8ae08d8a 100644 (file)
@@ -2858,7 +2858,8 @@ upload_constant_state(struct brw_context *brw,
 #if GEN_GEN >= 8 || GEN_IS_HASWELL
          pkt.ConstantBody.ReadLength[2] = stage_state->push_const_size;
          pkt.ConstantBody.Buffer[2] =
-            render_ro_bo(brw->curbe.curbe_bo, stage_state->push_const_offset);
+            render_ro_bo(stage_state->push_const_bo,
+                         stage_state->push_const_offset);
 #else
          pkt.ConstantBody.ReadLength[0] = stage_state->push_const_size;
          pkt.ConstantBody.Buffer[0].offset =