mtx_lock(&screen->lock);
set_foreach(ctx->used_resources, 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, NULL);
mtx_unlock(&screen->lock);
static void
etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
{
- struct etna_screen *screen = etna_screen(pscreen);
struct etna_resource *rsc = etna_resource(prsc);
- mtx_lock(&screen->lock);
- set_foreach(rsc->pending_ctx, entry) {
- struct etna_context *ctx = (struct etna_context *)entry->key;
-
- _mesa_set_remove_key(rsc->pending_ctx, ctx);
- }
- _mesa_set_destroy(rsc->pending_ctx, NULL);
- mtx_unlock(&screen->lock);
+ assert(!_mesa_set_next_entry(rsc->pending_ctx, NULL));
if (rsc->bo)
etna_bo_del(rsc->bo);
enum etna_resource_status status)
{
struct etna_screen *screen = ctx->screen;
+ struct pipe_resource *referenced = NULL;
struct etna_resource *rsc;
if (!prsc)
rsc->status |= status;
- _mesa_set_add(ctx->used_resources, rsc);
- _mesa_set_add(rsc->pending_ctx, ctx);
+ if (!_mesa_set_search(rsc->pending_ctx, ctx)) {
+ pipe_resource_reference(&referenced, prsc);
+ _mesa_set_add(ctx->used_resources, rsc);
+ _mesa_set_add(rsc->pending_ctx, ctx);
+ }
mtx_unlock(&screen->lock);
}