Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / limits / gl-min-textures.html
blob33b9f1f94cc0193e9e8540b0af61c52c431036ef
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 <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>
15 </head>
16 <body>
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;
22 void main()
24 gl_Position = vPosition;
26 </script>
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];
32 void main()
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));
46 gl_FragColor = c;
48 </script>
49 <script>
50 "use strict";
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;
75 </script>
76 <script src="../../js/js-test-post.js"></script>
78 </body>
79 </html>