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