Module: Mesa Branch: main Commit: 9da5b2c1f569ae73dabbe46844b6c2d9b6f4a4b0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9da5b2c1f569ae73dabbe46844b6c2d9b6f4a4b0
Author: Rob Clark <[email protected]> Date: Thu Aug 25 13:45:44 2022 -0700 freedreno: Add support for upload transfers Signed-off-by: Rob Clark <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18258> --- src/gallium/drivers/freedreno/freedreno_resource.c | 12 +++++++++++- src/gallium/drivers/freedreno/freedreno_resource.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index f310081b8d9..9b4a136d6ab 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -710,7 +710,10 @@ fd_resource_transfer_unmap(struct pipe_context *pctx, pipe_resource_reference(&trans->staging_prsc, NULL); } - if (!(ptrans->usage & PIPE_MAP_UNSYNCHRONIZED)) { + if (trans->upload_ptr) { + fd_bo_upload(rsc->bo, trans->upload_ptr, ptrans->box.x, ptrans->box.width); + free(trans->upload_ptr); + } else if (!(ptrans->usage & PIPE_MAP_UNSYNCHRONIZED)) { fd_bo_cpu_fini(rsc->bo); } @@ -789,6 +792,13 @@ resource_transfer_map_unsync(struct pipe_context *pctx, uint32_t offset; char *buf; + if ((prsc->target == PIPE_BUFFER) && + !(usage & (PIPE_MAP_READ | PIPE_MAP_DIRECTLY | PIPE_MAP_PERSISTENT)) && + fd_bo_prefer_upload(rsc->bo, box->width)) { + trans->upload_ptr = malloc(box->width); + return trans->upload_ptr; + } + buf = fd_bo_map(rsc->bo); /* With imported bo's allocated by something outside of mesa, when diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h index d4c555b8d2c..b328cb41f41 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.h +++ b/src/gallium/drivers/freedreno/freedreno_resource.h @@ -259,6 +259,7 @@ struct fd_transfer { struct threaded_transfer b; struct pipe_resource *staging_prsc; struct pipe_box staging_box; + void *upload_ptr; }; static inline struct fd_transfer *
