mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-05 03:35:56 +00:00
D3D11 only supports HLSL SM5.0 which doesn't support `space` (binding group in WGSL). So for D3D11, only one binding group will be used, and tint will not emit `space` for HLSL, so shaders can be used with D3D11. Bug: dawn:1705 Change-Id: Ie0e9868137f10762c5243e188d76f5e41879c2bc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125080 Commit-Queue: Peng Huang <penghuang@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Ben Clayton <bclayton@google.com>
51 lines
1.3 KiB
HLSL
51 lines
1.3 KiB
HLSL
static bool tint_discarded = false;
|
|
|
|
struct tint_symbol_2 {
|
|
int old_value;
|
|
bool exchanged;
|
|
};
|
|
|
|
RWByteAddressBuffer a : register(u0);
|
|
|
|
struct tint_symbol {
|
|
int value : SV_Target0;
|
|
};
|
|
struct atomic_compare_exchange_weak_ret_type {
|
|
int old_value;
|
|
bool exchanged;
|
|
};
|
|
|
|
atomic_compare_exchange_weak_ret_type aatomicCompareExchangeWeak(uint offset, int compare, int value) {
|
|
atomic_compare_exchange_weak_ret_type result=(atomic_compare_exchange_weak_ret_type)0;
|
|
a.InterlockedCompareExchange(offset, compare, value, result.old_value);
|
|
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)) {
|
|
const atomic_compare_exchange_weak_ret_type tint_symbol_3 = aatomicCompareExchangeWeak(0u, 0, 1);
|
|
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;
|
|
}
|