From 81df66bfff65751ad40ede3fa31415d06f17abe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Thu, 9 Dec 2021 17:11:01 +0100 Subject: [PATCH] intel/compiler: mark some variables as per-primitive in FS if they come from MS Reviewed-by: Caio Oliveira Part-of: --- src/intel/compiler/brw_nir.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 9a8d4db133e..42e628edd11 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -912,6 +912,25 @@ void brw_nir_link_shaders(const struct brw_compiler *compiler, nir_shader *producer, nir_shader *consumer) { + if (producer->info.stage == MESA_SHADER_MESH && + consumer->info.stage == MESA_SHADER_FRAGMENT) { + /* gl_MeshPerPrimitiveNV[].gl_ViewportIndex, gl_PrimitiveID and gl_Layer + * are per primitive, but fragment shader does not have them marked as + * such. Add the annotation here. + */ + nir_foreach_shader_in_variable(var, consumer) { + switch (var->data.location) { + case VARYING_SLOT_LAYER: + case VARYING_SLOT_PRIMITIVE_ID: + case VARYING_SLOT_VIEWPORT: + var->data.per_primitive = 1; + break; + default: + continue; + } + } + } + nir_lower_io_arrays_to_elements(producer, consumer); nir_validate_shader(producer, "after nir_lower_io_arrays_to_elements"); nir_validate_shader(consumer, "after nir_lower_io_arrays_to_elements");