dawn-cmake/test/bug/tint/824.wgsl
Ben Clayton 9e32b20096 Add transform::VarForDynamicIndex
Use this as part of the Spirv sanitizer.
Cleans up buggy dynamic array indexing logic in the SPIR-V writer.

Fixed: tint:824
Change-Id: Ia408e49bd808bc8dbf3a1897eb47f9b33b71fdfb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51780
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-05-20 11:55:28 +00:00

26 lines
887 B
WebGPU Shading Language

struct Output {
[[builtin(position)]] Position : vec4<f32>;
[[location(0)]] color : vec4<f32>;
};
[[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32,
[[builtin(instance_index)]] InstanceIndex : u32) -> Output {
// TODO: remove workaround for Tint unary array access broke
let zv : array<vec2<f32>, 4> = array<vec2<f32>, 4>(
vec2<f32>(0.2, 0.2),
vec2<f32>(0.3, 0.3),
vec2<f32>(-0.1, -0.1),
vec2<f32>(1.1, 1.1));
let z : f32 = zv[InstanceIndex].x;
var output : Output;
output.Position = vec4<f32>(0.5, 0.5, z, 1.0);
let colors : array<vec4<f32>, 4> = array<vec4<f32>, 4>(
vec4<f32>(1.0, 0.0, 0.0, 1.0),
vec4<f32>(0.0, 1.0, 0.0, 1.0),
vec4<f32>(0.0, 0.0, 1.0, 1.0),
vec4<f32>(1.0, 1.0, 1.0, 1.0)
);
output.color = colors[InstanceIndex];
return output;
}