Module: Mesa
Branch: main
Commit: 4703efd23f3dd2b42b048dff9d9312109f9d2d7d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4703efd23f3dd2b42b048dff9d9312109f9d2d7d

Author: Rob Clark <[email protected]>
Date:   Thu Aug 25 13:27:22 2022 -0700

freedreno/drm: Add offset param for fd_bo_upload()

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18258>

---

 src/freedreno/drm/freedreno_bo.c                | 6 +++---
 src/freedreno/drm/freedreno_drmif.h             | 2 +-
 src/freedreno/drm/freedreno_priv.h              | 2 +-
 src/freedreno/drm/virtio/virtio_bo.c            | 3 +--
 src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 2 +-
 5 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/freedreno/drm/freedreno_bo.c b/src/freedreno/drm/freedreno_bo.c
index 4e98b7b452e..e0f756505c0 100644
--- a/src/freedreno/drm/freedreno_bo.c
+++ b/src/freedreno/drm/freedreno_bo.c
@@ -487,14 +487,14 @@ fd_bo_map(struct fd_bo *bo)
 }
 
 void
-fd_bo_upload(struct fd_bo *bo, void *src, unsigned len)
+fd_bo_upload(struct fd_bo *bo, void *src, unsigned off, unsigned len)
 {
    if (bo->funcs->upload) {
-      bo->funcs->upload(bo, src, len);
+      bo->funcs->upload(bo, src, off, len);
       return;
    }
 
-   memcpy(bo_map(bo), src, len);
+   memcpy((uint8_t *)bo_map(bo) + off, src, len);
 }
 
 bool
diff --git a/src/freedreno/drm/freedreno_drmif.h 
b/src/freedreno/drm/freedreno_drmif.h
index 39590c1b017..7d5e970a3c1 100644
--- a/src/freedreno/drm/freedreno_drmif.h
+++ b/src/freedreno/drm/freedreno_drmif.h
@@ -219,7 +219,7 @@ uint32_t fd_bo_handle(struct fd_bo *bo);
 int fd_bo_dmabuf(struct fd_bo *bo);
 uint32_t fd_bo_size(struct fd_bo *bo);
 void *fd_bo_map(struct fd_bo *bo);
-void fd_bo_upload(struct fd_bo *bo, void *src, unsigned len);
+void fd_bo_upload(struct fd_bo *bo, void *src, unsigned off, unsigned len);
 bool fd_bo_prefer_upload(struct fd_bo *bo, unsigned len);
 int fd_bo_cpu_prep(struct fd_bo *bo, struct fd_pipe *pipe, uint32_t op);
 void fd_bo_cpu_fini(struct fd_bo *bo);
diff --git a/src/freedreno/drm/freedreno_priv.h 
b/src/freedreno/drm/freedreno_priv.h
index d12c98e83a2..fceca64689e 100644
--- a/src/freedreno/drm/freedreno_priv.h
+++ b/src/freedreno/drm/freedreno_priv.h
@@ -312,7 +312,7 @@ struct fd_bo_funcs {
     * Optional, copy data into bo, falls back to mmap+memcpy.  If not
     * implemented, it must be possible to mmap all buffers
     */
-   void (*upload)(struct fd_bo *bo, void *src, unsigned len);
+   void (*upload)(struct fd_bo *bo, void *src, unsigned off, unsigned len);
 
    /**
     * Optional, if upload is supported, should upload be preferred?
diff --git a/src/freedreno/drm/virtio/virtio_bo.c 
b/src/freedreno/drm/virtio/virtio_bo.c
index 253f90586ef..b04733b810e 100644
--- a/src/freedreno/drm/virtio/virtio_bo.c
+++ b/src/freedreno/drm/virtio/virtio_bo.c
@@ -202,9 +202,8 @@ bo_upload(struct fd_bo *bo, unsigned off, void *src, 
unsigned len)
 }
 
 static void
-virtio_bo_upload(struct fd_bo *bo, void *src, unsigned len)
+virtio_bo_upload(struct fd_bo *bo, void *src, unsigned off, unsigned len)
 {
-   unsigned off = 0;
    while (len > 0) {
       unsigned sz = MIN2(len, 0x1000);
       bo_upload(bo, off, src, sz);
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c 
b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
index e74ae816d19..57788c2e788 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
@@ -113,7 +113,7 @@ upload_shader_variant(struct ir3_shader_variant *v)
    /* Always include shaders in kernel crash dumps. */
    fd_bo_mark_for_dump(v->bo);
 
-   fd_bo_upload(v->bo, v->bin, v->info.size);
+   fd_bo_upload(v->bo, v->bin, 0, v->info.size);
 }
 
 struct ir3_shader_variant *

Reply via email to