freedreno/a6xx: Fix the size of buffer image views.
authorEric Anholt <eric@anholt.net>
Tue, 21 Jan 2020 23:16:56 +0000 (15:16 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 26 May 2020 18:17:46 +0000 (18:17 +0000)
We were using the size of the underlying buffer (in R8 elements), while we
need to be using the size of the image view (which may be a subset of the
underlying buffer, and may be in a different format from R8).

This fix means less dereferencing off of the end of shader image views for
buffer images, but more importantly is needed to get the right answer from
resinfo if we are to switch to that.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3501>

src/gallium/drivers/freedreno/a6xx/fd6_image.c

index a83d080fa5beffaf8071e4c61f08f7e71641b5bb..6098799e22dc7ab3e654a83c340c2217c9c8b700 100644 (file)
@@ -89,7 +89,7 @@ static void translate_image(struct fd6_image *img, const struct pipe_image_view
                /* size is encoded with low 15b in WIDTH and high bits in
                 * HEIGHT, in units of elements:
                 */
-               unsigned sz = prsc->width0;
+               unsigned sz = pimg->u.buf.size / util_format_get_blocksize(format);
                img->width  = sz & MASK(15);
                img->height = sz >> 15;
                img->depth  = 0;