Mesa (master): freedreno: fix PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE
Rob Clark
robclark at kemper.freedesktop.org
Thu Oct 23 14:48:50 UTC 2014
Module: Mesa
Branch: master
Commit: 6eabc119367f637be37d106851d9e90b1d3f07f9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6eabc119367f637be37d106851d9e90b1d3f07f9
Author: Rob Clark <robclark at freedesktop.org>
Date: Wed Oct 22 16:36:24 2014 -0400
freedreno: fix PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE
fd_bo_cpu_prep() doesn't realize the bo is already referenced in
unflushed cmdstream. It could be made to do so (but would have to be
implemented twice, ie. both for msm and kgsl). But we still can't do
the expected thing if the caller isn't using _NOSYNC. Because of the
way the tiling works, we need to build quite a bit of cmdstream at flush
time, which is not possible to do at the libdrm level.
So rather than trying to make fd_bo_cpu_prep() smarter than it can
possibly be, just *always* discard and reallocate if the
PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE flag is set.
Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
src/gallium/drivers/freedreno/freedreno_resource.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 49ae517..6b31d26 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -104,6 +104,8 @@ fd_resource_transfer_map(struct pipe_context *pctx,
char *buf;
int ret = 0;
+ DBG("prsc=%p, level=%u, usage=%x", prsc, level, usage);
+
ptrans = util_slab_alloc(&ctx->transfer_pool);
if (!ptrans)
return NULL;
@@ -124,18 +126,15 @@ fd_resource_transfer_map(struct pipe_context *pctx,
if (usage & PIPE_TRANSFER_WRITE)
op |= DRM_FREEDRENO_PREP_WRITE;
- if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)
- op |= DRM_FREEDRENO_PREP_NOSYNC;
-
/* some state trackers (at least XA) don't do this.. */
if (!(usage & (PIPE_TRANSFER_FLUSH_EXPLICIT | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)))
fd_resource_transfer_flush_region(pctx, ptrans, box);
- if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
+ if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
+ realloc_bo(rsc, fd_bo_size(rsc->bo));
+ } else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
ret = fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, op);
- if ((ret == -EBUSY) && (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE))
- realloc_bo(rsc, fd_bo_size(rsc->bo));
- else if (ret)
+ if (ret)
goto fail;
}
More information about the mesa-commit
mailing list