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>GLSL Indexing complex array expressions
</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 <script src=
"../../js/glsl-conformance-test.js"></script>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
21 Array indexing is detailed in the ESSL 3.00 spec section 5.9
22 ESSL 3.00 revisions after 3.00.4 changed the definition from 'subscripted array names' to 'subscripted arrays'
24 <script id=
"fshader-assignment" type=
"x-shader/x-fragment">#version
300 es
25 precision mediump float;
29 float a[
2] = float[
2](
0.0,
0.0);
30 float b[
2] = float[
2](
2.0,
1.0);
32 color = (c ==
2.0) ? vec4(
0,
1.0,
0,
1.0) : vec4(
1.0,
0,
0,
1.0);
35 <script id=
"fshader-function" type=
"x-shader/x-fragment">#version
300 es
36 precision mediump float;
40 float[
2] functionReturnArray() {
42 return float[
2](
2.0,
1.0);
46 float c = (functionReturnArray())[
0];
47 color = ((c ==
2.0) && hasRan) ? vec4(
0,
1.0,
0,
1.0) : vec4(
1.0,
0,
0,
1.0);
50 <script id=
"fshader-array-initialization" type=
"x-shader/x-fragment">#version
300 es
51 precision mediump float;
55 float a = (float[
3](
2.0,
1.0,
0.0))[
0];
56 color = (a ==
2.0) ? vec4(
0,
1.0,
0,
1.0) : vec4(
1.0,
0,
0,
1.0);
59 <script type=
"application/javascript">
61 description(
"Indexing complex array expressions");
64 GLSLConformanceTester.runRenderTests([
66 fShaderId: 'fshader-assignment',
69 passMsg: 'Test indexing a variable assignment: (a = b)[
0]'
72 fShaderId: 'fshader-function',
75 passMsg: 'Test indexing a function return with a side-effect: (functionReturnArray())[
0]'
78 fShaderId: 'fshader-array-initialization',
81 passMsg: 'Test indexing an array initialization: (float[
3](
2.0,
1.0,
0.0))[
0]'