Backed out changeset 7272b7396c78 (bug 1932758) for causing fenix debug failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / limits / gl-min-uniforms.html
blobe4a1bf7ea495d2ed078a5ed4142b073e74cb42ab
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 #define NUM_UNIFORMS 128 // See spec
22 attribute vec4 vPosition;
23 uniform vec4 uni[NUM_UNIFORMS];
24 varying vec4 color;
25 void main()
27 gl_Position = vPosition;
28 vec4 c = vec4(0,0,0,0);
29 for (int ii = 0; ii < NUM_UNIFORMS; ++ii) {
30 c += uni[ii];
32 color = c;
34 </script>
36 <script id="fshader" type="x-shader/x-fragment">
37 precision mediump float;
38 varying vec4 color;
39 void main()
41 gl_FragColor = color;
43 </script>
44 <script id="vshader2" type="x-shader/x-vertex">
45 attribute vec4 vPosition;
46 void main()
48 gl_Position = vPosition;
50 </script>
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];
56 void main()
58 vec4 c = vec4(0,0,0,0);
59 for (int ii = 0; ii < NUM_UNIFORMS; ++ii) {
60 c += uni[ii];
62 gl_FragColor = vec4(c.r, c.g, c.b, c.a / 120.0);
64 </script>
65 <script>
66 "use strict";
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;
99 </script>
100 <script src="../../js/js-test-post.js"></script>
102 </body>
103 </html>