1group if "If Statements" 2 3 case single_statement 4 values 5 { 6 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 7 output float out0 = [ 0.0 | 1.0 | 1.0 ]; 8 } 9 10 both "" 11 precision mediump float; 12 ${DECLARATIONS} 13 void main() 14 { 15 out0 = 0.0; 16 if (in0 >= 1.0) 17 out0 = 1.0; 18 ${OUTPUT} 19 } 20 "" 21 end 22 23 case compound_statement 24 values 25 { 26 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 27 output float out0 = [ 0.0 | 1.0 | 1.0 ]; 28 output float out1 = [ 1.0 | 0.0 | 0.0 ]; 29 } 30 31 both "" 32 precision mediump float; 33 ${DECLARATIONS} 34 void main() 35 { 36 out0 = 0.0; 37 out1 = 1.0; 38 if (in0 >= 1.0) 39 { 40 out0 = 1.0; 41 out1 = 0.0; 42 } 43 ${OUTPUT} 44 } 45 "" 46 end 47 48 case sequence_statements 49 values 50 { 51 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 52 output float out0 = [ 0.0 | 1.0 | 1.0 ]; 53 output float out1 = [ 1.0 | 0.0 | 0.0 ]; 54 } 55 56 both "" 57 precision mediump float; 58 ${DECLARATIONS} 59 void main() 60 { 61 out0 = 0.0; 62 out1 = 1.0; 63 if (in0 >= 1.0) 64 out0 = 1.0, out1 = 0.0; 65 ${OUTPUT} 66 } 67 "" 68 end 69 70 case sequence_condition 71 values 72 { 73 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 74 output float out0 = [ 0.0 | 1.0 | 1.0 ]; 75 output float out1 = [ 1.0 | 0.0 | 0.0 ]; 76 } 77 78 both "" 79 precision mediump float; 80 ${DECLARATIONS} 81 void main() 82 { 83 out0 = 0.0; 84 out1 = 1.0; 85 if (false, in0 >= 1.0) 86 out0 = 1.0, out1 = 0.0; 87 ${OUTPUT} 88 } 89 "" 90 end 91 92 case complex_condition 93 values 94 { 95 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 96 output float out0 = [ 0.0 | 1.0 | 1.0 ]; 97 output float out1 = [ 1.0 | 0.0 | 0.0 ]; 98 } 99 100 both "" 101 precision mediump float; 102 ${DECLARATIONS} 103 void main() 104 { 105 out0 = 0.0; 106 out1 = 1.0; 107 if (false || (in0 >= 1.0) && (in0 - 2.0*in0 < 0.0)) 108 out0 = 1.0, out1 = 0.0; 109 ${OUTPUT} 110 } 111 "" 112 end 113 114 case if_else 115 values 116 { 117 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 118 output float out0 = [ 0.0 | 1.0 | 1.0 ]; 119 } 120 121 both "" 122 precision mediump float; 123 ${DECLARATIONS} 124 void main() 125 { 126 if (in0 >= 1.0) 127 out0 = 1.0; 128 else 129 out0 = 0.0; 130 ${OUTPUT} 131 } 132 "" 133 end 134 135 case if_elseif 136 values 137 { 138 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 139 output float out0 = [ 0.0 | 1.0 | 2.0 ]; 140 } 141 142 both "" 143 precision mediump float; 144 ${DECLARATIONS} 145 void main() 146 { 147 out0 = 0.0; 148 if (in0 >= 2.0) 149 out0 = 2.0; 150 else if (in0 >= 1.0) 151 out0 = 1.0; 152 ${OUTPUT} 153 } 154 "" 155 end 156 157 case if_elseif_else 158 values 159 { 160 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 161 output float out0 = [ 0.0 | 1.0 | 2.0 ]; 162 } 163 164 both "" 165 precision mediump float; 166 ${DECLARATIONS} 167 void main() 168 { 169 if (in0 >= 2.0) 170 out0 = 2.0; 171 else if (in0 >= 1.0) 172 out0 = 1.0; 173 else 174 out0 = 0.0; 175 ${OUTPUT} 176 } 177 "" 178 end 179 180 case mixed_if_elseif_else 181 values 182 { 183 input float in0 = [ 0.0 | 1.0 | 2.0 ]; 184 output float out0 = [ 0.0 | 1.0 | 2.0 ]; 185 } 186 187 both "" 188 precision mediump float; 189 ${DECLARATIONS} 190 void main() 191 { 192 if (in0 >= 2.0) 193 { 194 out0 = 2.0; 195 } 196 else if (in0 >= 1.0) 197 out0 = 2.0, out0 = 1.0; 198 else 199 out0 = 0.0; 200 ${OUTPUT} 201 } 202 "" 203 end 204 205 case constant_conditional_assignment_to_matrix 206 vertex "" 207 // This variant doesn't provoke the crash seen in the versions below. 208 ${VERTEX_DECLARATIONS} 209 varying mediump float FragVarying; 210 const float in0 = 0.0; 211 void main() 212 { 213 mat2 projectionMatrix = mat2(0.0, 0.0, 0.0, 0.0); 214 if (in0 == 1.0) 215 { 216 projectionMatrix[0][0] = 1.0; 217 } 218 219 FragVarying = 1.0; 220 gl_Position = dEQP_Position + vec4(projectionMatrix[1][0], 0.0, 0.0, 0.0); 221 } 222 "" 223 fragment "" 224 precision mediump float; 225 varying float FragVarying; 226 void main() 227 { 228 gl_FragColor = vec4(FragVarying, 1.0, 1.0, 1.0); 229 } 230 "" 231 end 232 233 case input_conditional_assignment_to_matrix 234 values 235 { 236 input float in0 = [ 0.0 ]; 237 } 238 vertex "" 239 ${VERTEX_DECLARATIONS} 240 varying mediump float FragVarying; // Necessary to reproduce. 241 void main() 242 { 243 // Crashes with mat4 as well. Does not crash with vectors. 244 mat2 projectionMatrix = mat2(0.0, 0.0, 0.0, 0.0); 245 // Testing a non-constant variable is necessary. 246 if (in0 == 1.0) 247 { 248 // Using the matrix variable appears necessary. 249 projectionMatrix[0][0] = 1.0; 250 } 251 252 FragVarying = 1.0; 253 // Referencing the matrix is necessary though clearly the compiler 254 // doesn't realize the assignment is useless. 255 gl_Position = dEQP_Position + vec4(projectionMatrix[1][0], 0.0, 0.0, 0.0); 256 } 257 "" 258 fragment "" 259 precision mediump float; 260 varying float FragVarying; 261 void main() 262 { 263 gl_FragColor = vec4(FragVarying, 1.0, 1.0, 1.0); 264 } 265 "" 266 end 267 268 case uniform_conditional_assignment_to_matrix 269 values 270 { 271 uniform float uni0 = [ 0.0 ]; 272 } 273 vertex "" 274 ${VERTEX_DECLARATIONS} 275 varying mediump float FragVarying; // Necessary to reproduce. 276 void main() 277 { 278 // Crashes with mat4 as well. Does not crash with vectors. 279 mat2 projectionMatrix = mat2(0.0, 0.0, 0.0, 0.0); 280 // Testing a non-constant variable is necessary. 281 if (uni0 == 1.0) 282 { 283 // Using the matrix variable appears necessary. 284 projectionMatrix[0][0] = 1.0; 285 } 286 287 FragVarying = 1.0; 288 // Referencing the matrix is necessary though clearly the compiler 289 // doesn't realize the assignment is useless. 290 gl_Position = dEQP_Position + vec4(projectionMatrix[1][0], 0.0, 0.0, 0.0); 291 } 292 "" 293 fragment "" 294 precision mediump float; 295 varying float FragVarying; 296 void main() 297 { 298 gl_FragColor = vec4(FragVarying, 1.0, 1.0, 1.0); 299 } 300 "" 301 end 302 303end # if 304 305group invalid_if "Invalid If Conditionals" 306 307 case missing_parenthesis 308 expect compile_fail 309 both "" 310 precision mediump float; 311 void main() 312 { 313 if true 314 ${POSITION_FRAG_COLOR} = vec4(1.0); 315 } 316 "" 317 end 318 319 case unclosed_parenthesis 320 expect compile_fail 321 both "" 322 precision mediump float; 323 void main() 324 { 325 if (true 326 ${POSITION_FRAG_COLOR} = vec4(1.0); 327 } 328 "" 329 end 330 331 case int_condition 332 expect compile_fail 333 both "" 334 precision mediump float; 335 void main() 336 { 337 if (5) 338 ${POSITION_FRAG_COLOR} = vec4(1.0); 339 } 340 "" 341 end 342 343 case int_zero_condition 344 expect compile_fail 345 both "" 346 precision mediump float; 347 void main() 348 { 349 if (0) 350 ${POSITION_FRAG_COLOR} = vec4(1.0); 351 } 352 "" 353 end 354 355 case int_one_condition 356 expect compile_fail 357 both "" 358 precision mediump float; 359 void main() 360 { 361 if (1) 362 ${POSITION_FRAG_COLOR} = vec4(1.0); 363 } 364 "" 365 end 366 367 case int_uniform_condition 368 expect compile_fail 369 370 both "" 371 precision mediump float; 372 precision mediump int; 373 uniform int u0; 374 void main() 375 { 376 if (u0) 377 ${POSITION_FRAG_COLOR} = vec4(1.0); 378 } 379 "" 380 end 381 382 case float_condition 383 expect compile_fail 384 both "" 385 precision mediump float; 386 void main() 387 { 388 if (5.0) 389 ${POSITION_FRAG_COLOR} = vec4(1.0); 390 } 391 "" 392 end 393 394 case float_zero_condition 395 expect compile_fail 396 both "" 397 precision mediump float; 398 void main() 399 { 400 if (0.0) 401 ${POSITION_FRAG_COLOR} = vec4(1.0); 402 } 403 "" 404 end 405 406 case float_one_condition 407 expect compile_fail 408 both "" 409 precision mediump float; 410 void main() 411 { 412 if (1.0) 413 ${POSITION_FRAG_COLOR} = vec4(1.0); 414 } 415 "" 416 end 417 418 case sampler_condition 419 expect compile_fail 420 both "" 421 precision mediump float; 422 uniform sampler2D s0; 423 void main() 424 { 425 if (s0) 426 ${POSITION_FRAG_COLOR} = vec4(1.0); 427 } 428 "" 429 end 430 431end # invalid_if 432