From 077af5c928e4678bb16310696ea2a109ed6de8bb Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Fri, 29 May 2020 16:12:34 -0700 Subject: [PATCH] iris: Insert buffer-local memory barriers for SSBO reads and writes. 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 Part-of: --- src/gallium/drivers/iris/iris_resolve.c | 15 +++++++++++++++ src/gallium/drivers/iris/iris_state.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/gallium/drivers/iris/iris_resolve.c b/src/gallium/drivers/iris/iris_resolve.c index b6154f3f0d7..1bb0618c045 100644 --- a/src/gallium/drivers/iris/iris_resolve.c +++ b/src/gallium/drivers/iris/iris_resolve.c @@ -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); } } diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index 4a3452414dc..52388a19f9f 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -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; }