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>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>
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">
25 gl_Position = vec4(pos,
0.0,
1.0);
29 <script id=
"shader-fs-int" type=
"x-shader/x-fragment">
30 precision mediump float;
35 const int numLights =
1;
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);
48 <script id=
"shader-fs-bool" type=
"x-shader/x-fragment">
49 precision mediump float;
54 const int numLights =
1;
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);
67 <script id=
"shader-fs-bool-read" type=
"x-shader/x-fragment">
68 precision mediump float;
73 const int numLights =
1;
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];
83 result += light.color;
86 gl_FragColor = vec4(result.rgb,
1.0);
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.")
103 var wtu
= WebGLTestUtils
;
104 var canvas
= document
.getElementById("example");
105 var gl
= wtu
.create3DContext(canvas
);
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
) {
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
);
120 gl
, startX
, 0, squareSize
, squareSize
,
121 expectedColor
, "square should be 50% green", 1);
127 testFailed("context does not exist");
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");
137 var successfullyParsed
= true;
139 <script src=
"../../../js/js-test-post.js"></script>