1# ------------------------------------------------- 2# drawElements Quality Program OpenGL ES 3.2 Module 3# ------------------------------------------------- 4# 5# Copyright 2016 The Android Open Source Project 6# 7# Licensed under the Apache License, Version 2.0 (the "License"); 8# you may not use this file except in compliance with the License. 9# You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, software 14# distributed under the License is distributed on an "AS IS" BASIS, 15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16# See the License for the specific language governing permissions and 17# limitations under the License. 18 19 20group varying "Varying linkage" 21 group rules "Rules" 22 23 case type_mismatch 24 version 320 es 25 desc "Tessellation output and geometry input type mismatch" 26 expect link_fail 27 values 28 { 29 input float in0 = 1.0; 30 output float out0 = 1.0; 31 } 32 vertex "" 33 #version 320 es 34 ${VERTEX_DECLARATIONS} 35 out mediump float vtx_out; 36 void main() 37 { 38 vtx_out = in0; 39 ${VERTEX_OUTPUT} 40 } 41 "" 42 tessellation_control "" 43 #version 320 es 44 ${TESSELLATION_CONTROL_DECLARATIONS} 45 in mediump float vtx_out[]; 46 out mediump float tc_out[]; 47 void main() 48 { 49 tc_out[gl_InvocationID] = vtx_out[gl_InvocationID]; 50 ${TESSELLATION_CONTROL_OUTPUT} 51 } 52 "" 53 tessellation_evaluation "" 54 #version 320 es 55 ${TESSELLATION_EVALUATION_DECLARATIONS} 56 in mediump float tc_out[]; 57 out mediump float te_out; 58 void main() 59 { 60 te_out = tc_out[2]; 61 ${TESSELLATION_EVALUATION_OUTPUT} 62 } 63 "" 64 geometry "" 65 #version 320 es 66 ${GEOMETRY_DECLARATIONS} 67 in mediump vec2 te_out[]; 68 out mediump float geo_out; 69 void main() 70 { 71 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 72 { 73 geo_out = te_out[ndx].y; 74 gl_Position = gl_in[ndx].gl_Position; 75 EmitVertex(); 76 } 77 } 78 "" 79 fragment "" 80 #version 320 es 81 precision mediump float; 82 ${FRAGMENT_DECLARATIONS} 83 in mediump float geo_out; 84 void main() 85 { 86 out0 = geo_out; 87 ${FRAGMENT_OUTPUT} 88 } 89 "" 90 end 91 92 case different_precision 93 version 320 es 94 desc "Tessellation output and geometry input precisions are different" 95 values 96 { 97 input float in0 = 1.0; 98 output float out0 = 1.0; 99 } 100 vertex "" 101 #version 320 es 102 ${VERTEX_DECLARATIONS} 103 out mediump float vtx_out; 104 void main() 105 { 106 vtx_out = in0; 107 ${VERTEX_OUTPUT} 108 } 109 "" 110 tessellation_control "" 111 #version 320 es 112 ${TESSELLATION_CONTROL_DECLARATIONS} 113 in mediump float vtx_out[]; 114 out mediump float tc_out[]; 115 void main() 116 { 117 tc_out[gl_InvocationID] = vtx_out[gl_InvocationID]; 118 ${TESSELLATION_CONTROL_OUTPUT} 119 } 120 "" 121 tessellation_evaluation "" 122 #version 320 es 123 ${TESSELLATION_EVALUATION_DECLARATIONS} 124 in mediump float tc_out[]; 125 out mediump float te_out; 126 void main() 127 { 128 te_out = tc_out[2]; 129 ${TESSELLATION_EVALUATION_OUTPUT} 130 } 131 "" 132 geometry "" 133 #version 320 es 134 ${GEOMETRY_DECLARATIONS} 135 in highp float te_out[]; 136 out mediump float geo_out; 137 void main() 138 { 139 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 140 { 141 geo_out = te_out[ndx]; 142 gl_Position = gl_in[ndx].gl_Position; 143 EmitVertex(); 144 } 145 } 146 "" 147 fragment "" 148 #version 320 es 149 precision mediump float; 150 ${FRAGMENT_DECLARATIONS} 151 in mediump float geo_out; 152 void main() 153 { 154 out0 = geo_out; 155 ${FRAGMENT_OUTPUT} 156 } 157 "" 158 end 159 160 case no_output_declaration 161 version 320 es 162 desc "Geometry input has no matching output" 163 expect link_fail 164 values 165 { 166 input float in0 = 1.0; 167 output float out0 = 1.0; 168 } 169 vertex "" 170 #version 320 es 171 ${VERTEX_DECLARATIONS} 172 out mediump float vtx_out; 173 void main() 174 { 175 vtx_out = in0; 176 ${VERTEX_OUTPUT} 177 } 178 "" 179 tessellation_control "" 180 #version 320 es 181 ${TESSELLATION_CONTROL_DECLARATIONS} 182 in mediump float vtx_out[]; 183 out mediump float tc_out[]; 184 void main() 185 { 186 tc_out[gl_InvocationID] = vtx_out[gl_InvocationID]; 187 ${TESSELLATION_CONTROL_OUTPUT} 188 } 189 "" 190 tessellation_evaluation "" 191 #version 320 es 192 ${TESSELLATION_EVALUATION_DECLARATIONS} 193 in mediump float tc_out[]; 194 out mediump float te_out; 195 void main() 196 { 197 te_out = tc_out[2]; 198 ${TESSELLATION_EVALUATION_OUTPUT} 199 } 200 "" 201 geometry "" 202 #version 320 es 203 ${GEOMETRY_DECLARATIONS} 204 in mediump float te_out[]; 205 in mediump float te_out_nonexistent[]; 206 out mediump float geo_out; 207 void main() 208 { 209 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 210 { 211 geo_out = te_out[ndx] + te_out_nonexistent[ndx]; 212 gl_Position = gl_in[ndx].gl_Position; 213 EmitVertex(); 214 } 215 } 216 "" 217 fragment "" 218 #version 320 es 219 precision mediump float; 220 ${FRAGMENT_DECLARATIONS} 221 in mediump float geo_out; 222 void main() 223 { 224 out0 = geo_out; 225 ${FRAGMENT_OUTPUT} 226 } 227 "" 228 end 229 230 case superfluous_output_declaration 231 version 320 es 232 desc "Tessellation shader output is never used" 233 values 234 { 235 input float in0 = 1.0; 236 output float out0 = 1.0; 237 } 238 vertex "" 239 #version 320 es 240 ${VERTEX_DECLARATIONS} 241 out mediump float vtx_out; 242 void main() 243 { 244 vtx_out = in0; 245 ${VERTEX_OUTPUT} 246 } 247 "" 248 tessellation_control "" 249 #version 320 es 250 ${TESSELLATION_CONTROL_DECLARATIONS} 251 in mediump float vtx_out[]; 252 out mediump float tc_out[]; 253 void main() 254 { 255 tc_out[gl_InvocationID] = vtx_out[gl_InvocationID]; 256 ${TESSELLATION_CONTROL_OUTPUT} 257 } 258 "" 259 tessellation_evaluation "" 260 #version 320 es 261 ${TESSELLATION_EVALUATION_DECLARATIONS} 262 in mediump float tc_out[]; 263 out mediump float te_out; 264 out mediump float te_out_nonexistent; 265 void main() 266 { 267 te_out = tc_out[2]; 268 te_out_nonexistent = tc_out[0]; 269 ${TESSELLATION_EVALUATION_OUTPUT} 270 } 271 "" 272 geometry "" 273 #version 320 es 274 ${GEOMETRY_DECLARATIONS} 275 in mediump float te_out[]; 276 out mediump float geo_out; 277 void main() 278 { 279 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 280 { 281 geo_out = te_out[ndx]; 282 gl_Position = gl_in[ndx].gl_Position; 283 EmitVertex(); 284 } 285 } 286 "" 287 fragment "" 288 #version 320 es 289 precision mediump float; 290 ${FRAGMENT_DECLARATIONS} 291 in mediump float geo_out; 292 void main() 293 { 294 out0 = geo_out; 295 ${FRAGMENT_OUTPUT} 296 } 297 "" 298 end 299 300 case vertex_geometry_same_varying_name_1 301 version 320 es 302 desc "Vertex output and geometry input share the same name" 303 values 304 { 305 input float in0 = 1.0; 306 output float out0 = 1.0; 307 } 308 vertex "" 309 #version 320 es 310 ${VERTEX_DECLARATIONS} 311 out mediump float sharedVaringName; 312 void main() 313 { 314 sharedVaringName = in0; 315 ${VERTEX_OUTPUT} 316 } 317 "" 318 tessellation_control "" 319 #version 320 es 320 ${TESSELLATION_CONTROL_DECLARATIONS} 321 in mediump float sharedVaringName[]; 322 out mediump float tc_out[]; 323 void main() 324 { 325 tc_out[gl_InvocationID] = sharedVaringName[gl_InvocationID]; 326 ${TESSELLATION_CONTROL_OUTPUT} 327 } 328 "" 329 tessellation_evaluation "" 330 #version 320 es 331 ${TESSELLATION_EVALUATION_DECLARATIONS} 332 in mediump float tc_out[]; 333 out mediump float sharedVaringName; 334 void main() 335 { 336 sharedVaringName = tc_out[2]; 337 ${TESSELLATION_EVALUATION_OUTPUT} 338 } 339 "" 340 geometry "" 341 #version 320 es 342 ${GEOMETRY_DECLARATIONS} 343 in mediump float sharedVaringName[]; 344 out mediump float geo_out; 345 void main() 346 { 347 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 348 { 349 geo_out = sharedVaringName[ndx]; 350 gl_Position = gl_in[ndx].gl_Position; 351 EmitVertex(); 352 } 353 } 354 "" 355 fragment "" 356 #version 320 es 357 precision mediump float; 358 ${FRAGMENT_DECLARATIONS} 359 in mediump float geo_out; 360 void main() 361 { 362 out0 = geo_out; 363 ${FRAGMENT_OUTPUT} 364 } 365 "" 366 end 367 368 case vertex_geometry_same_varying_name_2 369 version 320 es 370 desc "Vertex output and geometry input share the same name" 371 values 372 { 373 input vec2 in0 = vec2(1.0, 1.0); 374 output float out0 = 1.0; 375 } 376 vertex "" 377 #version 320 es 378 ${VERTEX_DECLARATIONS} 379 out mediump vec2 sharedVaringName; 380 void main() 381 { 382 sharedVaringName = in0; 383 ${VERTEX_OUTPUT} 384 } 385 "" 386 tessellation_control "" 387 #version 320 es 388 ${TESSELLATION_CONTROL_DECLARATIONS} 389 in mediump vec2 sharedVaringName[]; 390 out mediump float tc_out[]; 391 void main() 392 { 393 tc_out[gl_InvocationID] = 2.0 * sharedVaringName[gl_InvocationID].x - sharedVaringName[gl_InvocationID].y; 394 ${TESSELLATION_CONTROL_OUTPUT} 395 } 396 "" 397 tessellation_evaluation "" 398 #version 320 es 399 ${TESSELLATION_EVALUATION_DECLARATIONS} 400 in mediump float tc_out[]; 401 out mediump float sharedVaringName; 402 void main() 403 { 404 sharedVaringName = tc_out[2]; 405 ${TESSELLATION_EVALUATION_OUTPUT} 406 } 407 "" 408 geometry "" 409 #version 320 es 410 ${GEOMETRY_DECLARATIONS} 411 in mediump float sharedVaringName[]; 412 out mediump float geo_out; 413 void main() 414 { 415 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 416 { 417 geo_out = sharedVaringName[ndx]; 418 gl_Position = gl_in[ndx].gl_Position; 419 EmitVertex(); 420 } 421 } 422 "" 423 fragment "" 424 #version 320 es 425 precision mediump float; 426 ${FRAGMENT_DECLARATIONS} 427 in mediump float geo_out; 428 void main() 429 { 430 out0 = geo_out; 431 ${FRAGMENT_OUTPUT} 432 } 433 "" 434 end 435 436 case io_block 437 version 320 es 438 desc "Use of io block between tessellation and geometry shaders" 439 values 440 { 441 input float in0 = 1.0; 442 output float out0 = 1.0; 443 } 444 vertex "" 445 #version 320 es 446 ${VERTEX_DECLARATIONS} 447 out mediump float vtx_out; 448 void main() 449 { 450 vtx_out = in0; 451 ${VERTEX_OUTPUT} 452 } 453 "" 454 tessellation_control "" 455 #version 320 es 456 ${TESSELLATION_CONTROL_DECLARATIONS} 457 in mediump float vtx_out[]; 458 out mediump float tc_out[]; 459 void main() 460 { 461 tc_out[gl_InvocationID] = vtx_out[gl_InvocationID]; 462 ${TESSELLATION_CONTROL_OUTPUT} 463 } 464 "" 465 tessellation_evaluation "" 466 #version 320 es 467 ${TESSELLATION_EVALUATION_DECLARATIONS} 468 in mediump float tc_out[]; 469 out IOBlockName { mediump float val; } instanceName; 470 void main() 471 { 472 instanceName.val = tc_out[2]; 473 ${TESSELLATION_EVALUATION_OUTPUT} 474 } 475 "" 476 geometry "" 477 #version 320 es 478 ${GEOMETRY_DECLARATIONS} 479 in IOBlockName { mediump float val; } instanceName[]; 480 out mediump float geo_out; 481 void main() 482 { 483 geo_out = instanceName[0].val; 484 gl_Position = gl_in[0].gl_Position; 485 EmitVertex(); 486 487 geo_out = instanceName[1].val; 488 gl_Position = gl_in[1].gl_Position; 489 EmitVertex(); 490 491 geo_out = instanceName[2].val; 492 gl_Position = gl_in[2].gl_Position; 493 EmitVertex(); 494 } 495 "" 496 fragment "" 497 #version 320 es 498 precision mediump float; 499 ${FRAGMENT_DECLARATIONS} 500 in mediump float geo_out; 501 void main() 502 { 503 out0 = geo_out; 504 ${FRAGMENT_OUTPUT} 505 } 506 "" 507 end 508 509 case array_in_io_block 510 version 320 es 511 desc "Float array in a io block between tessellation and geometry shaders" 512 values 513 { 514 input float in0 = 1.0; 515 output float out0 = 1.0; 516 } 517 vertex "" 518 #version 320 es 519 ${VERTEX_DECLARATIONS} 520 out mediump float vtx_out; 521 void main() 522 { 523 vtx_out = in0; 524 ${VERTEX_OUTPUT} 525 } 526 "" 527 tessellation_control "" 528 #version 320 es 529 ${TESSELLATION_CONTROL_DECLARATIONS} 530 in mediump float vtx_out[]; 531 out mediump float tc_out[]; 532 void main() 533 { 534 tc_out[gl_InvocationID] = vtx_out[gl_InvocationID]; 535 ${TESSELLATION_CONTROL_OUTPUT} 536 } 537 "" 538 tessellation_evaluation "" 539 #version 320 es 540 ${TESSELLATION_EVALUATION_DECLARATIONS} 541 in mediump float tc_out[]; 542 out IOBlockName { mediump float val[2]; } instanceName; 543 void main() 544 { 545 instanceName.val[0] = tc_out[2] + 1.0; 546 instanceName.val[1] = -1.0; 547 ${TESSELLATION_EVALUATION_OUTPUT} 548 } 549 "" 550 geometry "" 551 #version 320 es 552 ${GEOMETRY_DECLARATIONS} 553 in IOBlockName { mediump float val[2]; } instanceName[]; 554 out mediump float geo_out; 555 void main() 556 { 557 geo_out = instanceName[0].val[0] + instanceName[0].val[1]; 558 gl_Position = gl_in[0].gl_Position; 559 EmitVertex(); 560 561 geo_out = instanceName[1].val[0] + instanceName[1].val[1]; 562 gl_Position = gl_in[1].gl_Position; 563 EmitVertex(); 564 565 geo_out = instanceName[2].val[0] + instanceName[2].val[1]; 566 gl_Position = gl_in[2].gl_Position; 567 EmitVertex(); 568 } 569 "" 570 fragment "" 571 #version 320 es 572 precision mediump float; 573 ${FRAGMENT_DECLARATIONS} 574 in mediump float geo_out; 575 void main() 576 { 577 out0 = geo_out; 578 ${FRAGMENT_OUTPUT} 579 } 580 "" 581 end 582 end 583 584 import "linkage_tessellation_geometry_varying_types.test" 585end 586 587group uniform "Uniform linkage" 588 group rules "Rules" 589 case type_mismatch_1 590 version 320 es 591 desc "Uniform type mismatch" 592 expect link_fail 593 vertex "" 594 #version 320 es 595 ${VERTEX_DECLARATIONS} 596 void main() 597 { 598 ${VERTEX_OUTPUT} 599 } 600 "" 601 tessellation_control "" 602 #version 320 es 603 ${TESSELLATION_CONTROL_DECLARATIONS} 604 void main() 605 { 606 ${TESSELLATION_CONTROL_OUTPUT} 607 } 608 "" 609 tessellation_evaluation "" 610 #version 320 es 611 ${TESSELLATION_EVALUATION_DECLARATIONS} 612 uniform mediump float u_value; 613 out mediump float te_out; 614 void main() 615 { 616 te_out = u_value; 617 ${TESSELLATION_EVALUATION_OUTPUT} 618 } 619 "" 620 geometry "" 621 #version 320 es 622 ${GEOMETRY_DECLARATIONS} 623 uniform mediump vec2 u_value; 624 in mediump float te_out[]; 625 out mediump float geo_out; 626 void main() 627 { 628 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 629 { 630 geo_out = te_out[ndx] + u_value.y; 631 gl_Position = gl_in[ndx].gl_Position; 632 EmitVertex(); 633 } 634 } 635 "" 636 fragment "" 637 #version 320 es 638 precision mediump float; 639 ${FRAGMENT_DECLARATIONS} 640 in mediump float geo_out; 641 void main() 642 { 643 ${FRAG_COLOR} = vec4(geo_out); 644 } 645 "" 646 end 647 648 case precision_mismatch_1 649 version 320 es 650 desc "Uniform precision mismatch" 651 expect link_fail 652 vertex "" 653 #version 320 es 654 ${VERTEX_DECLARATIONS} 655 void main() 656 { 657 ${VERTEX_OUTPUT} 658 } 659 "" 660 tessellation_control "" 661 #version 320 es 662 ${TESSELLATION_CONTROL_DECLARATIONS} 663 void main() 664 { 665 ${TESSELLATION_CONTROL_OUTPUT} 666 } 667 "" 668 tessellation_evaluation "" 669 #version 320 es 670 ${TESSELLATION_EVALUATION_DECLARATIONS} 671 uniform mediump float u_value; 672 out mediump float te_out; 673 void main() 674 { 675 te_out = u_value; 676 ${TESSELLATION_EVALUATION_OUTPUT} 677 } 678 "" 679 geometry "" 680 #version 320 es 681 ${GEOMETRY_DECLARATIONS} 682 uniform highp float u_value; 683 in mediump float te_out[]; 684 out mediump float geo_out; 685 void main() 686 { 687 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 688 { 689 geo_out = te_out[ndx] + u_value; 690 gl_Position = gl_in[ndx].gl_Position; 691 EmitVertex(); 692 } 693 } 694 "" 695 fragment "" 696 #version 320 es 697 precision mediump float; 698 ${FRAGMENT_DECLARATIONS} 699 in mediump float geo_out; 700 void main() 701 { 702 ${FRAG_COLOR} = vec4(geo_out); 703 } 704 "" 705 end 706 707 case struct_partial_usage 708 version 320 es 709 desc "Uniform precision mismatch" 710 values 711 { 712 uniform float u_value.teVal = 1.0; 713 uniform float u_value.geoVal = 2.0; 714 output float out0 = 5.0; 715 } 716 vertex "" 717 #version 320 es 718 ${VERTEX_DECLARATIONS} 719 void main() 720 { 721 ${VERTEX_OUTPUT} 722 } 723 "" 724 tessellation_control "" 725 #version 320 es 726 ${TESSELLATION_CONTROL_DECLARATIONS} 727 void main() 728 { 729 ${TESSELLATION_CONTROL_OUTPUT} 730 } 731 "" 732 tessellation_evaluation "" 733 #version 320 es 734 ${TESSELLATION_EVALUATION_DECLARATIONS} 735 struct S 736 { 737 mediump float teVal; 738 mediump float geoVal; 739 }; 740 uniform S u_value; 741 out mediump float te_out; 742 void main() 743 { 744 te_out = u_value.teVal; 745 ${TESSELLATION_EVALUATION_OUTPUT} 746 } 747 "" 748 geometry "" 749 #version 320 es 750 ${GEOMETRY_DECLARATIONS} 751 struct S 752 { 753 mediump float teVal; 754 mediump float geoVal; 755 }; 756 uniform S u_value; 757 in mediump float te_out[]; 758 out mediump float geo_out; 759 void main() 760 { 761 for (int ndx = 0; ndx < gl_in.length(); ++ndx) 762 { 763 geo_out = te_out[ndx] + 2.0 * u_value.geoVal; 764 gl_Position = gl_in[ndx].gl_Position; 765 EmitVertex(); 766 } 767 } 768 "" 769 fragment "" 770 #version 320 es 771 precision mediump float; 772 ${FRAGMENT_DECLARATIONS} 773 in mediump float geo_out; 774 void main() 775 { 776 out0 = geo_out; 777 ${FRAGMENT_OUTPUT} 778 } 779 "" 780 end 781 end 782end 783