mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-03 13:11:34 +00:00
Prevents UB for divide-by-zero and integer overflow when dividing Fixed: tint:1349 Change-Id: Ieef66d27d7aec3011628ced076b2bccc7770a8af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108925 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
36 lines
621 B
HLSL
36 lines
621 B
HLSL
void set_int4(inout int4 vec, int idx, int val) {
|
|
vec = (idx.xxxx == int4(0, 1, 2, 3)) ? val.xxxx : vec;
|
|
}
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void unused_entry_point() {
|
|
return;
|
|
}
|
|
|
|
struct S {
|
|
int4 a[4];
|
|
};
|
|
|
|
static int counter = 0;
|
|
|
|
int foo() {
|
|
counter = (counter + 1);
|
|
return counter;
|
|
}
|
|
|
|
int bar() {
|
|
counter = (counter + 2);
|
|
return counter;
|
|
}
|
|
|
|
void main() {
|
|
S x = (S)0;
|
|
const int tint_symbol_save = foo();
|
|
const int tint_symbol_1 = bar();
|
|
{
|
|
int4 tint_symbol_3[4] = x.a;
|
|
set_int4(tint_symbol_3[tint_symbol_save], tint_symbol_1, (x.a[tint_symbol_save][tint_symbol_1] + 5));
|
|
x.a = tint_symbol_3;
|
|
}
|
|
}
|