Mesa (master): lima: allocate new bo for stream draw
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Sep 19 09:46:48 UTC 2020
Module: Mesa
Branch: master
Commit: 6a1926035bd5d0fb39ab3c7de7662cc552a5dc02
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6a1926035bd5d0fb39ab3c7de7662cc552a5dc02
Author: Erico Nunes <nunes.erico at gmail.com>
Date: Sat Aug 29 16:32:24 2020 +0200
lima: allocate new bo for stream draw
In stream draws, the resource bo might be in use in a previous draw.
Allocate a new one for the resource to avoid overwriting data in use.
Signed-off-by: Erico Nunes <nunes.erico at gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul at gmail.com>
Reviewed-by: Qiang Yu <yuq825 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6503>
---
src/gallium/drivers/lima/lima_resource.c | 36 ++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/gallium/drivers/lima/lima_resource.c b/src/gallium/drivers/lima/lima_resource.c
index aa5e1f21d66..5ee9c78ad0b 100644
--- a/src/gallium/drivers/lima/lima_resource.c
+++ b/src/gallium/drivers/lima/lima_resource.c
@@ -549,6 +549,7 @@ lima_transfer_map(struct pipe_context *pctx,
const struct pipe_box *box,
struct pipe_transfer **pptrans)
{
+ struct lima_screen *screen = lima_screen(pres->screen);
struct lima_context *ctx = lima_context(pctx);
struct lima_resource *res = lima_resource(pres);
struct lima_bo *bo = res->bo;
@@ -561,16 +562,33 @@ lima_transfer_map(struct pipe_context *pctx,
if (res->tiled && (usage & PIPE_TRANSFER_MAP_DIRECTLY))
return NULL;
- /* use once buffers are made sure to not read/write overlapped
- * range, so no need to sync */
- if (pres->usage != PIPE_USAGE_STREAM) {
- if (usage & PIPE_TRANSFER_READ_WRITE) {
- lima_flush_job_accessing_bo(ctx, bo, usage & PIPE_TRANSFER_WRITE);
+ /* bo might be in use in a previous stream draw. Allocate a new
+ * one for the resource to avoid overwriting data in use. */
+ if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
+ struct lima_bo *new_bo;
+ assert(res->bo && res->bo->size);
- unsigned op = usage & PIPE_TRANSFER_WRITE ?
- LIMA_GEM_WAIT_WRITE : LIMA_GEM_WAIT_READ;
- lima_bo_wait(bo, op, PIPE_TIMEOUT_INFINITE);
- }
+ new_bo = lima_bo_create(screen, res->bo->size, res->bo->flags);
+ if (!new_bo)
+ return NULL;
+
+ lima_bo_unreference(res->bo);
+ res->bo = new_bo;
+
+ if (pres->bind & PIPE_BIND_VERTEX_BUFFER)
+ ctx->dirty |= LIMA_CONTEXT_DIRTY_VERTEX_BUFF;
+
+ bo = res->bo;
+ }
+ else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED) &&
+ (usage & PIPE_TRANSFER_READ_WRITE)) {
+ /* use once buffers are made sure to not read/write overlapped
+ * range, so no need to sync */
+ lima_flush_job_accessing_bo(ctx, bo, usage & PIPE_TRANSFER_WRITE);
+
+ unsigned op = usage & PIPE_TRANSFER_WRITE ?
+ LIMA_GEM_WAIT_WRITE : LIMA_GEM_WAIT_READ;
+ lima_bo_wait(bo, op, PIPE_TIMEOUT_INFINITE);
}
if (!lima_bo_map(bo))
More information about the mesa-commit
mailing list