iris: save pointers to streamed state resources
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 15 Jun 2018 18:55:28 +0000 (11:55 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:06 +0000 (10:26 -0800)
will be used for cross-batch validation list fixing

src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_state.c

index 3696b069e52670098a6964a8510e0e6ed6a1122e..6ebb595b7982e2997f23223226e17f970f677bc4 100644 (file)
@@ -269,6 +269,18 @@ struct iris_context {
       // "I'm streaming this out at draw time and never want it again!"
       struct u_upload_mgr *dynamic_uploader;
 
+      /**
+       * Resources containing streamed state which our render context
+       * currently points to.  Used to re-add these to the validation
+       * list when we start a new batch and haven't resubmitted commands.
+       */
+      struct {
+         struct pipe_resource *cc_vp;
+         struct pipe_resource *sf_cl_vp;
+         struct pipe_resource *color_calc;
+         struct pipe_resource *scissor;
+         struct pipe_resource *blend;
+      } last_res;
    } state;
 };
 
index 76481b4ccdef074e7e0384f219b3dfaa6d2fcef2..51edb98fc498435e77cd05e8908403682ffba9a7 100644 (file)
@@ -279,34 +279,34 @@ ro_bo(struct iris_bo *bo, uint64_t offset)
 static uint32_t *
 stream_state(struct iris_batch *batch,
              struct u_upload_mgr *uploader,
+             struct pipe_resource **out_res,
              unsigned size,
              unsigned alignment,
              uint32_t *out_offset)
 {
-   struct pipe_resource *res = NULL;
    void *ptr = NULL;
 
-   u_upload_alloc(uploader, 0, size, alignment, out_offset, &res, &ptr);
+   u_upload_alloc(uploader, 0, size, alignment, out_offset, out_res, &ptr);
 
-   struct iris_bo *bo = iris_resource_bo(res);
+   struct iris_bo *bo = iris_resource_bo(*out_res);
    iris_use_pinned_bo(batch, bo, false);
 
    *out_offset += iris_bo_offset_from_base_address(bo);
 
-   pipe_resource_reference(&res, NULL);
-
    return ptr;
 }
 
 static uint32_t
 emit_state(struct iris_batch *batch,
            struct u_upload_mgr *uploader,
+           struct pipe_resource **out_res,
            const void *data,
            unsigned size,
            unsigned alignment)
 {
    unsigned offset = 0;
-   uint32_t *map = stream_state(batch, uploader, size, alignment, &offset);
+   uint32_t *map =
+      stream_state(batch, uploader, out_res, size, alignment, &offset);
 
    if (map)
       memcpy(map, data, size);
@@ -2216,6 +2216,7 @@ iris_upload_render_state(struct iris_context *ice,
       iris_emit_cmd(batch, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), ptr) {
          ptr.CCViewportPointer =
             emit_state(batch, ice->state.dynamic_uploader,
+                       &ice->state.last_res.cc_vp,
                        cso->cc_vp, sizeof(cso->cc_vp), 32);
       }
    }
@@ -2224,8 +2225,9 @@ iris_upload_render_state(struct iris_context *ice,
       struct iris_viewport_state *cso = ice->state.cso_vp;
       iris_emit_cmd(batch, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP), ptr) {
          ptr.SFClipViewportPointer =
-            emit_state(batch, ice->state.dynamic_uploader, cso->sf_cl_vp,
-                       4 * GENX(SF_CLIP_VIEWPORT_length) *
+            emit_state(batch, ice->state.dynamic_uploader,
+                       &ice->state.last_res.sf_cl_vp,
+                       cso->sf_cl_vp, 4 * GENX(SF_CLIP_VIEWPORT_length) *
                        ice->state.num_viewports, 64);
       }
    }
@@ -2244,8 +2246,9 @@ iris_upload_render_state(struct iris_context *ice,
          cso_fb->nr_cbufs * GENX(BLEND_STATE_ENTRY_length));
       uint32_t blend_offset;
       uint32_t *blend_map =
-         stream_state(batch, ice->state.dynamic_uploader, 4 * num_dwords, 64,
-                      &blend_offset);
+         stream_state(batch, ice->state.dynamic_uploader,
+                      &ice->state.last_res.blend,
+                      4 * num_dwords, 64, &blend_offset);
 
       uint32_t blend_state_header;
       iris_pack_state(GENX(BLEND_STATE), &blend_state_header, bs) {
@@ -2268,6 +2271,7 @@ iris_upload_render_state(struct iris_context *ice,
       uint32_t cc_offset;
       void *cc_map =
          stream_state(batch, ice->state.dynamic_uploader,
+                      &ice->state.last_res.color_calc,
                       sizeof(uint32_t) * GENX(COLOR_CALC_STATE_length),
                       64, &cc_offset);
       iris_pack_state(GENX(COLOR_CALC_STATE), cc_map, cc) {
@@ -2483,7 +2487,9 @@ iris_upload_render_state(struct iris_context *ice,
    if (dirty & IRIS_DIRTY_SCISSOR) {
       // XXX: allocate at set_scissor time?
       uint32_t scissor_offset = ice->state.num_scissors == 0 ? 0 :
-         emit_state(batch, ice->state.dynamic_uploader, ice->state.scissors,
+         emit_state(batch, ice->state.dynamic_uploader,
+                    &ice->state.last_res.scissor,
+                    ice->state.scissors,
                     sizeof(struct pipe_scissor_state) *
                     ice->state.num_scissors, 32);