| #include <metal_stdlib> |
| |
| using namespace metal; |
| |
| #define TINT_ISOLATE_UB(VOLATILE_NAME) \ |
| volatile bool VOLATILE_NAME = true; \ |
| if (VOLATILE_NAME) |
| |
| struct tint_private_vars_struct { |
| bool tint_discarded; |
| }; |
| |
| int f(int x, thread tint_private_vars_struct* const tint_private_vars) { |
| if ((x == 10)) { |
| (*(tint_private_vars)).tint_discarded = true; |
| } |
| return x; |
| } |
| |
| struct tint_symbol_2 { |
| int3 x [[user(locn1)]] [[flat]]; |
| }; |
| |
| struct tint_symbol_3 { |
| int value [[color(2)]]; |
| }; |
| |
| int tint_symbol_inner(int3 x, thread tint_private_vars_struct* const tint_private_vars) { |
| int y = x[0]; |
| TINT_ISOLATE_UB(tint_volatile_true) while(true) { |
| int const r = f(y, tint_private_vars); |
| if ((r == 0)) { |
| break; |
| } |
| } |
| return y; |
| } |
| |
| fragment tint_symbol_3 tint_symbol(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 = tint_symbol_inner(tint_symbol_1.x, &(tint_private_vars)); |
| tint_symbol_3 wrapper_result = {}; |
| wrapper_result.value = inner_result; |
| if (tint_private_vars.tint_discarded) { |
| discard_fragment(); |
| } |
| return wrapper_result; |
| } |
| |