1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<!--
Copyright (c) 2022 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL2 draw functions have expected behavior with compositing</title>
<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 src="../../js/tests/compositing-test.js"></script>
<style>
body {
height: 3000px;
}
</style>
</head>
<body>
<!-- Important to put the canvas at the top so that it's always visible even in the test suite runner.
Otherwise it just doesn't get composited in Firefox. -->
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description(`\
This test ensures WebGL implementations correctly clear the drawing buffer
on composite if preserveDrawingBuffer is false and is not cleared if
preserveDrawingBuffer is true.`);
debug("");
const wtu = WebGLTestUtils;
async function runCompositingTests() {
const compositingTestFn = createCompositingTestFn({
webglVersion: 2,
shadersFn(gl) {
const vs = `\
#version 300 es
in vec4 position;
void main() {
gl_Position = position;
}
`;
const fs = `\
#version 300 es
precision mediump float;
out vec4 fragColor;
void main() {
fragColor = vec4(1, 0, 0, 1);
}
`;
return [vs, fs];
},
});
function drawArrays(gl) {
gl.drawArrays(gl.TRIANGLES, 0, 6);
}
function drawElements(gl) {
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);
}
function drawArraysInstanced(gl) {
gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, 1);
}
function drawElementsInstanced(gl) {
gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0, 1);
}
function drawRangeElements(gl) {
gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_BYTE, 0);
}
await compositingTestFn(drawArrays);
await compositingTestFn(drawElements);
await compositingTestFn(drawArraysInstanced);
await compositingTestFn(drawElementsInstanced);
await compositingTestFn(drawRangeElements);
finishTest();
}
runCompositingTests();
var successfullyParsed = true;
</script>
</body>
</html>
|