array-assign-constructor.html (2262B)
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>GLSL array constructor assignment 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="fshaderNonConstantConstructorParameter" type="x-shader/x-fragment">#version 300 es 21 precision mediump float; 22 uniform int u; 23 24 out vec4 my_FragColor; 25 26 void main() { 27 // Test assigning a constructor result as opposed to initializing with a 28 // constructor result. 29 int a[3]; 30 a = int[3](0, 1, u); 31 bool fail = false; 32 for (int i = 0; i < 2; ++i) { 33 if (a[i] != i) { 34 fail = true; 35 } 36 } 37 if (a[2] != u) { 38 fail = true; 39 } 40 my_FragColor = vec4(0.0, (fail ? 0.0 : 1.0), 0.0, 1.0); 41 } 42 </script> 43 <script id="fshaderArrayOfStructs" type="x-shader/x-fragment">#version 300 es 44 precision mediump float; 45 46 out vec4 my_FragColor; 47 48 struct S { 49 int foo; 50 }; 51 52 void main() { 53 // Test assigning a constructor result as opposed to initializing with a 54 // constructor result. 55 S a[3]; 56 a = S[3](S(0), S(1), S(2)); 57 bool fail = false; 58 for (int i = 0; i < 3; ++i) { 59 if (a[i].foo != i) { 60 fail = true; 61 } 62 } 63 my_FragColor = vec4(0.0, (fail ? 0.0 : 1.0), 0.0, 1.0); 64 } 65 </script> 66 <script type="application/javascript"> 67 "use strict"; 68 description("Assigning return values of array constructors should work."); 69 debug(""); 70 71 // This test only covers cases which are not covered by the dEQP tests. 72 73 GLSLConformanceTester.runRenderTests([ 74 { 75 fShaderId: 'fshaderNonConstantConstructorParameter', 76 fShaderSuccess: true, 77 linkSuccess: true, 78 passMsg: 'Assigning a constructor result', 79 uniforms: [{name: "u", functionName: "uniform1i", value: 5}] 80 }, 81 { 82 fShaderId: 'fshaderArrayOfStructs', 83 fShaderSuccess: true, 84 linkSuccess: true, 85 passMsg: 'Assigning an array of structs' 86 } 87 ], 2); 88 </script> 89 </body> 90 </html>