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.

198 lines
5.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef RECORDING_H
  9. #define RECORDING_H
  10. #pragma once
  11. //-----------------------------------------------------------------------------
  12. // Use this to put us into a 'recording' mode
  13. //-----------------------------------------------------------------------------
  14. //#define RECORDING
  15. //-----------------------------------------------------------------------------
  16. // Uncomment these to record special frames in the recording
  17. // that reset the entire render state.
  18. //-----------------------------------------------------------------------------
  19. //#define RECORD_KEYFRAMES 1
  20. #define KEYFRAME_INTERVAL 100 // number of actual frames between each keyframe
  21. //-----------------------------------------------------------------------------
  22. // Use this to allow us to record crashes (write every command immediately)
  23. //-----------------------------------------------------------------------------
  24. //#define CRASH_RECORDING
  25. //-----------------------------------------------------------------------------
  26. // Use this to record textures (checkboards are used for textures otherwise)
  27. //-----------------------------------------------------------------------------
  28. #define RECORD_TEXTURES
  29. //-----------------------------------------------------------------------------
  30. // Use this to record debug strings . .these are only useful if you are doing "playback -list"
  31. //-----------------------------------------------------------------------------
  32. #define RECORD_DEBUG_STRINGS
  33. //-----------------------------------------------------------------------------
  34. // Recording state, if you change this, change the table in playback/playback.cpp
  35. //-----------------------------------------------------------------------------
  36. enum RecordingCommands_t
  37. {
  38. DX8_CREATE_DEVICE = 0,
  39. DX8_DESTROY_DEVICE,
  40. DX8_RESET,
  41. DX8_SHOW_CURSOR,
  42. DX8_BEGIN_SCENE,
  43. DX8_END_SCENE,
  44. DX8_PRESENT,
  45. DX8_CREATE_TEXTURE,
  46. DX8_DESTROY_TEXTURE,
  47. DX8_SET_TEXTURE,
  48. DX8_SET_TRANSFORM,
  49. DX8_CREATE_VERTEX_SHADER,
  50. DX8_CREATE_PIXEL_SHADER,
  51. DX8_DESTROY_VERTEX_SHADER,
  52. DX8_DESTROY_PIXEL_SHADER,
  53. DX8_SET_VERTEX_SHADER,
  54. DX8_SET_PIXEL_SHADER,
  55. DX8_SET_VERTEX_SHADER_CONSTANT,
  56. DX8_SET_PIXEL_SHADER_CONSTANT,
  57. DX8_SET_MATERIAL,
  58. DX8_LIGHT_ENABLE,
  59. DX8_SET_LIGHT,
  60. DX8_SET_VIEWPORT,
  61. DX8_CLEAR,
  62. DX8_VALIDATE_DEVICE,
  63. DX8_SET_RENDER_STATE,
  64. DX8_SET_TEXTURE_STAGE_STATE,
  65. DX8_CREATE_VERTEX_BUFFER,
  66. DX8_DESTROY_VERTEX_BUFFER,
  67. DX8_LOCK_VERTEX_BUFFER,
  68. DX8_VERTEX_DATA,
  69. DX8_UNLOCK_VERTEX_BUFFER,
  70. DX8_CREATE_INDEX_BUFFER,
  71. DX8_DESTROY_INDEX_BUFFER,
  72. DX8_LOCK_INDEX_BUFFER,
  73. DX8_INDEX_DATA,
  74. DX8_UNLOCK_INDEX_BUFFER,
  75. DX8_SET_STREAM_SOURCE,
  76. DX8_SET_INDICES,
  77. DX8_DRAW_PRIMITIVE,
  78. DX8_DRAW_INDEXED_PRIMITIVE,
  79. DX8_LOCK_TEXTURE,
  80. DX8_UNLOCK_TEXTURE,
  81. DX8_KEYFRAME, // isn't actually a dx8 command, used to help find particular frames
  82. DX8_SET_TEXTURE_DATA,
  83. DX8_BLIT_TEXTURE_BITS,
  84. DX8_GET_DEVICE_CAPS,
  85. DX8_GET_ADAPTER_IDENTIFIER,
  86. DX8_HARDWARE_SYNC,
  87. DX8_COPY_FRAMEBUFFER_TO_TEXTURE,
  88. DX8_DEBUG_STRING,
  89. DX8_CREATE_DEPTH_TEXTURE,
  90. DX8_DESTROY_DEPTH_TEXTURE,
  91. DX8_SET_RENDER_TARGET,
  92. DX8_TEST_COOPERATIVE_LEVEL,
  93. DX8_SET_VERTEX_BUFFER_FORMAT, // isn't actually a dx8 command. . let's playback know what format a buffer is for listing info
  94. DX8_SET_SAMPLER_STATE,
  95. DX8_SET_VERTEX_DECLARATION,
  96. DX8_CREATE_VERTEX_DECLARATION,
  97. DX8_SET_FVF,
  98. DX8_SET_CLIP_PLANE,
  99. DX8_SYNC_TOKEN,
  100. DX8_LOCK_VERTEX_TEXTURE,
  101. DX8_UNLOCK_VERTEX_TEXTURE,
  102. DX8_SET_SCISSOR_RECT,
  103. DX8_NUM_RECORDING_COMMANDS
  104. };
  105. #ifdef RECORDING
  106. void RecordCommand( RecordingCommands_t cmd, int numargs );
  107. void RecordArgument( void const* pMemory, int size );
  108. void FinishRecording( void );
  109. inline void RecordInt( int i )
  110. {
  111. RecordArgument( &i, sizeof(int) );
  112. }
  113. inline void RecordFloat( float f )
  114. {
  115. RecordArgument( &f, sizeof(float) );
  116. }
  117. # define RECORD_COMMAND( _cmd, _numargs ) RecordCommand( _cmd, _numargs )
  118. # define RECORD_INT( _int ) RecordInt( _int )
  119. # define RECORD_FLOAT( _float ) RecordFloat( _float )
  120. # define RECORD_STRING( _string ) RecordArgument( _string, strlen(_string) + 1 )
  121. # define RECORD_STRUCT( _struct, _size ) RecordArgument( _struct, _size )
  122. # define RECORD_RENDER_STATE( _state, _val ) \
  123. RECORD_COMMAND( DX8_SET_RENDER_STATE, 2 ); \
  124. RECORD_INT( _state ); \
  125. RECORD_INT( _val )
  126. # define RECORD_TEXTURE_STAGE_STATE( _stage, _state, _val ) \
  127. RECORD_COMMAND( DX8_SET_TEXTURE_STAGE_STATE, 3 ); \
  128. RECORD_INT( _stage ); \
  129. RECORD_INT( _state ); \
  130. RECORD_INT( _val )
  131. # define RECORD_SAMPLER_STATE( _stage, _state, _val ) \
  132. RECORD_COMMAND( DX8_SET_SAMPLER_STATE, 3 ); \
  133. RECORD_INT( _stage ); \
  134. RECORD_INT( _state ); \
  135. RECORD_INT( _val )
  136. # ifdef RECORD_DEBUG_STRINGS
  137. # define RECORD_DEBUG_STRING( _str ) \
  138. RECORD_COMMAND( DX8_DEBUG_STRING, 1 ); \
  139. RECORD_STRING( _str )
  140. # else
  141. # define RECORD_DEBUG_STRING( _str ) 0
  142. # endif
  143. #else // not RECORDING
  144. # undef RECORD_TEXTURES
  145. # define RECORD_COMMAND( _cmd, _numargs ) 0
  146. # define RECORD_INT( _int ) 0
  147. # define RECORD_FLOAT( _float ) 0
  148. # define RECORD_STRING( _string ) 0
  149. # define RECORD_STRUCT( _struct, _size ) 0
  150. # define RECORD_RENDER_STATE( _state, _val ) 0
  151. # define RECORD_TEXTURE_STAGE_STATE( _stage, _state, _val ) 0
  152. # define RECORD_SAMPLER_STATE( _stage, _state, _val ) 0
  153. # define RECORD_DEBUG_STRING( _str ) 0
  154. #endif // RECORDING
  155. #endif // RECORDING_H