From 8ed23654c9f7fed77bc706fbfd1d25edf0d7020e Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 15 Oct 2015 21:16:41 -0700 Subject: [PATCH] nir/spirv: Fix handling of vector component selects via OpAccessChain When we get to the end of the _vtn_load/store_varaible recursion, we may have one link left in the deref chain if there is a vector component select on the end. In this case, we need to truncate the deref chain early so that, when we make the copy for the load, we don't get the extra deref. The final deref will be handled by the vector extract/insert that comes later. --- src/glsl/nir/spirv_to_nir.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/glsl/nir/spirv_to_nir.c b/src/glsl/nir/spirv_to_nir.c index 6dfe530905d..a62ec6661b0 100644 --- a/src/glsl/nir/spirv_to_nir.c +++ b/src/glsl/nir/spirv_to_nir.c @@ -912,6 +912,11 @@ _vtn_variable_load(struct vtn_builder *b, nir_deref *old_child = src_deref_tail->child; if (glsl_type_is_vector_or_scalar(val->type)) { + /* Terminate the deref chain in case there is one more link to pick + * off a component of the vector. + */ + src_deref_tail->child = NULL; + nir_intrinsic_instr *load = nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var); load->variables[0] = @@ -979,6 +984,11 @@ _vtn_variable_store(struct vtn_builder *b, struct vtn_type *dest_type, nir_deref *old_child = dest_deref_tail->child; if (glsl_type_is_vector_or_scalar(src->type)) { + /* Terminate the deref chain in case there is one more link to pick + * off a component of the vector. + */ + dest_deref_tail->child = NULL; + nir_intrinsic_instr *store = nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_var); store->variables[0] = -- 2.30.2