SPIRV-Cross/reference/shaders-msl-no-opt/asm/packing/row-major-split-access-chain.asm.comp
Hans-Kristian Arntzen fa5b206d97 MSL: Workaround broken vector -> scalar access chain in MSL.
On MSL, the compiler refuses to allow access chains into a normal vector type.
What happens in practice instead is a read-modify-write where a vector type is
loaded, modified and written back.

The workaround is to convert a vector into a pointer-to-scalar before
the access chain continues to add the scalar index.
2020-07-06 10:03:44 +02:00

17 lines
239 B
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct SSBORow
{
float v;
float4x4 row_major0;
};
kernel void main0(device SSBORow& _4 [[buffer(0)]])
{
_4.v = ((device float*)&_4.row_major0[2u])[1];
}