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.
10 <meta charset=
"utf-8">
11 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
12 <script src=
"../../js/js-test-pre.js"></script>
13 <script src=
"../../js/webgl-test-utils.js"></script>
16 <div id=
"description"></div>
17 <div id=
"console"></div>
21 description('Tests that index validation for drawElements works with large attribute buffers');
23 var wtu
= WebGLTestUtils
;
24 var context
= wtu
.create3DContext();
25 var program
= wtu
.loadStandardProgram(context
);
27 context
.useProgram(program
);
29 // Create a small index buffer.
30 var indexObject
= context
.createBuffer();
31 context
.bindBuffer(context
.ELEMENT_ARRAY_BUFFER
, indexObject
);
32 var indexArray
= new Uint16Array([0, 1, 2]);
33 context
.bufferData(context
.ELEMENT_ARRAY_BUFFER
, indexArray
, context
.STATIC_DRAW
);
35 // Create a large attribute buffer.
36 var vertexObject
= context
.createBuffer();
37 context
.enableVertexAttribArray(0);
38 context
.bindBuffer(context
.ARRAY_BUFFER
, vertexObject
);
39 context
.bufferData(context
.ARRAY_BUFFER
, new Float32Array(3 * 65536), context
.STATIC_DRAW
);
40 context
.vertexAttribPointer(0, 3, context
.FLOAT
, false, 0, 0);
42 debug("Test large attribute buffer")
43 wtu
.shouldGenerateGLError(context
, context
.NO_ERROR
, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
45 // Enlarge the attribute buffer slightly.
46 debug("Test even larger attribute buffer")
47 context
.bufferData(context
.ARRAY_BUFFER
, new Float32Array(3 * 65536 + 3), context
.STATIC_DRAW
);
48 wtu
.shouldGenerateGLError(context
, context
.NO_ERROR
, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
51 var successfullyParsed
= true;
54 <script src=
"../../js/js-test-post.js"></script>