Skip to content

Add test for unwritten gl_PointSize. #2822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion sdk/tests/conformance/rendering/point-size.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>

<script id="vshader" type="x-shader/x-vertex">
attribute vec3 pos;
attribute vec4 colorIn;
Expand All @@ -45,7 +46,6 @@
gl_Position = vec4(pos, 1.0);
}
</script>

<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
varying vec4 color;
Expand All @@ -55,6 +55,20 @@
gl_FragColor = color;
}
</script>

<script id="trivial-vs" type="x-shader/x-vertex">
void main()
{
gl_Position = vec4(0,0,0,1);
}
</script>
<script id="trivial-fs" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(0,1,0,1);
}
</script>

</head>
<body>
<canvas id="testbed" width="2" height="2"></canvas>
Expand Down Expand Up @@ -142,6 +156,54 @@
shouldBe('gl.getError()', 'gl.NO_ERROR');
test(program2);

const trivialProg = wtu.setupProgram(gl, ['trivial-vs', 'trivial-fs']);
gl.useProgram(trivialProg);
wtu.glErrorShouldBe(gl, 0, 'Use trivial program.');

// We don't write to gl_PointSize, but since it's supposed to be clamped within the valid range,
// and the valid range must be positive, we should be guaranteed to get at least one pixel drawn.
// So, just use a 1x1 FB for testing.
gl.canvas.width = 1;
gl.canvas.height = 1;
gl.viewport(0, 0, 1, 1);

gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [255, 0, 0, 255]);

gl.disableVertexAttribArray(0);
gl.disableVertexAttribArray(1);
gl.drawArrays(gl.POINTS, 0, 1);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 255, 0, 255]);
wtu.glErrorShouldBe(gl, 0, 'After trivial program draw.');

if (gl.transformFeedbackVaryings) {
gl.transformFeedbackVaryings(trivialProg, ['gl_Position'], gl.INTERLEAVED_ATTRIBS);
gl.linkProgram(trivialProg);
gl.useProgram(trivialProg);
wtu.glErrorShouldBe(gl, 0, 'Relinking trivial program with TF-varyings.');

const buffer = gl.createBuffer();
gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buffer);
gl.bufferData(gl.TRANSFORM_FEEDBACK_BUFFER, 16, gl.STREAM_READ);

gl.clear(gl.COLOR_BUFFER_BIT);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [255, 0, 0, 255]);

gl.beginTransformFeedback(gl.POINTS);

gl.drawArrays(gl.POINTS, 0, 1);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 255, 0, 255]);

gl.endTransformFeedback();

gl.finish(); // Prevent 'please wait on a fence' warning.
window.tfResults = new Float32Array(4);
gl.getBufferSubData(gl.TRANSFORM_FEEDBACK_BUFFER, 0, window.tfResults);

shouldBeString('window.tfResults', new Float32Array([0, 0, 0, 1]).toString());
}

var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>
Expand Down