summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/etnaviv/etnaviv_context.c
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2019-06-08 19:52:55 +0200
committerLucas Stach <[email protected]>2019-10-18 17:03:25 +0000
commit90e223646bf9541c4b751bcbd04cd81e27fb42e1 (patch)
treef3ead4c7b1d11573e6b5624aef4c218d5eded1e8 /src/gallium/drivers/etnaviv/etnaviv_context.c
parent2946bd6628fb5395679c2c88ebb7c43a5c6b8f8a (diff)
etnaviv: Make contexts track resources
Currently, the screen tracks all resources for all contexts, but this is not correct. Each context should track the resources it uses. This also allows a context to detect whether a resource is used by another context and to notify another context using a resource that the current context is done using the resource. Signed-off-by: Marek Vasut <[email protected]> Cc: Christian Gmeiner <[email protected]> Cc: Guido Günther <[email protected]> Cc: Lucas Stach <[email protected]>
Diffstat (limited to 'src/gallium/drivers/etnaviv/etnaviv_context.c')
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_context.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c
index b31b1158303..219d1de45f0 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_context.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
@@ -48,6 +48,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
+#include "util/hash_table.h"
#include "util/u_blitter.h"
#include "util/u_helpers.h"
#include "util/u_memory.h"
@@ -60,6 +61,25 @@ static void
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);
+
+ /*
+ * 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) {
+ struct etna_resource *rsc = (struct etna_resource *)entry->key;
+
+ _mesa_set_remove_key(rsc->pending_ctx, ctx);
+ }
+ _mesa_set_destroy(ctx->used_resources, NULL);
+
+ mtx_unlock(&screen->lock);
+ }
if (ctx->dummy_rt)
etna_bo_del(ctx->dummy_rt);
@@ -399,16 +419,18 @@ etna_cmd_stream_reset_notify(struct etna_cmd_stream *stream, void *priv)
ctx->dirty_sampler_views = ~0L;
/*
- * Go through all _resources_ associated with this _screen_, pending
- * in this _context_ and mark them as not pending in this _context_
- * anymore, since they were just flushed.
+ * Go through all _resources_ pending in this _context_ and mark them as
+ * not pending in this _context_ anymore, since they were just flushed.
*/
mtx_lock(&screen->lock);
- set_foreach(screen->used_resources, entry) {
+ set_foreach(ctx->used_resources, entry) {
struct etna_resource *rsc = (struct etna_resource *)entry->key;
+ rsc->status = 0;
+
_mesa_set_remove_key(rsc->pending_ctx, ctx);
}
+ _mesa_set_clear(ctx->used_resources, NULL);
mtx_unlock(&screen->lock);
}
@@ -447,6 +469,11 @@ 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,
+ _mesa_key_pointer_equal);
+ if (!ctx->used_resources)
+ goto fail;
+
/* context ctxate setup */
ctx->specs = screen->specs;
ctx->screen = screen;