Module: Mesa Branch: staging/22.2 Commit: 2c56768a2f5b213d1eb2c87cb2579cae3137e8e6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c56768a2f5b213d1eb2c87cb2579cae3137e8e6
Author: Alyssa Rosenzweig <[email protected]> Date: Tue Jul 5 15:11:59 2022 -0400 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 <[email protected]> Suggested-by: Karol Herbst <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18560> (cherry picked from commit b4dd1b8916d95576fb7277e96f1c3a1e5afc126d) --- .pick_status.json | 2 +- src/gallium/drivers/panfrost/pan_compute.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d6cd364acdc..38e82725b4f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -679,7 +679,7 @@ "description": "panfrost: Respect buffer offset for OpenCL", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "80b90a0f2b83291da69f7eef38395e61e919ab97" }, diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c index 1759252e542..93f9078bb3c 100644 --- a/src/gallium/drivers/panfrost/pan_compute.c +++ b/src/gallium/drivers/panfrost/pan_compute.c @@ -123,8 +123,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)); } }
