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 <title>WebGL the minimum number of uniforms are supported.
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <script src=
"../../js/js-test-pre.js"></script>
14 <script src=
"../../js/webgl-test-utils.js"> </script>
17 <canvas id=
"example" width=
"4" height=
"4" style=
"width: 40px; height: 30px;"></canvas>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id=
"vshader" type=
"x-shader/x-vertex">
21 #define NUM_UNIFORMS
128 // See spec
22 attribute vec4 vPosition;
23 uniform vec4 uni[NUM_UNIFORMS];
27 gl_Position = vPosition;
28 vec4 c = vec4(
0,
0,
0,
0);
29 for (int ii =
0; ii < NUM_UNIFORMS; ++ii) {
36 <script id=
"fshader" type=
"x-shader/x-fragment">
37 precision mediump float;
44 <script id=
"vshader2" type=
"x-shader/x-vertex">
45 attribute vec4 vPosition;
48 gl_Position = vPosition;
52 <script id=
"fshader2" type=
"x-shader/x-fragment">
53 precision mediump float;
54 #define NUM_UNIFORMS
16 // See spec
55 uniform vec4 uni[NUM_UNIFORMS];
58 vec4 c = vec4(
0,
0,
0,
0);
59 for (int ii =
0; ii < NUM_UNIFORMS; ++ii) {
62 gl_FragColor = vec4(c.r, c.g, c.b, c.a /
120.0);
67 description(document
.title
);
68 var wtu
= WebGLTestUtils
;
69 var gl
= wtu
.create3DContext("example");
70 var program
= wtu
.setupTexturedQuad(gl
);
72 //------------------------------------------------------------------------------
73 var program
= wtu
.setupProgram(gl
, ['vshader', 'fshader'], ['vPosition'], [0]);
75 for (var ii
= 0; ii
< 128; ++ii
) {
76 var loc
= gl
.getUniformLocation(program
, "uni[" + ii
+ "]");
77 gl
.uniform4f(loc
, 2/256, 2/512, 2/1024, ii/8128);
80 wtu
.clearAndDrawUnitQuad(gl
);
81 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
82 wtu
.checkCanvasRect(gl
, 0, 0, gl
.canvas
.width
, gl
.canvas
.height
, [255, 127, 64, 255], "Should render 255,127,64,32 (+/-1)", 1);
84 //------------------------------------------------------------------------------
85 var program
= wtu
.setupProgram(gl
, ['vshader2', 'fshader2'], ['vPosition'], [0]);
87 for (var ii
= 0; ii
< 16; ++ii
) {
88 var loc
= gl
.getUniformLocation(program
, "uni[" + ii
+ "]");
89 gl
.uniform4f(loc
, 16/2048, 16/1024, 16/512, ii
);
92 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
93 wtu
.clearAndDrawUnitQuad(gl
);
94 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
95 wtu
.checkCanvasRect(gl
, 0, 0, gl
.canvas
.width
, gl
.canvas
.height
, [32, 64, 127, 255], "Should render 32,64,127,255 (+/-1)", 1);
97 var successfullyParsed
= true;
100 <script src=
"../../js/js-test-post.js"></script>