dawn-cmake/test/tint/builtins/insertBits/vec3/i32.spvasm.expected.fxc.hlsl
Zhaoming Jiang 4f3f45c00f Tint/transform: Fix insertBits polyfill for HLSL
This CL fix insertBits polyfill to handle with the left-shifting
behavior in HLSL, i.e. `(1u << 32u) == (1u << 0u) == 1u` where we want
the result to be `0u`.

Fixed: tint:1743
Change-Id: Ibb82abe4ab2f76dbb0fa06057fb19f15f961d969
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108166
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-11-09 01:54:08 +00:00

25 lines
663 B
HLSL

int3 tint_insert_bits(int3 v, int3 n, uint offset, uint count) {
const uint e = (offset + count);
const uint mask = ((((offset < 32u) ? (1u << offset) : 0u) - 1u) ^ (((e < 32u) ? (1u << e) : 0u) - 1u));
return ((((offset < 32u) ? (n << uint3((offset).xxx)) : (0).xxx) & int3((int(mask)).xxx)) | (v & int3((int(~(mask))).xxx)));
}
void f_1() {
int3 v = (0).xxx;
int3 n = (0).xxx;
uint offset_1 = 0u;
uint count = 0u;
const int3 x_18 = v;
const int3 x_19 = n;
const uint x_20 = offset_1;
const uint x_21 = count;
const int3 x_16 = tint_insert_bits(x_18, x_19, x_20, x_21);
return;
}
[numthreads(1, 1, 1)]
void f() {
f_1();
return;
}