intel/compiler: Fix sparse cube map array coordinate lowering
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 3 Aug 2023 22:24:53 +0000 (15:24 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Fri, 4 Aug 2023 07:09:05 +0000 (00:09 -0700)
commit95db3e87fee377c5fa8fb779bc151e8d7f4e790a
tree8c2723674c5a6c3d9cdf2df6b3db3b61ec2f3ad2
parent2a580bba76705bc6e6b1e850dd78fb56064af58f
intel/compiler: Fix sparse cube map array coordinate lowering

Brown paper bag fix for my untested review feedback comments.

Cube array images use a coordinate of the form <X, Y, 6*Slice+Face>,
while cube array textures use a <X, Y, Slice, Face> style coordinate.

This code tried to convert one to the other, but instead of writing
Z / 6 and Z % 6, we tried to reuse our original division result.  What
we wanted was Z - (Z/6) * 6, but instead we botched it and wrote Z-Z*6
which produced...totally invalid cube faces.

Fixes: fe81d40bff26 ("intel/nir: add lower for sparse images & textures")
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Tested-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24481>
src/intel/compiler/brw_nir_lower_sparse.c