[Mesa-dev] [PATCH 13/28] spirv/nir: fill glsl_type array stride
Alejandro PiƱeiro
apinheiro at igalia.com
Mon Oct 22 12:24:35 UTC 2018
We need all the info when asking for the type, so we needed to call
type_decoration_cb earlier, in order to get the ArrayStride.
It is somewhat ugly to do this only for Array types, but we can't do
it before the switch as type_decoration_cb have some asserts to ensure
that the type and the decoration are compatible.
One alternative would be keep the call to type_decoration_cb at the
end, but create the glsl type for Arrays at the end, after calling
it. Again we are treating Arrays in a different way.
A full alternative to treat all types in the same way would be have a
first switch(opcode) that would fill the base_type, call
type_decoration_cb, and then a new switch(opcode) that would fill
extra data and create the glsl_type. That looks like an overkill
though.
---
src/compiler/spirv/spirv_to_nir.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 1201143d2f4..312d7d286ba 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1143,9 +1143,14 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
}
val->type->base_type = vtn_base_type_array;
- val->type->type = glsl_array_type(array_element->type, val->type->length);
+ /* We need to call type_decoration_cb earlier, in order to get the
+ * proper value of ArrayStride
+ */
+ vtn_foreach_decoration(b, val, type_decoration_cb, NULL);
+
+ val->type->type = glsl_full_array_type(array_element->type, val->type->length,
+ val->type->stride);
val->type->array_element = array_element;
- val->type->stride = 0;
break;
}
@@ -1324,7 +1329,11 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
vtn_fail("Unhandled opcode");
}
- vtn_foreach_decoration(b, val, type_decoration_cb, NULL);
+ /* For Arrays we already called foreach_decoration */
+ if (opcode != SpvOpTypeRuntimeArray && opcode != SpvOpTypeArray) {
+ vtn_foreach_decoration(b, val, type_decoration_cb, NULL);
+ }
+
}
static nir_constant *
--
2.14.1
More information about the mesa-dev
mailing list