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