Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / buffers / index-validation-copies-indices.html
blobe823f95f69f0b62ff6ebf2f7159967df414b9f10
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 -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
10 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
11 <script src="../../js/js-test-pre.js"></script>
12 <script src="../../js/webgl-test-utils.js"></script>
13 </head>
14 <body>
15 <div id="description"></div>
16 <div id="console"></div>
18 <script>
19 "use strict";
20 description('Test that client data is always copied during bufferData and bufferSubData calls, because otherwise the data the GL uses to draw may differ from that checked by the index validation code.')
22 var wtu = WebGLTestUtils;
23 var context = wtu.create3DContext();
24 var program = wtu.loadStandardProgram(context);
26 context.useProgram(program);
27 var vertexObject = context.createBuffer();
28 context.enableVertexAttribArray(0);
29 context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
30 // 4 vertices -> 2 triangles
31 context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context.STATIC_DRAW);
32 context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
34 var indexObject = context.createBuffer();
36 context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
37 var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
38 context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
39 wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
40 var indexValidationError = wtu.shouldGenerateGLError(context,
41 [context.INVALID_OPERATION, context.NO_ERROR],
42 "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
43 wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
44 indices[0] = 2;
45 indices[5] = 1;
46 wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
47 wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
48 wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
50 debug("")
51 var successfullyParsed = true;
52 </script>
54 <script src="../../js/js-test-post.js"></script>
55 </body>
56 </html>