2022-11-14 20:30:38 +00:00
|
|
|
static bool tint_discarded = false;
|
|
|
|
|
|
|
|
struct tint_symbol_2 {
|
|
|
|
int old_value;
|
|
|
|
bool exchanged;
|
|
|
|
};
|
|
|
|
|
2023-03-31 17:55:19 +00:00
|
|
|
RWByteAddressBuffer a : register(u0);
|
2022-11-14 20:30:38 +00:00
|
|
|
|
|
|
|
struct tint_symbol {
|
|
|
|
int value : SV_Target0;
|
|
|
|
};
|
|
|
|
struct atomic_compare_exchange_weak_ret_type {
|
|
|
|
int old_value;
|
|
|
|
bool exchanged;
|
|
|
|
};
|
|
|
|
|
2023-02-24 17:16:55 +00:00
|
|
|
atomic_compare_exchange_weak_ret_type aatomicCompareExchangeWeak(uint offset, int compare, int value) {
|
2022-11-14 20:30:38 +00:00
|
|
|
atomic_compare_exchange_weak_ret_type result=(atomic_compare_exchange_weak_ret_type)0;
|
2023-02-24 17:16:55 +00:00
|
|
|
a.InterlockedCompareExchange(offset, compare, value, result.old_value);
|
2022-11-14 20:30:38 +00:00
|
|
|
result.exchanged = result.old_value == compare;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int foo_inner() {
|
|
|
|
tint_discarded = true;
|
|
|
|
int x = 0;
|
|
|
|
tint_symbol_2 tint_symbol_1 = (tint_symbol_2)0;
|
|
|
|
if (!(tint_discarded)) {
|
2023-02-24 17:16:55 +00:00
|
|
|
const atomic_compare_exchange_weak_ret_type tint_symbol_3 = aatomicCompareExchangeWeak(0u, 0, 1);
|
2022-11-14 20:30:38 +00:00
|
|
|
tint_symbol_1.old_value = tint_symbol_3.old_value;
|
|
|
|
tint_symbol_1.exchanged = tint_symbol_3.exchanged;
|
|
|
|
}
|
|
|
|
const tint_symbol_2 result = tint_symbol_1;
|
|
|
|
if (result.exchanged) {
|
|
|
|
x = result.old_value;
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
tint_symbol foo() {
|
|
|
|
const int inner_result = foo_inner();
|
|
|
|
tint_symbol wrapper_result = (tint_symbol)0;
|
|
|
|
wrapper_result.value = inner_result;
|
|
|
|
if (tint_discarded) {
|
|
|
|
discard;
|
|
|
|
}
|
|
|
|
return wrapper_result;
|
|
|
|
}
|