}
}
+static void
+set_output_usage_mask(const nir_shader *nir, const nir_intrinsic_instr *instr,
+ uint8_t *output_usage_mask)
+{
+ nir_deref_instr *deref_instr =
+ nir_instr_as_deref(instr->src[0].ssa->parent_instr);
+ nir_variable *var = nir_deref_instr_get_variable(deref_instr);
+ unsigned attrib_count = glsl_count_attribute_slots(var->type, false);
+ unsigned idx = var->data.location;
+ unsigned comp = var->data.location_frac;
+ unsigned const_offset = 0;
+
+ get_deref_offset(deref_instr, &const_offset);
+
+ for (unsigned i = 0; i < attrib_count; i++) {
+ output_usage_mask[idx + i + const_offset] |=
+ instr->const_index[0] << comp;
+ }
+}
+
static void
gather_intrinsic_store_deref_info(const nir_shader *nir,
const nir_intrinsic_instr *instr,
nir_variable *var = nir_deref_instr_get_variable(nir_instr_as_deref(instr->src[0].ssa->parent_instr));
if (var->data.mode == nir_var_shader_out) {
- unsigned attrib_count = glsl_count_attribute_slots(var->type, false);
unsigned idx = var->data.location;
- unsigned comp = var->data.location_frac;
- unsigned const_offset = 0;
-
- get_deref_offset(nir_instr_as_deref(instr->src[0].ssa->parent_instr), &const_offset);
switch (nir->info.stage) {
case MESA_SHADER_VERTEX:
- for (unsigned i = 0; i < attrib_count; i++) {
- info->vs.output_usage_mask[idx + i + const_offset] |=
- instr->const_index[0] << comp;
- }
+ set_output_usage_mask(nir, instr,
+ info->vs.output_usage_mask);
break;
case MESA_SHADER_GEOMETRY:
- for (unsigned i = 0; i < attrib_count; i++) {
- info->gs.output_usage_mask[idx + i + const_offset] |=
- instr->const_index[0] << comp;
- }
+ set_output_usage_mask(nir, instr,
+ info->gs.output_usage_mask);
break;
case MESA_SHADER_TESS_EVAL:
- for (unsigned i = 0; i < attrib_count; i++) {
- info->tes.output_usage_mask[idx + i + const_offset] |=
- instr->const_index[0] << comp;
- }
+ set_output_usage_mask(nir, instr,
+ info->tes.output_usage_mask);
break;
case MESA_SHADER_TESS_CTRL: {
unsigned param = shader_io_get_unique_index(idx);