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.

98 lines
4.2 KiB

  1. //========= Copyright 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. // Flushes the dynamic mesh. Should be called when state changes
  27. virtual void Flush() = 0;
  28. // Discards the dynamic vertex and index buffer
  29. virtual void DiscardVertexBuffers() = 0;
  30. // Creates, destroys static meshes
  31. virtual IMesh* CreateStaticMesh( VertexFormat_t vertexFormat, const char *pTextureBudgetGroup, IMaterial *pMaterial = NULL ) = 0;
  32. virtual void DestroyStaticMesh( IMesh* pMesh ) = 0;
  33. // Gets at the dynamic mesh
  34. virtual IMesh* GetDynamicMesh( IMaterial* pMaterial, VertexFormat_t vertexFormat, int nHWSkinBoneCount, bool buffered = true,
  35. IMesh* pVertexOverride = 0, IMesh* pIndexOverride = 0) = 0;
  36. // ------------ New Vertex/Index Buffer interface ----------------------------
  37. // Do we need support for bForceTempMesh and bSoftwareVertexShader?
  38. // I don't think we use bSoftwareVertexShader anymore. .need to look into bForceTempMesh.
  39. virtual IVertexBuffer *CreateVertexBuffer( ShaderBufferType_t type, VertexFormat_t fmt, int nVertexCount, const char *pBudgetGroup ) = 0;
  40. virtual IIndexBuffer *CreateIndexBuffer( ShaderBufferType_t indexBufferType, MaterialIndexFormat_t fmt, int nIndexCount, const char *pBudgetGroup ) = 0;
  41. virtual void DestroyVertexBuffer( IVertexBuffer * ) = 0;
  42. virtual void DestroyIndexBuffer( IIndexBuffer * ) = 0;
  43. // Do we need to specify the stream here in the case of locking multiple dynamic VBs on different streams?
  44. virtual IVertexBuffer *GetDynamicVertexBuffer( int streamID, VertexFormat_t vertexFormat, bool bBuffered = true ) = 0;
  45. virtual IIndexBuffer *GetDynamicIndexBuffer( MaterialIndexFormat_t fmt, bool bBuffered = true ) = 0;
  46. virtual void BindVertexBuffer( int streamID, IVertexBuffer *pVertexBuffer, int nOffsetInBytes, int nFirstVertex, int nVertexCount, VertexFormat_t fmt, int nRepetitions = 1 ) = 0;
  47. virtual void BindIndexBuffer( IIndexBuffer *pIndexBuffer, int nOffsetInBytes ) = 0;
  48. virtual void Draw( MaterialPrimitiveType_t primitiveType, int nFirstIndex, int nIndexCount ) = 0;
  49. // ------------ End ----------------------------
  50. virtual VertexFormat_t GetCurrentVertexFormat( void ) const = 0;
  51. virtual void RenderPassWithVertexAndIndexBuffers( void ) = 0;
  52. // Computes the vertex format
  53. virtual VertexFormat_t ComputeVertexFormat( unsigned int flags,
  54. int numTexCoords, int* pTexCoordDimensions, int numBoneWeights,
  55. int userDataSize ) const = 0;
  56. // Returns the number of buffers...
  57. virtual int BufferCount() const = 0;
  58. // Use fat vertices (for tools)
  59. virtual void UseFatVertices( bool bUseFat ) = 0;
  60. // Returns the number of vertices + indices we can render using the dynamic mesh
  61. // Passing true in the second parameter will return the max # of vertices + indices
  62. // we can use before a flush is provoked and may return different values
  63. // if called multiple times in succession.
  64. // Passing false into the second parameter will return
  65. // the maximum possible vertices + indices that can be rendered in a single batch
  66. virtual void GetMaxToRender( IMesh *pMesh, bool bMaxUntilFlush, int *pMaxVerts, int *pMaxIndices ) = 0;
  67. // Returns the max number of vertices we can render for a given material
  68. virtual int GetMaxVerticesToRender( IMaterial *pMaterial ) = 0;
  69. virtual int GetMaxIndicesToRender( ) = 0;
  70. virtual IMesh *GetFlexMesh() = 0;
  71. virtual void ComputeVertexDescription( unsigned char* pBuffer, VertexFormat_t vertexFormat, MeshDesc_t& desc ) const = 0;
  72. virtual IVertexBuffer *GetDynamicVertexBuffer( IMaterial *pMaterial, bool buffered = true ) = 0;
  73. virtual IIndexBuffer *GetDynamicIndexBuffer( IMaterial *pMaterial, bool buffered = true ) = 0;
  74. virtual void MarkUnusedVertexFields( unsigned int nFlags, int nTexCoordCount, bool *pUnusedTexCoords ) = 0;
  75. };
  76. #endif // IMESHDX8_H