SPIRV-Cross/reference/shaders-msl/asm/comp/buffer-write-relative-addr.asm.comp
Chip Davis 6757ef8512 Use bitcast_to_builtin_load() instead of hacking to_expression().
This only affects the builtin when it is used, and not when it's passed
to a function. It's a lot cleaner than the way I was doing it before.

Remove the `to_expression()` hack.
2018-09-11 11:15:17 -05:00

32 lines
968 B
Plaintext

#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct cb5_struct
{
float4 _m0[5];
};
// Returns 2D texture coords corresponding to 1D texel buffer coords
uint2 spvTexelBufferCoord(uint tc)
{
return uint2(tc % 4096, tc / 4096);
}
kernel void main0(constant cb5_struct& cb0_5 [[buffer(1)]], texture2d<uint, access::write> u0 [[texture(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]])
{
float4 r0;
r0.x = as_type<float>(int(gl_LocalInvocationID.x) << 4);
r0.y = as_type<float>(int(gl_LocalInvocationID.x));
uint _44 = as_type<uint>(r0.x) >> 2u;
uint4 _51 = as_type<uint4>(cb0_5._m0[uint(as_type<int>(r0.y)) + 1u]);
u0.write(_51.xxxx, spvTexelBufferCoord(_44));
u0.write(_51.yyyy, spvTexelBufferCoord((_44 + 1u)));
u0.write(_51.zzzz, spvTexelBufferCoord((_44 + 2u)));
u0.write(_51.wwww, spvTexelBufferCoord((_44 + 3u)));
}