From d22a20de74ff80ddf2add75ffa65a038c32d2230 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 13 Nov 2025 11:44:14 +0200 Subject: [PATCH] brw: fixup 64bit atomics emulation on 2D array images Signed-off-by: Lionel Landwerlin Fixes: ce7208c3ee ("brw: add support for texel address lowering") Acked-by: Nanley Chery (cherry picked from commit b3cc54731f1952c2eab05826be5a4dbca07fadf4) Part-of: --- .pick_status.json | 2 +- .../brw/brw_nir_lower_texel_address.c | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 43173d0b4e6..173cc05aa14 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/intel/compiler/brw/brw_nir_lower_texel_address.c b/src/intel/compiler/brw/brw_nir_lower_texel_address.c index 9aea3e2f614..3be54815887 100644 --- a/src/intel/compiler/brw/brw_nir_lower_texel_address.c +++ b/src/intel/compiler/brw/brw_nir_lower_texel_address.c @@ -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);