panvk: Fix img2buf copies with image X offset not aligned on 16 pixels

There are probably better ways of handling copies, but the whole thing
will disappear with the transition to vk_meta. The only reason we fix
it now is so we can enable more tests in CI and catch potential
regressions.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28417>
This commit is contained in:
Boris Brezillon 2024-03-29 14:52:37 +01:00 committed by Marge Bot
parent 7b06393257
commit 58a5ae3f72

View file

@ -1342,7 +1342,7 @@ panvk_meta_copy_img2buf_shader(struct panvk_device *dev,
nir_imul(&b, nir_channel(&b, coord, 1), buflinestride));
offset = nir_iadd(&b, offset,
nir_imul(&b, nir_channel(&b, coord, 2), bufsurfstride));
bufptr = nir_iadd(&b, bufptr, nir_u2u64(&b, offset));
bufptr = nir_iadd(&b, bufptr, nir_i2i64(&b, offset));
unsigned imgcompsz =
imgtexelsz <= 4 ? 1 : MIN2(1 << (ffs(imgtexelsz) - 1), 4);
@ -1470,6 +1470,7 @@ panvk_meta_copy_img2buf(struct panvk_cmd_buffer *cmdbuf,
const VkBufferImageCopy2 *region)
{
struct panvk_device *dev = to_panvk_device(cmdbuf->vk.base.device);
unsigned blksz = util_format_get_blocksize(img->pimage.layout.format);
struct panvk_meta_copy_format_info key = {
.imgfmt = panvk_meta_copy_img2buf_format(img->pimage.layout.format),
.mask = panvk_meta_copy_img_mask(img->pimage.layout.format,
@ -1483,7 +1484,8 @@ panvk_meta_copy_img2buf(struct panvk_cmd_buffer *cmdbuf,
mali_ptr rsd = dev->meta.copy.img2buf[texdimidx][fmtidx].rsd;
struct panvk_meta_copy_img2buf_info info = {
.buf.ptr = panvk_buffer_gpu_ptr(buf, region->bufferOffset),
.buf.ptr = panvk_buffer_gpu_ptr(buf, region->bufferOffset) -
(region->imageOffset.x & 15) * blksz,
.buf.stride.line =
(region->bufferRowLength ?: region->imageExtent.width) * buftexelsz,
.img.offset.x = MAX2(region->imageOffset.x & ~15, 0),