From 80a5deee620cfee7a8d1f63ef1b2b1736995895b Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 13 Apr 2022 02:14:36 -0700 Subject: [PATCH] microsoft/spirv_to_dxil: Allow forcing per-sample shading Needed to support VkPipelineMultisampleStateCreateInfo::sampleShadingEnable. Reviewed-by: Erik Faye-Lund Reviewed-by: Jesse Natalie Part-of: --- src/microsoft/spirv_to_dxil/spirv_to_dxil.c | 7 +++++++ src/microsoft/spirv_to_dxil/spirv_to_dxil.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c index d02b6e1cbc1..7539678072b 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c @@ -565,6 +565,13 @@ spirv_to_dxil(const uint32_t *words, size_t word_count, NIR_PASS_V(nir, nir_lower_system_values); + // Force sample-rate shading if we're asked to. + if (conf->force_sample_rate_shading) { + assert(stage == MESA_SHADER_FRAGMENT); + nir_foreach_shader_in_variable(var, nir) + var->data.sample = true; + } + if (conf->zero_based_vertex_instance_id) { // vertex_id and instance_id should have already been transformed to // base zero before spirv_to_dxil was called. Therefore, we can zero out diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h index f53a5445bc5..cad69ef425c 100644 --- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.h +++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.h @@ -165,6 +165,9 @@ struct dxil_spirv_runtime_conf { // The caller supports read-only images to be turned into SRV accesses, // which allows us to run the nir_opt_access() pass bool read_only_images_as_srvs; + + // Force sample rate shading on a fragment shader + bool force_sample_rate_shading; }; struct dxil_spirv_debug_options {