Counter Strike : Global Offensive Source Code
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.

206 lines
9.5 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Byteswapping datadescs for the corresponding worldstructures. These
  4. // must stay in sync with the stucts in worldstructures.h.
  5. //
  6. //===========================================================================//
  7. #include "worldstructures.h"
  8. //--------------------------------------------------------------------------------------
  9. // Fake-material related
  10. //--------------------------------------------------------------------------------------
  11. BEGIN_BYTESWAP_DATADESC( MaterialResourceBinding_t )
  12. DEFINE_FIELD( m_cBindStage, FIELD_CHARACTER ),
  13. DEFINE_FIELD( m_cBindSlot, FIELD_CHARACTER ),
  14. DEFINE_FIELD( m_cBindSampler, FIELD_CHARACTER ),
  15. END_BYTESWAP_DATADESC()
  16. BEGIN_BYTESWAP_DATADESC( Material_t )
  17. DEFINE_ARRAY( m_szShaderVS, FIELD_CHARACTER, MAX_SHADER_NAME ),
  18. DEFINE_ARRAY( m_szShaderPS, FIELD_CHARACTER, MAX_SHADER_NAME ),
  19. DEFINE_FIELD( m_nBinds, FIELD_INTEGER ),
  20. DEFINE_EMBEDDED_ARRAY( m_Binds, MAX_BINDS ),
  21. DEFINE_FIELD( m_bAlphaTest, FIELD_BOOLEAN ),
  22. DEFINE_FIELD( m_bInstanced, FIELD_BOOLEAN ),
  23. DEFINE_FIELD( m_bUseAtlas, FIELD_BOOLEAN ),
  24. DEFINE_FIELD( m_bVertexColor, FIELD_BOOLEAN ),
  25. END_BYTESWAP_DATADESC()
  26. //--------------------------------------------------------------------------------------
  27. // Tiled coordinate
  28. //--------------------------------------------------------------------------------------
  29. BEGIN_BYTESWAP_DATADESC( IntVector )
  30. DEFINE_FIELD( x, FIELD_INTEGER ),
  31. DEFINE_FIELD( y, FIELD_INTEGER ),
  32. DEFINE_FIELD( z, FIELD_INTEGER ),
  33. END_BYTESWAP_DATADESC()
  34. BEGIN_BYTESWAP_DATADESC( TiledPosition_t )
  35. DEFINE_EMBEDDED( m_vTile ),
  36. DEFINE_FIELD( m_vLocal, FIELD_VECTOR ),
  37. END_BYTESWAP_DATADESC()
  38. //--------------------------------------------------------------------------------------
  39. // AABB
  40. //--------------------------------------------------------------------------------------
  41. BEGIN_BYTESWAP_DATADESC( AABB_t )
  42. DEFINE_FIELD( m_vMinBounds, FIELD_VECTOR ),
  43. DEFINE_FIELD( m_vMaxBounds, FIELD_VECTOR ),
  44. END_BYTESWAP_DATADESC()
  45. //--------------------------------------------------------------------------------------
  46. // Generic chunk descriptor
  47. //--------------------------------------------------------------------------------------
  48. BEGIN_BYTESWAP_DATADESC( BVHChunkDescriptor_t )
  49. DEFINE_FIELD( m_nChunkType, FIELD_INTEGER ),
  50. DEFINE_FIELD( m_nOffset, FIELD_INTEGER64 ), // TODO: Add int64 to datamap.h
  51. DEFINE_FIELD( m_nSize, FIELD_INTEGER64 ), // TODO: Add int64 to datamap.h
  52. END_BYTESWAP_DATADESC()
  53. //--------------------------------------------------------------------------------------
  54. // use this buffer desc instead of BufferDesc_t because BufferDesc_t has pointers
  55. // that won't serialized consistently between 32 and 64bits
  56. //--------------------------------------------------------------------------------------
  57. BEGIN_BYTESWAP_DATADESC( BVHBufferDesc_t )
  58. DEFINE_FIELD( m_nBufferType, FIELD_INTEGER ),
  59. DEFINE_FIELD( m_nElementCount, FIELD_INTEGER ),
  60. DEFINE_FIELD( m_nElementSizeInBytes, FIELD_INTEGER ),
  61. END_BYTESWAP_DATADESC()
  62. //--------------------------------------------------------------------------------------
  63. // Dictionary related
  64. //--------------------------------------------------------------------------------------
  65. BEGIN_BYTESWAP_DATADESC( CBVHDictionaryEntry )
  66. DEFINE_EMBEDDED( m_ChunkDesc ),
  67. DEFINE_FIELD( m_nRefCount, FIELD_INTEGER ),
  68. DEFINE_FIELD( m_nLastFrameUsed, FIELD_INTEGER ),
  69. DEFINE_FIELD( m_nResourceType, FIELD_INTEGER ),
  70. DEFINE_ARRAY( m_pName, FIELD_CHARACTER, MAX_RESOURCE_NAME ),
  71. DEFINE_FIELD( m_Flags, FIELD_CHARACTER ),
  72. DEFINE_FIELD( m_bInstanceData, FIELD_BOOLEAN ),
  73. DEFINE_ARRAY( m_padding, FIELD_CHARACTER, 2 ),
  74. END_BYTESWAP_DATADESC()
  75. BEGIN_BYTESWAP_DATADESC( BVHResourceDictionaryHeader_t )
  76. DEFINE_FIELD( m_nInputLayouts, FIELD_INTEGER ),
  77. DEFINE_FIELD( m_nResources, FIELD_INTEGER ),
  78. DEFINE_ARRAY( m_pPageFile, FIELD_CHARACTER, MAX_PAGE_FILE_NAME ),
  79. END_BYTESWAP_DATADESC()
  80. //--------------------------------------------------------------------------------------
  81. // Input layout
  82. //--------------------------------------------------------------------------------------
  83. BEGIN_BYTESWAP_DATADESC( BVHInputLayoutDesc_t )
  84. DEFINE_ARRAY( m_pName, FIELD_CHARACTER, RENDER_INPUT_LAYOUT_FIELD_SEMANTIC_NAME_SIZE ),
  85. DEFINE_FIELD( m_nFields, FIELD_INTEGER ),
  86. DEFINE_FIELD( m_64Bits, FIELD_INTEGER64 ), // TODO: Add int64 to datamap.h
  87. END_BYTESWAP_DATADESC()
  88. //--------------------------------------------------------------------------------------
  89. // Draw-call related
  90. //--------------------------------------------------------------------------------------
  91. BEGIN_BYTESWAP_DATADESC( BVHResourceBinding_t )
  92. DEFINE_FIELD( m_nResourceIndex, FIELD_INTEGER ),
  93. DEFINE_FIELD( m_nBindOffset, FIELD_INTEGER ),
  94. DEFINE_FIELD( m_nElementStride, FIELD_INTEGER ),
  95. DEFINE_FIELD( m_cBindStage, FIELD_CHARACTER ),
  96. DEFINE_FIELD( m_cBindSlot, FIELD_CHARACTER ),
  97. DEFINE_ARRAY( m_padding, FIELD_CHARACTER, 2 ),
  98. END_BYTESWAP_DATADESC()
  99. BEGIN_BYTESWAP_DATADESC( CBVHDrawCall )
  100. DEFINE_FIELD( m_Flags, FIELD_INTEGER ),
  101. DEFINE_EMBEDDED( m_Bounds ),
  102. DEFINE_FIELD( m_nInputLayout, FIELD_INTEGER ),
  103. DEFINE_FIELD( m_nResourceBindings, FIELD_INTEGER ),
  104. DEFINE_FIELD( m_nPrimitiveType, FIELD_INTEGER ),
  105. DEFINE_FIELD( m_nBaseVertex, FIELD_INTEGER ),
  106. DEFINE_FIELD( m_nVertexCount, FIELD_INTEGER ),
  107. DEFINE_FIELD( m_nStartIndex, FIELD_INTEGER ),
  108. DEFINE_FIELD( m_nIndexCount, FIELD_INTEGER ),
  109. DEFINE_FIELD( m_nStartInstance, FIELD_INTEGER ),
  110. DEFINE_FIELD( m_nInstanceCount, FIELD_INTEGER ),
  111. DEFINE_FIELD( m_64Bits, FIELD_INTEGER64 ), // TODO: Add int64 to datamap.h
  112. END_BYTESWAP_DATADESC()
  113. //--------------------------------------------------------------------------------------
  114. // BVHNode related
  115. //--------------------------------------------------------------------------------------
  116. BEGIN_BYTESWAP_DATADESC( BVHNodeHeader_t )
  117. DEFINE_FIELD( m_nID, FIELD_INTEGER ),
  118. DEFINE_FIELD( m_Flags, FIELD_INTEGER ),
  119. DEFINE_FIELD( m_nParent, FIELD_INTEGER ),
  120. DEFINE_EMBEDDED( m_Origin ),
  121. DEFINE_EMBEDDED( m_Bounds ),
  122. DEFINE_FIELD( m_flMinimumDistance, FIELD_FLOAT ),
  123. DEFINE_FIELD( m_nChildren, FIELD_INTEGER ),
  124. DEFINE_FIELD( m_nResources, FIELD_INTEGER ),
  125. DEFINE_FIELD( m_nDrawCalls, FIELD_INTEGER ),
  126. END_BYTESWAP_DATADESC()
  127. //--------------------------------------------------------------------------------------
  128. // World related
  129. //--------------------------------------------------------------------------------------
  130. BEGIN_BYTESWAP_DATADESC( BVHBuilderParams_t )
  131. DEFINE_FIELD( m_nSizeBytesPerVoxel, FIELD_INTEGER ),
  132. DEFINE_FIELD( m_flMinDrawVolumeSize, FIELD_FLOAT ),
  133. DEFINE_FIELD( m_flMinDistToCamera, FIELD_FLOAT ),
  134. DEFINE_FIELD( m_flMinAtlasDist, FIELD_FLOAT ),
  135. DEFINE_FIELD( m_flMinSimplifiedDist, FIELD_FLOAT ),
  136. DEFINE_FIELD( m_flHorzFOV, FIELD_FLOAT ),
  137. DEFINE_FIELD( m_flHalfScreenWidth, FIELD_FLOAT ),
  138. DEFINE_FIELD( m_nAtlasTextureSizeX, FIELD_INTEGER ),
  139. DEFINE_FIELD( m_nAtlasTextureSizeY, FIELD_INTEGER ),
  140. DEFINE_FIELD( m_nUniqueTextureSizeX, FIELD_INTEGER ),
  141. DEFINE_FIELD( m_nUniqueTextureSizeY, FIELD_INTEGER ),
  142. DEFINE_FIELD( m_nCompressedAtlasSize, FIELD_INTEGER ),
  143. DEFINE_FIELD( m_flGutterSize, FIELD_FLOAT ),
  144. DEFINE_FIELD( m_flUVMapThreshold, FIELD_FLOAT ),
  145. DEFINE_FIELD( m_vWorldUnitsPerTile, FIELD_VECTOR ),
  146. DEFINE_FIELD( m_nMaxTexScaleSlots, FIELD_INTEGER ),
  147. DEFINE_FIELD( m_bWrapInAtlas, FIELD_BOOLEAN ),
  148. DEFINE_ARRAY( m_padding, FIELD_CHARACTER, 3 ),
  149. END_BYTESWAP_DATADESC()
  150. //--------------------------------------------------------------------------------------
  151. // File header
  152. //--------------------------------------------------------------------------------------
  153. BEGIN_BYTESWAP_DATADESC( WorldFileHeader_t )
  154. DEFINE_FIELD( m_nFileVersion, FIELD_INTEGER ),
  155. DEFINE_FIELD( m_vWorldUnitsPerTile, FIELD_VECTOR ),
  156. DEFINE_FIELD( m_nChunks, FIELD_INTEGER ),
  157. DEFINE_EMBEDDED( m_BuilderParams ),
  158. END_BYTESWAP_DATADESC()
  159. //--------------------------------------------------------------------------------------
  160. // Known chunk headers
  161. //--------------------------------------------------------------------------------------
  162. BEGIN_BYTESWAP_DATADESC( HierarchyChunkHeader_t )
  163. DEFINE_FIELD( m_nNodes, FIELD_INTEGER ),
  164. DEFINE_FIELD( m_nMaxNodeSizeBytes, FIELD_INTEGER ),
  165. DEFINE_FIELD( m_nAvgNodeSizeBytes, FIELD_INTEGER ),
  166. END_BYTESWAP_DATADESC()
  167. BEGIN_BYTESWAP_DATADESC( EntityChunkHeader_t )
  168. DEFINE_FIELD( m_nEntities, FIELD_INTEGER ),
  169. END_BYTESWAP_DATADESC()
  170. BEGIN_BYTESWAP_DATADESC( VisibilityChunkHeader_t )
  171. DEFINE_FIELD( m_nNodes, FIELD_INTEGER ),
  172. DEFINE_FIELD( m_nDWORDS, FIELD_INTEGER ),
  173. DEFINE_FIELD( m_nX, FIELD_INTEGER ),
  174. DEFINE_FIELD( m_nY, FIELD_INTEGER ),
  175. DEFINE_FIELD( m_nZ, FIELD_INTEGER ),
  176. DEFINE_FIELD( m_vCellSize, FIELD_VECTOR ),
  177. DEFINE_FIELD( m_vStart, FIELD_VECTOR ),
  178. END_BYTESWAP_DATADESC()
  179. BEGIN_BYTESWAP_DATADESC( RenderInputLayoutFieldProxy_t )
  180. DEFINE_ARRAY( m_pSemanticName, FIELD_CHARACTER, RENDER_INPUT_LAYOUT_FIELD_SEMANTIC_NAME_SIZE ),
  181. DEFINE_FIELD( m_nSemanticIndex, FIELD_INTEGER ),
  182. DEFINE_FIELD( m_Format, FIELD_INTEGER ),
  183. DEFINE_FIELD( m_nOffset, FIELD_INTEGER ),
  184. DEFINE_FIELD( m_nSlot, FIELD_INTEGER ),
  185. DEFINE_FIELD( m_nSlotType, FIELD_INTEGER ),
  186. DEFINE_FIELD( m_nInstanceStepRate, FIELD_INTEGER ),
  187. END_BYTESWAP_DATADESC()