freedreno: rebind resource in all contexts

If the resource is rebound, we need to invalidate in all contexts.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4744>
This commit is contained in:
Rob Clark
2020-04-24 15:00:20 -07:00
committed by Marge Bot
parent f12188ff52
commit d9e56d8a69
5 changed files with 27 additions and 15 deletions
@@ -178,6 +178,10 @@ fd_context_destroy(struct pipe_context *pctx)
DBG("");
mtx_lock(&ctx->screen->lock);
list_del(&ctx->node);
mtx_unlock(&ctx->screen->lock);
fd_log_process(ctx, true);
assert(list_is_empty(&ctx->log_chunks));
@@ -419,6 +423,10 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
list_inithead(&ctx->acc_active_queries);
list_inithead(&ctx->log_chunks);
mtx_lock(&ctx->screen->lock);
list_add(&ctx->node, &ctx->screen->context_list);
mtx_unlock(&ctx->screen->lock);
ctx->log_out = stdout;
if ((fd_mesa_debug & FD_DBG_LOG) &&
@@ -162,6 +162,8 @@ enum fd_dirty_shader_state {
struct fd_context {
struct pipe_context base;
struct list_head node; /* node in screen->context_list */
/* We currently need to serialize emitting GMEM batches, because of
* VSC state access in the context.
*
@@ -146,11 +146,19 @@ rebind_resource_in_ctx(struct fd_context *ctx, struct fd_resource *rsc)
}
static void
rebind_resource(struct fd_context *ctx, struct fd_resource *rsc)
rebind_resource(struct fd_resource *rsc)
{
struct fd_screen *screen = fd_screen(rsc->base.screen);
mtx_lock(&screen->lock);
fd_resource_lock(rsc);
rebind_resource_in_ctx(ctx, rsc);
if (rsc->dirty)
list_for_each_entry (struct fd_context, ctx, &screen->context_list, node)
rebind_resource_in_ctx(ctx, rsc);
fd_resource_unlock(rsc);
mtx_unlock(&screen->lock);
}
static void
@@ -379,17 +387,7 @@ fd_resource_uncompress(struct fd_context *ctx, struct fd_resource *rsc)
/* shadow should not fail in any cases where we need to uncompress: */
debug_assert(success);
/*
* TODO what if rsc is used in other contexts, we don't currently
* have a good way to rebind_resource() in other contexts. And an
* app that is reading one resource in multiple contexts, isn't
* going to expect that the resource is modified.
*
* Hopefully the edge cases where we need to uncompress are rare
* enough that they mostly only show up in deqp.
*/
rebind_resource(ctx, rsc);
rebind_resource(rsc);
}
static struct fd_resource *
@@ -638,7 +636,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
if (needs_flush || fd_resource_busy(rsc, op)) {
realloc_bo(rsc, fd_bo_size(rsc->bo));
rebind_resource(ctx, rsc);
rebind_resource(rsc);
}
} else if ((usage & PIPE_TRANSFER_WRITE) &&
prsc->target == PIPE_BUFFER &&
@@ -681,7 +679,7 @@ fd_resource_transfer_map(struct pipe_context *pctx,
if (needs_flush && fd_try_shadow_resource(ctx, rsc, level,
box, DRM_FORMAT_MOD_LINEAR)) {
needs_flush = busy = false;
rebind_resource(ctx, rsc);
rebind_resource(rsc);
ctx->stats.shadow_uploads++;
} else {
struct fd_resource *staging_rsc;
@@ -961,6 +961,8 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro)
fd_bc_init(&screen->batch_cache);
list_inithead(&screen->context_list);
(void) mtx_init(&screen->lock, mtx_plain);
pscreen->destroy = fd_screen_destroy;
@@ -46,6 +46,8 @@ struct fd_bo;
struct fd_screen {
struct pipe_screen base;
struct list_head context_list;
mtx_t lock;
/* it would be tempting to use pipe_reference here, but that