ac/nir: handle DEPTH as PITCH in ac_nir_lower_resinfo
authorMarek Olšák <marek.olsak@amd.com>
Thu, 1 Jun 2023 11:10:27 +0000 (07:10 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Jun 2023 18:46:20 +0000 (18:46 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23015>

src/amd/common/ac_nir_lower_resinfo.c

index 2da4edd..2ee014d 100644 (file)
@@ -111,6 +111,19 @@ lower_query_size(nir_builder *b, nir_ssa_def *desc, nir_src *lod,
       }
    }
 
+   /* On GFX10.3+, DEPTH contains the pitch if the type is 1D, 2D, or 2D_MSAA. We only program
+    * the pitch for 2D. We need to set depth and last_array to 0 in that case.
+    */
+   if (gfx_level >= GFX10_3 && (has_depth || is_array)) {
+      nir_ssa_def *type = get_field(b, desc, 3, ~C_00A00C_TYPE);
+      nir_ssa_def *is_2d = nir_ieq(b, type, nir_imm_int(b, V_008F1C_SQ_RSRC_IMG_2D));
+
+      if (has_depth)
+         depth = nir_bcsel(b, is_2d, nir_imm_int(b, 0), depth);
+      if (is_array)
+         last_array = nir_bcsel(b, is_2d, nir_imm_int(b, 0), last_array);
+   }
+
    /* All values are off by 1. */
    if (has_width)
       width = nir_iadd_imm(b, width, 1);