1 # -*- coding: utf-8 -*- 2 3 #------------------------------------------------------------------------- 4 # drawElements Quality Program utilities 5 # -------------------------------------- 6 # 7 # Copyright 2015 The Android Open Source Project 8 # 9 # Licensed under the Apache License, Version 2.0 (the "License"); 10 # you may not use this file except in compliance with the License. 11 # You may obtain a copy of the License at 12 # 13 # http://www.apache.org/licenses/LICENSE-2.0 14 # 15 # Unless required by applicable law or agreed to in writing, software 16 # distributed under the License is distributed on an "AS IS" BASIS, 17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 # See the License for the specific language governing permissions and 19 # limitations under the License. 20 # 21 #------------------------------------------------------------------------- 22 23 from genutil import * 24 25 allCases = [] 26 27 VERTEX = "VERTEX" 28 FRAGMENT = "FRAGMENT" 29 30 CASE_FRAGMENT_SHADER_TEMPLATE = """ 31 case ${{NAME}} 32 version 310 es 33 expect ${{EXPECT}} 34 35 vertex "" 36 #version 310 es 37 precision highp float; 38 39 in vec4 a_pos; 40 41 void main() 42 { 43 gl_Position = a_pos; 44 } 45 "" 46 47 fragment "" 48 ${{SOURCE}} 49 "" 50 end"""[1:] 51 52 CASE_VERTEX_SHADER_TEMPLATE = """ 53 case ${{NAME}} 54 version 310 es 55 expect ${{EXPECT}} 56 57 vertex "" 58 ${{SOURCE}} 59 "" 60 61 fragment "" 62 #version 310 es 63 precision highp float; 64 65 layout(location=0) out vec4 o_color; 66 67 void main() 68 { 69 o_color = vec4(1.0); 70 } 71 "" 72 end"""[1:] 73 74 class UniformBlockCase(ShaderCase): 75 def __init__(self, name, shaderType, source, valid): 76 self.name = name 77 self.shaderType = shaderType 78 self.source = source 79 self.valid = valid 80 81 def __str__(self): 82 if self.shaderType == FRAGMENT: 83 sourceParams = { 84 "OUTPUT": "o_color", 85 "OUTPUT_DECLARATION": "layout(location=0) out vec4 o_color;" 86 } 87 88 source = fillTemplate(self.source, sourceParams) 89 90 testCaseParams = { 91 "NAME": self.name, 92 "SOURCE": source, 93 "EXPECT": ("build_successful" if self.valid else "compile_fail") 94 } 95 96 return fillTemplate(CASE_FRAGMENT_SHADER_TEMPLATE, testCaseParams) 97 elif self.shaderType == VERTEX: 98 sourceParams = { 99 "OUTPUT": "gl_Position", 100 "OUTPUT_DECLARATION": "" 101 } 102 103 source = fillTemplate(self.source, sourceParams) 104 105 testCaseParams = { 106 "NAME": self.name, 107 "SOURCE": source, 108 "EXPECT": ("build_successful" if self.valid else "compile_fail") 109 } 110 111 return fillTemplate(CASE_VERTEX_SHADER_TEMPLATE, testCaseParams) 112 113 assert False 114 115 def createCases(name, source, valid): 116 return [UniformBlockCase(name + "_vertex", VERTEX, source, valid), 117 UniformBlockCase(name + "_fragment", FRAGMENT, source, valid)] 118 119 repeatShaderTemplate = """ 120 #version 310 es 121 precision highp float; 122 123 ${{OUTPUT_DECLARATION}} 124 125 uniform UniformBlock 126 { 127 uniform vec4 uniformMember; 128 } uniformBlock; 129 130 void main() 131 { 132 ${{OUTPUT}} = uniformBlock.uniformMember; 133 }"""[1:] 134 135 layoutQualifierShaderTemplate = """ 136 #version 310 es 137 precision highp float; 138 139 ${{OUTPUT_DECLARATION}} 140 141 layout(%s) uniform UniformBlock 142 { 143 vec4 uniformMember; 144 } uniformBlock; 145 146 void main() 147 { 148 ${{OUTPUT}} = uniformBlock.uniformMember; 149 }"""[1:] 150 151 layoutGlobalQualifierShaderTemplate = """ 152 #version 310 es 153 precision highp float; 154 155 layout(%s) uniform; 156 157 ${{OUTPUT_DECLARATION}} 158 159 uniform UniformBlock 160 { 161 vec4 uniformMember; 162 } uniformBlock; 163 164 void main() 165 { 166 ${{OUTPUT}} = uniformBlock.uniformMember; 167 }"""[1:] 168 169 layoutMemberQualifierShaderTemplate = """ 170 #version 310 es 171 precision highp float; 172 173 ${{OUTPUT_DECLARATION}} 174 175 uniform UniformBlock 176 { 177 layout(%s) mat4 uniformMember; 178 } uniformBlock; 179 180 void main() 181 { 182 ${{OUTPUT}} = uniformBlock.uniformMember[0]; 183 }"""[1:] 184 185 layoutMemberVec4QualifierShaderTemplate = """ 186 #version 310 es 187 precision highp float; 188 189 ${{OUTPUT_DECLARATION}} 190 191 uniform UniformBlock 192 { 193 layout(%s) vec4 uniformMember; 194 } uniformBlock; 195 196 void main() 197 { 198 ${{OUTPUT}} = uniformBlock.uniformMember; 199 }"""[1:] 200 201 noInstanceNameShaderTemplate = """ 202 #version 310 es 203 precision highp float; 204 205 ${{OUTPUT_DECLARATION}} 206 207 uniform UniformBlock 208 { 209 vec4 uniformMember; 210 }; 211 212 void main() 213 { 214 ${{OUTPUT}} = uniformMember; 215 }"""[1:] 216 217 sameVariableAndInstanceNameShaderTemplate = """ 218 #version 310 es 219 precision highp float; 220 221 ${{OUTPUT_DECLARATION}} 222 223 uniform UniformBlock 224 { 225 vec4 uniformMember; 226 } uniformBlock; 227 228 void main() 229 { 230 vec4 uniformBlock = vec4(0.0); 231 ${{OUTPUT}} = uniformBlock; 232 }"""[1:] 233 234 sameVariableAndBlockNameShaderTemplate = """ 235 #version 310 es 236 precision highp float; 237 238 ${{OUTPUT_DECLARATION}} 239 240 uniform UniformBlock 241 { 242 vec4 uniformMember; 243 } uniformBlock; 244 245 void main() 246 { 247 vec4 UniformBlock = vec4(0.0); 248 ${{OUTPUT}} = UniformBlock + uniformBlock.uniformMember; 249 }"""[1:] 250 251 repeatedBlockShaderTemplate = """ 252 #version 310 es 253 precision highp float; 254 255 ${{OUTPUT_DECLARATION}} 256 257 uniform UniformBlock 258 { 259 vec4 uniformMember; 260 } uniformBlockA; 261 262 uniform UniformBlock 263 { 264 vec4 uniformMember; 265 } uniformBlockB; 266 267 void main() 268 { 269 ${{OUTPUT}} = uniformBlockA.uniformMember + uniformBlockB.uniformMember; 270 }"""[1:] 271 272 repeatedBlockNoInstanceNameShaderTemplate = """ 273 #version 310 es 274 precision highp float; 275 276 ${{OUTPUT_DECLARATION}} 277 278 uniform UniformBlock 279 { 280 vec4 uniformMember; 281 } uniformBlock; 282 283 uniform UniformBlock 284 { 285 vec4 uniformMember; 286 }; 287 288 void main() 289 { 290 ${{OUTPUT}} = uniformBlock.uniformMember + uniformMember; 291 }"""[1:] 292 293 structMemberShaderTemplate = """ 294 #version 310 es 295 precision highp float; 296 297 ${{OUTPUT_DECLARATION}} 298 299 struct Struct 300 { 301 vec4 uniformMember; 302 }; 303 304 uniform UniformBlock 305 { 306 Struct st; 307 } uniformBlock; 308 309 void main() 310 { 311 ${{OUTPUT}} = uniformBlock.st.uniformMember; 312 }"""[1:] 313 314 layoutStructMemberQualifierShaderTemplate = """ 315 #version 310 es 316 precision highp float; 317 318 ${{OUTPUT_DECLARATION}} 319 320 struct Struct 321 { 322 vec4 uniformMember; 323 }; 324 325 uniform UniformBlock 326 { 327 layout(%s) Struct st; 328 } uniformBlock; 329 330 void main() 331 { 332 ${{OUTPUT}} = uniformBlock.st.uniformMember; 333 }"""[1:] 334 335 longIdentifierBlockNameShaderTemplate = (""" 336 #version 310 es 337 precision highp float; 338 339 ${{OUTPUT_DECLARATION}} 340 341 // Total of 1024 characters 342 uniform """ + ("a" * 1024) + """ 343 { 344 vec4 uniformMember; 345 } uniformBlock; 346 347 void main() 348 { 349 ${{OUTPUT}} = uniformBlock.uniformMember; 350 }""")[1:] 351 352 longIdentifierInstanceNameShaderTemplate = (""" 353 #version 310 es 354 precision highp float; 355 356 ${{OUTPUT_DECLARATION}} 357 358 uniform UniformBlock 359 { 360 vec4 uniformMember; 361 } """ + ("a" * 1024) + """; 362 // Total of 1024 characters 363 364 void main() 365 { 366 ${{OUTPUT}} = """ + ("a" * 1024) + """.uniformMember; 367 }""")[1:] 368 369 underscoreIdentifierInstanceNameShaderTemplate = (""" 370 #version 310 es 371 precision highp float; 372 373 ${{OUTPUT_DECLARATION}} 374 375 uniform UniformBlock 376 { 377 vec4 uniformMember; 378 } _; 379 380 void main() 381 { 382 ${{OUTPUT}} = _.uniformMember; 383 }""")[1:] 384 385 underscoreIdentifierBlockNameShaderTemplate = (""" 386 #version 310 es 387 precision highp float; 388 389 ${{OUTPUT_DECLARATION}} 390 391 uniform _ 392 { 393 vec4 uniformMember; 394 } uniformBlock; 395 396 void main() 397 { 398 ${{OUTPUT}} = uniformBlock.uniformMember; 399 }""")[1:] 400 401 validCases = (createCases("repeat_interface_qualifier", repeatShaderTemplate, True) 402 + sum([createCases("layout_%s" % qualifier, layoutQualifierShaderTemplate % qualifier, True) 403 for qualifier in ["shared", "packed", "std140", "row_major", "column_major"]], []) 404 + createCases("layout_all", layoutQualifierShaderTemplate % "shared, packed, std140, row_major, column_major", True) 405 + createCases("layout_all_8_times", layoutQualifierShaderTemplate % str.join(", ", ["shared", "packed", "std140", "row_major", "column_major"] * 8), True) 406 + sum([createCases("global_layout_%s" % qualifier, layoutGlobalQualifierShaderTemplate % qualifier, True) 407 for qualifier in ["shared", "packed", "std140", "row_major", "column_major"]], []) 408 + createCases("global_layout_all", layoutGlobalQualifierShaderTemplate % "shared, packed, std140, row_major, column_major", True) 409 + createCases("global_layout_all_8_times", layoutGlobalQualifierShaderTemplate % str.join(", ", ["shared", "packed", "std140", "row_major", "column_major"] * 8), True) 410 + sum([createCases("member_layout_%s" % qualifier, layoutMemberQualifierShaderTemplate % qualifier, True) 411 for qualifier in ["row_major", "column_major"]], []) 412 + sum([createCases("member_layout_%s_vec4" % qualifier, layoutMemberVec4QualifierShaderTemplate % qualifier, True) 413 for qualifier in ["row_major", "column_major"]], []) 414 + createCases("member_layout_all", layoutMemberQualifierShaderTemplate % "row_major, column_major", True) 415 + createCases("member_layout_all_8_times", layoutMemberQualifierShaderTemplate % str.join(", ", ["row_major", "column_major"] * 8), True) 416 + createCases("no_instance_name", noInstanceNameShaderTemplate, True) 417 + createCases("same_variable_and_block_name", sameVariableAndBlockNameShaderTemplate, True) 418 + createCases("same_variable_and_instance_name", sameVariableAndInstanceNameShaderTemplate, True) 419 + createCases("struct_member", structMemberShaderTemplate, True) 420 + sum([createCases("struct_member_layout_%s" % qualifier, layoutStructMemberQualifierShaderTemplate % qualifier, True) 421 for qualifier in ["row_major", "column_major"]], []) 422 + createCases("struct_member_layout_all", layoutStructMemberQualifierShaderTemplate % "row_major, column_major", True) 423 + createCases("struct_member_layout_all_8_times", layoutStructMemberQualifierShaderTemplate % str.join(", ", ["row_major", "column_major"] * 8), True) 424 + createCases("long_block_name", longIdentifierBlockNameShaderTemplate, True) 425 + createCases("long_instance_name", longIdentifierInstanceNameShaderTemplate, True) 426 + createCases("underscore_block_name", underscoreIdentifierBlockNameShaderTemplate, True) 427 + createCases("underscore_instance_name", underscoreIdentifierInstanceNameShaderTemplate, True)) 428 429 invalidMemberInterfaceQualifierShaderTemplate = """ 430 #version 310 es 431 precision highp float; 432 433 ${{OUTPUT_DECLARATION}} 434 435 uniform UniformBlock 436 { 437 %s vec4 uniformMember; 438 } uniformBlock; 439 440 void main() 441 { 442 ${{OUTPUT}} = uniformBlock.uniformMember; 443 }"""[1:] 444 445 conflictingInstanceNamesShaderTemplate = """ 446 #version 310 es 447 precision highp float; 448 449 ${{OUTPUT_DECLARATION}} 450 451 uniform UniformBlockA 452 { 453 vec4 uniformMember; 454 } uniformBlock; 455 456 uniform UniformBlockB 457 { 458 vec4 uniformMember; 459 } uniformBlock; 460 461 void main() 462 { 463 ${{OUTPUT}} = uniformBlock.uniformMember; 464 }"""[1:] 465 466 conflictingFunctionAndInstanceNameShaderTemplate = """ 467 #version 310 es 468 precision highp float; 469 470 ${{OUTPUT_DECLARATION}} 471 472 uniform UniformBlock 473 { 474 vec4 uniformMember; 475 } uniformBlock; 476 477 float uniformBlock (float x) 478 { 479 return x; 480 } 481 482 void main() 483 { 484 ${{OUTPUT}} = uniformBlock.uniformMember; 485 }"""[1:] 486 487 conflictingFunctionAndBlockNameShaderTemplate = """ 488 #version 310 es 489 precision highp float; 490 491 ${{OUTPUT_DECLARATION}} 492 493 uniform UniformBlock 494 { 495 vec4 uniformMember; 496 } uniformBlock; 497 498 float UniformBlock (float x) 499 { 500 return x; 501 } 502 503 void main() 504 { 505 ${{OUTPUT}} = uniformBlock.uniformMember; 506 }"""[1:] 507 508 conflictingVariableAndInstanceNameShaderTemplate = """ 509 #version 310 es 510 precision highp float; 511 512 ${{OUTPUT_DECLARATION}} 513 514 uniform UniformBlock 515 { 516 vec4 uniformMember; 517 } uniformBlock; 518 519 %s vec4 uniformBlock; 520 521 void main() 522 { 523 ${{OUTPUT}} = uniformBlock.uniformMember; 524 }"""[1:] 525 526 conflictingVariableAndBlockNameShaderTemplate = """ 527 #version 310 es 528 precision highp float; 529 530 ${{OUTPUT_DECLARATION}} 531 532 uniform UniformBlock 533 { 534 vec4 uniformMember; 535 } uniformBlock; 536 537 %s vec4 UniformBlock; 538 539 void main() 540 { 541 ${{OUTPUT}} = uniformBlock.uniformMember; 542 }"""[1:] 543 544 545 matchingInstanceAndBlockNameShaderTemplate = """ 546 #version 310 es 547 precision highp float; 548 549 ${{OUTPUT_DECLARATION}} 550 551 uniform UniformBlock 552 { 553 vec4 uniformMember; 554 } UniformBlock; 555 556 void main() 557 { 558 ${{OUTPUT}} = UniformBlock.uniformMember; 559 }"""[1:] 560 561 referenceUsingBlockNameShaderTemplate = """ 562 #version 310 es 563 precision highp float; 564 565 ${{OUTPUT_DECLARATION}} 566 567 uniform UniformBlock 568 { 569 vec4 uniformMember; 570 } uniformBlock; 571 572 void main() 573 { 574 ${{OUTPUT}} = UniformBlock.uniformMember; 575 }"""[1:] 576 577 emptyBlockShaderTemplate = """ 578 #version 310 es 579 precision highp float; 580 581 ${{OUTPUT_DECLARATION}} 582 583 uniform UniformBlock 584 { 585 } uniformBlock; 586 587 void main() 588 { 589 ${{OUTPUT}} = vec4(0.0); 590 }"""[1:] 591 592 emptyLayoutShaderTemplate = """ 593 #version 310 es 594 precision highp float; 595 596 ${{OUTPUT_DECLARATION}} 597 598 layout() uniform UniformBlock 599 { 600 vec4 uniformMember; 601 } uniformBlock; 602 603 void main() 604 { 605 ${{OUTPUT}} = uniformBlock.uniformMember; 606 }"""[1:] 607 608 emptyGlobalLayoutShaderTemplate = """ 609 #version 310 es 610 precision highp float; 611 612 layout() uniform; 613 614 ${{OUTPUT_DECLARATION}} 615 616 uniform UniformBlock 617 { 618 vec4 uniformMember; 619 } uniformBlock; 620 621 void main() 622 { 623 ${{OUTPUT}} = uniformBlock.uniformMember; 624 }"""[1:] 625 626 emptyMemberLayoutShaderTemplate = """ 627 #version 310 es 628 precision highp float; 629 630 ${{OUTPUT_DECLARATION}} 631 632 uniform UniformBlock 633 { 634 layout() vec4 uniformMember; 635 } uniformBlock; 636 637 void main() 638 { 639 ${{OUTPUT}} = uniformBlock.uniformMember; 640 }"""[1:] 641 642 invalidMemberLayoutShaderTemplate = """ 643 #version 310 es 644 precision highp float; 645 646 ${{OUTPUT_DECLARATION}} 647 648 uniform UniformBlock 649 { 650 layout(%s) vec4 uniformMember; 651 } uniformBlock; 652 653 void main() 654 { 655 ${{OUTPUT}} = uniformBlock.uniformMember; 656 }"""[1:] 657 658 structureDefinitionShaderTemplate = """ 659 #version 310 es 660 precision highp float; 661 662 ${{OUTPUT_DECLARATION}} 663 664 uniform UniformBlock 665 { 666 struct A 667 { 668 vec4 uniformMember; 669 } a; 670 } uniformBlock; 671 672 void main() 673 { 674 ${{OUTPUT}} = uniformBlock.a.uniformMember; 675 }"""[1:] 676 677 samplerShaderTemplate = """ 678 #version 310 es 679 precision highp float; 680 681 ${{OUTPUT_DECLARATION}} 682 683 uniform UniformBlock 684 { 685 sampler2D sampler; 686 vec4 uniformMember; 687 } uniformBlock; 688 689 void main() 690 { 691 ${{OUTPUT}} = uniformBlock.uniformMember; 692 }"""[1:] 693 694 missingBlockNameShaderTemplate = """ 695 #version 310 es 696 precision highp float; 697 698 ${{OUTPUT_DECLARATION}} 699 700 uniform 701 { 702 vec4 uniformMember; 703 } uniformBlock; 704 705 void main() 706 { 707 ${{OUTPUT}} = uniformBlock.uniformMember; 708 }"""[1:] 709 710 invalidNumberBlockNameShaderTemplate = """ 711 #version 310 es 712 precision highp float; 713 714 ${{OUTPUT_DECLARATION}} 715 716 uniform 0UniformBlock 717 { 718 vec4 uniformMember; 719 } uniformBlock; 720 721 void main() 722 { 723 ${{OUTPUT}} = uniformBlock.uniformMember; 724 }"""[1:] 725 726 invalidHashBlockNameShaderTemplate = """ 727 #version 310 es 728 precision highp float; 729 730 ${{OUTPUT_DECLARATION}} 731 732 uniform #UniformBlock 733 { 734 vec4 uniformMember; 735 } uniformBlock; 736 737 void main() 738 { 739 ${{OUTPUT}} = uniformBlock.uniformMember; 740 }"""[1:] 741 742 invalidDollarBlockNameShaderTemplate = """ 743 #version 310 es 744 precision highp float; 745 746 ${{OUTPUT_DECLARATION}} 747 748 uniform $UniformBlock 749 { 750 vec4 uniformMember; 751 } uniformBlock; 752 753 void main() 754 { 755 ${{OUTPUT}} = uniformBlock.uniformMember; 756 }"""[1:] 757 758 invalidIdentifierBlockNameShaderTemplate = """ 759 #version 310 es 760 precision highp float; 761 762 ${{OUTPUT_DECLARATION}} 763 764 uniform gl_UniformBlock 765 { 766 vec4 uniformMember; 767 } uniformBlock; 768 769 void main() 770 { 771 ${{OUTPUT}} = uniformBlock.uniformMember; 772 }"""[1:] 773 774 tooLongIdentifierBlockNameShaderTemplate = (""" 775 #version 310 es 776 precision highp float; 777 778 ${{OUTPUT_DECLARATION}} 779 780 // Total of 1025 characters 781 uniform """ + ("a" * 1025) + """ 782 { 783 vec4 uniformMember; 784 } uniformBlock; 785 786 void main() 787 { 788 ${{OUTPUT}} = uniformBlock.uniformMember; 789 }""")[1:] 790 791 invalidNumberInstanceNameShaderTemplate = """ 792 #version 310 es 793 precision highp float; 794 795 ${{OUTPUT_DECLARATION}} 796 797 uniform UniformInstance 798 { 799 vec4 uniformMember; 800 } 0uniformBlock; 801 802 void main() 803 { 804 ${{OUTPUT}} = 0uniformBlock.uniformMember; 805 }"""[1:] 806 807 invalidHashInstanceNameShaderTemplate = """ 808 #version 310 es 809 precision highp float; 810 811 ${{OUTPUT_DECLARATION}} 812 813 uniform UniformInstance 814 { 815 vec4 uniformMember; 816 } #uniformBlock; 817 818 void main() 819 { 820 ${{OUTPUT}} = #uniformBlock.uniformMember; 821 }"""[1:] 822 823 invalidDollarInstanceNameShaderTemplate = """ 824 #version 310 es 825 precision highp float; 826 827 ${{OUTPUT_DECLARATION}} 828 829 uniform UniformInstance 830 { 831 vec4 uniformMember; 832 } $uniformBlock; 833 834 void main() 835 { 836 ${{OUTPUT}} = $uniformBlock.uniformMember; 837 }"""[1:] 838 839 invalidIdentifierInstanceNameShaderTemplate = """ 840 #version 310 es 841 precision highp float; 842 843 ${{OUTPUT_DECLARATION}} 844 845 uniform UniformBlock 846 { 847 vec4 uniformMember; 848 } gl_uniformBlock; 849 850 void main() 851 { 852 ${{OUTPUT}} = gl_uniformBlock.uniformMember; 853 }"""[1:] 854 855 tooLongIdentifierInstanceNameShaderTemplate = (""" 856 #version 310 es 857 precision highp float; 858 859 ${{OUTPUT_DECLARATION}} 860 861 uniform UniformBlock 862 { 863 vec4 uniformMember; 864 } """ + ("a" * 1025) + """; 865 // Total of 1025 characters 866 867 void main() 868 { 869 ${{OUTPUT}} = """ + ("a" * 1025) + """.uniformMember; 870 }""")[1:] 871 872 invalidCases = ( 873 sum([createCases("member_%s_interface_qualifier" % qualifier, invalidMemberInterfaceQualifierShaderTemplate % qualifier, False) 874 for qualifier in ["in", "out", "buffer", "attribute", "varying"]], []) 875 + createCases("conflicting_instance_names", conflictingInstanceNamesShaderTemplate, False) 876 + createCases("conflicting_function_and_instance_name", conflictingFunctionAndInstanceNameShaderTemplate, False) 877 + createCases("conflicting_function_and_block_name", conflictingFunctionAndBlockNameShaderTemplate, False) 878 + sum([createCases("conflicting_%s_and_instance_name" % qualifier, conflictingVariableAndInstanceNameShaderTemplate % qualifier, False) 879 for qualifier in ["uniform", "in", "out"]], []) 880 + sum([createCases("conflicting_%s_and_block_name" % qualifier, conflictingVariableAndBlockNameShaderTemplate % qualifier, False) 881 for qualifier in ["uniform", "in", "out"]], []) 882 + createCases("matching_instance_and_block_name", matchingInstanceAndBlockNameShaderTemplate, False) 883 + createCases("reference_using_block_name", referenceUsingBlockNameShaderTemplate, False) 884 + createCases("empty_block", emptyBlockShaderTemplate, False) 885 + createCases("empty_layout", emptyLayoutShaderTemplate, False) 886 + createCases("empty_member_layout", emptyMemberLayoutShaderTemplate, False) 887 + createCases("empty_global_layout", emptyGlobalLayoutShaderTemplate, False) 888 + createCases("structure_definition", structureDefinitionShaderTemplate, False) 889 + sum([createCases("member_layout_%s" % qualifier, invalidMemberLayoutShaderTemplate % qualifier, False) 890 for qualifier in ["shared", "packed", "std140" "std430",]], []) 891 + createCases("missing_block_name", missingBlockNameShaderTemplate, False) 892 + createCases("invalid_number_block_name", invalidNumberBlockNameShaderTemplate, False) 893 + createCases("invalid_identifier_block_name", invalidIdentifierBlockNameShaderTemplate, False) 894 + createCases("invalid_hash_block_name", invalidHashBlockNameShaderTemplate, False) 895 + createCases("invalid_dollar_block_name", invalidDollarBlockNameShaderTemplate, False) 896 + createCases("too_long_block_name", tooLongIdentifierBlockNameShaderTemplate, False) 897 + createCases("invalid_number_instance_name", invalidNumberInstanceNameShaderTemplate, False) 898 + createCases("invalid_identifier_instance_name", invalidIdentifierInstanceNameShaderTemplate, False) 899 + createCases("invalid_hash_instance_name", invalidHashInstanceNameShaderTemplate, False) 900 + createCases("invalid_dollar_instance_name", invalidDollarInstanceNameShaderTemplate, False) 901 + createCases("repeated_block", repeatedBlockShaderTemplate, False) 902 + createCases("repeated_block_no_instance_name", repeatedBlockNoInstanceNameShaderTemplate, False) 903 + sum([createCases("layout_%s" % qualifier, layoutQualifierShaderTemplate % qualifier, False) 904 for qualifier in ["std430"]], []) 905 + sum([createCases("global_layout_%s" % qualifier, layoutGlobalQualifierShaderTemplate % qualifier, False) 906 for qualifier in ["std430"]], []) 907 ) 908 909 allCases.append(CaseGroup("valid", "Valid uniform interface block syntax tests.", validCases)) 910 allCases.append(CaseGroup("invalid", "Invalid uniform interface block syntax tests.", invalidCases)) 911 912 if __name__ == "__main__": 913 print "Generating shader case files." 914 writeAllCases("uniform_block.test", allCases) 915