summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c')
-rw-r--r--lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c70
1 files changed, 31 insertions, 39 deletions
diff --git a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c
index e2ef97f28..4a992b5f6 100644
--- a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -321,7 +321,6 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
memset(map, 0, size);
}
- mtx_init(&rsc->lock, mtx_recursive);
rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
if (!rsc->pending_ctx)
@@ -464,10 +463,8 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
{
struct etna_resource *rsc = etna_resource(prsc);
- mtx_lock(&rsc->lock);
assert(!_mesa_set_next_entry(rsc->pending_ctx, NULL));
_mesa_set_destroy(rsc->pending_ctx, NULL);
- mtx_unlock(&rsc->lock);
if (rsc->bo)
etna_bo_del(rsc->bo);
@@ -486,8 +483,6 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
for (unsigned i = 0; i < ETNA_NUM_LOD; i++)
FREE(rsc->levels[i].patch_offsets);
- mtx_destroy(&rsc->lock);
-
FREE(rsc);
}
@@ -564,7 +559,6 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
goto fail;
}
- mtx_init(&rsc->lock, mtx_recursive);
rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
if (!rsc->pending_ctx)
@@ -609,6 +603,34 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
}
}
+enum etna_resource_status
+etna_resource_get_status(struct etna_context *ctx, struct etna_resource *rsc)
+{
+ enum etna_resource_status newstatus = 0;
+
+ set_foreach(rsc->pending_ctx, entry) {
+ struct etna_context *extctx = (struct etna_context *)entry->key;
+
+ set_foreach(extctx->used_resources_read, entry2) {
+ struct etna_resource *rsc2 = (struct etna_resource *)entry2->key;
+ if (ctx == extctx || rsc2 != rsc)
+ continue;
+
+ newstatus |= ETNA_PENDING_READ;
+ }
+
+ set_foreach(extctx->used_resources_write, entry2) {
+ struct etna_resource *rsc2 = (struct etna_resource *)entry2->key;
+ if (ctx == extctx || rsc2 != rsc)
+ continue;
+
+ newstatus |= ETNA_PENDING_WRITE;
+ }
+ }
+
+ return newstatus;
+}
+
void
etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
enum etna_resource_status status)
@@ -622,41 +644,18 @@ etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
mtx_lock(&ctx->lock);
rsc = etna_resource(prsc);
-again:
- mtx_lock(&rsc->lock);
set_foreach(rsc->pending_ctx, entry) {
struct etna_context *extctx = (struct etna_context *)entry->key;
struct pipe_context *pctx = &extctx->base;
- bool need_flush = false;
-
- if (mtx_trylock(&extctx->lock) != thrd_success) {
- /*
- * The other context could be locked in etna_flush() and
- * stuck waiting for the resource lock, so release the
- * resource lock here, let etna_flush() finish, and try
- * again.
- */
- mtx_unlock(&rsc->lock);
- thrd_yield();
- goto again;
- }
set_foreach(extctx->used_resources_read, entry2) {
struct etna_resource *rsc2 = (struct etna_resource *)entry2->key;
if (ctx == extctx || rsc2 != rsc)
continue;
- if (status & ETNA_PENDING_WRITE) {
- need_flush = true;
- break;
- }
- }
-
- if (need_flush) {
- pctx->flush(pctx, NULL, 0);
- mtx_unlock(&extctx->lock);
- continue;
+ if (status & ETNA_PENDING_WRITE)
+ pctx->flush(pctx, NULL, 0);
}
set_foreach(extctx->used_resources_write, entry2) {
@@ -664,14 +663,8 @@ again:
if (ctx == extctx || rsc2 != rsc)
continue;
- need_flush = true;
- break;
- }
-
- if (need_flush)
pctx->flush(pctx, NULL, 0);
-
- mtx_unlock(&extctx->lock);
+ }
}
rsc->status = status;
@@ -683,7 +676,6 @@ again:
_mesa_set_add(rsc->pending_ctx, ctx);
}
- mtx_unlock(&rsc->lock);
mtx_unlock(&ctx->lock);
}