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
3.00 forward declaration 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>
15 <script src=
"../../js/glsl-conformance-test.js"></script>
18 <div id=
"description"></div>
19 <div id=
"console"></div>
20 <script id=
"vertexShaderForwardDecl" type=
"x-shader/x-vertex">#version
300 es
21 precision mediump float;
23 // Forward declaration. Breaks on Pixel C due to flattening of
24 // precision qualifiers. It seems the GLSL compiler can't handle the
25 // precision qualifier on the return value.
26 float identity(float val);
28 float identity(float val) {
33 gl_Position = vec4(identity(
1.0),
0.0,
0.0,
1.0);
36 <script id=
"vertexShader" type=
"x-shader/x-vertex">#version
300 es
38 gl_Position = vec4(
1.0,
0.0,
0.0,
1.0);
41 <script id=
"fragmentShader" type=
"x-shader/x-fragment">#version
300 es
42 precision mediump float;
44 out vec4 my_FragColor;
46 my_FragColor = vec4(
0.0,
1.0,
0.0,
1.0);
49 <script id=
"fragmentShaderForwardDecl" type=
"x-shader/x-fragment">#version
300 es
50 precision mediump float;
52 // Forward declaration. Breaks on Pixel C due to flattening of
53 // precision qualifiers. It seems the GLSL compiler can't handle the
54 // precision qualifier on the return value.
55 float identity(float val);
57 float identity(float val) {
61 out vec4 my_FragColor;
63 my_FragColor = vec4(
0.0, identity(
1.0),
0.0,
1.0);
66 <script type=
"application/javascript">
68 description(
"Forward declarations of functions should succeed.");
70 GLSLConformanceTester.runTests([
72 vShaderId:
"vertexShaderForwardDecl",
74 fShaderId:
"fragmentShader",
77 passMsg:
"vertex shader with forward declaration must pass",
80 vShaderId:
"vertexShader",
82 fShaderId:
"fragmentShaderForwardDecl",
85 passMsg:
"fragment shader with forward declaration must pass",