dawn-cmake/test/tint/bug/dawn/947.wgsl.expected.wgsl
James Price 7dd0ab791a tint: Show the source of non-uniformity
Show the original source of non-uniformity when producing errors from
the uniformity analysis.

Bug: tint:880
Change-Id: Id386ae8fa5ff1b1443d54c0b5ef12ab76b3b3f13
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89723
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-05-11 22:05:15 +00:00

50 lines
1.7 KiB
WebGPU Shading Language

bug/dawn/947.wgsl:59:20 warning: 'textureSample' must only be called from uniform control flow
var srcColor = textureSample(myTexture, mySampler, texcoord);
^^^^^^^^^^^^^
bug/dawn/947.wgsl:54:15 note: reading from user-defined input 'texcoord' may result in a non-uniform value
clamp(texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0));
^^^^^^^^
struct Uniforms {
u_scale : vec2<f32>,
u_offset : vec2<f32>,
}
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
struct VertexOutputs {
@location(0)
texcoords : vec2<f32>,
@builtin(position)
position : vec4<f32>,
}
@stage(vertex)
fn vs_main(@builtin(vertex_index) VertexIndex : u32) -> VertexOutputs {
var texcoord = array<vec2<f32>, 3>(vec2<f32>(-0.5, 0.0), vec2<f32>(1.5, 0.0), vec2<f32>(0.5, 2.0));
var output : VertexOutputs;
output.position = vec4<f32>(((texcoord[VertexIndex] * 2.0) - vec2<f32>(1.0, 1.0)), 0.0, 1.0);
var flipY = (uniforms.u_scale.y < 0.0);
if (flipY) {
output.texcoords = ((((texcoord[VertexIndex] * uniforms.u_scale) + uniforms.u_offset) * vec2<f32>(1.0, -1.0)) + vec2<f32>(0.0, 1.0));
} else {
output.texcoords = ((((texcoord[VertexIndex] * vec2<f32>(1.0, -1.0)) + vec2<f32>(0.0, 1.0)) * uniforms.u_scale) + uniforms.u_offset);
}
return output;
}
@binding(1) @group(0) var mySampler : sampler;
@binding(2) @group(0) var myTexture : texture_2d<f32>;
@stage(fragment)
fn fs_main(@location(0) texcoord : vec2<f32>) -> @location(0) vec4<f32> {
var clampedTexcoord = clamp(texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0));
if (!(all((clampedTexcoord == texcoord)))) {
discard;
}
var srcColor = textureSample(myTexture, mySampler, texcoord);
return srcColor;
}