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>#version directive should be on the very first line of a OpenGL ES Shading Language
3.00 shader
</title>
12 <link rel=
"stylesheet" href=
"../../resources/js-test-style.css"/>
13 <link rel=
"stylesheet" href=
"../../resources/glsl-feature-tests.css"/>
14 <script src=
"../../js/js-test-pre.js"></script>
15 <script src=
"../../js/webgl-test-utils.js"></script>
16 <script src=
"../../js/glsl-conformance-test.js"></script>
19 <div id=
"description"></div>
20 <div id=
"console"></div>
21 <!-- Version directive should be on the very first line in ESSL 3, see ESSL 3 section 3.3 -->
22 <script id=
"VertexShaderCommentBeforeVersion" type=
"x-shader/x-vertex">// This shader is wrong, this is the first line that should have version
24 precision mediump float;
28 gl_Position = aPosition;
31 <script id=
"VertexShaderNewlineBeforeVersion" type=
"x-shader/x-vertex">
33 precision mediump float;
37 gl_Position = aPosition;
40 <script id=
"CorrectVertexShader" type=
"x-shader/x-vertex">#version
300 es
41 precision mediump float;
45 gl_Position = aPosition;
48 <script id=
"FragmentShaderCommentBeforeVersion" type=
"x-shader/x-fragment">// This shader is wrong, this is the first line that should have version
50 precision mediump float;
51 out vec4 my_FragColor;
53 my_FragColor = vec4(
0.0,
1.0,
0.0,
1.0);
56 <script id=
"FragmentShaderNewlineBeforeVersion" type=
"x-shader/x-fragment">
58 precision mediump float;
59 out vec4 my_FragColor;
61 my_FragColor = vec4(
0.0,
1.0,
0.0,
1.0);
64 <script id=
"CorrectFragmentShader" type=
"x-shader/x-fragment">#version
300 es
65 precision mediump float;
66 out vec4 my_FragColor;
68 my_FragColor = vec4(
0.0,
1.0,
0.0,
1.0);
71 <script type=
"application/javascript">
74 GLSLConformanceTester.runTests([
76 vShaderId:
"VertexShaderNewlineBeforeVersion",
77 vShaderSuccess: false,
78 fShaderId:
"CorrectFragmentShader",
81 passMsg:
"Vertex shader with a newline before the version directive should fail."
84 vShaderId:
"VertexShaderCommentBeforeVersion",
85 vShaderSuccess: false,
86 fShaderId:
"CorrectFragmentShader",
89 passMsg:
"Vertex shader with a comment before the version directive should fail."
92 vShaderId:
"CorrectVertexShader",
94 fShaderId:
"FragmentShaderCommentBeforeVersion",
95 fShaderSuccess: false,
97 passMsg:
"Fragment shader with a comment before the version directive should fail."
100 vShaderId:
"CorrectVertexShader",
101 vShaderSuccess: true,
102 fShaderId:
"FragmentShaderNewlineBeforeVersion",
103 fShaderSuccess: false,
105 passMsg:
"Fragment shader with a newline before the version directive should fail."
108 var successfullyParsed = true;