diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index ad0423ad99e..3d55698cde1 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -859,4 +859,15 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) gather_info_block(block, shader, dead_ctx); } ralloc_free(dead_ctx); + + if (shader->info.stage == MESA_SHADER_FRAGMENT && + (shader->info.fs.uses_sample_qualifier || + (shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_ID)) || + shader->info.system_values_read & BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_POS))) { + /* This shouldn't be cleared because if optimizations remove all + * sample-qualified inputs and that pass is run again, the sample + * shading must stay enabled. + */ + shader->info.fs.uses_sample_shading = true; + } } diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index dfaaa4f0fa6..bc3d45b06db 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -286,6 +286,11 @@ typedef struct shader_info { */ bool uses_sample_qualifier:1; + /** + * Whether sample shading is used. + */ + bool uses_sample_shading:1; + /** * Whether early fragment tests are enabled as defined by * ARB_shader_image_load_store.