diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index aa1b1a6509c..41a7016e1bf 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -3367,10 +3367,17 @@ rewrite_tex_dest(nir_builder *b, nir_tex_instr *tex, nir_variable *var, struct z return NULL; nir_ssa_def *dest = &tex->dest.ssa; if (rewrite_depth && zs) { - 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!"); + /* 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_ssa_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; } if (bit_size != dest_size) { diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index c5a5b72e104..483bc3af160 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -797,7 +797,11 @@ struct zink_shader { } non_fs; struct { - uint32_t legacy_shadow_mask; //is_new_style_shadow is false for these + /* Bitmask of textures that have shadow sampling result components + * other than RED accessed. This is a subset of !is_new_style_shadow + * (GLSL <1.30, ARB_fp) shadow sampling usage. + */ + uint32_t legacy_shadow_mask; nir_variable *fbfetch; //for fs output } fs; };