From 9cb345588bef489e49bf09bb126050268217b705 Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Fri, 11 May 2018 14:38:12 +0200 Subject: [PATCH] radv: Remove deref chain support in radv shader info pass. Acked-by: Rob Clark Acked-by: Bas Nieuwenhuizen Acked-by: Dave Airlie --- src/amd/vulkan/radv_shader_info.c | 106 +++--------------------------- 1 file changed, 9 insertions(+), 97 deletions(-) diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 5ef7d745805..8026cca46c8 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -48,49 +48,9 @@ static void mark_tess_output(struct radv_shader_info *info, info->tcs.outputs_written |= (mask << param); } -static void get_deref_offset(nir_deref_var *deref, unsigned *const_out) -{ - nir_deref *tail = &deref->deref; - unsigned const_offset = 0; - - if (deref->var->data.compact) { - assert(tail->child->deref_type == nir_deref_type_array); - assert(glsl_type_is_scalar(glsl_without_array(deref->var->type))); - - nir_deref_array *deref_array = nir_deref_as_array(tail->child); - /* We always lower indirect dereferences for "compact" array vars. */ - assert(deref_array->deref_array_type == nir_deref_array_type_direct); - - *const_out = deref_array->base_offset; - return; - } - - while (tail->child != NULL) { - const struct glsl_type *parent_type = tail->type; - tail = tail->child; - - if (tail->deref_type == nir_deref_type_array) { - nir_deref_array *deref_array = nir_deref_as_array(tail); - unsigned size = glsl_count_attribute_slots(tail->type, false); - - const_offset += size * deref_array->base_offset; - } else if (tail->deref_type == nir_deref_type_struct) { - nir_deref_struct *deref_struct = nir_deref_as_struct(tail); - - for (unsigned i = 0; i < deref_struct->index; i++) { - const struct glsl_type *ft = glsl_get_struct_field(parent_type, i); - const_offset += glsl_count_attribute_slots(ft, false); - } - } else - unreachable("unsupported deref type"); - } - - *const_out = const_offset; -} - static void -get_deref_instr_offset(nir_deref_instr *instr, - unsigned *const_out) +get_deref_offset(nir_deref_instr *instr, + unsigned *const_out) { nir_variable *var = nir_deref_instr_get_variable(instr); nir_deref_path path; @@ -132,14 +92,13 @@ get_deref_instr_offset(nir_deref_instr *instr, } static void -gather_intrinsic_load_var_info(const nir_shader *nir, +gather_intrinsic_load_deref_info(const nir_shader *nir, const nir_intrinsic_instr *instr, struct radv_shader_info *info) { switch (nir->info.stage) { case MESA_SHADER_VERTEX: { - nir_variable *var = instr->intrinsic == nir_intrinsic_load_var ? instr->variables[0]->var : - nir_deref_instr_get_variable(nir_instr_as_deref(instr->src[0].ssa->parent_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_in) { unsigned idx = var->data.location; @@ -156,12 +115,11 @@ gather_intrinsic_load_var_info(const nir_shader *nir, } static void -gather_intrinsic_store_var_info(const nir_shader *nir, +gather_intrinsic_store_deref_info(const nir_shader *nir, const nir_intrinsic_instr *instr, struct radv_shader_info *info) { - nir_variable *var = instr->intrinsic == nir_intrinsic_store_var ? instr->variables[0]->var : - nir_deref_instr_get_variable(nir_instr_as_deref(instr->src[0].ssa->parent_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); @@ -169,10 +127,7 @@ gather_intrinsic_store_var_info(const nir_shader *nir, unsigned comp = var->data.location_frac; unsigned const_offset = 0; - if (instr->intrinsic == nir_intrinsic_store_var) - get_deref_offset(instr->variables[0], &const_offset); - else - get_deref_instr_offset(nir_instr_as_deref(instr->src[0].ssa->parent_instr), &const_offset); + get_deref_offset(nir_instr_as_deref(instr->src[0].ssa->parent_instr), &const_offset); switch (nir->info.stage) { case MESA_SHADER_VERTEX: @@ -222,7 +177,6 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr, struct radv_shader_info *info) { switch (instr->intrinsic) { - case nir_intrinsic_interp_var_at_sample: case nir_intrinsic_interp_deref_at_sample: info->ps.needs_sample_positions = true; break; @@ -276,41 +230,6 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr, case nir_intrinsic_vulkan_resource_index: info->desc_set_used_mask |= (1 << nir_intrinsic_desc_set(instr)); break; - case nir_intrinsic_image_var_load: - case nir_intrinsic_image_var_store: - case nir_intrinsic_image_var_atomic_add: - case nir_intrinsic_image_var_atomic_min: - case nir_intrinsic_image_var_atomic_max: - case nir_intrinsic_image_var_atomic_and: - case nir_intrinsic_image_var_atomic_or: - case nir_intrinsic_image_var_atomic_xor: - case nir_intrinsic_image_var_atomic_exchange: - case nir_intrinsic_image_var_atomic_comp_swap: - case nir_intrinsic_image_var_size: { - const struct glsl_type *type = glsl_without_array(instr->variables[0]->var->type); - - enum glsl_sampler_dim dim = glsl_get_sampler_dim(type); - if (dim == GLSL_SAMPLER_DIM_SUBPASS || - dim == GLSL_SAMPLER_DIM_SUBPASS_MS) { - info->ps.layer_input = true; - info->ps.uses_input_attachments = true; - } - mark_sampler_desc(instr->variables[0]->var, info); - - if (nir_intrinsic_image_var_store || - nir_intrinsic_image_var_atomic_add || - nir_intrinsic_image_var_atomic_min || - nir_intrinsic_image_var_atomic_max || - nir_intrinsic_image_var_atomic_and || - nir_intrinsic_image_var_atomic_or || - nir_intrinsic_image_var_atomic_xor || - nir_intrinsic_image_var_atomic_exchange || - nir_intrinsic_image_var_atomic_comp_swap) { - if (nir->info.stage == MESA_SHADER_FRAGMENT) - info->ps.writes_memory = true; - } - break; - } case nir_intrinsic_image_deref_load: case nir_intrinsic_image_deref_store: case nir_intrinsic_image_deref_atomic_add: @@ -361,13 +280,11 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr, if (nir->info.stage == MESA_SHADER_FRAGMENT) info->ps.writes_memory = true; break; - case nir_intrinsic_load_var: case nir_intrinsic_load_deref: - gather_intrinsic_load_var_info(nir, instr, info); + gather_intrinsic_load_deref_info(nir, instr, info); break; - case nir_intrinsic_store_var: case nir_intrinsic_store_deref: - gather_intrinsic_store_var_info(nir, instr, info); + gather_intrinsic_store_deref_info(nir, instr, info); break; default: break; @@ -390,11 +307,6 @@ gather_tex_info(const nir_shader *nir, const nir_tex_instr *instr, break; } } - - if (instr->sampler) - mark_sampler_desc(instr->sampler->var, info); - if (instr->texture) - mark_sampler_desc(instr->texture->var, info); } static void -- 2.30.2