Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
1.8 KiB

  1. use String::CRC32;
  2. BEGIN {use File::Basename; push @INC, dirname($0); }
  3. require "valve_perl_helpers.pl";
  4. sub GetShaderType
  5. {
  6. my $shadername = shift;
  7. my $shadertype;
  8. if( $shadername =~ m/\.vsh/i )
  9. {
  10. $shadertype = "vsh";
  11. }
  12. elsif( $shadername =~ m/\.psh/i )
  13. {
  14. $shadertype = "psh";
  15. }
  16. elsif( $shadername =~ m/\.fxc/i )
  17. {
  18. $shadertype = "fxc";
  19. }
  20. else
  21. {
  22. die;
  23. }
  24. return $shadertype;
  25. }
  26. sub GetShaderSrc
  27. {
  28. my $shadername = shift;
  29. if ( $shadername =~ m/^(.*)-----/i )
  30. {
  31. return $1;
  32. }
  33. else
  34. {
  35. return $shadername;
  36. }
  37. }
  38. sub GetShaderType
  39. {
  40. my $shadername = shift;
  41. my $shadertype;
  42. if( $shadername =~ m/\.vsh/i )
  43. {
  44. $shadertype = "vsh";
  45. }
  46. elsif( $shadername =~ m/\.psh/i )
  47. {
  48. $shadertype = "psh";
  49. }
  50. elsif( $shadername =~ m/\.fxc/i )
  51. {
  52. $shadertype = "fxc";
  53. }
  54. else
  55. {
  56. die;
  57. }
  58. return $shadertype;
  59. }
  60. sub GetShaderBase
  61. {
  62. my $shadername = shift;
  63. if ( $shadername =~ m/-----(.*)$/i )
  64. {
  65. return $1;
  66. }
  67. else
  68. {
  69. my $shadertype = &GetShaderType( $shadername );
  70. $shadername =~ s/\.$shadertype//i;
  71. return $shadername;
  72. }
  73. }
  74. $g_x360 = 0;
  75. $g_vcsext = ".vcs";
  76. while( 1 )
  77. {
  78. $inputbase = shift;
  79. if( $inputbase =~ m/-x360/ )
  80. {
  81. $g_x360 = 1;
  82. $g_vcsext = ".360.vcs";
  83. }
  84. else
  85. {
  86. last;
  87. }
  88. }
  89. # rip the txt off the end if it's there.
  90. $inputbase =~ s/\.txt//i;
  91. my @srcfiles = &LoadShaderListFile( $inputbase );
  92. foreach $srcfile ( @srcfiles )
  93. {
  94. my $shadertype = &GetShaderType( $srcfile );
  95. my $shaderbase = &GetShaderBase( $srcfile );
  96. my $shadersrc = &GetShaderSrc( $srcfile );
  97. my $vcsFileName = "..\\..\\..\\game\\hl2\\shaders\\$shadertype\\$shaderbase" . $g_vcsext;
  98. # print "shadersrc: $shadersrc vcsFileName: $vcsFileName\n";
  99. if( $g_x360 && ( $shaderbase =~ m/_ps20$/i ) )
  100. {
  101. next; # skip _ps20 files for 360
  102. }
  103. &CheckCRCAgainstTarget( $shadersrc, $vcsFileName, 1 );
  104. }