const-array-init.html (2425B)
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>Constant array initialization 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> 16 </head> 17 <body> 18 <div id="description"></div> 19 <div id="console"></div> 20 <script id="fshaderGlobalConstArray" type="x-shader/x-fragment">#version 300 es 21 precision mediump float; 22 out vec4 my_FragColor; 23 24 const vec4 constants[2] = vec4[] ( 25 vec4(0.6, 0.3, 0.0, 3.0), 26 vec4(-0.6, 0.7, 0.0, -2.0) 27 ); 28 29 void main() 30 { 31 my_FragColor = constants[0] + constants[1]; 32 return; 33 } 34 </script> 35 <script id="fshaderGlobalConstArrayWithReferenceToConstArray" type="x-shader/x-fragment">#version 300 es 36 precision mediump float; 37 out vec4 my_FragColor; 38 39 const vec4 constants[2] = vec4[] ( 40 vec4(0.6, 0.3, 0.0, 3.0), 41 vec4(-0.6, 0.7, 0.0, -2.0) 42 ); 43 44 const vec4 constants2[2] = vec4[] ( 45 constants[1], 46 constants[0] 47 ); 48 49 void main() 50 { 51 my_FragColor = constants2[0] + constants2[1]; 52 return; 53 } 54 </script> 55 <script id="fshaderGlobalConstArrayInitializedToConstArray" type="x-shader/x-fragment">#version 300 es 56 precision mediump float; 57 out vec4 my_FragColor; 58 59 const vec4 constants[2] = vec4[] ( 60 vec4(0.6, 0.3, 0.0, 3.0), 61 vec4(-0.6, 0.7, 0.0, -2.0) 62 ); 63 64 const vec4 constants2[2] = constants; 65 66 void main() 67 { 68 my_FragColor = constants2[0] + constants2[1]; 69 return; 70 } 71 </script> 72 <script type="text/javascript"> 73 "use strict"; 74 description("Test initializing a constant global array"); 75 76 GLSLConformanceTester.runRenderTests([ 77 { 78 fShaderId: 'fshaderGlobalConstArray', 79 fShaderSuccess: true, 80 linkSuccess: true, 81 passMsg: "Global constant array with vec4 constructors and literals in the initializer" 82 }, 83 { 84 fShaderId: 'fshaderGlobalConstArrayWithReferenceToConstArray', 85 fShaderSuccess: true, 86 linkSuccess: true, 87 passMsg: "Global constant array which indexes another global constant array in the initializer" 88 }, 89 { 90 fShaderId: 'fshaderGlobalConstArrayInitializedToConstArray', 91 fShaderSuccess: true, 92 linkSuccess: true, 93 passMsg: "Global constant array initialized to another global constant array" 94 } 95 ], 2); 96 </script> 97 </body> 98 </html>