From 0d2923dfbbec4bfe919ec5005b16191122d3ac96 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 18 Oct 2023 12:21:02 -0400 Subject: [PATCH] zink: fix legacy depth texture rewriting for single component reads if only a single component is read, this instruction can (and must) be rewritten to use that component since depth sampling in vulkan is single-component cc: mesa-stable Part-of: --- src/gallium/drivers/zink/zink_compiler.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 9193a938825..38ff2ef2534 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -3358,18 +3358,21 @@ rewrite_tex_dest(nir_builder *b, nir_tex_instr *tex, nir_variable *var, struct z return NULL; nir_def *dest = &tex->def; if (rewrite_depth && zs) { + if (nir_def_components_read(dest) & ~1) { + /* this needs recompiles */ + if (b->shader->info.stage == MESA_SHADER_FRAGMENT) + flag_shadow_tex(var, zs); + else + mesa_loge("unhandled old-style shadow sampler in non-fragment stage!"); + return NULL; + } /* If only .x is used in the NIR, then it's effectively not a legacy depth * sample anyway and we don't want to ask for shader recompiles. This is * the typical path, since GL_DEPTH_TEXTURE_MODE defaults to either RED or * LUMINANCE, so apps just use the first channel. */ - if (nir_def_components_read(dest) & ~1) { - if (b->shader->info.stage == MESA_SHADER_FRAGMENT) - flag_shadow_tex(var, zs); - else - mesa_loge("unhandled old-style shadow sampler in non-fragment stage!"); - } - return NULL; + tex->def.num_components = 1; + tex->is_new_style_shadow = true; } if (bit_size != dest_size) { tex->def.bit_size = bit_size;