| #include <metal_stdlib> | |
| using namespace metal; | |
| template<typename T, size_t N> | |
| struct tint_array { | |
| const constant T& operator[](size_t i) const constant { return elements[i]; } | |
| device T& operator[](size_t i) device { return elements[i]; } | |
| const device T& operator[](size_t i) const device { return elements[i]; } | |
| thread T& operator[](size_t i) thread { return elements[i]; } | |
| const thread T& operator[](size_t i) const thread { return elements[i]; } | |
| threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } | |
| const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } | |
| T elements[N]; | |
| }; | |
| struct tint_private_vars_struct { | |
| float2 rand_seed; | |
| }; | |
| struct RenderParams_tint_packed_vec3 { | |
| /* 0x0000 */ float4x4 modelViewProjectionMatrix; | |
| /* 0x0040 */ packed_float3 right; | |
| /* 0x004c */ tint_array<int8_t, 4> tint_pad; | |
| /* 0x0050 */ packed_float3 up; | |
| /* 0x005c */ tint_array<int8_t, 4> tint_pad_1; | |
| }; | |
| struct Particle_tint_packed_vec3 { | |
| /* 0x0000 */ packed_float3 position; | |
| /* 0x000c */ float lifetime; | |
| /* 0x0010 */ float4 color; | |
| /* 0x0020 */ float2 velocity; | |
| /* 0x0028 */ tint_array<int8_t, 8> tint_pad_2; | |
| }; | |
| struct Particles_tint_packed_vec3 { | |
| /* 0x0000 */ tint_array<Particle_tint_packed_vec3, 1> particles; | |
| }; | |
| struct Particle { | |
| float3 position; | |
| float lifetime; | |
| float4 color; | |
| float2 velocity; | |
| }; | |
| Particle tint_unpack_vec3_in_composite(Particle_tint_packed_vec3 in) { | |
| Particle result = {}; | |
| result.position = float3(in.position); | |
| result.lifetime = in.lifetime; | |
| result.color = in.color; | |
| result.velocity = in.velocity; | |
| return result; | |
| } | |
| void asinh_468a48() { | |
| half arg_0 = 0.0h; | |
| half res = asinh(arg_0); | |
| } | |
| struct tint_symbol_1 { | |
| float4 value [[position]]; | |
| }; | |
| float4 vertex_main_inner() { | |
| asinh_468a48(); | |
| return float4(0.0f); | |
| } | |
| vertex tint_symbol_1 vertex_main() { | |
| float4 const inner_result = vertex_main_inner(); | |
| tint_symbol_1 wrapper_result = {}; | |
| wrapper_result.value = inner_result; | |
| return wrapper_result; | |
| } | |
| fragment void fragment_main() { | |
| asinh_468a48(); | |
| return; | |
| } | |
| kernel void rgba32uintin() { | |
| asinh_468a48(); | |
| return; | |
| } | |
| struct TestData { | |
| tint_array<atomic_int, 4> dmat2atxa2; | |
| }; | |
| struct RenderParams { | |
| float4x4 modelViewProjectionMatrix; | |
| float3 right; | |
| float3 up; | |
| }; | |
| struct VertexInput { | |
| float3 position; | |
| float4 color; | |
| float2 quad_pos; | |
| }; | |
| struct VertexOutput { | |
| float4 position; | |
| float4 color; | |
| float2 quad_pos; | |
| }; | |
| struct tint_symbol_3 { | |
| float3 position [[attribute(0)]]; | |
| float4 color [[attribute(1)]]; | |
| float2 quad_pos [[attribute(2)]]; | |
| }; | |
| struct tint_symbol_4 { | |
| float4 color [[user(locn0)]]; | |
| float2 quad_pos [[user(locn1)]]; | |
| float4 position [[position]]; | |
| }; | |
| VertexOutput vs_main_inner(VertexInput in, const constant RenderParams_tint_packed_vec3* const tint_symbol_6) { | |
| float3 quad_pos = (float2x3(float3((*(tint_symbol_6)).right), float3((*(tint_symbol_6)).up)) * in.quad_pos); | |
| float3 position = (in.position - (quad_pos + 0.00999999977648258209f)); | |
| VertexOutput out = {}; | |
| out.position = ((*(tint_symbol_6)).modelViewProjectionMatrix * float4(position, 1.0f)); | |
| out.color = in.color; | |
| out.quad_pos = in.quad_pos; | |
| return out; | |
| } | |
| vertex tint_symbol_4 vs_main(const constant RenderParams_tint_packed_vec3* tint_symbol_7 [[buffer(0)]], tint_symbol_3 tint_symbol_2 [[stage_in]]) { | |
| VertexInput const tint_symbol_5 = {.position=tint_symbol_2.position, .color=tint_symbol_2.color, .quad_pos=tint_symbol_2.quad_pos}; | |
| VertexOutput const inner_result_1 = vs_main_inner(tint_symbol_5, tint_symbol_7); | |
| tint_symbol_4 wrapper_result_1 = {}; | |
| wrapper_result_1.position = inner_result_1.position; | |
| wrapper_result_1.color = inner_result_1.color; | |
| wrapper_result_1.quad_pos = inner_result_1.quad_pos; | |
| return wrapper_result_1; | |
| } | |
| struct SimulationParams { | |
| /* 0x0000 */ float deltaTime; | |
| /* 0x0004 */ tint_array<int8_t, 12> tint_pad_3; | |
| /* 0x0010 */ float4 seed; | |
| }; | |
| struct Particles { | |
| tint_array<Particle, 1> particles; | |
| }; | |
| void assign_and_preserve_padding(device Particle_tint_packed_vec3* const dest, Particle value) { | |
| (*(dest)).position = packed_float3(value.position); | |
| (*(dest)).lifetime = value.lifetime; | |
| (*(dest)).color = value.color; | |
| (*(dest)).velocity = value.velocity; | |
| } | |
| void simulate_inner(uint3 GlobalInvocationID, thread tint_private_vars_struct* const tint_private_vars, const constant SimulationParams* const tint_symbol_8, device Particles_tint_packed_vec3* const tint_symbol_9) { | |
| (*(tint_private_vars)).rand_seed = (((*(tint_symbol_8)).seed.xy * float2(GlobalInvocationID.xy)) * (*(tint_symbol_8)).seed.zw); | |
| uint const idx = GlobalInvocationID[0]; | |
| Particle particle = tint_unpack_vec3_in_composite((*(tint_symbol_9)).particles[idx]); | |
| assign_and_preserve_padding(&((*(tint_symbol_9)).particles[idx]), particle); | |
| } | |
| kernel void simulate(const constant SimulationParams* tint_symbol_10 [[buffer(1)]], device Particles_tint_packed_vec3* tint_symbol_11 [[buffer(2)]], uint3 GlobalInvocationID [[thread_position_in_grid]]) { | |
| thread tint_private_vars_struct tint_private_vars = {}; | |
| simulate_inner(GlobalInvocationID, &(tint_private_vars), tint_symbol_10, tint_symbol_11); | |
| return; | |
| } | |
| struct UBO { | |
| /* 0x0000 */ uint width; | |
| }; | |
| struct Buffer { | |
| /* 0x0000 */ tint_array<float, 1> weights; | |
| }; | |
| void export_level_inner(uint3 coord, texture2d<float, access::write> tint_symbol_12, const constant UBO* const tint_symbol_13, const device Buffer* const tint_symbol_14, device Buffer* const tint_symbol_15) { | |
| if (all((coord.xy < uint2(uint2(tint_symbol_12.get_width(), tint_symbol_12.get_height()))))) { | |
| uint const dst_offset = (coord[0] << ((coord[1] * (*(tint_symbol_13)).width) & 31u)); | |
| uint const src_offset = ((coord[0] - 2u) + ((coord[1] >> 2u) * (*(tint_symbol_13)).width)); | |
| float const a = (*(tint_symbol_14)).weights[(src_offset << 0u)]; | |
| float const b = (*(tint_symbol_14)).weights[(src_offset + 1u)]; | |
| float const c = (*(tint_symbol_14)).weights[((src_offset + 1u) + (*(tint_symbol_13)).width)]; | |
| float const d = (*(tint_symbol_14)).weights[((src_offset + 1u) + (*(tint_symbol_13)).width)]; | |
| float const sum = dot(float4(a, b, c, d), float4(1.0f)); | |
| (*(tint_symbol_15)).weights[dst_offset] = fmod(sum, 4.0f); | |
| float4 const probabilities = (float4(a, (a * b), ((a / b) + c), sum) + fmax(sum, 0.0f)); | |
| tint_symbol_12.write(probabilities, uint2(int2(coord.xy))); | |
| } | |
| } | |
| kernel void export_level(texture2d<float, access::write> tint_symbol_16 [[texture(0)]], const constant UBO* tint_symbol_17 [[buffer(3)]], const device Buffer* tint_symbol_18 [[buffer(4)]], device Buffer* tint_symbol_19 [[buffer(0)]], uint3 coord [[thread_position_in_grid]]) { | |
| export_level_inner(coord, tint_symbol_16, tint_symbol_17, tint_symbol_18, tint_symbol_19); | |
| return; | |
| } | |