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 <link rel=
"stylesheet" href=
"../../../resources/js-test-style.css" />
11 <link rel=
"stylesheet" href=
"../../../resources/glsl-feature-tests.css" />
12 <script src=
"../../../js/js-test-pre.js"></script>
13 <script src=
"../../../js/webgl-test-utils.js"></script>
14 <script src=
"../../../js/glsl-conformance-test.js"></script>
15 <title>Ternary Operators in Global Initializers
</title>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id=
"fragmentShader" type=
"text/something-not-javascript">
21 precision mediump float;
22 const $(type) green = $(green);
23 const $(type) black = $(black);
24 $(type) var = (true) ? green : black;
26 gl_FragColor = $(asVec4);
31 description("This test verifies that ternary operators can be used in global initializers.");
33 var wtu
= WebGLTestUtils
;
35 { type
: 'float', green
: '1.0', black
: '0.0', asVec4
: 'vec4(0.0,var,0.0,1.0)' },
36 { type
: 'vec2', green
: 'vec2(0.0,1.0)', black
: 'vec2(0.0,0.0)', asVec4
: 'vec4(var,0.0,1.0)' },
37 { type
: 'vec3', green
: 'vec3(0.0,1.0,0.0)', black
: 'vec3(0.0,0.0,0.0)', asVec4
: 'vec4(var,1.0)' },
38 { type
: 'vec4', green
: 'vec4(0.0,1.0,0.0,1.0)', black
: 'vec4(0.0,0.0,0.0,0.0)', asVec4
: 'var' },
39 { type
: 'int', green
: '1', black
: '0', asVec4
: 'vec4(0.0,var,0.0,1.0)' },
40 { type
: 'ivec2', green
: 'ivec2(0,1)', black
: 'ivec2(0,0)', asVec4
: 'vec4(var,0.0,1.0)' },
41 { type
: 'ivec3', green
: 'ivec3(0,1,0)', black
: 'ivec3(0,0,0)', asVec4
: 'vec4(var,1.0)' },
42 { type
: 'ivec4', green
: 'ivec4(0,1,0,1)', black
: 'ivec4(0,0,0,0)', asVec4
: 'vec4(var)' },
43 { type
: 'bool', green
: 'true', black
: 'false', asVec4
: 'vec4(0.0,var,0.0,1.0)' },
44 { type
: 'bvec2', green
: 'bvec2(false,true)', black
: 'bvec2(false,false)', asVec4
: 'vec4(var,0.0,1.0)' },
45 { type
: 'bvec3', green
: 'bvec3(false,true,false)', black
: 'bvec3(false,false,false)', asVec4
: 'vec4(var,1.0)' },
46 { type
: 'bvec4', green
: 'bvec4(false,true,false,true)',black
: 'bvec4(false,false,false,false)', asVec4
: 'vec4(var)' },
48 typeInfos
.forEach(function (typeInfo
) {
51 green
: typeInfo
.green
,
52 black
: typeInfo
.black
,
53 asVec4
: typeInfo
.asVec4
,
56 fShaderSource
: wtu
.replaceParams(wtu
.getScript('fragmentShader'), replaceParams
),
57 passMsg
: typeInfo
.type
,
63 GLSLConformanceTester
.runTests(tests
);
64 var successfullyParsed
= true;