| // | |
| // compute_main | |
| // | |
| #include <metal_stdlib> | |
| using namespace metal; | |
| struct tint_module_vars_struct { | |
| thread uint3* tint_print_invocation_id; | |
| }; | |
| void compute_main_inner(uint3 tint_symbol, tint_module_vars_struct tint_module_vars) { | |
| (*tint_module_vars.tint_print_invocation_id) = tint_symbol; | |
| uint3 const v = (*tint_module_vars.tint_print_invocation_id); | |
| (os_log_default.log("[ comp compute_main:L5 global_invocation_id(%u, %u, %u) ] hello world", v.x, v.y, v.z)); | |
| } | |
| [[max_total_threads_per_threadgroup(1)]] | |
| kernel void compute_main(uint3 tint_symbol [[thread_position_in_grid]]) { | |
| thread uint3 tint_print_invocation_id = 0u; | |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.tint_print_invocation_id=(&tint_print_invocation_id)}; | |
| (compute_main_inner(tint_symbol, tint_module_vars)); | |
| } | |
| // | |
| // fragment_main | |
| // | |
| #include <metal_stdlib> | |
| using namespace metal; | |
| struct tint_module_vars_struct { | |
| thread float3* tint_print_invocation_id; | |
| }; | |
| void fragment_main_inner(float4 tint_symbol, tint_module_vars_struct tint_module_vars) { | |
| (*tint_module_vars.tint_print_invocation_id) = tint_symbol.xyz; | |
| float3 const v = (*tint_module_vars.tint_print_invocation_id); | |
| (os_log_default.log("[ frag fragment_main:L10 position(%f, %f, %f) ] hello from fragment", v.x, v.y, v.z)); | |
| } | |
| fragment void fragment_main(float4 tint_symbol [[position]]) { | |
| thread float3 tint_print_invocation_id = 0.0f; | |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.tint_print_invocation_id=(&tint_print_invocation_id)}; | |
| (fragment_main_inner(tint_symbol, tint_module_vars)); | |
| } | |
| // | |
| // vertex_main | |
| // | |
| #include <metal_stdlib> | |
| using namespace metal; | |
| struct VertexOutput { | |
| float4 pos; | |
| }; | |
| struct tint_module_vars_struct { | |
| thread uint2* tint_print_invocation_id; | |
| }; | |
| struct vertex_main_outputs { | |
| float4 VertexOutput_pos [[position]]; | |
| }; | |
| VertexOutput vertex_main_inner(uint tint_symbol, uint tint_symbol_1, tint_module_vars_struct tint_module_vars) { | |
| (*tint_module_vars.tint_print_invocation_id) = uint2(tint_symbol, tint_symbol_1); | |
| VertexOutput out = {}; | |
| out.pos = float4(0.0f); | |
| uint2 const v = (*tint_module_vars.tint_print_invocation_id); | |
| (os_log_default.log("[ vert vertex_main:L21 instance=%u, vertex=%u ] hello from vertex", v.x, v.y)); | |
| return out; | |
| } | |
| vertex vertex_main_outputs vertex_main(uint tint_symbol [[instance_id]], uint tint_symbol_1 [[vertex_id]]) { | |
| thread uint2 tint_print_invocation_id = 0u; | |
| tint_module_vars_struct const tint_module_vars = tint_module_vars_struct{.tint_print_invocation_id=(&tint_print_invocation_id)}; | |
| vertex_main_outputs tint_wrapper_result = {}; | |
| tint_wrapper_result.VertexOutput_pos = vertex_main_inner(tint_symbol, tint_symbol_1, tint_module_vars).pos; | |
| return tint_wrapper_result; | |
| } |