iris: Insert buffer-local memory barriers for SSBO reads and writes.
authorFrancisco Jerez <currojerez@riseup.net>
Fri, 29 May 2020 23:12:34 +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 vertex buffers, render
buffers, etc -- 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 b6154f3..1bb0618 100644 (file)
@@ -152,6 +152,20 @@ resolve_image_views(struct iris_context *ice,
 }
 
 
+static void
+flush_ssbos(struct iris_batch *batch,
+            struct iris_shader_state *shs)
+{
+   uint32_t ssbos = shs->bound_ssbos;
+
+   while (ssbos) {
+      const int i = u_bit_scan(&ssbos);
+      struct pipe_shader_buffer *ssbo = &shs->ssbo[i];
+      struct iris_resource *res = (void *)ssbo->buffer;
+      iris_emit_buffer_barrier_for(batch, res->bo, IRIS_DOMAIN_DATA_WRITE);
+   }
+}
+
 /**
  * \brief Resolve buffers before drawing.
  *
@@ -176,6 +190,7 @@ iris_predraw_resolve_inputs(struct iris_context *ice,
                             consider_framebuffer);
       resolve_image_views(ice, batch, shs, info, draw_aux_buffer_disabled,
                           consider_framebuffer);
+      flush_ssbos(batch, shs);
    }
 }
 
index 4a34524..52388a1 100644 (file)
@@ -3400,6 +3400,8 @@ iris_set_shader_buffers(struct pipe_context *ctx,
       }
    }
 
+   ice->state.dirty |= (IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES |
+                        IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES);
    ice->state.stage_dirty |= IRIS_STAGE_DIRTY_BINDINGS_VS << stage;
 }