forbidden-operators.html (3125B)
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>WebGL GLSL Conformance Tests - Unsupported variants of operators</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 <script id="fshader-array-ternary-operator" type="x-shader/x-fragment">#version 300 es 22 precision mediump float; 23 void main() 24 { 25 float a[3]; 26 float b[3]; 27 float c[3] = true ? a : b; 28 } 29 </script> 30 <script id="fshader-struct-array-ternary-operator" type="x-shader/x-fragment">#version 300 es 31 precision mediump float; 32 struct MyStruct { 33 bool a[3]; 34 }; 35 36 void main() 37 { 38 MyStruct b; 39 MyStruct c; 40 MyStruct d = true ? b : c; 41 } 42 </script> 43 <script id="fshader-void-ternary-operator" type="x-shader/x-fragment">#version 300 es 44 precision mediump float; 45 void foo() {} 46 47 void main() 48 { 49 true ? foo() : foo(); 50 } 51 </script> 52 <script id="fshader-array-sequence-operator" type="x-shader/x-fragment">#version 300 es 53 precision mediump float; 54 void main() 55 { 56 float a[3]; 57 float b[3] = (true, a); 58 } 59 </script> 60 <script id="fshader-struct-array-sequence-operator" type="x-shader/x-fragment">#version 300 es 61 precision mediump float; 62 struct MyStruct { 63 bool a[3]; 64 }; 65 66 void main() 67 { 68 MyStruct b; 69 MyStruct c = (true, b); 70 } 71 </script> 72 <script id="fshader-void-sequence-operator" type="x-shader/x-fragment">#version 300 es 73 precision mediump float; 74 void foo() {} 75 76 void main() 77 { 78 (foo(), foo()); 79 } 80 </script> 81 <script> 82 "use strict"; 83 description("Check unsupported variants of operators."); 84 85 // WebGL 2.0 spec section "Unsupported variants of GLSL ES 3.00 operators" 86 87 GLSLConformanceTester.runTests([ 88 { fShaderId: 'fshader-array-ternary-operator', 89 fShaderSuccess: false, 90 linkSuccess: false, 91 passMsg: "Using ternary operators with arrays is not allowed", 92 }, 93 { fShaderId: 'fshader-struct-array-ternary-operator', 94 fShaderSuccess: false, 95 linkSuccess: false, 96 passMsg: "Using ternary operators with structs containing arrays is not allowed", 97 }, 98 { fShaderId: 'fshader-void-ternary-operator', 99 fShaderSuccess: false, 100 linkSuccess: false, 101 passMsg: "Using ternary operators with void is not allowed", 102 }, 103 { fShaderId: 'fshader-array-sequence-operator', 104 fShaderSuccess: false, 105 linkSuccess: false, 106 passMsg: "Using sequence operators with arrays is not allowed", 107 }, 108 { fShaderId: 'fshader-struct-array-sequence-operator', 109 fShaderSuccess: false, 110 linkSuccess: false, 111 passMsg: "Using sequence operators with structs containing arrays is not allowed", 112 }, 113 { fShaderId: 'fshader-void-sequence-operator', 114 fShaderSuccess: false, 115 linkSuccess: false, 116 passMsg: "Using sequence operators with void is not allowed", 117 } 118 ], 2); 119 120 debug(""); 121 var successfullyParsed = true; 122 </script> 123 </body> 124 </html>