| #include <metal_stdlib> |
| using namespace metal; |
| struct Inner { |
| int scalar_i32; |
| float scalar_f32; |
| half scalar_f16; |
| }; |
| 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 S { |
| float scalar_f32; |
| int scalar_i32; |
| uint scalar_u32; |
| half scalar_f16; |
| float2 vec2_f32; |
| int2 vec2_i32; |
| uint2 vec2_u32; |
| half2 vec2_f16; |
| float3 vec3_f32; |
| int3 vec3_i32; |
| uint3 vec3_u32; |
| half3 vec3_f16; |
| float4 vec4_f32; |
| int4 vec4_i32; |
| uint4 vec4_u32; |
| half4 vec4_f16; |
| float2x2 mat2x2_f32; |
| float2x3 mat2x3_f32; |
| float2x4 mat2x4_f32; |
| float3x2 mat3x2_f32; |
| float3x3 mat3x3_f32; |
| float3x4 mat3x4_f32; |
| float4x2 mat4x2_f32; |
| float4x3 mat4x3_f32; |
| float4x4 mat4x4_f32; |
| half2x2 mat2x2_f16; |
| half2x3 mat2x3_f16; |
| half2x4 mat2x4_f16; |
| half3x2 mat3x2_f16; |
| half3x3 mat3x3_f16; |
| half3x4 mat3x4_f16; |
| half4x2 mat4x2_f16; |
| half4x3 mat4x3_f16; |
| half4x4 mat4x4_f16; |
| tint_array<float3, 2> arr2_vec3_f32; |
| tint_array<half4x2, 2> arr2_mat4x2_f16; |
| Inner struct_inner; |
| tint_array<Inner, 4> array_struct_inner; |
| }; |
| struct tint_module_vars_struct { |
| device S* sb; |
| }; |
| |
| void tint_store_and_preserve_padding_7(device Inner* const target, Inner value_param) { |
| (*target).scalar_i32 = value_param.scalar_i32; |
| (*target).scalar_f32 = value_param.scalar_f32; |
| (*target).scalar_f16 = value_param.scalar_f16; |
| } |
| void tint_store_and_preserve_padding_8(device tint_array<Inner, 4>* const target, tint_array<Inner, 4> value_param) { |
| { |
| uint v = 0u; |
| v = 0u; |
| while(true) { |
| uint const v_1 = v; |
| if ((v_1 >= 4u)) { |
| break; |
| } |
| tint_store_and_preserve_padding_7((&(*target)[v_1]), value_param[v_1]); |
| { |
| v = (v_1 + 1u); |
| } |
| continue; |
| } |
| } |
| } |
| void tint_store_and_preserve_padding_6(device tint_array<float3, 2>* const target, tint_array<float3, 2> value_param) { |
| { |
| uint v_2 = 0u; |
| v_2 = 0u; |
| while(true) { |
| uint const v_3 = v_2; |
| if ((v_3 >= 2u)) { |
| break; |
| } |
| (*target)[v_3] = value_param[v_3]; |
| { |
| v_2 = (v_3 + 1u); |
| } |
| continue; |
| } |
| } |
| } |
| void tint_store_and_preserve_padding_5(device half4x3* const target, half4x3 value_param) { |
| (*target)[0u] = value_param[0u]; |
| (*target)[1u] = value_param[1u]; |
| (*target)[2u] = value_param[2u]; |
| (*target)[3u] = value_param[3u]; |
| } |
| void tint_store_and_preserve_padding_4(device half3x3* const target, half3x3 value_param) { |
| (*target)[0u] = value_param[0u]; |
| (*target)[1u] = value_param[1u]; |
| (*target)[2u] = value_param[2u]; |
| } |
| void tint_store_and_preserve_padding_3(device half2x3* const target, half2x3 value_param) { |
| (*target)[0u] = value_param[0u]; |
| (*target)[1u] = value_param[1u]; |
| } |
| void tint_store_and_preserve_padding_2(device float4x3* const target, float4x3 value_param) { |
| (*target)[0u] = value_param[0u]; |
| (*target)[1u] = value_param[1u]; |
| (*target)[2u] = value_param[2u]; |
| (*target)[3u] = value_param[3u]; |
| } |
| void tint_store_and_preserve_padding_1(device float3x3* const target, float3x3 value_param) { |
| (*target)[0u] = value_param[0u]; |
| (*target)[1u] = value_param[1u]; |
| (*target)[2u] = value_param[2u]; |
| } |
| void tint_store_and_preserve_padding(device float2x3* const target, float2x3 value_param) { |
| (*target)[0u] = value_param[0u]; |
| (*target)[1u] = value_param[1u]; |
| } |
| kernel void tint_symbol(device S* sb [[buffer(0)]]) { |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.sb=sb}; |
| (*tint_module_vars.sb).scalar_f32 = 0.0f; |
| (*tint_module_vars.sb).scalar_i32 = 0; |
| (*tint_module_vars.sb).scalar_u32 = 0u; |
| (*tint_module_vars.sb).scalar_f16 = 0.0h; |
| (*tint_module_vars.sb).vec2_f32 = float2(0.0f); |
| (*tint_module_vars.sb).vec2_i32 = int2(0); |
| (*tint_module_vars.sb).vec2_u32 = uint2(0u); |
| (*tint_module_vars.sb).vec2_f16 = half2(0.0h); |
| (*tint_module_vars.sb).vec3_f32 = float3(0.0f); |
| (*tint_module_vars.sb).vec3_i32 = int3(0); |
| (*tint_module_vars.sb).vec3_u32 = uint3(0u); |
| (*tint_module_vars.sb).vec3_f16 = half3(0.0h); |
| (*tint_module_vars.sb).vec4_f32 = float4(0.0f); |
| (*tint_module_vars.sb).vec4_i32 = int4(0); |
| (*tint_module_vars.sb).vec4_u32 = uint4(0u); |
| (*tint_module_vars.sb).vec4_f16 = half4(0.0h); |
| (*tint_module_vars.sb).mat2x2_f32 = float2x2(float2(0.0f), float2(0.0f)); |
| tint_store_and_preserve_padding((&(*tint_module_vars.sb).mat2x3_f32), float2x3(float3(0.0f), float3(0.0f))); |
| (*tint_module_vars.sb).mat2x4_f32 = float2x4(float4(0.0f), float4(0.0f)); |
| (*tint_module_vars.sb).mat3x2_f32 = float3x2(float2(0.0f), float2(0.0f), float2(0.0f)); |
| tint_store_and_preserve_padding_1((&(*tint_module_vars.sb).mat3x3_f32), float3x3(float3(0.0f), float3(0.0f), float3(0.0f))); |
| (*tint_module_vars.sb).mat3x4_f32 = float3x4(float4(0.0f), float4(0.0f), float4(0.0f)); |
| (*tint_module_vars.sb).mat4x2_f32 = float4x2(float2(0.0f), float2(0.0f), float2(0.0f), float2(0.0f)); |
| tint_store_and_preserve_padding_2((&(*tint_module_vars.sb).mat4x3_f32), float4x3(float3(0.0f), float3(0.0f), float3(0.0f), float3(0.0f))); |
| (*tint_module_vars.sb).mat4x4_f32 = float4x4(float4(0.0f), float4(0.0f), float4(0.0f), float4(0.0f)); |
| (*tint_module_vars.sb).mat2x2_f16 = half2x2(half2(0.0h), half2(0.0h)); |
| tint_store_and_preserve_padding_3((&(*tint_module_vars.sb).mat2x3_f16), half2x3(half3(0.0h), half3(0.0h))); |
| (*tint_module_vars.sb).mat2x4_f16 = half2x4(half4(0.0h), half4(0.0h)); |
| (*tint_module_vars.sb).mat3x2_f16 = half3x2(half2(0.0h), half2(0.0h), half2(0.0h)); |
| tint_store_and_preserve_padding_4((&(*tint_module_vars.sb).mat3x3_f16), half3x3(half3(0.0h), half3(0.0h), half3(0.0h))); |
| (*tint_module_vars.sb).mat3x4_f16 = half3x4(half4(0.0h), half4(0.0h), half4(0.0h)); |
| (*tint_module_vars.sb).mat4x2_f16 = half4x2(half2(0.0h), half2(0.0h), half2(0.0h), half2(0.0h)); |
| tint_store_and_preserve_padding_5((&(*tint_module_vars.sb).mat4x3_f16), half4x3(half3(0.0h), half3(0.0h), half3(0.0h), half3(0.0h))); |
| (*tint_module_vars.sb).mat4x4_f16 = half4x4(half4(0.0h), half4(0.0h), half4(0.0h), half4(0.0h)); |
| tint_store_and_preserve_padding_6((&(*tint_module_vars.sb).arr2_vec3_f32), tint_array<float3, 2>{}); |
| (*tint_module_vars.sb).arr2_mat4x2_f16 = tint_array<half4x2, 2>{}; |
| tint_store_and_preserve_padding_7((&(*tint_module_vars.sb).struct_inner), Inner{}); |
| tint_store_and_preserve_padding_8((&(*tint_module_vars.sb).array_struct_inner), tint_array<Inner, 4>{}); |
| } |