summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance2/buffers/uniform-buffers.html
blob: 8fc8db756feeecca9968870b15f8a98c5fbcade4 (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
<!--

/*
** Copyright (c) 2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/

-->

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Uniform Buffers Conformance Tests</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 id='vshader' type='x-shader/x-vertex'>#version 300 es
layout(location=0) in vec3 p;
void main()
{
    gl_Position = vec4(p.xyz, 1.0);
}
</script>
<script id='fbadshader' type='x-shader/x-fragment'>#version 300 es
precision mediump float;
layout(location=0) out vec4 oColor;

uniform UBOData {
    float UBORed;
    float UBOGreen;
    float UBOBlue;
};

uniform Color {
    float Red;
    float UBOGreen;
    float Blue;
};

void main()
{
    oColor = vec4(UBORed * Red, UBOGreen * UBOGreen, UBOBlue * Blue, 1.0);
}
</script>
<script id='fshader' type='x-shader/x-fragment'>#version 300 es
precision mediump float;
layout(location=0) out vec4 oColor;

uniform UBOData {
    float UBORed;
    float UBOGreen;
    float UBOBlue;
};

uniform UBOD {
    float UBOR;
    float UBOG;
    float UBOB;
};

void main()
{
    oColor = vec4(UBORed * UBOR, UBOGreen * UBOG, UBOBlue * UBOB, 1.0);
}
</script>
<script id='fshadernamed' type='x-shader/x-fragment'>#version 300 es
precision mediump float;
layout(location=0) out vec4 oColor;

uniform UBOData {
    float Red;
    float Green;
    float Blue;
} UBOA;

void main()
{
    oColor = vec4(UBOA.Red, UBOA.Green, UBOA.Blue, 1.0);
}
</script>
<script id='fshadernamedarray' type='x-shader/x-fragment'>#version 300 es
precision mediump float;
layout(location=0) out vec4 oColor;

uniform UBOData {
    float Red;
    float Green;
    float Blue;
} UBOA[2];

void main()
{
    oColor = vec4((UBOA[0].Red + UBOA[1].Red) / 2.0,
                  (UBOA[0].Green + UBOA[1].Green) / 2.0,
                  (UBOA[0].Blue + UBOA[1].Blue) / 2.0, 1.0);
}
</script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<script>
"use strict";
description("This test verifies the functionality of the Uniform Buffer objects");

debug("");

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

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

    runBindingTest();
    runDrawTest();
    runNamedDrawTest();
    runNamedArrayDrawTest();
}

function runBindingTest() {
    debug("");
    debug("Testing uniform buffer binding behavior");
    shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "UNIFORM_BUFFER_BINDING query should succeed");

    debug("Testing basic uniform buffer binding and unbinding");
    b1 = gl.createBuffer();
    b2 = gl.createBuffer();
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "createBuffer should not set an error");
    shouldBeNonNull("b1");
    shouldBeNonNull("b2");
    gl.bindBuffer(gl.UNIFORM_BUFFER, b1);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to bind uniform buffer");
    shouldBe("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)", "b1");
    gl.bindBuffer(gl.UNIFORM_BUFFER, b2);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to update uniform buffer binding");
    shouldBe("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)", "b2");
    gl.bindBuffer(gl.UNIFORM_BUFFER, null);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to unbind uniform buffer");

    debug("Testing deleting uniform buffers");
    gl.deleteBuffer(b1);
    gl.deleteBuffer(b2);
    shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");

    // Shouldn't be able to bind a deleted buffer.
    gl.bindBuffer(gl.UNIFORM_BUFFER, b2);
    wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "binding a deleted buffer should generate INVALID_OPERATION");
    shouldBeNull("gl.getParameter(gl.UNIFORM_BUFFER_BINDING)");
}

function runDrawTest() {
    debug("");
    debug("Testing drawing with uniform buffers");

    wtu.setupUnitQuad(gl);

    var testProgram = wtu.setupProgram(gl, ['vshader', 'fbadshader']);
    if (testProgram) {
        testFailed("To define the same uniform in two uniform blocks should fail");
    } else {
        testPassed("To define the same uniform in two uniform blocks should fail");
    }

    var program = wtu.setupProgram(gl, ['vshader', 'fshader']);
    if (!program) {
        testFailed("Could not compile shader with uniform blocks without error");
        return;
    }

    var blockIndex_1 = gl.getUniformBlockIndex(program, "UBOData");
    var blockSize_1 = gl.getActiveUniformBlockParameter(program, blockIndex_1, gl.UNIFORM_BLOCK_DATA_SIZE);
    var uniformIndices_1 = gl.getUniformIndices(program, ["UBORed", "UBOGreen", "UBOBlue"]);
    var uniformOffsets_1 = gl.getActiveUniforms(program, uniformIndices_1, gl.UNIFORM_OFFSET);
    var blockIndex_2 = gl.getUniformBlockIndex(program, "UBOD");
    var blockSize_2 = gl.getActiveUniformBlockParameter(program, blockIndex_2, gl.UNIFORM_BLOCK_DATA_SIZE);
    var uniformIndices_2 = gl.getUniformIndices(program, ["UBOR", "UBOG", "UBOB"]);
    var uniformOffsets_2 = gl.getActiveUniforms(program, uniformIndices_2, gl.UNIFORM_OFFSET);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to query uniform block information without error");

    if (uniformOffsets_1.length < 3 || uniformOffsets_2.length < 3) {
        testFailed("Could not query uniform offsets");
        return;
    }

    // Verify that the uniform offsets are aligned on 4-byte boundries
    // While unaligned values are allowed by the ES3 spec it would be *really* weird for anyone to actually do that.
    if (uniformOffsets_1[0] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets_1[0] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets_1[1] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets_1[1] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets_1[2] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets_1[2] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets_2[0] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets_2[0] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets_2[1] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets_2[1] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets_2[2] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets_2[2] / Float32Array.BYTES_PER_ELEMENT)) {
        testFailed("Uniform offsets are not well aligned");
        return;
    }

    var uboArray_1 = new ArrayBuffer(blockSize_1);
    var uboFloatView_1 = new Float32Array(uboArray_1);
    uboFloatView_1[uniformOffsets_1[0] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // UBORed
    uboFloatView_1[uniformOffsets_1[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // UBOGreen
    uboFloatView_1[uniformOffsets_1[2] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // UBOBlue
    var uboArray_2 = new ArrayBuffer(blockSize_2);
    var uboFloatView_2 = new Float32Array(uboArray_2);
    uboFloatView_2[uniformOffsets_2[0] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // UBOR
    uboFloatView_2[uniformOffsets_2[1] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // UBOG
    uboFloatView_2[uniformOffsets_2[2] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // UBOB

    var b_1 = gl.createBuffer();
    gl.bindBuffer(gl.UNIFORM_BUFFER, b_1);
    gl.bufferData(gl.UNIFORM_BUFFER, uboFloatView_1, gl.DYNAMIC_DRAW);
    var b_2 = gl.createBuffer();
    gl.bindBuffer(gl.UNIFORM_BUFFER, b_2);
    gl.bufferData(gl.UNIFORM_BUFFER, uboFloatView_2, gl.DYNAMIC_DRAW);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to set UBO data with no errors");

    var bindings = [1, 2];
    gl.uniformBlockBinding(program, blockIndex_1, bindings[0]);
    gl.bindBufferBase(gl.UNIFORM_BUFFER, bindings[0], b_1);
    gl.uniformBlockBinding(program, blockIndex_2, bindings[1]);
    gl.bindBufferBase(gl.UNIFORM_BUFFER, bindings[1], b_2);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call bindBufferBase without errors");

    wtu.clearAndDrawUnitQuad(gl);
    wtu.checkCanvas(gl, [255, 0, 0, 255], "draw call should set canvas to red", 2);

    debug("Changing the data in the uniform buffer should automatically update the uniforms exposed to the draw call");
    uboFloatView_1[uniformOffsets_1[0] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // UBORed
    uboFloatView_1[uniformOffsets_1[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // UBOGreen
    uboFloatView_1[uniformOffsets_1[2] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // UBOBlue
    gl.bindBuffer(gl.UNIFORM_BUFFER, b_1);
    gl.bufferData(gl.UNIFORM_BUFFER, uboFloatView_1, gl.DYNAMIC_DRAW);

    wtu.clearAndDrawUnitQuad(gl);
    wtu.checkCanvas(gl, [0, 0, 255, 255], "draw call should set canvas to blue", 2);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}

function runNamedDrawTest() {
    debug("");
    debug("Testing drawing with named uniform buffers");

    wtu.setupUnitQuad(gl);

    var program = wtu.setupProgram(gl, ['vshader', 'fshadernamed']);
    if (!program) {
        testFailed("Could not compile shader with named uniform blocks without error");
    }

    var blockIndex = gl.getUniformBlockIndex(program, "UBOData");
    var blockSize = gl.getActiveUniformBlockParameter(program, blockIndex, gl.UNIFORM_BLOCK_DATA_SIZE);
    var uniformIndices = gl.getUniformIndices(program, ["UBOData.Red", "UBOData.Green", "UBOData.Blue"]);
    var uniformOffsets = gl.getActiveUniforms(program, uniformIndices, gl.UNIFORM_OFFSET);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to query uniform block information without error");

    if (uniformOffsets.length < 3) {
        testFailed("Could not query uniform offsets");
        return;
    }

    // Verify that the uniform offsets are aligned on 4-byte boundries
    // While unaligned values are allowed by the ES3 spec it would be *really* weird for anyone to actually do that.
    if (uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT)) {
        testFailed("Uniform offsets are not well aligned");
        return;
    }

    var uboArray = new ArrayBuffer(blockSize);
    var uboFloatView = new Float32Array(uboArray);
    uboFloatView[uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Red
    uboFloatView[uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Green
    uboFloatView[uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Blue

    b1 = gl.createBuffer();
    gl.bindBuffer(gl.UNIFORM_BUFFER, b1);
    gl.bufferData(gl.UNIFORM_BUFFER, uboArray, gl.DYNAMIC_DRAW);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to set UBO data with no errors");

    var binding = 3;
    gl.uniformBlockBinding(program, blockIndex, binding);
    gl.bindBufferBase(gl.UNIFORM_BUFFER, binding, b1);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call bindBufferBase without errors");

    wtu.clearAndDrawUnitQuad(gl);
    wtu.checkCanvas(gl, [255, 0, 0, 255], "draw call should set canvas to red", 2);

    debug("Changing the data in the uniform buffer should automatically update the uniforms exposed to the draw call");
    uboFloatView[uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Red
    uboFloatView[uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Green
    uboFloatView[uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Blue
    gl.bufferData(gl.UNIFORM_BUFFER, uboArray, gl.DYNAMIC_DRAW);

    wtu.clearAndDrawUnitQuad(gl);
    wtu.checkCanvas(gl, [0, 0, 255, 255], "draw call should set canvas to blue", 2);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}

function runNamedArrayDrawTest() {
    debug("");
    debug("Testing drawing with named uniform buffer arrays");

    wtu.setupUnitQuad(gl);

    var program = wtu.setupProgram(gl, ['vshader', 'fshadernamedarray']);
    if (!program) {
        testFailed("could not compile shader with named uniform block arrays without error");
        return;
    }

    var blockIndex = [gl.getUniformBlockIndex(program, "UBOData[0]"),
                      gl.getUniformBlockIndex(program, "UBOData[1]")];
    if (blockIndex[0] == gl.INVALID_INDEX ||
        blockIndex[1] == gl.INVALID_INDEX) {
        testFailed("Could not query uniform block index");
        return;
    }
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to query uniform block indices without error");
    var blockSize = [gl.getActiveUniformBlockParameter(program, blockIndex[0], gl.UNIFORM_BLOCK_DATA_SIZE),
                     gl.getActiveUniformBlockParameter(program, blockIndex[1], gl.UNIFORM_BLOCK_DATA_SIZE)];
    if (blockSize[0] != blockSize[1]) {
        testFailed("uniform block instance array with different block sizes");
    }
    var uniformIndices = gl.getUniformIndices(program, ["UBOData.Red", "UBOData.Green", "UBOData.Blue"]);
    if (uniformIndices < 3 ||
        uniformIndices[0] == gl.INVALID_INDEX ||
        uniformIndices[1] == gl.INVALID_INDEX ||
        uniformIndices[2] == gl.INVALID_INDEX) {
        testFailed("Could not query uniform indices");
        return;
    }
    var uniformOffsets = gl.getActiveUniforms(program, uniformIndices, gl.UNIFORM_OFFSET);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to query uniform block information without error");
    if (uniformOffsets.length < 3) {
        testFailed("Could not query uniform offsets");
        return;
    }

    var offsetAlignment = gl.getParameter(gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT);
    var offset = Math.ceil(blockSize[0] / offsetAlignment) * offsetAlignment;
    // Verify that the uniform offsets are aligned on 4-byte boundries
    // While unaligned values are allowed by the ES3 spec it would be *really* weird for anyone to actually do that.
    if (offset / Float32Array.BYTES_PER_ELEMENT != Math.floor(offset / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT) ||
        uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT != Math.floor(uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT)) {
        testFailed("Uniform offsets are not well aligned");
        return;
    }
    var bufferSize = offset + blockSize[1];
    var uboArray = new ArrayBuffer(bufferSize);
    var uboFloatView = new Float32Array(uboArray);
    uboFloatView[uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Red
    uboFloatView[uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Green
    uboFloatView[uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Blue
    uboFloatView[offset / Float32Array.BYTES_PER_ELEMENT +
                 uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Red
    uboFloatView[offset / Float32Array.BYTES_PER_ELEMENT +
                 uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Green
    uboFloatView[offset / Float32Array.BYTES_PER_ELEMENT +
                 uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Blue

    b1 = gl.createBuffer();
    gl.bindBuffer(gl.UNIFORM_BUFFER, b1);
    gl.bufferData(gl.UNIFORM_BUFFER, uboArray, gl.DYNAMIC_DRAW);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to set UBO data with no errors");

    var bindings = [4, 5];
    gl.uniformBlockBinding(program, blockIndex[0], bindings[0]);
    gl.bindBufferRange(gl.UNIFORM_BUFFER, bindings[0], b1, 0, blockSize[0]);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call bindBufferRange without errors");
    gl.uniformBlockBinding(program, blockIndex[1], bindings[1]);
    gl.bindBufferRange(gl.UNIFORM_BUFFER, bindings[1], b1, offset, blockSize[1]);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be able to call bindBufferRange without errors");

    wtu.clearAndDrawUnitQuad(gl);
    wtu.checkCanvas(gl, [127, 0, 127, 255], "draw call should set canvas to (0.5, 0, 0.5)", 2);

    debug("Changing the data in the uniform buffer should automatically update the uniforms exposed to the draw call");
    uboFloatView[uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Red
    uboFloatView[uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Green
    uboFloatView[uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Blue
    uboFloatView[offset / Float32Array.BYTES_PER_ELEMENT +
                 uniformOffsets[0] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Red
    uboFloatView[offset / Float32Array.BYTES_PER_ELEMENT +
                 uniformOffsets[1] / Float32Array.BYTES_PER_ELEMENT] = 0.0; // Green
    uboFloatView[offset / Float32Array.BYTES_PER_ELEMENT +
                 uniformOffsets[2] / Float32Array.BYTES_PER_ELEMENT] = 1.0; // Blue
    gl.bufferData(gl.UNIFORM_BUFFER, uboArray, gl.DYNAMIC_DRAW);

    wtu.clearAndDrawUnitQuad(gl);
    wtu.checkCanvas(gl, [0, 127, 255, 255], "draw call should set canvas to (0, 0.5, 1)", 2);
    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}

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

</body>
</html>