Mesa (main): st/pbo_compute: use different calc for non-3d compute buffer sizing

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 31 20:50:35 UTC 2022


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu May 26 14:48:47 2022 -0400

st/pbo_compute: use different calc for non-3d compute buffer sizing

this avoids looking at irrelevant 3d pixelstore params like
GL_PACK_IMAGE_HEIGHT when they don't apply, which will cause the storage
buffer to be incorrectly sized and break the operation

Fixes: e7b95619596 ("gallium: implement compute pbo download")

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16728>

---

 src/mesa/state_tracker/st_pbo_compute.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_pbo_compute.c b/src/mesa/state_tracker/st_pbo_compute.c
index 08a6e69d246..72faab4dfc6 100644
--- a/src/mesa/state_tracker/st_pbo_compute.c
+++ b/src/mesa/state_tracker/st_pbo_compute.c
@@ -929,7 +929,12 @@ download_texture_compute(struct st_context *st,
    }
 
    /* Set up destination buffer */
-   unsigned img_stride = _mesa_image_image_stride(pack, width, height, format, type);
+   unsigned img_stride = src->target == PIPE_TEXTURE_3D ||
+                         src->target == PIPE_TEXTURE_2D_ARRAY ||
+                         src->target == PIPE_TEXTURE_CUBE_ARRAY ?
+                         /* only use image stride for 3d images to avoid pulling in IMAGE_HEIGHT pixelstore */
+                         _mesa_image_image_stride(pack, width, height, format, type) :
+                         _mesa_image_row_stride(pack, width, format, type) * height;
    unsigned buffer_size = (depth + (dim == 3 ? pack->SkipImages : 0)) * img_stride;
    {
       struct pipe_shader_buffer buffer;



More information about the mesa-commit mailing list