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.

169 lines
3.3 KiB

  1. # getfinalstate.pl blah.txt line
  2. # note: the state is *before* the line that you specify
  3. die "Usage: playback_getstate.pl blah.txt cmd\n" if scalar( @ARGV ) != 2;
  4. open INPUT, shift || die;
  5. $desiredcmd = shift;
  6. $line = 0;
  7. sub PadNumber
  8. {
  9. local( $str ) = shift;
  10. local( $desiredLen ) = shift;
  11. local( $len ) = length $str;
  12. while( $len < $desiredLen )
  13. {
  14. $str = "0" . $str;
  15. $len++;
  16. }
  17. return $str;
  18. }
  19. while( <INPUT> )
  20. {
  21. m/^cmd: (\d+) /;
  22. $cmdnum = $1;
  23. # print "$cmdnum\n";
  24. if( $cmdnum == $desiredcmd )
  25. {
  26. print "$_";
  27. last;
  28. }
  29. if( /Dx8SetTextureStageState:\s*stage:\s*(\d+)\s*state:\s*(\S+)\s*,\s*value:\s*(\S+)/ )
  30. {
  31. $texturestate{"$2 $1"} = $3;
  32. # print "$1 $2 $3\n";
  33. }
  34. # elsif( /Dx8SetTextureStageState/i )
  35. # {
  36. # die "$_";
  37. # }
  38. if( /Dx8SetRenderState:\s*(\S+)\s+(\S+.*)*$/ )
  39. {
  40. $renderstate{$1} = $2;
  41. }
  42. # elsif( /Dx8SetRenderState/i )
  43. # {
  44. # die "$_";
  45. # }
  46. if( /Dx8SetVertexShaderConstant:\s*reg:\s*(\d+)\s*numvecs:\s*(\d+)\s*val:\s*(.*)$/ )
  47. {
  48. local( $reg ) = $1;
  49. local( $count ) = $2;
  50. local( $val ) = $3;
  51. local( $i );
  52. for( $i = 0; $i < $count; $i++, $reg++ )
  53. {
  54. $val =~ s/^\s*(\[\s*\S+\s+\S+\s+\S+\s+\S+\s*\])(.*$)/$2/;
  55. $vertconst{ "vshconst " . &PadNumber( $reg, 2 ) } = $1;
  56. }
  57. }
  58. # elsif( /Dx8SetVertexShaderConstant/i )
  59. # {
  60. # die "$_";
  61. # }
  62. if( /Dx8SetPixelShaderConstant:\s*reg:\s*(\d+)\s*numvecs:\s*(\d+)\s*val:\s*(.*)$/ )
  63. {
  64. local( $reg ) = $1;
  65. local( $count ) = $2;
  66. local( $val ) = $3;
  67. local( $i );
  68. for( $i = 0; $i < $count; $i++, $reg++ )
  69. {
  70. $val =~ s/^\s*(\[\s*\S+\s+\S+\s+\S+\s+\S+\s*\])(.*$)/$2/;
  71. $pixelconst{ "pshconst " . &PadNumber( $reg, 2 ) } = $1;
  72. }
  73. }
  74. # elsif( /Dx8SetPixelShaderConstant/i )
  75. # {
  76. # die "$_";
  77. # }
  78. if( /Dx8SetStreamSource:\s*vertexBufferID:\s*(\d+)\s*streamID:\s*(\d+)\s*vertexSize:\s*(\d+)\s*$/ )
  79. {
  80. $streamsrc{$2} = "vertexBufferID: $1 vertexSize: $3";
  81. }
  82. # elsif( /Dx8SetStreamSource/i )
  83. # {
  84. # die "$_";
  85. # }
  86. if( /Dx8CreateVertexShader:\s*id:\s*(\d+)\s+dwDecl:\s*(.*)$/ )
  87. {
  88. $vshdecl{$1} = $2;
  89. }
  90. elsif( /Dx8CreateVertexShader/i )
  91. {
  92. die "$_";
  93. }
  94. if( /Dx8SetVertexShader:\s*vertexShader:\s*(\d+)\s*$/ )
  95. {
  96. $currentVertexShader = $1;
  97. }
  98. elsif( /Dx8SetVertexShader:/i )
  99. {
  100. die "$_";
  101. }
  102. if( /Dx8SetPixelShader:\s*pixelShader:\s*(\d+)\s*$/ )
  103. {
  104. $currentPixelShader = $1;
  105. }
  106. elsif( /Dx8SetPixelShader:/i )
  107. {
  108. die "$_";
  109. }
  110. if( /Dx8SetVertexBufferFormat:\s*id:\s*(\d+)\s*vertexFormat:\s*(.*)$/ )
  111. {
  112. $vbformat{$1} = $2;
  113. }
  114. elsif( /Dx8SetVertexBufferFormat/i )
  115. {
  116. die "$_";
  117. }
  118. }
  119. close INPUT;
  120. foreach $state ( sort( keys( %texturestate ) ) )
  121. {
  122. print "$state = $texturestate{$state}\n";
  123. }
  124. foreach $state ( sort( keys( %renderstate ) ) )
  125. {
  126. print "$state = $renderstate{$state}\n";
  127. }
  128. foreach $state ( sort( keys( %vertconst ) ) )
  129. {
  130. print "$state = $vertconst{$state}\n";
  131. }
  132. foreach $state ( sort( keys( %pixelconst ) ) )
  133. {
  134. print "$state = $pixelconst{$state}\n";
  135. }
  136. foreach $state ( sort( keys( %streamsrc ) ) )
  137. {
  138. $streamsrc{$state} =~ m/vertexBufferID:\s*(\d+)\s+/;
  139. local( $vertbufid ) = $1;
  140. print "stream $state = $streamsrc{$state} vbformat: $vbformat{$vertbufid}\n";
  141. }
  142. #foreach $state ( sort( keys( %vbformat ) ) )
  143. #{
  144. # print "vbformat $state = $vbformat{$state}\n";
  145. #}
  146. print "current vsh: $currentVertexShader vshdecl: $vshdecl{$currentVertexShader}\n";
  147. print "current psh: $currentPixelShader\n";