mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-14 00:56:05 +00:00
This fixes edge-cases, like the condition expression being a type-cast, which DXC apparently sees as a variable re-declaration. Example: fn foo(x : f32) { switch (i32(x)) { default { } } } was emitted as HLSL: void foo(float x) { int(x); do { } while (false); } The `int(x)` is seen as a re-declaration of `x` by DXC. We fix this by only emitted the condition expression if it has side-effects (which currently means it contains a call expression). Bug: tint:1820 Change-Id: I7e4320fa09ea2d634c9e324cb0b752b0ee7dcde9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118161 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
11 lines
130 B
HLSL
11 lines
130 B
HLSL
[numthreads(1, 1, 1)]
|
|
void f() {
|
|
int i = 0;
|
|
int result = 0;
|
|
do {
|
|
result = 44;
|
|
break;
|
|
} while (false);
|
|
return;
|
|
}
|