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");