From 7eab94d5420b4c7fae17a7348e4e4f10da675550 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Tue, 5 May 2026 12:52:46 -0700 Subject: [PATCH 1/2] intel/nir: fix sparse shadow comparison for BRW While Jay overwrites sparse_tex->op with the newer opcodes that only return red and the sparse stuff, BRW keeps using the original opcode of the cloned instruction, so it can't change def->num_components. This was not previously detectable since we did not have sparse enabled for depth/stencil on Anv for a while. A patch to re-enable that was proposed a while ago (MR !37423), never merged, but then a recent attempt to try to merge it (by me) detected this regression. Let's fix the regression first, then we can finally re-enable sparse depth/stencil support in Anv, hopefully. Fixes: 7468261d3d13 ("intel/nir: Make intel_nir_lower_sparse work for either brw or jay") Reviewed-by: Kenneth Graunke Signed-off-by: Paulo Zanoni Part-of: --- src/intel/compiler/intel_nir_lower_sparse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intel/compiler/intel_nir_lower_sparse.c b/src/intel/compiler/intel_nir_lower_sparse.c index 8a52fb93ed7..ead2f5403c7 100644 --- a/src/intel/compiler/intel_nir_lower_sparse.c +++ b/src/intel/compiler/intel_nir_lower_sparse.c @@ -136,13 +136,15 @@ split_tex_residency(nir_builder *b, nir_tex_instr *tex, bool jay) /* Clone the original instruction */ nir_tex_instr *sparse_tex = nir_instr_as_tex(nir_instr_clone(b->shader, &tex->instr)); - nir_def_init(&sparse_tex->instr, &sparse_tex->def, 2, tex->def.bit_size); + nir_def_init(&sparse_tex->instr, &sparse_tex->def, + tex->def.num_components, tex->def.bit_size); nir_builder_instr_insert(b, &sparse_tex->instr); if (jay) { sparse_tex->op = tex->op == nir_texop_txf ? nir_texop_sparse_residency_txf_intel : nir_texop_sparse_residency_intel; + sparse_tex->def.num_components = 2; } /* txl/txb/tex and tg4 both access the same pixels for residency checking From ff5b9095113f3b39b28813b37f52e75a3f177e12 Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Mon, 15 Sep 2025 16:25:12 -0700 Subject: [PATCH 2/2] anv/sparse: bring back our (limited) support for depth/stencil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ambiguity of the Vulkan spec was clarified, and we don't need to support sparse depth/stencil with exactly the same number of samples as non-sparse. If you want to pass CTS, you'll need VK-GL-CTS commit 03976477f521 ("Don't require more than VK_SAMPLE_COUNT_1_BIT for non-color sparse resident images"). This is essentially a revert of d5da6980d3e7 ("anv/sparse: don't support depth/stencil with sparse") and 7b337e214d3c ("anv: remove dead code"). Thanks to Iván Briano for working with Khronos to get clarification on the spec and for implementing the VK-GL-CTS fix. Reviewed-by: Iván Briano Signed-off-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_sparse.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index 8f62315c13a..b3f087adbe6 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -1658,15 +1658,30 @@ anv_sparse_image_check_support(struct anv_physical_device *pdevice, return VK_ERROR_FEATURE_NOT_PRESENT; } - /* While our hardware allows us to support sparse with some depth/stencil - * formats (e.g., single-sampled 2D), the spec seems to be expecting that, - * if we support a format, we have to support it with all the multi-sampled - * flags we support for non-sparse. Therefore, just give up depth/stencil - * entirely since games don't seem to be requiring it. + /* Please see ISL's filter_tiling() functions for accurate explanations on + * why depth/stencil images are not always supported with the tiling + * formats we want. */ VkImageAspectFlags aspects = vk_format_aspects(vk_format); - if (aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) - return VK_ERROR_FORMAT_NOT_SUPPORTED; + if (aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { + /* For multi-sampled images, the image layouts for color and + * depth/stencil are different, and only the color layout is compatible + * with the standard block shapes. + */ + valid_samples &= VK_SAMPLE_COUNT_1_BIT; + + /* For 125+, isl_gfx125_filter_tiling() claims 3D is not supported. + * For the previous platforms, isl_gfx6_filter_tiling() says only 2D is + * supported. + */ + if (pdevice->info.verx10 >= 125) { + if (type == VK_IMAGE_TYPE_3D) + return VK_ERROR_FORMAT_NOT_SUPPORTED; + } else { + if (type != VK_IMAGE_TYPE_2D) + return VK_ERROR_FORMAT_NOT_SUPPORTED; + } + } const struct anv_format *anv_format = anv_get_format(pdevice, vk_format); if (!anv_format) @@ -1709,5 +1724,8 @@ anv_sparse_image_check_support(struct anv_physical_device *pdevice, if (valid_samples_out) *valid_samples_out = valid_samples; + if (!valid_samples) + return VK_ERROR_FORMAT_NOT_SUPPORTED; + return VK_SUCCESS; }