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.

110 lines
4.8 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #ifndef IMESHDX8_H
  9. #define IMESHDX8_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "meshbase.h"
  14. #include "shaderapi/ishaderapi.h"
  15. abstract_class IMeshMgr
  16. {
  17. public:
  18. // Initialize, shutdown
  19. virtual void Init() = 0;
  20. virtual void Shutdown() = 0;
  21. // Task switch...
  22. virtual void ReleaseBuffers() = 0;
  23. virtual void RestoreBuffers() = 0;
  24. // Releases all dynamic vertex buffers
  25. virtual void DestroyVertexBuffers() = 0;
  26. // Discards the dynamic vertex and index buffer
  27. virtual void DiscardVertexBuffers() = 0;
  28. // Creates, destroys static meshes
  29. virtual IMesh* CreateStaticMesh( VertexFormat_t vertexFormat, const char *pTextureBudgetGroup, IMaterial *pMaterial = NULL, VertexStreamSpec_t *pStreamSpec = NULL ) = 0;
  30. virtual void DestroyStaticMesh( IMesh* pMesh ) = 0;
  31. // Gets at the dynamic mesh
  32. virtual IMesh* GetDynamicMesh( IMaterial* pMaterial, VertexFormat_t vertexFormat, int nHWSkinBoneCount, bool buffered = true,
  33. IMesh* pVertexOverride = 0, IMesh* pIndexOverride = 0) = 0;
  34. // ------------ New Vertex/Index Buffer interface ----------------------------
  35. // Do we need support for bForceTempMesh and bSoftwareVertexShader?
  36. // I don't think we use bSoftwareVertexShader anymore. .need to look into bForceTempMesh.
  37. virtual IVertexBuffer *CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pBudgetGroup ) = 0;
  38. virtual IIndexBuffer *CreateIndexBuffer( ShaderBufferType_t indexBufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pBudgetGroup ) = 0;
  39. virtual void DestroyVertexBuffer( IVertexBuffer * ) = 0;
  40. virtual void DestroyIndexBuffer( IIndexBuffer * ) = 0;
  41. // Do we need to specify the stream here in the case of locking multiple dynamic VBs on different streams?
  42. virtual IVertexBuffer *GetDynamicVertexBuffer( int streamID, VertexFormat_t vertexFormat, bool bBuffered = true ) = 0;
  43. virtual IIndexBuffer *GetDynamicIndexBuffer( ) = 0;
  44. virtual void BindVertexBuffer( int streamID, IVertexBuffer *pVertexBuffer, int nOffsetInBytes, int nFirstVertex, int nVertexCount, VertexFormat_t fmt, int nRepetitions = 1 ) = 0;
  45. virtual void BindIndexBuffer( IIndexBuffer *pIndexBuffer, int nOffsetInBytes ) = 0;
  46. virtual void Draw( MaterialPrimitiveType_t primitiveType, int nFirstIndex, int nIndexCount ) = 0;
  47. // ------------ End ----------------------------
  48. virtual VertexFormat_t GetCurrentVertexFormat( void ) const = 0;
  49. virtual void RenderPassWithVertexAndIndexBuffers( const unsigned char *pInstanceCommandBuffer ) = 0;
  50. virtual void DrawInstancedPrims( const unsigned char *pInstanceCommandBuffer ) = 0;
  51. // Computes the vertex format
  52. virtual VertexFormat_t ComputeVertexFormat( unsigned int flags,
  53. int numTexCoords, int* pTexCoordDimensions, int numBoneWeights,
  54. int userDataSize ) const = 0;
  55. // Returns the number of buffers...
  56. virtual int BufferCount() const = 0;
  57. // Use fat vertices (for tools)
  58. virtual void UseFatVertices( bool bUseFat ) = 0;
  59. // Returns the number of vertices + indices we can render using the dynamic mesh
  60. // Passing true in the second parameter will return the max # of vertices + indices
  61. // we can use before a flush is provoked and may return different values
  62. // if called multiple times in succession.
  63. // Passing false into the second parameter will return
  64. // the maximum possible vertices + indices that can be rendered in a single batch
  65. virtual void GetMaxToRender( IMesh *pMesh, bool bMaxUntilFlush, int *pMaxVerts, int *pMaxIndices ) = 0;
  66. // Returns the max number of vertices we can render for a given material
  67. virtual int GetMaxVerticesToRender( IMaterial *pMaterial ) = 0;
  68. virtual int GetMaxIndicesToRender( ) = 0;
  69. virtual IMesh *GetFlexMesh() = 0;
  70. virtual void ComputeVertexDescription( unsigned char* pBuffer, VertexFormat_t vertexFormat, MeshDesc_t& desc ) const = 0;
  71. virtual int VertexFormatSize( VertexFormat_t vertexFormat ) const = 0;
  72. virtual IVertexBuffer *GetDynamicVertexBuffer( IMaterial *pMaterial, bool buffered = true ) = 0;
  73. virtual void MarkUnusedVertexFields( unsigned int nFlags, int nTexCoordCount, bool *pUnusedTexCoords ) = 0;
  74. virtual void DrawInstances( int nInstanceCount, const MeshInstanceData_t *pInstances ) = 0;
  75. #ifdef _GAMECONSOLE
  76. virtual int GetDynamicIndexBufferAllocationCount() = 0;
  77. virtual int GetDynamicIndexBufferIndicesLeft() = 0;
  78. // Backdoor used by the queued context to directly use write-combined memory
  79. virtual IMesh *GetExternalMesh( const ExternalMeshInfo_t& info ) = 0;
  80. virtual void SetExternalMeshData( IMesh *pMesh, const ExternalMeshData_t &data ) = 0;
  81. virtual IIndexBuffer *GetExternalIndexBuffer( int nIndexCount, uint16 *pIndexData ) = 0;
  82. #endif
  83. };
  84. #endif // IMESHDX8_H