From e94a027af8953ba22f4daa3009ab71479b35c78f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 28 Nov 2018 12:26:52 -0600 Subject: nir: Add a ptr_as_array deref type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These correspond directly to SPIR-V's OpPtrAccessChain. As such, they treat whatever their parent gives them as if it's the first element in some array and dereferences that array. If the parent is, itself, an array deref, then the two indices can just be added together to get the final array deref. However, it can also be used in cases where what you have is a dereference to some random vec2 value somewhere. In this case, we require a cast before the ptr_as_array and use the ptr_stride field in the cast to provide a stride for the ptr_as_array derefs. Reviewed-by: Alejandro PiƱeiro Reviewed-by: Caio Marcelo de Oliveira Filho --- src/compiler/spirv/vtn_variables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/compiler/spirv/vtn_variables.c') diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 6e96cb606b4..3041fa47ec1 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1627,7 +1627,7 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa, assert(!vtn_pointer_is_external_block(b, ptr)); const struct glsl_type *deref_type = ptr_type->deref->type; ptr->deref = nir_build_deref_cast(&b->nb, ssa, nir_mode, - glsl_get_bare_type(deref_type)); + glsl_get_bare_type(deref_type), 0); } return ptr; -- cgit v1.2.3