dawn-cmake/test/bug/tint/980.wgsl.expected.hlsl
Ben Clayton 3242d3e8c9 writer/hlsl: Use vector write helper for dynamic indices
This uses FXC compilation failure mitigation for _any_ vector index assignment that has a non-constant index. FXC can still fall over if the loop calls a function that performs the dynamic index.

Use some vector swizzle logic to avoid branches in the helper.

Fixed: tint:980
Change-Id: I2a759d88a7d884bc61b4631cf57feb4acc8178de
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57882
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-07-14 18:43:51 +00:00

23 lines
544 B
HLSL

void set_float3(inout float3 vec, int idx, float val) {
vec = (idx.xxx == int3(0, 1, 2)) ? val.xxx : vec;
}
float3 Bad(uint index, float3 rd) {
float3 normal = float3((0.0f).xxx);
set_float3(normal, index, -(sign(rd[index])));
return normalize(normal);
}
RWByteAddressBuffer io : register(u0, space0);
struct tint_symbol_1 {
uint idx : SV_GroupIndex;
};
[numthreads(1, 1, 1)]
void main(tint_symbol_1 tint_symbol) {
const uint idx = tint_symbol.idx;
io.Store3(0u, asuint(Bad(io.Load(12u), asfloat(io.Load3(0u)))));
return;
}