From: Samuel Pitoiset Date: Thu, 30 Aug 2018 07:35:41 +0000 (+0200) Subject: radv: add set_output_usage_mask() helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ffe3a2a298da78d68742d3683109b5cd8e13c656;p=mesa.git radv: add set_output_usage_mask() helper Signed-off-by: Samuel Pitoiset Reviewed-by: Dave Airlie --- diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index a45c847c46c..5925fd924c8 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -114,6 +114,26 @@ gather_intrinsic_load_deref_info(const nir_shader *nir, } } +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, @@ -122,31 +142,20 @@ gather_intrinsic_store_deref_info(const nir_shader *nir, 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);