| #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_packed_vec3_f32_array_element { |
| /* 0x0000 */ packed_float3 packed; |
| /* 0x000c */ tint_array<int8_t, 4> tint_pad; |
| }; |
| |
| struct Particle { |
| tint_array<float3, 8> position; |
| float lifetime; |
| float4 color; |
| float3 velocity; |
| }; |
| |
| struct Particle_packed_vec3 { |
| /* 0x0000 */ tint_array<tint_packed_vec3_f32_array_element, 8> position; |
| /* 0x0080 */ float lifetime; |
| /* 0x0084 */ tint_array<int8_t, 12> tint_pad_1; |
| /* 0x0090 */ float4 color; |
| /* 0x00a0 */ packed_float3 velocity; |
| /* 0x00ac */ tint_array<int8_t, 4> tint_pad_2; |
| }; |
| |
| struct Particles_packed_vec3 { |
| /* 0x0000 */ tint_array<Particle_packed_vec3, 1> p; |
| }; |
| |
| struct Simulation { |
| /* 0x0000 */ uint i; |
| }; |
| |
| struct tint_module_vars_struct { |
| const device Particles_packed_vec3* particles; |
| const constant Simulation* sim; |
| }; |
| |
| tint_array<float3, 8> tint_load_array_packed_vec3(const device tint_array<tint_packed_vec3_f32_array_element, 8>* const from) { |
| float3 const v = float3((*from)[0u].packed); |
| float3 const v_1 = float3((*from)[1u].packed); |
| float3 const v_2 = float3((*from)[2u].packed); |
| float3 const v_3 = float3((*from)[3u].packed); |
| float3 const v_4 = float3((*from)[4u].packed); |
| float3 const v_5 = float3((*from)[5u].packed); |
| float3 const v_6 = float3((*from)[6u].packed); |
| return tint_array<float3, 8>{v, v_1, v_2, v_3, v_4, v_5, v_6, float3((*from)[7u].packed)}; |
| } |
| |
| Particle tint_load_struct_packed_vec3(const device Particle_packed_vec3* const from) { |
| tint_array<float3, 8> const v_7 = tint_load_array_packed_vec3((&(*from).position)); |
| float const v_8 = (*from).lifetime; |
| float4 const v_9 = (*from).color; |
| return Particle{.position=v_7, .lifetime=v_8, .color=v_9, .velocity=float3((*from).velocity)}; |
| } |
| |
| kernel void tint_symbol(const device Particles_packed_vec3* particles [[buffer(1)]], const constant Simulation* sim [[buffer(0)]]) { |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.particles=particles, .sim=sim}; |
| Particle particle = tint_load_struct_packed_vec3((&(*tint_module_vars.particles).p[0])); |
| particle.position[(*tint_module_vars.sim).i] = particle.position[(*tint_module_vars.sim).i]; |
| } |