mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-05 11:45:54 +00:00
We cannot explicitly name the result type of this builtin, so we have to redeclare it manually. Fixed: oss-fuzz:53347, oss-fuzz:53343 Change-Id: I23816b8b35eb20ae91472143ab30668b573d65bf Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110160 Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Auto-Submit: James Price <jrprice@google.com>
51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
#include <metal_stdlib>
|
|
|
|
using namespace metal;
|
|
|
|
struct atomic_compare_exchange_resulti32 {
|
|
int old_value;
|
|
bool exchanged;
|
|
};
|
|
atomic_compare_exchange_resulti32 atomicCompareExchangeWeak_1(device atomic_int* atomic, int compare, int value) {
|
|
int old_value = compare;
|
|
bool exchanged = atomic_compare_exchange_weak_explicit(atomic, &old_value, value, memory_order_relaxed, memory_order_relaxed);
|
|
return {old_value, exchanged};
|
|
}
|
|
|
|
struct tint_symbol_2 {
|
|
int old_value;
|
|
bool exchanged;
|
|
};
|
|
|
|
struct tint_symbol {
|
|
int value [[color(0)]];
|
|
};
|
|
|
|
int foo_inner(thread bool* const tint_symbol_4, device atomic_int* const tint_symbol_5) {
|
|
*(tint_symbol_4) = true;
|
|
int x = 0;
|
|
tint_symbol_2 tint_symbol_1 = {};
|
|
if (!(*(tint_symbol_4))) {
|
|
atomic_compare_exchange_resulti32 const tint_symbol_3 = atomicCompareExchangeWeak_1(tint_symbol_5, 0, 1);
|
|
tint_symbol_1.old_value = tint_symbol_3.old_value;
|
|
tint_symbol_1.exchanged = tint_symbol_3.exchanged;
|
|
}
|
|
tint_symbol_2 const result = tint_symbol_1;
|
|
if (result.exchanged) {
|
|
x = result.old_value;
|
|
}
|
|
return x;
|
|
}
|
|
|
|
fragment tint_symbol foo(device atomic_int* tint_symbol_7 [[buffer(0)]]) {
|
|
thread bool tint_symbol_6 = false;
|
|
int const inner_result = foo_inner(&(tint_symbol_6), tint_symbol_7);
|
|
tint_symbol wrapper_result = {};
|
|
wrapper_result.value = inner_result;
|
|
if (tint_symbol_6) {
|
|
discard_fragment();
|
|
}
|
|
return wrapper_result;
|
|
}
|
|
|