Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / uniforms / null-uniform-location.html
blob0c49bdb2f08986deff0b0105733fb787b08310da
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 <!DOCTYPE html>
8 <html>
9 <head>
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>
14 </head>
15 <body>
16 <div id="description"></div>
17 <div id="console"></div>
19 <script>
20 "use strict";
21 description("Tests calling the various uniform[Matrix]* APIs with a null uniform location");
23 var wtu = WebGLTestUtils;
24 var gl = wtu.create3DContext();
25 var program = wtu.loadStandardProgram(gl);
27 wtu.glErrorShouldBe(gl, gl.NO_ERROR);
28 shouldBeUndefined("gl.useProgram(program)");
29 var floatArray = new Float32Array([1, 2, 3, 4]);
30 var intArray = new Int32Array([1, 2, 3, 4]);
32 function callUniformFunction(name) {
33 var isArrayVariant = (name.charAt(name.length - 1) == 'v');
34 var isMatrix = (name.indexOf("Matrix") != -1);
35 var isFloat =
36 (name.charAt(name.length - 1) == 'f' ||
37 name.charAt(name.length - 2) == 'f');
38 var sizeIndex = (isArrayVariant ? name.length - 3 : name.length - 2);
39 var size = parseInt(name.substring(sizeIndex, sizeIndex + 1));
40 // Initialize argument list with null uniform location
41 var args = [ null ];
42 if (isArrayVariant) {
43 // Call variant which takes values as array
44 if (isMatrix) {
45 size = size * size;
46 args.push(false);
48 var array = (isFloat ? new Float32Array(size) : new Int32Array(size));
49 for (var i = 0; i < size; i++) {
50 array[i] = i;
52 args.push(array);
53 } else {
54 // Call variant which takes values as parameters
55 for (var i = 0; i < size; i++) {
56 args.push(i);
59 var func = gl[name];
60 return func.apply(gl, args);
63 var funcs = [ "uniform1f", "uniform1fv", "uniform1i", "uniform1iv",
64 "uniform2f", "uniform2fv", "uniform2i", "uniform2iv",
65 "uniform3f", "uniform3fv", "uniform3i", "uniform3iv",
66 "uniform4f", "uniform4fv", "uniform4i", "uniform4iv",
67 "uniformMatrix2fv", "uniformMatrix3fv", "uniformMatrix4fv" ];
68 var callString;
70 for (var i = 0; i < funcs.length; i++) {
71 callString = "callUniformFunction('" + funcs[i] + "')";
72 shouldBeUndefined(callString);
73 wtu.glErrorShouldBe(gl, gl.NO_ERROR);
76 var successfullyParsed = true;
77 </script>
78 <script src="../../js/js-test-post.js"></script>
80 </body>
81 </html>