summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/rendering/attrib-type-match.html
blob: 5b1b2884aafe7d87f0fc5ba30aa8c08fb1cbdbed (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
<!--
Copyright (c) 2019 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>WebGL Conformance Tests: Vertex Attribute Type Match</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/desktop-gl-constants.js"></script>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<!-- Shaders for testing instanced draws -->
<script id="outputVertexShader" type="x-shader/x-vertex">#version 300 es
in vec4 aPosition;
in ivec2 aOffsetI;
in uvec2 aOffsetU;
in vec4 aColor;
out vec4 vColor;
void main() {
    vColor = aColor;
    vec2 offset = vec2(float(aOffsetI.x) + float(aOffsetU.x),
                       float(aOffsetI.y) + float(aOffsetU.y));
    gl_Position = aPosition + vec4(offset, 0.0, 0.0);
}
</script>

<script id="outputFragmentShader" type="x-shader/x-fragment">#version 300 es
precision mediump float;
in vec4 vColor;
out vec4 fragColor;
void main() {
    fragColor = vColor;
}
</script>

<script id='vshader_inactive_attrib' type='x-shader/x-vertex'>#version 300 es
in ivec4 p;
in ivec4 a;
void main()
{
    gl_Position = vec4(p);
}
</script>
<script id='vshader_active_attrib_int' type='x-shader/x-vertex'>#version 300 es
in ivec4 p;
in ivec4 a;
in uvec4 b;
void main()
{
    gl_Position = vec4(p) + vec4(a) + vec4(b);
}
</script>
<script id='vshader_active_attrib_float' type='x-shader/x-vertex'>#version 300 es
in vec4 p;
in vec4 a;
in vec4 c;
void main()
{
    gl_Position = vec4(p) + vec4(a) + vec4(c);
}
</script>
<script id='fshader' type='x-shader/x-fragment'>#version 300 es
precision mediump float;
layout(location=0) out vec4 oColor;
void main()
{
    oColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>


<script>
"use strict";
description("This test verifies an active vertex attribute's base type has to match the verexAttrib function type.");

debug("");

var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas, null, 2);

if (!gl) {
    testFailed("WebGL context does not exist");
} else {
    testPassed("WebGL context exists");

    testGenericAttribs();
    runTests();
}

function testGenericAttribs() {
    debug("");
    debug("Test Generic Vertex Attributes for some corner cases");

    var pIndex = 2;
    var aIndex = 3;
    var bIndex = 4;
    var cIndex = 5;
    var program0 = wtu.setupProgram(gl, ["vshader_inactive_attrib", "fshader"],
        ['p', 'a'], [pIndex, aIndex]);
    var program1 = wtu.setupProgram(gl, ["vshader_active_attrib_int", "fshader"],
        ['p', 'a', 'b'], [pIndex, aIndex, bIndex]);
    var program2 = wtu.setupProgram(gl, ["vshader_active_attrib_float", "fshader"],
        ['p', 'a', 'c'], [pIndex, aIndex, cIndex]);
    if (!program0 || !program1 || !program2) {
      testFailed("Set up program failed");
      return;
    }
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No GL error from set up");

    wtu.setupUnitQuad(gl, 0);

    debug("Inactive input in vertex shader");
    gl.useProgram(program0);
    gl.vertexAttribI4i(pIndex, 1, 0, 0, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArrays succeeds: type in shader mismatch default vertex type is valid for inactive attrib");

    gl.vertexAttrib4f(aIndex, 0.0, 1.0, 0.0, 0.0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArrays succeeds: type in shader mismatch vertexAttrib type is valid for inactive attrib");

    debug("active int/uint inputs in vertex shader");
    gl.useProgram(program1);
    gl.vertexAttribI4i(pIndex, 1, 0, 0, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "Type mismatch: type in shader mismatch the default type for a vertex attrib");
    gl.vertexAttribI4i(aIndex, 0, 1, 0, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "Type mismatch: type in shader mismatch the default type for a vertex attrib");
    gl.vertexAttribI4ui(bIndex, 0, 0, 1, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArrays succeeds");

    debug("active float input in vertex shader");
    gl.useProgram(program2);
    gl.vertexAttrib4f(pIndex, 1.0, 0.0, 0.0, 0.0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "Type mismatch: generic attrib is valid per context. 'a' is set to int type by previous test case");
    gl.vertexAttrib4f(aIndex, 0.0, 1.0, 0.0, 0.0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArrays succeeds: default type of generic attrib is float");
}

function setupAttribValues(offsetILoc, offsetULoc, colorLoc) {
    gl.vertexAttribI4i(offsetILoc, -1, -2, 0, 0);
    gl.vertexAttribI4ui(offsetULoc, 1, 2, 0, 0);
    gl.vertexAttrib4f(colorLoc, 1.0, 0, 0, 1.0);
}

function setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                             offsetIBuffer, offsetUBuffer, colorBuffer) {
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetIBuffer);
    gl.vertexAttribIPointer(offsetILoc, 2, gl.INT, 0, 0);

    gl.bindBuffer(gl.ARRAY_BUFFER, offsetUBuffer);
    gl.vertexAttribIPointer(offsetULoc, 2, gl.UNSIGNED_INT, 0, 0);

    gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
    gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
}

function runTests() {
    debug("");
    debug("Test vertexAttrib with drawArrays and drawArraysInstanced");

    var instanceCount = 4;

    var positionLoc = 0;
    var offsetILoc = 2;
    var offsetULoc = 3;
    var colorLoc = 4;
    var program = wtu.setupProgram(gl, ["outputVertexShader", "outputFragmentShader"],
        ['aPosition', 'aOffsetI', 'aOffsetU','aColor'],
        [positionLoc, offsetILoc, offsetULoc, colorLoc]);
    if (!program) {
      testFailed("Set up program failed");
      return;
    }
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No GL error from set up");

    wtu.setupUnitQuad(gl, 0);

    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArrays succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 0, 0, 255]);
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstanced succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 0, 0, 255]);

    debug("int type function on uint type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4i(offsetULoc, 1, 2, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("float type function on uint type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttrib4f(offsetULoc, 1.0, 2.0, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("uint type function on int type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4ui(offsetILoc, 1, 2, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("float type function on int type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttrib4f(offsetILoc, 1.0, 2.0, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("int type function on float type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4i(colorLoc, 1, 0, 0, 1);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("uint type function on float type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4ui(colorLoc, 1, 0, 0, 1);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("");
    debug("Test vertexAttrib with drawElements, drawRangeElements, and drawElementsInstanced");
    wtu.setupIndexedQuad(gl, 1, 0);

    debug("Correct setup");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElements succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 0, 0, 255]);
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawRangeElements succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 0, 0, 255]);
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstanced succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 0, 0, 255]);

    debug("int type function on uint type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4i(offsetULoc, 1, 2, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("float type function on uint type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttrib4f(offsetULoc, 1.0, 2.0, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("uint type function on int type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4ui(offsetILoc, 1, 2, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("float type function on int type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttrib4f(offsetILoc, 1.0, 2.0, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("int type function on float type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4i(colorLoc, 1, 0, 0, 1);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("uint type function on float type attrib");
    setupAttribValues(offsetILoc, offsetULoc, colorLoc);
    gl.vertexAttribI4ui(colorLoc, 1, 0, 0, 1);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");


    var offsetIBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetIBuffer);
    var offsetI = new Int32Array([-1, -2,
                                  -1, -2,
                                  -1, -2,
                                  -1, -2,
                                  -1, -2,
                                  -1, -2]);
    gl.bufferData(gl.ARRAY_BUFFER, offsetI, gl.STATIC_DRAW);

    var offsetUBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetUBuffer);
    var offsetU = new Uint32Array([1, 2,
                                   1, 2,
                                   1, 2,
                                   1, 2,
                                   1, 2,
                                   1, 2]);
    gl.bufferData(gl.ARRAY_BUFFER, offsetU, gl.STATIC_DRAW);

    var offsetFBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetFBuffer);
    var offsetF = new Float32Array([1.0, 2.0,
                                    1.0, 2.0,
                                    1.0, 2.0,
                                    1.0, 2.0,
                                    1.0, 2.0,
                                    1.0, 2.0]);
    gl.bufferData(gl.ARRAY_BUFFER, offsetF, gl.STATIC_DRAW);

    var colorBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
    var colors = new Float32Array([0.0, 1.0, 0.0, 1.0,
                                   0.0, 1.0, 0.0, 1.0,
                                   0.0, 1.0, 0.0, 1.0,
                                   0.0, 1.0, 0.0, 1.0,
                                   0.0, 1.0, 0.0, 1.0,
                                   0.0, 1.0, 0.0, 1.0]);
    gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);

    var colorUBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, colorUBuffer);
    var colorsU = new Uint32Array([0, 1, 0, 1,
                                   0, 1, 0, 1,
                                   0, 1, 0, 1,
                                   0, 1, 0, 1,
                                   0, 1, 0, 1,
                                   0, 1, 0, 1]);
    gl.bufferData(gl.ARRAY_BUFFER, colorsU, gl.STATIC_DRAW);

    gl.enableVertexAttribArray(offsetILoc);
    gl.enableVertexAttribArray(offsetULoc);
    gl.enableVertexAttribArray(colorLoc);

    debug("");
    debug("Test vertexAttrib{I}Pointer with drawArrays and drawArraysInstanced");
    wtu.setupUnitQuad(gl, 0);

    debug("Correct setup");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArrays succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [0, 255, 0, 255]);
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstanced succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [0, 255, 0, 255]);

    debug("vertexAttribIPointer with int type on uint type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetIBuffer);
    gl.vertexAttribIPointer(offsetULoc, 2, gl.INT, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribPointer on uint type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetFBuffer);
    gl.vertexAttribPointer(offsetULoc, 2, gl.FLOAT, false, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("VertexAttribIPointer with uint type on int type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetUBuffer);
    gl.vertexAttribIPointer(offsetILoc, 2, gl.UNSIGNED_INT, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribPointer on int type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetFBuffer);
    gl.vertexAttribPointer(offsetILoc, 2, gl.FLOAT, false, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribIPointer with uint type on float type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, colorUBuffer);
    gl.vertexAttribIPointer(colorLoc, 4, gl.UNSIGNED_INT, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribIPointer with int type on float type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, colorUBuffer);
    gl.vertexAttribIPointer(colorLoc, 4, gl.INT, 0, 0);
    gl.drawArrays(gl.TRIANGLES, 0, 6);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("");
    debug("Test vertexAttrib{I}Pointer with drawElements, drawRangeElements, and drawElementsInstanced");
    wtu.setupIndexedQuad(gl, 1, 0);

    debug("Correct setup");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Setting up succeeds");
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElements succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [0, 255, 0, 255]);
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawRangeElements succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [0, 255, 0, 255]);
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstanced succeeds");
    wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [0, 255, 0, 255]);

    debug("vertexAttribIPointer with int type on uint type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetIBuffer);
    gl.vertexAttribIPointer(offsetULoc, 2, gl.INT, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribPointer on uint type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetFBuffer);
    gl.vertexAttribPointer(offsetULoc, 2, gl.FLOAT, false, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("VertexAttribIPointer with uint type on int type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetUBuffer);
    gl.vertexAttribIPointer(offsetILoc, 2, gl.UNSIGNED_INT, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribPointer on int type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, offsetFBuffer);
    gl.vertexAttribPointer(offsetILoc, 2, gl.FLOAT, false, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribIPointer with uint type on float type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, colorUBuffer);
    gl.vertexAttribIPointer(colorLoc, 4, gl.UNSIGNED_INT, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");

    debug("vertexAttribIPointer with int type on float type attrib");
    setupAttribPointers(offsetILoc, offsetULoc, colorLoc,
                        offsetIBuffer, offsetUBuffer, colorBuffer);
    gl.bindBuffer(gl.ARRAY_BUFFER, colorUBuffer);
    gl.vertexAttribIPointer(colorLoc, 4, gl.INT, 0, 0);
    gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawRangeElements(gl.TRIANGLES, 0, 5, 6, gl.UNSIGNED_SHORT, 0);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
    gl.drawElementsInstanced(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "type mismatch");
}

debug("");
var successfullyParsed = true;
</script>
<script src="../../js/js-test-post.js"></script>

</body>
</html>