| #include <metal_stdlib> |
| |
| using namespace metal; |
| |
| #define TINT_ISOLATE_UB \ |
| if (volatile bool tint_volatile_true = true; tint_volatile_true) |
| |
| struct tint_private_vars_struct { |
| bool tint_discarded; |
| }; |
| |
| int tint_ftoi(float v) { |
| return select(2147483647, select(int(v), (-2147483647 - 1), (v < -2147483648.0f)), (v < 2147483520.0f)); |
| } |
| |
| struct tint_symbol_1 { |
| float in [[user(locn0)]]; |
| float2 coord [[user(locn1)]]; |
| }; |
| |
| struct tint_symbol_2 { |
| int value [[color(0)]]; |
| }; |
| |
| int foo_inner(float in, float2 coord, thread tint_private_vars_struct* const tint_private_vars, texture2d<float, access::sample> tint_symbol_4, sampler tint_symbol_5, device atomic_int* const tint_symbol_6) { |
| if ((in == 0.0f)) { |
| (*(tint_private_vars)).tint_discarded = true; |
| } |
| int result = tint_ftoi(tint_symbol_4.sample(tint_symbol_5, coord)[0]); |
| { |
| int i = 0; |
| TINT_ISOLATE_UB while(true) { |
| if (!((i < 10))) { |
| break; |
| } |
| { |
| result = as_type<int>((as_type<uint>(result) + as_type<uint>(i))); |
| } |
| { |
| int tint_symbol_3 = 0; |
| if (!((*(tint_private_vars)).tint_discarded)) { |
| tint_symbol_3 = atomic_fetch_add_explicit(tint_symbol_6, 1, memory_order_relaxed); |
| } |
| i = tint_symbol_3; |
| } |
| } |
| } |
| return result; |
| } |
| |
| fragment tint_symbol_2 foo(texture2d<float, access::sample> tint_symbol_7 [[texture(0)]], sampler tint_symbol_8 [[sampler(0)]], device atomic_int* tint_symbol_9 [[buffer(0)]], tint_symbol_1 tint_symbol [[stage_in]]) { |
| thread tint_private_vars_struct tint_private_vars = {}; |
| tint_private_vars.tint_discarded = false; |
| int const inner_result = foo_inner(tint_symbol.in, tint_symbol.coord, &(tint_private_vars), tint_symbol_7, tint_symbol_8, tint_symbol_9); |
| tint_symbol_2 wrapper_result = {}; |
| wrapper_result.value = inner_result; |
| if (tint_private_vars.tint_discarded) { |
| discard_fragment(); |
| } |
| return wrapper_result; |
| } |
| |