diff options
author | Marek Vasut <marex@denx.de> | 2019-09-05 01:23:52 +0200 |
---|---|---|
committer | Lucas Stach <dev@lynxeye.de> | 2019-10-18 17:03:25 +0000 |
commit | 1456aa61cc51f6e7727944d58a662d00158cf111 (patch) | |
tree | e1d80298f8ee713fd10b6cbb12ecd33d96f29e11 /src/gallium/drivers/etnaviv/etnaviv_context.c | |
parent | 1194afdfe3524de686735de7ff25c77dc435fa54 (diff) |
etnaviv: Rework resource status tracking
Have each context track which resources it marked as pending read and
pending write. Have each resource track in which context it is pending.
This way, it is possible to identify when a resource is both pending
read and pending write at the same time. Moreover, the status field
can be correctly calculated and updated when necessary.
Signed-off-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'src/gallium/drivers/etnaviv/etnaviv_context.c')
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index ff03650ffa5..4a33b7a9229 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -63,23 +63,38 @@ etna_context_destroy(struct pipe_context *pctx) struct etna_context *ctx = etna_context(pctx); struct etna_screen *screen = ctx->screen; - if (ctx->used_resources) { - mtx_lock(&screen->lock); + mtx_lock(&screen->lock); + if (ctx->used_resources_read) { + + /* + * There should be no resources tracked in the context when it's being + * destroyed. Be sure there are none to avoid memory leaks on buggy + * programs. + */ + set_foreach(ctx->used_resources_read, entry) { + struct etna_resource *rsc = (struct etna_resource *)entry->key; + + _mesa_set_remove_key(rsc->pending_ctx, ctx); + } + _mesa_set_destroy(ctx->used_resources_read, NULL); + + } + if (ctx->used_resources_write) { /* * There should be no resources tracked in the context when it's being * destroyed. Be sure there are none to avoid memory leaks on buggy * programs. */ - set_foreach(ctx->used_resources, entry) { + set_foreach(ctx->used_resources_write, entry) { struct etna_resource *rsc = (struct etna_resource *)entry->key; _mesa_set_remove_key(rsc->pending_ctx, ctx); } - _mesa_set_destroy(ctx->used_resources, NULL); + _mesa_set_destroy(ctx->used_resources_write, NULL); - mtx_unlock(&screen->lock); } + mtx_unlock(&screen->lock); if (ctx->dummy_rt) etna_bo_del(ctx->dummy_rt); @@ -417,17 +432,25 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, * Go through all _resources_ pending in this _context_ and mark them as * not pending in this _context_ anymore, since they were just flushed. */ - set_foreach(ctx->used_resources, entry) { + set_foreach(ctx->used_resources_read, entry) { struct etna_resource *rsc = (struct etna_resource *)entry->key; struct pipe_resource *referenced = &rsc->base; - rsc->status = 0; + _mesa_set_remove_key(rsc->pending_ctx, ctx); + + pipe_resource_reference(&referenced, NULL); + } + _mesa_set_clear(ctx->used_resources_read, NULL); + + set_foreach(ctx->used_resources_write, entry) { + struct etna_resource *rsc = (struct etna_resource *)entry->key; + struct pipe_resource *referenced = &rsc->base; _mesa_set_remove_key(rsc->pending_ctx, ctx); pipe_resource_reference(&referenced, NULL); } - _mesa_set_clear(ctx->used_resources, NULL); + _mesa_set_clear(ctx->used_resources_write, NULL); mtx_unlock(&screen->lock); @@ -479,9 +502,14 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) if (ctx->stream == NULL) goto fail; - ctx->used_resources = _mesa_set_create(NULL, _mesa_hash_pointer, + ctx->used_resources_read = _mesa_set_create(NULL, _mesa_hash_pointer, + _mesa_key_pointer_equal); + if (!ctx->used_resources_read) + goto fail; + + ctx->used_resources_write = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); - if (!ctx->used_resources) + if (!ctx->used_resources_write) goto fail; /* context ctxate setup */ |