From 8cdace95acdf83bdab3d1f1a55e77aec1dfdb39e Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Fri, 13 Sep 2019 08:33:38 +0200 Subject: [PATCH] freedreno: ssbo: mark resource read or written depending on usage Signed-off-by: Christian Gmeiner Reviewed-by: Rob Clark Tested-by: Marge Bot Part-of: --- .../drivers/freedreno/freedreno_draw.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 94e2aae9e68..cbbd82b7a23 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -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 = -- 2.30.2