fa5b206d97
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.
27 lines
720 B
Plaintext
27 lines
720 B
Plaintext
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct SSBO0
|
|
{
|
|
short4 inputs[1];
|
|
};
|
|
|
|
struct SSBO1
|
|
{
|
|
int4 outputs[1];
|
|
};
|
|
|
|
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
|
|
|
|
kernel void main0(device SSBO0& _25 [[buffer(0)]], device SSBO1& _39 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
|
|
{
|
|
uint ident = gl_GlobalInvocationID.x;
|
|
half2 a = as_type<half2>(_25.inputs[ident].xy);
|
|
((device int*)&_39.outputs[ident])[0u] = int(as_type<uint>(a + half2(half(1.0))));
|
|
((device int*)&_39.outputs[ident])[1u] = as_type<int>(_25.inputs[ident].zw);
|
|
((device int*)&_39.outputs[ident])[2u] = int(as_type<uint>(ushort2(_25.inputs[ident].xy)));
|
|
}
|
|
|