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 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>
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;
35 gl_Position = vPosition;
36 v_color = (u0 + u2 + u1.var1) - vec4(
2.0);
40 <script id=
"fshader" type=
"x-shader/x-fragment">
41 precision mediump float;
45 gl_FragColor = v_color;
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");
77 var successfullyParsed
= true;
80 <script src=
"../../js/js-test-post.js"></script>