brw: fixup 64bit atomics emulation on 2D array images

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Fixes: ce7208c3ee ("brw: add support for texel address lowering")
Acked-by: Nanley Chery <nanley.g.chery@intel.com>
(cherry picked from commit b3cc54731f)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
This commit is contained in:
Lionel Landwerlin 2025-11-13 11:44:14 +02:00 committed by Dylan Baker
parent 1f1b69c35a
commit d22a20de74
2 changed files with 20 additions and 3 deletions

View file

@ -984,7 +984,7 @@
"description": "brw: fixup 64bit atomics emulation on 2D array images",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "ce7208c3eeefc34193e79997a0447a90fd740453",
"notes": null

View file

@ -125,6 +125,7 @@ static nir_def *
image_tiled_address(nir_builder *b,
enum isl_tiling tiling,
enum glsl_sampler_dim dim,
bool is_array,
unsigned bpp,
nir_def **coords,
nir_def *pitch,
@ -138,6 +139,15 @@ image_tiled_address(nir_builder *b,
1,
&tile_info);
/* With 2D images, the V coordinate should include the array layer since
* the TileId/IntraTile offset should be computed using the QPitch not
* being aligned to a tile's height.
*/
if (dim == GLSL_SAMPLER_DIM_2D && is_array) {
coords[1] = nir_iadd(b, coords[1], nir_imul(b, qpitch, coords[2]));
coords[2] = nir_imm_int(b, 0);
}
/* Compute the intra tile offset using the swizzle (swizzles use u,v,r,p
* but we do not support msaa images)
*/
@ -174,6 +184,13 @@ image_tiled_address(nir_builder *b,
* 5: Memory Data Formats:
*
* "TileID = [(r » Cr) * (QPitch » Cv) + (v » Cv)] * (Pitch » Cu) + (u » Cu)"
*
* There is a different formula for 2D images:
* "TileID = (v » Cv) * (Pitch » Cu) + (u » Cu)"
* with v = (r * QPitch) + v
*
* But the 3D formula works for 2D with the array layer being moved into
* the V coordinate.
*/
nir_def *tile_id =
nir_iadd(b,
@ -245,8 +262,8 @@ image_address(nir_builder *b,
}
nir_push_else(b, NULL);
{
tiled_addr = image_tiled_address(b, tiling, dim, bpp,
coords, pitch, qpitch);
tiled_addr = image_tiled_address(b, tiling, dim, is_array,
bpp, coords, pitch, qpitch);
}
nir_pop_if(b, NULL);