dawn-cmake/test/tint/bug/dawn/947.wgsl.expected.glsl
Stephen White 790e4c2d60 GLSL writer: emit gl_PointSize = 1 in all vertex shaders for OpenGL.
The OpenGL ES 3.1 spec says:

"The point size is taken from the shader built-in gl_PointSize written by the vertex shader, and clamped to the implementation-dependent point size range. If the value written to gl_PointSize is less than or equal to zero, or if no value is written, the point size is undefined."

ANGLE/D3D11 will emit a warning on this and abort processing, causing dawn_end2end tests to fail.

Bug: dawn:1390
Change-Id: I6a56467842ba80d8a070af7240ee07bb111089dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87720
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-04-22 21:25:02 +00:00

82 lines
2.0 KiB
GLSL

#version 310 es
layout(location = 0) out vec2 texcoords_1;
struct Uniforms {
vec2 u_scale;
vec2 u_offset;
};
layout(binding = 0) uniform Uniforms_1 {
vec2 u_scale;
vec2 u_offset;
} uniforms;
struct VertexOutputs {
vec2 texcoords;
vec4 position;
};
VertexOutputs vs_main(uint VertexIndex) {
vec2 texcoord[3] = vec2[3](vec2(-0.5f, 0.0f), vec2(1.5f, 0.0f), vec2(0.5f, 2.0f));
VertexOutputs tint_symbol = VertexOutputs(vec2(0.0f, 0.0f), vec4(0.0f, 0.0f, 0.0f, 0.0f));
tint_symbol.position = vec4(((texcoord[VertexIndex] * 2.0f) - vec2(1.0f, 1.0f)), 0.0f, 1.0f);
bool flipY = (uniforms.u_scale.y < 0.0f);
if (flipY) {
tint_symbol.texcoords = ((((texcoord[VertexIndex] * uniforms.u_scale) + uniforms.u_offset) * vec2(1.0f, -1.0f)) + vec2(0.0f, 1.0f));
} else {
tint_symbol.texcoords = ((((texcoord[VertexIndex] * vec2(1.0f, -1.0f)) + vec2(0.0f, 1.0f)) * uniforms.u_scale) + uniforms.u_offset);
}
return tint_symbol;
}
void main() {
gl_PointSize = 1.0;
VertexOutputs inner_result = vs_main(uint(gl_VertexID));
texcoords_1 = inner_result.texcoords;
gl_Position = inner_result.position;
gl_Position.y = -(gl_Position.y);
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
#version 310 es
precision mediump float;
layout(location = 0) in vec2 texcoord_1;
layout(location = 0) out vec4 value;
struct Uniforms {
vec2 u_scale;
vec2 u_offset;
};
struct VertexOutputs {
vec2 texcoords;
vec4 position;
};
bool tint_discard = false;
uniform highp sampler2D myTexture_mySampler;
vec4 fs_main(vec2 texcoord) {
vec2 clampedTexcoord = clamp(texcoord, vec2(0.0f, 0.0f), vec2(1.0f, 1.0f));
if (!(all(equal(clampedTexcoord, texcoord)))) {
tint_discard = true;
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
}
vec4 srcColor = texture(myTexture_mySampler, texcoord);
return srcColor;
}
void tint_discard_func() {
discard;
}
void main() {
vec4 inner_result = fs_main(texcoord_1);
if (tint_discard) {
tint_discard_func();
return;
}
value = inner_result;
return;
}