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.
This commit is contained in:
parent
2552df41a1
commit
8ed23654c9
|
@ -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] =
|
||||
|
|
Loading…
Reference in New Issue