[Mesa-dev] [PATCH 18/19] radv: Remove deref chain support in radv shader info pass.

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Sun May 13 00:20:12 UTC 2018


---
 src/amd/vulkan/radv_shader_info.c | 98 ++-----------------------------
 1 file changed, 5 insertions(+), 93 deletions(-)

diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c
index bdf30ead2f8..ab424720de1 100644
--- a/src/amd/vulkan/radv_shader_info.c
+++ b/src/amd/vulkan/radv_shader_info.c
@@ -47,49 +47,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;
@@ -135,7 +95,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;
@@ -189,41 +148,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:
@@ -274,11 +198,9 @@ 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:
 		if (nir->info.stage == 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;
@@ -288,10 +210,8 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr,
 			}
 		}
 		break;
-	case nir_intrinsic_store_var:
 	case nir_intrinsic_store_deref: {
-		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);
@@ -300,10 +220,7 @@ gather_intrinsic_info(const nir_shader *nir, const nir_intrinsic_instr *instr,
 			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);
 
 			if (nir->info.stage == MESA_SHADER_VERTEX) {
 				for (unsigned i = 0; i < attrib_count; i++) {
@@ -351,11 +268,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.17.0



More information about the mesa-dev mailing list