summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/freedreno_resource.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2016-07-19 18:24:57 -0400
committerRob Clark <[email protected]>2016-07-30 09:23:42 -0400
commite684c32d2fdda204b79661ecf26881eae133d64a (patch)
tree762e83dd401b7ec18778b2078e3d473ab42c7d91 /src/gallium/drivers/freedreno/freedreno_resource.c
parent010e4b2d52d5b5ab1eb866dfa0a2df5b984c343d (diff)
freedreno: some locking
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_resource.c')
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index a091f5f1774..9ac95509abc 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -179,6 +179,8 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
*/
fd_bc_invalidate_resource(rsc, false);
+ pipe_mutex_lock(ctx->screen->lock);
+
/* Swap the backing bo's, so shadow becomes the old buffer,
* blit from shadow to new buffer. From here on out, we
* cannot fail.
@@ -210,6 +212,8 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
}
swap(rsc->batch_mask, shadow->batch_mask);
+ pipe_mutex_unlock(ctx->screen->lock);
+
struct pipe_blit_info blit = {0};
blit.dst.resource = prsc;
blit.dst.format = prsc->format;
@@ -487,10 +491,15 @@ fd_resource_transfer_map(struct pipe_context *pctx,
* to wait.
*/
} else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
- if ((usage & PIPE_TRANSFER_WRITE) && rsc->write_batch &&
- rsc->write_batch->back_blit) {
+ struct fd_batch *write_batch = NULL;
+
+ /* hold a reference, so it doesn't disappear under us: */
+ fd_batch_reference(&write_batch, rsc->write_batch);
+
+ if ((usage & PIPE_TRANSFER_WRITE) && write_batch &&
+ write_batch->back_blit) {
/* if only thing pending is a back-blit, we can discard it: */
- fd_batch_reset(rsc->write_batch);
+ fd_batch_reset(write_batch);
}
/* If the GPU is writing to the resource, or if it is reading from the
@@ -527,11 +536,13 @@ fd_resource_transfer_map(struct pipe_context *pctx,
}
assert(rsc->batch_mask == 0);
} else {
- fd_batch_flush(rsc->write_batch, true);
+ fd_batch_flush(write_batch, true);
}
assert(!rsc->write_batch);
}
+ fd_batch_reference(&write_batch, NULL);
+
/* The GPU keeps track of how the various bo's are being used, and
* will wait if necessary for the proper operation to have
* completed.