diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-07-03 13:14:33 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-07-15 16:18:57 -0700 |
commit | 1210e8caaffd7dfaa0db2bee2047133c0fe76e13 (patch) | |
tree | ba43590dc5831d29de73c8e1a4b1cfcf9178875b /src/compiler/spirv/spirv_to_nir.c | |
parent | 026cfa10995ff3316476fa19507fa27adc531de5 (diff) |
spirv: Ignore ArrayStride for storage classes that should not use it
The stride was already overriden when using
lower_workgroup_access_to_offsets, so elaborate a bit the commentary
there.
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/spirv/spirv_to_nir.c')
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index ebefd4d7bf5..6a9ccfe0f38 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -1383,7 +1383,20 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, val->type->deref = vtn_value(b, w[3], vtn_value_type_type)->type; - vtn_foreach_decoration(b, val, array_stride_decoration_cb, NULL); + /* Only certain storage classes use ArrayStride. The others (in + * particular Workgroup) are expected to be laid out by the driver. + */ + switch (storage_class) { + case SpvStorageClassUniform: + case SpvStorageClassPushConstant: + case SpvStorageClassStorageBuffer: + case SpvStorageClassPhysicalStorageBufferEXT: + vtn_foreach_decoration(b, val, array_stride_decoration_cb, NULL); + break; + default: + /* Nothing to do. */ + break; + } if (b->physical_ptrs) { switch (storage_class) { @@ -1398,14 +1411,15 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode, } } else if (storage_class == SpvStorageClassWorkgroup && b->options->lower_workgroup_access_to_offsets) { - /* Workgroup is laid out by the implementation. */ + /* Lay out Workgroup types so it can be lowered to offsets during + * SPIR-V to NIR conversion. When not lowering to offsets, the + * stride will be calculated by the driver. + */ uint32_t size, align; val->type->deref = vtn_type_layout_std430(b, val->type->deref, &size, &align); val->type->length = size; val->type->align = align; - - /* Override any ArrayStride previously set. */ val->type->stride = vtn_align_u32(size, align); } } |