microsoft/compiler: Use nir info.fs.uses_sample_shading to force sample-rate
authorJesse Natalie <jenatali@microsoft.com>
Thu, 5 Jan 2023 18:36:27 +0000 (10:36 -0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 17 Jan 2023 12:47:16 +0000 (12:47 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20614>

src/gallium/drivers/d3d12/d3d12_nir_passes.c
src/microsoft/compiler/nir_to_dxil.c
src/microsoft/spirv_to_dxil/dxil_spirv_nir.c

index 4f2f6cb..742239b 100644 (file)
@@ -946,6 +946,8 @@ d3d12_disable_multisampling(nir_shader *s)
       var->data.sample = false;
    }
    BITSET_CLEAR(s->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID);
+   s->info.fs.uses_sample_qualifier = false;
+   s->info.fs.uses_sample_shading = false;
    return progress;
 }
 
index 6d7fe3f..3994c63 100644 (file)
@@ -5764,7 +5764,9 @@ emit_module(struct ntd_context *ctx, const struct nir_to_dxil_options *opts)
    }
 
    ctx->mod.info.has_per_sample_input =
-      BITSET_TEST(ctx->shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID);
+      BITSET_TEST(ctx->shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID) ||
+      ctx->shader->info.fs.uses_sample_shading ||
+      ctx->shader->info.fs.uses_sample_qualifier;
    if (!ctx->mod.info.has_per_sample_input && ctx->shader->info.stage == MESA_SHADER_FRAGMENT) {
       nir_foreach_variable_with_modes(var, ctx->shader, nir_var_shader_in | nir_var_system_value) {
          if (var->data.sample) {
@@ -6032,9 +6034,8 @@ allocate_sysvalues(struct ntd_context *ctx)
       driver_location = MAX2(driver_location, var->data.driver_location + 1);
 
    if (ctx->shader->info.stage == MESA_SHADER_FRAGMENT &&
-       ctx->shader->info.inputs_read &&
        !BITSET_TEST(ctx->shader->info.system_values_read, SYSTEM_VALUE_SAMPLE_ID)) {
-      bool need_sample_id = false;
+      bool need_sample_id = ctx->shader->info.fs.uses_sample_shading;
 
       /* "var->data.sample = true" sometimes just mean, "I want per-sample
        * shading", which explains why we can end up with vars having flat
index 8349d80..6d37026 100644 (file)
@@ -794,8 +794,7 @@ dxil_spirv_nir_passes(nir_shader *nir,
    // Force sample-rate shading if we're asked to.
    if (conf->force_sample_rate_shading) {
       assert(nir->info.stage == MESA_SHADER_FRAGMENT);
-      nir_foreach_shader_in_variable(var, nir)
-         var->data.sample = true;
+      nir->info.fs.uses_sample_shading = true;
    }
 
    if (conf->zero_based_vertex_instance_id) {