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 attribute vec4 vPosition;
24 gl_Position = vPosition;
28 <script id=
"fshader" type=
"x-shader/x-fragment">
29 #define NUM_TEXTURES
8 // See spec
30 precision mediump float;
31 uniform sampler2D uni[NUM_TEXTURES];
34 vec4 c = vec4(
0,
0,
0,
0);
35 // The loop was manually unrolled in order to verify that this works.
36 // A separate test sampler-array-using-loop-index.html checks that
37 // loops indexing sampler arrays still work.
38 c += texture2D(uni[
0], vec2(
0.5,
0.5));
39 c += texture2D(uni[
1], vec2(
0.5,
0.5));
40 c += texture2D(uni[
2], vec2(
0.5,
0.5));
41 c += texture2D(uni[
3], vec2(
0.5,
0.5));
42 c += texture2D(uni[
4], vec2(
0.5,
0.5));
43 c += texture2D(uni[
5], vec2(
0.5,
0.5));
44 c += texture2D(uni[
6], vec2(
0.5,
0.5));
45 c += texture2D(uni[
7], vec2(
0.5,
0.5));
51 description(document
.title
);
52 var wtu
= WebGLTestUtils
;
53 var gl
= wtu
.create3DContext("example");
54 var program
= wtu
.setupTexturedQuad(gl
);
56 //------------------------------------------------------------------------------
57 var program
= wtu
.setupProgram(
58 gl
, ['vshader', 'fshader'], ['vPosition'], [0]);
60 for (var ii
= 0; ii
< 8; ++ii
) {
61 var loc
= gl
.getUniformLocation(program
, "uni[" + ii
+ "]");
62 gl
.activeTexture(gl
.TEXTURE0
+ ii
);
63 var tex
= gl
.createTexture();
64 wtu
.fillTexture(gl
, tex
, 1, 1, [32, 16, 8, ii
* 9], 0);
65 gl
.uniform1i(loc
, ii
);
68 wtu
.clearAndDrawUnitQuad(gl
);
69 wtu
.glErrorShouldBe(gl
, gl
.NO_ERROR
, "Should be no errors from setup.");
70 wtu
.checkCanvas(gl
, [255, 128, 64, 252],
71 "Should render using all texture units", 1);
73 var successfullyParsed
= true;
76 <script src=
"../../js/js-test-post.js"></script>