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 02de2f640c1..8d609f1ddb5 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1125,9 +1125,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; } @@ -1306,7 +1311,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 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev