Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / glsl / bugs / array-of-struct-with-int-first-position.html
blobe7dd805566e35648ed04bfe224f19b64825f6a41
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>Driver Bug - Array of structs with int or bool in first position</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>
17 <body>
18 <canvas id="example" style="border: none;" width="788" height="256"></canvas>
19 <div id="description"></div>
20 <div id="console"></div>
22 <script id="shader-vs" type="x-shader/x-vertex">
23 attribute vec2 pos;
24 void main(void) {
25 gl_Position = vec4(pos, 0.0, 1.0);
27 </script>
29 <script id="shader-fs-int" type="x-shader/x-fragment">
30 precision mediump float;
31 struct Light {
32 int unused;
33 vec3 color;
35 const int numLights = 1;
36 void main() {
37 Light lights[numLights];
38 lights[0].color = vec3(0.0, 0.5, 0.0);
40 vec3 result = vec3(0.0, 0.0, 0.0);
41 for (int i=0; i<numLights; i++) {
42 result += lights[i].color;
44 gl_FragColor = vec4(result.rgb, 1.0);
46 </script>
48 <script id="shader-fs-bool" type="x-shader/x-fragment">
49 precision mediump float;
50 struct Light {
51 bool unused;
52 vec3 color;
54 const int numLights = 1;
55 void main() {
56 Light lights[numLights];
57 lights[0].color = vec3(0.0, 0.5, 0.0);
59 vec3 result = vec3(0.0, 0.0, 0.0);
60 for (int i=0; i<numLights; i++) {
61 result += lights[i].color;
63 gl_FragColor = vec4(result.rgb, 1.0);
65 </script>
67 <script id="shader-fs-bool-read" type="x-shader/x-fragment">
68 precision mediump float;
69 struct Light {
70 bool useLight;
71 vec3 color;
73 const int numLights = 1;
74 void main() {
75 Light lights[numLights];
76 lights[0].color = vec3(0.0, 0.5, 0.0);
77 lights[0].useLight = true;
79 vec3 result = vec3(0.0, 0.0, 0.0);
80 for (int i=0; i<numLights; i++) {
81 Light light = lights[i];
82 if (light.useLight) {
83 result += light.color;
86 gl_FragColor = vec4(result.rgb, 1.0);
88 </script>
90 <script>
91 "use strict";
93 function test() {
94 description();
95 debug(
96 "This test checks accessing an array of structs, where the struct " +
97 "definition has an int or bool in the first position. " +
98 "This test has has failed in OS X on some NVIDIA cards, " +
99 "such as the NVIDIA GeForce GT 650M. If things are working " +
100 "correctly, then there will be a series of 50% green squares.")
101 debug("");
103 var wtu = WebGLTestUtils;
104 var canvas = document.getElementById("example");
105 var gl = wtu.create3DContext(canvas);
107 var testNum = 0;
108 var border = 10; // border between test squares for visibility
109 var squareSize = 256;
110 var expectedColor = [0, 127, 0, 255]; // 50% green
112 function subTest(message, fragmentShader) {
113 debug(message);
114 var startX = (squareSize + border) * testNum;
115 var program = wtu.setupProgram(
116 gl, ["shader-vs", fragmentShader], ["pos"], null, true);
117 gl.viewport(startX, 0, squareSize, squareSize);
118 wtu.drawUnitQuad(gl);
119 wtu.checkCanvasRect(
120 gl, startX, 0, squareSize, squareSize,
121 expectedColor, "square should be 50% green", 1);
122 debug("");
123 testNum++;
126 if (!gl) {
127 testFailed("context does not exist");
128 } else {
129 wtu.setupUnitQuad(gl);
130 subTest("Test unused int in first struct position.", "shader-fs-int");
131 subTest("Test unused bool in first struct position.", "shader-fs-bool");
132 subTest("Test used bool in first struct position.", "shader-fs-bool-read");
136 test();
137 var successfullyParsed = true;
138 </script>
139 <script src="../../../js/js-test-post.js"></script>
140 </body>
141 </html>