dawn-cmake/test/tint/bug/tint/1046.wgsl.expected.wgsl
dan sinclair b29892be09 Update src/tint unittests to new @stage format.
This CL updates all of the Tint unittests to the new @stage shorter
syntax. This also updates the WGSL writer to emit the new short forms
instead of using the deprecated form.

Bug: tint:1503
Change-Id: I8c49e5319a19cccb5b4b5078f3ab39c50f31a9a8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92483
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-06-07 13:55:34 +00:00

68 lines
1.4 KiB
WebGPU Shading Language

struct PointLight {
position : vec4<f32>,
}
struct PointLights {
values : array<PointLight>,
}
struct Uniforms {
worldView : mat4x4<f32>,
proj : mat4x4<f32>,
numPointLights : u32,
color_source : u32,
color : vec4<f32>,
}
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
@binding(1) @group(0) var<storage, read> pointLights : PointLights;
@binding(2) @group(0) var mySampler : sampler;
@binding(3) @group(0) var myTexture : texture_2d<f32>;
struct FragmentInput {
@builtin(position)
position : vec4<f32>,
@location(0)
view_position : vec4<f32>,
@location(1)
normal : vec4<f32>,
@location(2)
uv : vec2<f32>,
@location(3)
color : vec4<f32>,
}
struct FragmentOutput {
@location(0)
color : vec4<f32>,
}
fn getColor(fragment : FragmentInput) -> vec4<f32> {
var color : vec4<f32>;
if ((uniforms.color_source == 0u)) {
color = fragment.color;
} else if ((uniforms.color_source == 1u)) {
color = fragment.normal;
color.a = 1.0;
} else if ((uniforms.color_source == 2u)) {
color = uniforms.color;
} else if ((uniforms.color_source == 3u)) {
color = textureSample(myTexture, mySampler, fragment.uv);
}
return color;
}
@fragment
fn main(fragment : FragmentInput) -> FragmentOutput {
var output : FragmentOutput;
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
_ = uniforms;
_ = mySampler;
_ = myTexture;
_ = &(pointLights);
return output;
}