Open chirsz-ever opened 2 years ago
Arrays in SPIR-V are value types, but MSL inherits pointer-decay ala C. Copying arrays leads to very poor code in MSL, and the template value type wrapper is a workaround that we are forced to keep for performance. There is a force_native_arrays
option for MSL, but it has many edge cases w.r.t. correctness. For trivial array use, it should be fine though ...
For example, use this glsl code to generate SPIR-V for Vulkan with
glslangValidator -V test.frag
:Then pass it to SPIRV-Cross with
spirv-cross --msl frag.spv
, this would generate:The
spvUnsafeArray
type looks unnecessary, the better code would be like: