misplaced-version-directive.html (3311B)
1 <!-- 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. 5 --> 6 7 <!DOCTYPE html> 8 <html> 9 <head> 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> 17 </head> 18 <body> 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 23 #version 300 es 24 precision mediump float; 25 in vec4 aPosition; 26 27 void main() { 28 gl_Position = aPosition; 29 } 30 </script> 31 <script id="VertexShaderNewlineBeforeVersion" type="x-shader/x-vertex"> 32 #version 300 es 33 precision mediump float; 34 in vec4 aPosition; 35 36 void main() { 37 gl_Position = aPosition; 38 } 39 </script> 40 <script id="CorrectVertexShader" type="x-shader/x-vertex">#version 300 es 41 precision mediump float; 42 in vec4 aPosition; 43 44 void main() { 45 gl_Position = aPosition; 46 } 47 </script> 48 <script id="FragmentShaderCommentBeforeVersion" type="x-shader/x-fragment">// This shader is wrong, this is the first line that should have version 49 #version 300 es 50 precision mediump float; 51 out vec4 my_FragColor; 52 void main() { 53 my_FragColor = vec4(0.0, 1.0, 0.0, 1.0); 54 } 55 </script> 56 <script id="FragmentShaderNewlineBeforeVersion" type="x-shader/x-fragment"> 57 #version 300 es 58 precision mediump float; 59 out vec4 my_FragColor; 60 void main() { 61 my_FragColor = vec4(0.0, 1.0, 0.0, 1.0); 62 } 63 </script> 64 <script id="CorrectFragmentShader" type="x-shader/x-fragment">#version 300 es 65 precision mediump float; 66 out vec4 my_FragColor; 67 void main() { 68 my_FragColor = vec4(0.0, 1.0, 0.0, 1.0); 69 } 70 </script> 71 <script type="application/javascript"> 72 "use strict"; 73 description(); 74 GLSLConformanceTester.runTests([ 75 { 76 vShaderId: "VertexShaderNewlineBeforeVersion", 77 vShaderSuccess: false, 78 fShaderId: "CorrectFragmentShader", 79 fShaderSuccess: true, 80 linkSuccess: false, 81 passMsg: "Vertex shader with a newline before the version directive should fail." 82 }, 83 { 84 vShaderId: "VertexShaderCommentBeforeVersion", 85 vShaderSuccess: false, 86 fShaderId: "CorrectFragmentShader", 87 fShaderSuccess: true, 88 linkSuccess: false, 89 passMsg: "Vertex shader with a comment before the version directive should fail." 90 }, 91 { 92 vShaderId: "CorrectVertexShader", 93 vShaderSuccess: true, 94 fShaderId: "FragmentShaderCommentBeforeVersion", 95 fShaderSuccess: false, 96 linkSuccess: false, 97 passMsg: "Fragment shader with a comment before the version directive should fail." 98 }, 99 { 100 vShaderId: "CorrectVertexShader", 101 vShaderSuccess: true, 102 fShaderId: "FragmentShaderNewlineBeforeVersion", 103 fShaderSuccess: false, 104 linkSuccess: false, 105 passMsg: "Fragment shader with a newline before the version directive should fail." 106 } 107 ], 2); 108 var successfullyParsed = true; 109 </script> 110 </body> 111 </html>