It's disallowed according to the SPIR-V spec or at least I think that's
what the spec says. It's in a section explicitly about explicit layout
of things in the StorageBuffer, Uniform, and PushConstant storage
classes so it's not 100% clear that it applies with other storage
classes. However, it seems like it should apply in general and
violating it can trigger (fairly harmless) asserts in NIR.
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
struct vtn_type *type = val->type;
if (dec->decoration == SpvDecorationArrayStride) {
- vtn_fail_if(dec->operands[0] == 0, "ArrayStride must be non-zero");
- type->stride = dec->operands[0];
+ if (vtn_type_contains_block(b, type)) {
+ vtn_warn("The ArrayStride decoration cannot be applied to an array "
+ "type which contains a structure type decorated Block "
+ "or BufferBlock");
+ /* Ignore the decoration */
+ } else {
+ vtn_fail_if(dec->operands[0] == 0, "ArrayStride must be non-zero");
+ type->stride = dec->operands[0];
+ }
}
}