From b4dd1b8916d95576fb7277e96f1c3a1e5afc126d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 5 Jul 2022 15:11:59 -0400 Subject: [PATCH] panfrost: Respect buffer offset for OpenCL This is so dumb. Panfrost port of d98b82a1039 ("iris/cs: take buffer offsets into account for CL") Fixes buffer.sub_buffers_read_write Fixes: 80b90a0f2b8 ("panfrost: Implement panfrost_set_global_binding") Signed-off-by: Alyssa Rosenzweig Suggested-by: Karol Herbst Part-of: --- src/gallium/drivers/panfrost/pan_compute.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 2c5d51b5475..2e74c3b09ae 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -124,8 +124,17 @@ panfrost_set_global_binding(struct pipe_context *pctx, util_range_add(&rsrc->base, &rsrc->valid_buffer_range, 0, rsrc->base.width0); - /* The handle points to uint32_t, but space is allocated for 64 bits */ - memcpy(handles[i], &rsrc->image.data.bo->ptr.gpu, sizeof(mali_ptr)); + /* The handle points to uint32_t, but space is allocated for 64 + * bits. We need to respect the offset passed in. This interface + * is so bad. + */ + mali_ptr addr = 0; + static_assert(sizeof(addr) == 8, "size out of sync"); + + memcpy(&addr, handles[i], sizeof(addr)); + addr += rsrc->image.data.bo->ptr.gpu; + + memcpy(handles[i], &addr, sizeof(addr)); } }