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 23from genutil import * 24 25allCases = [] 26 27VERTEX = "VERTEX" 28FRAGMENT = "FRAGMENT" 29 30CASE_FRAGMENT_SHADER_TEMPLATE = """ 31case ${{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 "" 50end"""[1:] 51 52CASE_VERTEX_SHADER_TEMPLATE = """ 53case ${{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 "" 72end"""[1:] 73 74class 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 115def createCases(name, source, valid): 116 return [UniformBlockCase(name + "_vertex", VERTEX, source, valid), 117 UniformBlockCase(name + "_fragment", FRAGMENT, source, valid)] 118 119repeatShaderTemplate = """ 120#version 310 es 121precision highp float; 122 123${{OUTPUT_DECLARATION}} 124 125uniform UniformBlock 126{ 127 uniform vec4 uniformMember; 128} uniformBlock; 129 130void main() 131{ 132 ${{OUTPUT}} = uniformBlock.uniformMember; 133}"""[1:] 134 135layoutQualifierShaderTemplate = """ 136#version 310 es 137precision highp float; 138 139${{OUTPUT_DECLARATION}} 140 141layout(%s) uniform UniformBlock 142{ 143 vec4 uniformMember; 144} uniformBlock; 145 146void main() 147{ 148 ${{OUTPUT}} = uniformBlock.uniformMember; 149}"""[1:] 150 151layoutGlobalQualifierShaderTemplate = """ 152#version 310 es 153precision highp float; 154 155layout(%s) uniform; 156 157${{OUTPUT_DECLARATION}} 158 159uniform UniformBlock 160{ 161 vec4 uniformMember; 162} uniformBlock; 163 164void main() 165{ 166 ${{OUTPUT}} = uniformBlock.uniformMember; 167}"""[1:] 168 169layoutMemberQualifierShaderTemplate = """ 170#version 310 es 171precision highp float; 172 173${{OUTPUT_DECLARATION}} 174 175uniform UniformBlock 176{ 177 layout(%s) mat4 uniformMember; 178} uniformBlock; 179 180void main() 181{ 182 ${{OUTPUT}} = uniformBlock.uniformMember[0]; 183}"""[1:] 184 185layoutMemberVec4QualifierShaderTemplate = """ 186#version 310 es 187precision highp float; 188 189${{OUTPUT_DECLARATION}} 190 191uniform UniformBlock 192{ 193 layout(%s) vec4 uniformMember; 194} uniformBlock; 195 196void main() 197{ 198 ${{OUTPUT}} = uniformBlock.uniformMember; 199}"""[1:] 200 201noInstanceNameShaderTemplate = """ 202#version 310 es 203precision highp float; 204 205${{OUTPUT_DECLARATION}} 206 207uniform UniformBlock 208{ 209 vec4 uniformMember; 210}; 211 212void main() 213{ 214 ${{OUTPUT}} = uniformMember; 215}"""[1:] 216 217sameVariableAndInstanceNameShaderTemplate = """ 218#version 310 es 219precision highp float; 220 221${{OUTPUT_DECLARATION}} 222 223uniform UniformBlock 224{ 225 vec4 uniformMember; 226} uniformBlock; 227 228void main() 229{ 230 vec4 uniformBlock = vec4(0.0); 231 ${{OUTPUT}} = uniformBlock; 232}"""[1:] 233 234sameVariableAndBlockNameShaderTemplate = """ 235#version 310 es 236precision highp float; 237 238${{OUTPUT_DECLARATION}} 239 240uniform UniformBlock 241{ 242 vec4 uniformMember; 243} uniformBlock; 244 245void main() 246{ 247 vec4 UniformBlock = vec4(0.0); 248 ${{OUTPUT}} = UniformBlock + uniformBlock.uniformMember; 249}"""[1:] 250 251repeatedBlockShaderTemplate = """ 252#version 310 es 253precision highp float; 254 255${{OUTPUT_DECLARATION}} 256 257uniform UniformBlock 258{ 259 vec4 uniformMember; 260} uniformBlockA; 261 262uniform UniformBlock 263{ 264 vec4 uniformMember; 265} uniformBlockB; 266 267void main() 268{ 269 ${{OUTPUT}} = uniformBlockA.uniformMember + uniformBlockB.uniformMember; 270}"""[1:] 271 272repeatedBlockNoInstanceNameShaderTemplate = """ 273#version 310 es 274precision highp float; 275 276${{OUTPUT_DECLARATION}} 277 278uniform UniformBlock 279{ 280 vec4 uniformMember; 281} uniformBlock; 282 283uniform UniformBlock 284{ 285 vec4 uniformMember; 286}; 287 288void main() 289{ 290 ${{OUTPUT}} = uniformBlock.uniformMember + uniformMember; 291}"""[1:] 292 293structMemberShaderTemplate = """ 294#version 310 es 295precision highp float; 296 297${{OUTPUT_DECLARATION}} 298 299struct Struct 300{ 301 vec4 uniformMember; 302}; 303 304uniform UniformBlock 305{ 306 Struct st; 307} uniformBlock; 308 309void main() 310{ 311 ${{OUTPUT}} = uniformBlock.st.uniformMember; 312}"""[1:] 313 314layoutStructMemberQualifierShaderTemplate = """ 315#version 310 es 316precision highp float; 317 318${{OUTPUT_DECLARATION}} 319 320struct Struct 321{ 322 vec4 uniformMember; 323}; 324 325uniform UniformBlock 326{ 327 layout(%s) Struct st; 328} uniformBlock; 329 330void main() 331{ 332 ${{OUTPUT}} = uniformBlock.st.uniformMember; 333}"""[1:] 334 335longIdentifierBlockNameShaderTemplate = (""" 336#version 310 es 337precision highp float; 338 339${{OUTPUT_DECLARATION}} 340 341// Total of 1024 characters 342uniform """ + ("a" * 1024) + """ 343{ 344 vec4 uniformMember; 345} uniformBlock; 346 347void main() 348{ 349 ${{OUTPUT}} = uniformBlock.uniformMember; 350}""")[1:] 351 352longIdentifierInstanceNameShaderTemplate = (""" 353#version 310 es 354precision highp float; 355 356${{OUTPUT_DECLARATION}} 357 358uniform UniformBlock 359{ 360 vec4 uniformMember; 361} """ + ("a" * 1024) + """; 362// Total of 1024 characters 363 364void main() 365{ 366 ${{OUTPUT}} = """ + ("a" * 1024) + """.uniformMember; 367}""")[1:] 368 369underscoreIdentifierInstanceNameShaderTemplate = (""" 370#version 310 es 371precision highp float; 372 373${{OUTPUT_DECLARATION}} 374 375uniform UniformBlock 376{ 377 vec4 uniformMember; 378} _; 379 380void main() 381{ 382 ${{OUTPUT}} = _.uniformMember; 383}""")[1:] 384 385underscoreIdentifierBlockNameShaderTemplate = (""" 386#version 310 es 387precision highp float; 388 389${{OUTPUT_DECLARATION}} 390 391uniform _ 392{ 393 vec4 uniformMember; 394} uniformBlock; 395 396void main() 397{ 398 ${{OUTPUT}} = uniformBlock.uniformMember; 399}""")[1:] 400 401validCases = (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 429invalidMemberInterfaceQualifierShaderTemplate = """ 430#version 310 es 431precision highp float; 432 433${{OUTPUT_DECLARATION}} 434 435uniform UniformBlock 436{ 437 %s vec4 uniformMember; 438} uniformBlock; 439 440void main() 441{ 442 ${{OUTPUT}} = uniformBlock.uniformMember; 443}"""[1:] 444 445conflictingInstanceNamesShaderTemplate = """ 446#version 310 es 447precision highp float; 448 449${{OUTPUT_DECLARATION}} 450 451uniform UniformBlockA 452{ 453 vec4 uniformMember; 454} uniformBlock; 455 456uniform UniformBlockB 457{ 458 vec4 uniformMember; 459} uniformBlock; 460 461void main() 462{ 463 ${{OUTPUT}} = uniformBlock.uniformMember; 464}"""[1:] 465 466conflictingFunctionAndInstanceNameShaderTemplate = """ 467#version 310 es 468precision highp float; 469 470${{OUTPUT_DECLARATION}} 471 472uniform UniformBlock 473{ 474 vec4 uniformMember; 475} uniformBlock; 476 477float uniformBlock (float x) 478{ 479 return x; 480} 481 482void main() 483{ 484 ${{OUTPUT}} = uniformBlock.uniformMember; 485}"""[1:] 486 487conflictingFunctionAndBlockNameShaderTemplate = """ 488#version 310 es 489precision highp float; 490 491${{OUTPUT_DECLARATION}} 492 493uniform UniformBlock 494{ 495 vec4 uniformMember; 496} uniformBlock; 497 498float UniformBlock (float x) 499{ 500 return x; 501} 502 503void main() 504{ 505 ${{OUTPUT}} = uniformBlock.uniformMember; 506}"""[1:] 507 508conflictingVariableAndInstanceNameShaderTemplate = """ 509#version 310 es 510precision highp float; 511 512${{OUTPUT_DECLARATION}} 513 514uniform UniformBlock 515{ 516 vec4 uniformMember; 517} uniformBlock; 518 519%s vec4 uniformBlock; 520 521void main() 522{ 523 ${{OUTPUT}} = uniformBlock.uniformMember; 524}"""[1:] 525 526conflictingVariableAndBlockNameShaderTemplate = """ 527#version 310 es 528precision highp float; 529 530${{OUTPUT_DECLARATION}} 531 532uniform UniformBlock 533{ 534 vec4 uniformMember; 535} uniformBlock; 536 537%s vec4 UniformBlock; 538 539void main() 540{ 541 ${{OUTPUT}} = uniformBlock.uniformMember; 542}"""[1:] 543 544 545matchingInstanceAndBlockNameShaderTemplate = """ 546#version 310 es 547precision highp float; 548 549${{OUTPUT_DECLARATION}} 550 551uniform UniformBlock 552{ 553 vec4 uniformMember; 554} UniformBlock; 555 556void main() 557{ 558 ${{OUTPUT}} = UniformBlock.uniformMember; 559}"""[1:] 560 561referenceUsingBlockNameShaderTemplate = """ 562#version 310 es 563precision highp float; 564 565${{OUTPUT_DECLARATION}} 566 567uniform UniformBlock 568{ 569 vec4 uniformMember; 570} uniformBlock; 571 572void main() 573{ 574 ${{OUTPUT}} = UniformBlock.uniformMember; 575}"""[1:] 576 577emptyBlockShaderTemplate = """ 578#version 310 es 579precision highp float; 580 581${{OUTPUT_DECLARATION}} 582 583uniform UniformBlock 584{ 585} uniformBlock; 586 587void main() 588{ 589 ${{OUTPUT}} = vec4(0.0); 590}"""[1:] 591 592emptyLayoutShaderTemplate = """ 593#version 310 es 594precision highp float; 595 596${{OUTPUT_DECLARATION}} 597 598layout() uniform UniformBlock 599{ 600 vec4 uniformMember; 601} uniformBlock; 602 603void main() 604{ 605 ${{OUTPUT}} = uniformBlock.uniformMember; 606}"""[1:] 607 608emptyGlobalLayoutShaderTemplate = """ 609#version 310 es 610precision highp float; 611 612layout() uniform; 613 614${{OUTPUT_DECLARATION}} 615 616uniform UniformBlock 617{ 618 vec4 uniformMember; 619} uniformBlock; 620 621void main() 622{ 623 ${{OUTPUT}} = uniformBlock.uniformMember; 624}"""[1:] 625 626emptyMemberLayoutShaderTemplate = """ 627#version 310 es 628precision highp float; 629 630${{OUTPUT_DECLARATION}} 631 632uniform UniformBlock 633{ 634 layout() vec4 uniformMember; 635} uniformBlock; 636 637void main() 638{ 639 ${{OUTPUT}} = uniformBlock.uniformMember; 640}"""[1:] 641 642invalidMemberLayoutShaderTemplate = """ 643#version 310 es 644precision highp float; 645 646${{OUTPUT_DECLARATION}} 647 648uniform UniformBlock 649{ 650 layout(%s) vec4 uniformMember; 651} uniformBlock; 652 653void main() 654{ 655 ${{OUTPUT}} = uniformBlock.uniformMember; 656}"""[1:] 657 658structureDefinitionShaderTemplate = """ 659#version 310 es 660precision highp float; 661 662${{OUTPUT_DECLARATION}} 663 664uniform UniformBlock 665{ 666 struct A 667 { 668 vec4 uniformMember; 669 } a; 670} uniformBlock; 671 672void main() 673{ 674 ${{OUTPUT}} = uniformBlock.a.uniformMember; 675}"""[1:] 676 677samplerShaderTemplate = """ 678#version 310 es 679precision highp float; 680 681${{OUTPUT_DECLARATION}} 682 683uniform UniformBlock 684{ 685 sampler2D sampler; 686 vec4 uniformMember; 687} uniformBlock; 688 689void main() 690{ 691 ${{OUTPUT}} = uniformBlock.uniformMember; 692}"""[1:] 693 694missingBlockNameShaderTemplate = """ 695#version 310 es 696precision highp float; 697 698${{OUTPUT_DECLARATION}} 699 700uniform 701{ 702 vec4 uniformMember; 703} uniformBlock; 704 705void main() 706{ 707 ${{OUTPUT}} = uniformBlock.uniformMember; 708}"""[1:] 709 710invalidNumberBlockNameShaderTemplate = """ 711#version 310 es 712precision highp float; 713 714${{OUTPUT_DECLARATION}} 715 716uniform 0UniformBlock 717{ 718 vec4 uniformMember; 719} uniformBlock; 720 721void main() 722{ 723 ${{OUTPUT}} = uniformBlock.uniformMember; 724}"""[1:] 725 726invalidHashBlockNameShaderTemplate = """ 727#version 310 es 728precision highp float; 729 730${{OUTPUT_DECLARATION}} 731 732uniform #UniformBlock 733{ 734 vec4 uniformMember; 735} uniformBlock; 736 737void main() 738{ 739 ${{OUTPUT}} = uniformBlock.uniformMember; 740}"""[1:] 741 742invalidDollarBlockNameShaderTemplate = """ 743#version 310 es 744precision highp float; 745 746${{OUTPUT_DECLARATION}} 747 748uniform $UniformBlock 749{ 750 vec4 uniformMember; 751} uniformBlock; 752 753void main() 754{ 755 ${{OUTPUT}} = uniformBlock.uniformMember; 756}"""[1:] 757 758invalidIdentifierBlockNameShaderTemplate = """ 759#version 310 es 760precision highp float; 761 762${{OUTPUT_DECLARATION}} 763 764uniform gl_UniformBlock 765{ 766 vec4 uniformMember; 767} uniformBlock; 768 769void main() 770{ 771 ${{OUTPUT}} = uniformBlock.uniformMember; 772}"""[1:] 773 774tooLongIdentifierBlockNameShaderTemplate = (""" 775#version 310 es 776precision highp float; 777 778${{OUTPUT_DECLARATION}} 779 780// Total of 1025 characters 781uniform """ + ("a" * 1025) + """ 782{ 783 vec4 uniformMember; 784} uniformBlock; 785 786void main() 787{ 788 ${{OUTPUT}} = uniformBlock.uniformMember; 789}""")[1:] 790 791invalidNumberInstanceNameShaderTemplate = """ 792#version 310 es 793precision highp float; 794 795${{OUTPUT_DECLARATION}} 796 797uniform UniformInstance 798{ 799 vec4 uniformMember; 800} 0uniformBlock; 801 802void main() 803{ 804 ${{OUTPUT}} = 0uniformBlock.uniformMember; 805}"""[1:] 806 807invalidHashInstanceNameShaderTemplate = """ 808#version 310 es 809precision highp float; 810 811${{OUTPUT_DECLARATION}} 812 813uniform UniformInstance 814{ 815 vec4 uniformMember; 816} #uniformBlock; 817 818void main() 819{ 820 ${{OUTPUT}} = #uniformBlock.uniformMember; 821}"""[1:] 822 823invalidDollarInstanceNameShaderTemplate = """ 824#version 310 es 825precision highp float; 826 827${{OUTPUT_DECLARATION}} 828 829uniform UniformInstance 830{ 831 vec4 uniformMember; 832} $uniformBlock; 833 834void main() 835{ 836 ${{OUTPUT}} = $uniformBlock.uniformMember; 837}"""[1:] 838 839invalidIdentifierInstanceNameShaderTemplate = """ 840#version 310 es 841precision highp float; 842 843${{OUTPUT_DECLARATION}} 844 845uniform UniformBlock 846{ 847 vec4 uniformMember; 848} gl_uniformBlock; 849 850void main() 851{ 852 ${{OUTPUT}} = gl_uniformBlock.uniformMember; 853}"""[1:] 854 855tooLongIdentifierInstanceNameShaderTemplate = (""" 856#version 310 es 857precision highp float; 858 859${{OUTPUT_DECLARATION}} 860 861uniform UniformBlock 862{ 863 vec4 uniformMember; 864} """ + ("a" * 1025) + """; 865// Total of 1025 characters 866 867void main() 868{ 869 ${{OUTPUT}} = """ + ("a" * 1025) + """.uniformMember; 870}""")[1:] 871 872invalidCases = ( 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 909allCases.append(CaseGroup("valid", "Valid uniform interface block syntax tests.", validCases)) 910allCases.append(CaseGroup("invalid", "Invalid uniform interface block syntax tests.", invalidCases)) 911 912if __name__ == "__main__": 913 print "Generating shader case files." 914 writeAllCases("uniform_block.test", allCases) 915