Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / rendering / draw-with-changing-start-vertex-bug.html
blob8b8dc71f59bd3adf14c2bd4a54464d74ae439e53
1 <!--
2 Copyright (c) 2019 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!--
8 This bug would occur after the app would render several times with the
9 same vertex attributes and buffers, but using a different start offset.
10 One of the buffers would likely have to be DYNAMIC.
12 See http://anglebug.com/1327 and http://crbug.com/594509
13 -->
15 <!DOCTYPE html>
16 <html>
17 <head>
18 <meta charset="utf-8">
19 <title>Draw with changing start vertex test</title>
20 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
21 <script src="../../js/js-test-pre.js"></script>
22 <script src="../../js/webgl-test-utils.js"></script>
23 </head>
24 <body>
25 <canvas id="canvas" width="16" height="16"> </canvas>
26 <div id="description"></div>
27 <div id="console"></div>
28 <script id="vshader" type="x-shader/x-vertex">
29 attribute mediump vec4 position;
30 attribute mediump vec4 test;
31 attribute mediump vec4 expected;
32 varying mediump vec4 color;
33 void main(void)
35 gl_Position = position;
36 vec4 threshold = max(abs(expected) * 0.01, 1.0 / 64.0);
37 color = vec4(lessThanEqual(abs(test - expected), threshold));
39 </script>
41 <script id="fshader" type="x-shader/x-fragment">
42 varying mediump vec4 color;
43 void main(void)
45 gl_FragColor = color;
47 </script>
49 <script>
50 "use strict";
51 description("Test calling drawArrays with repeatedly with a different start vertex");
53 var wtu = WebGLTestUtils;
54 var canvas = document.getElementById("canvas1");
55 var gl = wtu.create3DContext(canvas);
57 var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["position", "test", "expected"]);
59 var vertexCount = 24;
60 var testData = new Float32Array(vertexCount);
62 for (var index = 0; index < vertexCount; ++index) {
63 testData[index] = index;
66 var quadData = new Float32Array(14)
67 quadData[0] = -1.0; quadData[1] = 1.0;
68 quadData[2] = -1.0; quadData[3] = -1.0;
69 quadData[4] = 1.0; quadData[5] = -1.0;
70 quadData[6] = -1.0; quadData[7] = 1.0;
71 quadData[8] = 1.0; quadData[9] = -1.0;
72 quadData[10] = 1.0; quadData[11] = 1.0;
73 quadData[12] = 0.0; quadData[13] = 0.0;
75 var quadBuffer = gl.createBuffer();
76 gl.bindBuffer(gl.ARRAY_BUFFER, quadBuffer);
77 gl.bufferData(gl.ARRAY_BUFFER, quadData, gl.STATIC_DRAW);
78 gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
79 gl.enableVertexAttribArray(0);
81 // Must be STATIC to trigger the bug.
82 var testBuffer = gl.createBuffer();
83 gl.bindBuffer(gl.ARRAY_BUFFER, testBuffer);
84 gl.bufferData(gl.ARRAY_BUFFER, testData, gl.STATIC_DRAW);
85 gl.vertexAttribPointer(1, 1, gl.FLOAT, false, 0, 0);
86 gl.enableVertexAttribArray(1);
88 // Must be DYNAMIC to trigger the bug.
89 var expectedBuffer = gl.createBuffer();
90 gl.bindBuffer(gl.ARRAY_BUFFER, expectedBuffer);
91 gl.bufferData(gl.ARRAY_BUFFER, testData, gl.DYNAMIC_DRAW);
92 gl.vertexAttribPointer(2, 1, gl.FLOAT, false, 0, 0);
93 gl.enableVertexAttribArray(2);
95 function check() {
96 wtu.checkCanvas(gl, [255, 255, 255, 255], "should be white");
99 gl.drawArrays(gl.TRIANGLES, 0, 6);
100 check()
102 gl.drawArrays(gl.TRIANGLES, 0, 6);
103 check()
105 gl.drawArrays(gl.TRIANGLES, 1, 6);
106 check()
108 debug("");
109 var successfullyParsed = true;
110 </script>
112 <script src="../../js/js-test-post.js"></script>
113 </body>
114 </html>