Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / uniforms / gl-uniform-struct-unused.html
blobb755e59ee255e2d7fc42ca59e9006a4e07631733
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 uniform struct Conformance Test</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 <div id="description"></div>
18 <div id="console"></div>
19 <canvas id="example" width="2" height="2"> </canvas>
21 <script id="vshader" type="x-shader/x-vertex">
22 attribute vec4 vPosition;
23 uniform vec4 u0;
24 struct MyStruct {
25 vec4 var1;
26 vec4 var2;
27 vec4 var3;
28 vec4 var4;
30 uniform MyStruct u1;
31 uniform vec4 u2;
32 varying vec4 v_color;
33 void main()
35 gl_Position = vPosition;
36 v_color = (u0 + u2 + u1.var1) - vec4(2.0);
38 </script>
40 <script id="fshader" type="x-shader/x-fragment">
41 precision mediump float;
42 varying vec4 v_color;
43 void main()
45 gl_FragColor = v_color;
47 </script>
49 <script>
50 "use strict";
51 description("This test ensures WebGL implementations handle unused members at the end of structs correctly.");
53 var wtu = WebGLTestUtils;
54 var gl = wtu.create3DContext();
55 var c = document.getElementById("console");
56 program = wtu.setupProgram(gl, ["vshader", "fshader"], [ "vPosition"]);
58 wtu.setupUnitQuad(gl, [0, 1]);
59 var white = [1.0, 1.0, 1.0, 1.0];
60 var black = [0.0, 0.0, 0.0, 0.0];
61 gl.uniform4fv(gl.getUniformLocation(program, "u0"), white);
62 gl.uniform4fv(gl.getUniformLocation(program, "u1.var1"), white);
63 gl.uniform4fv(gl.getUniformLocation(program, "u1.var2"), black);
64 gl.uniform4fv(gl.getUniformLocation(program, "u1.var3"), black);
65 gl.uniform4fv(gl.getUniformLocation(program, "u1.var4"), black);
66 gl.uniform4fv(gl.getUniformLocation(program, "u2"), white);
67 wtu.clearAndDrawUnitQuad(gl);
68 wtu.checkCanvas(gl, [255, 255, 255, 255], "should be white", 0);
69 gl.uniform4fv(gl.getUniformLocation(program, "u1.var2"), black);
70 gl.uniform4fv(gl.getUniformLocation(program, "u1.var3"), black);
71 gl.uniform4fv(gl.getUniformLocation(program, "u1.var4"), black);
72 wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]);
73 wtu.checkCanvas(gl, [255, 255, 255, 255], "should still be white", 0);
75 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors");
76 debug("");
77 var successfullyParsed = true;
79 </script>
80 <script src="../../js/js-test-post.js"></script>
82 </body>
83 </html>