dawn-cmake/test/bug/tint/980.wgsl.expected.msl
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

20 lines
390 B
Plaintext

#include <metal_stdlib>
using namespace metal;
struct S {
/* 0x0000 */ packed_float3 v;
/* 0x000c */ uint i;
};
float3 Bad(uint index, float3 rd) {
float3 normal = float3(0.0f);
normal[index] = -(sign(rd[index]));
return normalize(normal);
}
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], device S& io [[buffer(0)]]) {
io.v = Bad(io.i, io.v);
return;
}