freedreno: ssbo: mark resource read or written depending on usage
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Fri, 13 Sep 2019 06:33:38 +0000 (08:33 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 25 Mar 2020 20:49:32 +0000 (20:49 +0000)
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1963>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/1963>

src/gallium/drivers/freedreno/freedreno_draw.c

index 94e2aae9e68b929fc440766420bf2e3ad073233f..cbbd82b7a23e3ba526e7fb1876cbb86e7fe6078f 100644 (file)
@@ -185,12 +185,15 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
                        resource_written(batch, pfb->cbufs[i]->texture);
        }
 
-       /* Mark SSBOs as being written.. we don't actually know which ones are
-        * read vs written, so just assume the worst
-        */
+       /* Mark SSBOs */
        if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_SSBO) {
-               foreach_bit(i, ctx->shaderbuf[PIPE_SHADER_FRAGMENT].enabled_mask)
-                               resource_written(batch, ctx->shaderbuf[PIPE_SHADER_FRAGMENT].sb[i].buffer);
+               const struct fd_shaderbuf_stateobj *so = &ctx->shaderbuf[PIPE_SHADER_FRAGMENT];
+
+               foreach_bit (i, so->enabled_mask & so->writable_mask)
+                       resource_written(batch, so->sb[i].buffer);
+
+               foreach_bit (i, so->enabled_mask & ~so->writable_mask)
+                               resource_read(batch, so->sb[i].buffer);
        }
 
        if (ctx->dirty_shader[PIPE_SHADER_FRAGMENT] & FD_DIRTY_SHADER_IMAGE) {
@@ -417,6 +420,7 @@ static void
 fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
 {
        struct fd_context *ctx = fd_context(pctx);
+       const struct fd_shaderbuf_stateobj *so = &ctx->shaderbuf[PIPE_SHADER_COMPUTE];
        struct fd_batch *batch, *save_batch = NULL;
        unsigned i;
 
@@ -427,11 +431,12 @@ fd_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
 
        mtx_lock(&ctx->screen->lock);
 
-       /* Mark SSBOs as being written.. we don't actually know which ones are
-        * read vs written, so just assume the worst
-        */
-       foreach_bit(i, ctx->shaderbuf[PIPE_SHADER_COMPUTE].enabled_mask)
-               resource_written(batch, ctx->shaderbuf[PIPE_SHADER_COMPUTE].sb[i].buffer);
+       /* Mark SSBOs */
+       foreach_bit (i, so->enabled_mask & so->writable_mask)
+               resource_written(batch, so->sb[i].buffer);
+
+       foreach_bit (i, so->enabled_mask & ~so->writable_mask)
+               resource_read(batch, so->sb[i].buffer);
 
        foreach_bit(i, ctx->shaderimg[PIPE_SHADER_COMPUTE].enabled_mask) {
                struct pipe_image_view *img =