array-equality.html (5925B)
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 equality 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="fshaderSimple" type="x-shader/x-fragment">#version 300 es 21 precision mediump float; 22 23 out vec4 my_FragColor; 24 25 void main() { 26 // This simple test uses the ESSL1 style array initialization in order 27 // to be able to test array equality independently of array constructors. 28 int a[3]; 29 int b[3]; 30 int c[3]; 31 for (int i = 0; i < 3; ++i) { 32 a[i] = i; 33 b[i] = i; 34 c[i] = i + 1; 35 } 36 bool success = (a == b) && (a != c); 37 my_FragColor = vec4(0.0, (success ? 1.0 : 0.0), 0.0, 1.0); 38 } 39 </script> 40 <script id="fshaderArrayOfStructs" type="x-shader/x-fragment">#version 300 es 41 precision mediump float; 42 43 out vec4 my_FragColor; 44 45 struct S { 46 int foo; 47 }; 48 49 void main() { 50 // This simple test uses the ESSL1 style array initialization in order 51 // to be able to test array equality independently of array constructors. 52 S a[3]; 53 S b[3]; 54 S c[3]; 55 for (int i = 0; i < 3; ++i) { 56 a[i].foo = i; 57 b[i].foo = i; 58 c[i].foo = i + 1; 59 } 60 bool success = (a == b) && (a != c); 61 my_FragColor = vec4(0.0, (success ? 1.0 : 0.0), 0.0, 1.0); 62 } 63 </script> 64 <script id="simple-float-array-fs" type="x-shader/x-fragment">#version 300 es 65 precision mediump float; 66 67 uniform float a[3]; 68 uniform float b[3]; 69 70 out vec4 fragColor; 71 72 void main(void) { 73 fragColor = vec4(0.0, 0.0, 0.0, 1.0); 74 75 if (a == b) { 76 fragColor.g = 1.0; 77 } 78 } 79 </script> 80 <script id="simple-vec-array-fs" type="x-shader/x-fragment">#version 300 es 81 precision mediump float; 82 83 uniform vec3 a[3]; 84 uniform vec3 b[3]; 85 86 out vec4 fragColor; 87 88 void main(void) { 89 fragColor = vec4(0.0, 0.0, 0.0, 1.0); 90 91 if (a == b) { 92 fragColor.g = 1.0; 93 } 94 } 95 </script> 96 <script id="simple-mat-array-fs" type="x-shader/x-fragment">#version 300 es 97 precision mediump float; 98 99 uniform mat3 a[3]; 100 uniform mat3 b[3]; 101 102 out vec4 fragColor; 103 104 void main(void) { 105 fragColor = vec4(0.0, 0.0, 0.0, 1.0); 106 107 if (a == b) { 108 fragColor.g = 1.0; 109 } 110 } 111 </script> 112 <script type="application/javascript"> 113 "use strict"; 114 description("Comparing arrays should work."); 115 116 GLSLConformanceTester.runRenderTests([ 117 { 118 fShaderId: 'fshaderSimple', 119 fShaderSuccess: true, 120 linkSuccess: true, 121 passMsg: 'Arrays of integers' 122 }, 123 { 124 fShaderId: 'fshaderArrayOfStructs', 125 fShaderSuccess: true, 126 linkSuccess: true, 127 passMsg: 'Arrays of structs' 128 }, 129 { 130 fShaderId: "simple-float-array-fs", 131 fShaderSuccess: true, 132 linkSuccess: true, 133 render: true, 134 passMsg: "Simple float array with default values", 135 }, 136 { 137 fShaderId: "simple-float-array-fs", 138 fShaderSuccess: true, 139 linkSuccess: true, 140 render: true, 141 renderColor: [0, 0, 0, 255], 142 uniforms: [ 143 { name: 'a', functionName: 'uniform1fv', value: [1, 2, 3]}, 144 { name: 'b', functionName: 'uniform1fv', value: [1, 2, 4]}, 145 ], 146 passMsg: "Simple float array with different values", 147 }, 148 { 149 fShaderId: "simple-float-array-fs", 150 fShaderSuccess: true, 151 linkSuccess: true, 152 render: true, 153 uniforms: [ 154 { name: 'a', functionName: 'uniform1fv', value: [1, 2, 3]}, 155 { name: 'b', functionName: 'uniform1fv', value: [1, 2, 3]}, 156 ], 157 passMsg: "Simple float array with same values", 158 }, 159 { 160 fShaderId: "simple-vec-array-fs", 161 fShaderSuccess: true, 162 linkSuccess: true, 163 render: true, 164 passMsg: "Simple vec array with default values", 165 }, 166 { 167 fShaderId: "simple-vec-array-fs", 168 fShaderSuccess: true, 169 linkSuccess: true, 170 render: true, 171 renderColor: [0, 0, 0, 255], 172 uniforms: [ 173 { name: 'a', functionName: 'uniform3fv', value: [1, 2, 3, 4, 5, 6, 7, 8, 9]}, 174 { name: 'b', functionName: 'uniform3fv', value: [1, 2, 3, 4, 5, 6, 7, 8, 10]}, 175 ], 176 passMsg: "Simple vec array with different values", 177 }, 178 { 179 fShaderId: "simple-vec-array-fs", 180 fShaderSuccess: true, 181 linkSuccess: true, 182 render: true, 183 uniforms: [ 184 { name: 'a', functionName: 'uniform3fv', value: [1, 2, 3, 4, 5, 6, 7, 8, 9]}, 185 { name: 'b', functionName: 'uniform3fv', value: [1, 2, 3, 4, 5, 6, 7, 8, 9]}, 186 ], 187 passMsg: "Simple vec array with same values", 188 }, 189 { 190 // "simple-mat-array-fs" 191 fShaderId: "simple-mat-array-fs", 192 fShaderSuccess: true, 193 linkSuccess: true, 194 render: true, 195 passMsg: "Simple mat array with default values", 196 }, 197 { 198 fShaderId: "simple-mat-array-fs", 199 fShaderSuccess: true, 200 linkSuccess: true, 201 render: true, 202 renderColor: [0, 0, 0, 255], 203 uniforms: [ 204 { name: 'a', functionName: 'uniformMatrix3fv', value: [ 205 11, 12, 13, 14, 15, 16, 17, 18, 19, 206 21, 22, 23, 24, 25, 26, 27, 28, 29, 207 31, 32, 33, 34, 35, 36, 37, 38, 39, 208 ]}, 209 { name: 'b', functionName: 'uniformMatrix3fv', value: [ 210 11, 12, 13, 14, 15, 16, 17, 18, 19, 211 21, 22, 23, 24, 25, 26, 27, 28, 29, 212 31, 32, 33, 34, 35, 36, 37, 30, 39, 213 ]}, 214 ], 215 passMsg: "Simple vec array with different values", 216 }, 217 { 218 fShaderId: "simple-mat-array-fs", 219 fShaderSuccess: true, 220 linkSuccess: true, 221 render: true, 222 uniforms: [ 223 { name: 'a', functionName: 'uniformMatrix3fv', value: [ 224 11, 12, 13, 14, 15, 16, 17, 18, 19, 225 21, 22, 23, 24, 25, 26, 27, 28, 29, 226 31, 32, 33, 34, 35, 36, 37, 38, 39, 227 ]}, 228 { name: 'b', functionName: 'uniformMatrix3fv', value: [ 229 11, 12, 13, 14, 15, 16, 17, 18, 19, 230 21, 22, 23, 24, 25, 26, 27, 28, 29, 231 31, 32, 33, 34, 35, 36, 37, 38, 39, 232 ]}, 233 ], 234 passMsg: "Simple vec array with same values", 235 }, 236 ], 2); 237 </script> 238 </body> 239 </html>