iris: Insert buffer-local memory barriers for UBO reads.
authorFrancisco Jerez <currojerez@riseup.net>
Fri, 29 May 2020 23:12:55 +0000 (16:12 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 2 Sep 2021 03:14:37 +0000 (03:14 +0000)
Similar to what was previously done for other kinds of buffers --
Insert memory barriers at resolves-and-flushes time instead of relying
on the history flush mechanism.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12691>

src/gallium/drivers/iris/iris_resolve.c
src/gallium/drivers/iris/iris_state.c

index 1bb0618..b67002d 100644 (file)
@@ -151,6 +151,19 @@ resolve_image_views(struct iris_context *ice,
    }
 }
 
+static void
+flush_ubos(struct iris_batch *batch,
+            struct iris_shader_state *shs)
+{
+   uint32_t cbufs = shs->bound_cbufs;
+
+   while (cbufs) {
+      const int i = u_bit_scan(&cbufs);
+      struct pipe_shader_buffer *cbuf = &shs->constbuf[i];
+      struct iris_resource *res = (void *)cbuf->buffer;
+      iris_emit_buffer_barrier_for(batch, res->bo, IRIS_DOMAIN_OTHER_READ);
+   }
+}
 
 static void
 flush_ssbos(struct iris_batch *batch,
@@ -192,6 +205,9 @@ iris_predraw_resolve_inputs(struct iris_context *ice,
                           consider_framebuffer);
       flush_ssbos(batch, shs);
    }
+
+   if (ice->state.stage_dirty & (IRIS_STAGE_DIRTY_CONSTANTS_VS << stage))
+      flush_ubos(batch, shs);
 }
 
 void
index 52388a1..1b682f5 100644 (file)
@@ -3231,6 +3231,11 @@ iris_set_constant_buffer(struct pipe_context *ctx,
          assert(map);
          memcpy(map, input->user_buffer, input->buffer_size);
       } else if (input->buffer) {
+         if (cbuf->buffer != input->buffer) {
+            ice->state.dirty |= (IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES |
+                                 IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES);
+         }
+
          if (take_ownership) {
             pipe_resource_reference(&cbuf->buffer, NULL);
             cbuf->buffer = input->buffer;
@@ -7310,6 +7315,8 @@ iris_rebind_buffer(struct iris_context *ice,
 
             if (res->bo == iris_resource_bo(cbuf->buffer)) {
                pipe_resource_reference(&surf_state->res, NULL);
+               ice->state.dirty |= (IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES |
+                                    IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES);
                ice->state.stage_dirty |= IRIS_STAGE_DIRTY_CONSTANTS_VS << s;
             }
          }