Guest User

Untitled

a guest
Dec 14th, 2019
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2.  
  3. #include "IAppSystem.hpp"
  4.  
  5. #define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  6. #define MAXSTUDIOSKINS 32
  7.  
  8. // These are given to FindMaterial to reference the texture groups that Show up on the
  9. #define TEXTURE_GROUP_LIGHTMAP "Lightmaps"
  10. #define TEXTURE_GROUP_WORLD "World textures"
  11. #define TEXTURE_GROUP_MODEL "Model textures"
  12. #define TEXTURE_GROUP_VGUI "VGUI textures"
  13. #define TEXTURE_GROUP_PARTICLE "Particle textures"
  14. #define TEXTURE_GROUP_DECAL "Decal textures"
  15. #define TEXTURE_GROUP_SKYBOX "SkyBox textures"
  16. #define TEXTURE_GROUP_CLIENT_EFFECTS "ClientEffect textures"
  17. #define TEXTURE_GROUP_OTHER "Other textures"
  18. #define TEXTURE_GROUP_PRECACHED "Precached"
  19. #define TEXTURE_GROUP_CUBE_MAP "CubeMap textures"
  20. #define TEXTURE_GROUP_RENDER_TARGET "RenderTargets"
  21. #define TEXTURE_GROUP_UNACCOUNTED "Unaccounted textures"
  22. //#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER "Static Vertex"
  23. #define TEXTURE_GROUP_STATIC_INDEX_BUFFER "Static Indices"
  24. #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_DISP "Displacement Verts"
  25. #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_COLOR "Lighting Verts"
  26. #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_WORLD "World Verts"
  27. #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_MODELS "Model Verts"
  28. #define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_OTHER "Other Verts"
  29. #define TEXTURE_GROUP_DYNAMIC_INDEX_BUFFER "Dynamic Indices"
  30. #define TEXTURE_GROUP_DYNAMIC_VERTEX_BUFFER "Dynamic Verts"
  31. #define TEXTURE_GROUP_DEPTH_BUFFER "DepthBuffer"
  32. #define TEXTURE_GROUP_VIEW_MODEL "ViewModel"
  33. #define TEXTURE_GROUP_PIXEL_SHADERS "Pixel Shaders"
  34. #define TEXTURE_GROUP_VERTEX_SHADERS "Vertex Shaders"
  35. #define TEXTURE_GROUP_RENDER_TARGET_SURFACE "RenderTarget Surfaces"
  36. #define TEXTURE_GROUP_MORPH_TARGETS "Morph Targets"
  37.  
  38. //-----------------------------------------------------------------------------
  39. // forward declarations
  40. //-----------------------------------------------------------------------------
  41. class IMaterial;
  42. class IMesh;
  43. class IVertexBuffer;
  44. class IIndexBuffer;
  45. struct MaterialSystem_Config_t;
  46. class VMatrix;
  47. class matrix3x4_t;
  48. class ITexture;
  49. struct MaterialSystemHWID_t;
  50. class KeyValues;
  51. class IShader;
  52. class IVertexTexture;
  53. class IMorph;
  54. class IMatRenderContext;
  55. class ICallQueue;
  56. struct MorphWeight_t;
  57. class IFileList;
  58. struct VertexStreamSpec_t;
  59. struct ShaderStencilState_t;
  60. struct MeshInstanceData_t;
  61. class IClientMaterialSystem;
  62. class CPaintMaterial;
  63. class IPaintMapDataManager;
  64. class IPaintMapTextureManager;
  65. class GPUMemoryStats;
  66. struct AspectRatioInfo_t;
  67. struct CascadedShadowMappingState_t;
  68.  
  69. class IMaterialProxyFactory;
  70. class ITexture;
  71. class IMaterialSystemHardwareConfig;
  72. class CShadowMgr;
  73.  
  74. enum CompiledVtfFlags
  75. {
  76. TEXTUREFLAGS_POINTSAMPLE = 0x00000001,
  77. TEXTUREFLAGS_TRILINEAR = 0x00000002,
  78. TEXTUREFLAGS_CLAMPS = 0x00000004,
  79. TEXTUREFLAGS_CLAMPT = 0x00000008,
  80. TEXTUREFLAGS_ANISOTROPIC = 0x00000010,
  81. TEXTUREFLAGS_HINT_DXT5 = 0x00000020,
  82. TEXTUREFLAGS_PWL_CORRECTED = 0x00000040,
  83. TEXTUREFLAGS_NORMAL = 0x00000080,
  84. TEXTUREFLAGS_NOMIP = 0x00000100,
  85. TEXTUREFLAGS_NOLOD = 0x00000200,
  86. TEXTUREFLAGS_ALL_MIPS = 0x00000400,
  87. TEXTUREFLAGS_PROCEDURAL = 0x00000800,
  88. TEXTUREFLAGS_ONEBITALPHA = 0x00001000,
  89. TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000,
  90. TEXTUREFLAGS_ENVMAP = 0x00004000,
  91. TEXTUREFLAGS_RENDERTARGET = 0x00008000,
  92. TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000,
  93. TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000,
  94. TEXTUREFLAGS_SINGLECOPY = 0x00040000,
  95. TEXTUREFLAGS_PRE_SRGB = 0x00080000,
  96. TEXTUREFLAGS_UNUSED_00100000 = 0x00100000,
  97. TEXTUREFLAGS_UNUSED_00200000 = 0x00200000,
  98. TEXTUREFLAGS_UNUSED_00400000 = 0x00400000,
  99. TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000,
  100. TEXTUREFLAGS_UNUSED_01000000 = 0x01000000,
  101. TEXTUREFLAGS_CLAMPU = 0x02000000,
  102. TEXTUREFLAGS_VERTEXTEXTURE = 0x04000000,
  103. TEXTUREFLAGS_SSBUMP = 0x08000000,
  104. TEXTUREFLAGS_UNUSED_10000000 = 0x10000000,
  105. TEXTUREFLAGS_BORDER = 0x20000000,
  106. TEXTUREFLAGS_UNUSED_40000000 = 0x40000000,
  107. TEXTUREFLAGS_UNUSED_80000000 = 0x80000000
  108. };
  109.  
  110. enum StandardLightmap_t
  111. {
  112. MATERIAL_SYSTEM_LIGHTMAP_PAGE_WHITE = -1,
  113. MATERIAL_SYSTEM_LIGHTMAP_PAGE_WHITE_BUMP = -2,
  114. MATERIAL_SYSTEM_LIGHTMAP_PAGE_USER_DEFINED = -3
  115. };
  116.  
  117.  
  118. struct MaterialSystem_SortInfo_t
  119. {
  120. IMaterial* material;
  121. int lightmapPageID;
  122. };
  123.  
  124. enum MaterialThreadMode_t
  125. {
  126. MATERIAL_SINGLE_THREADED,
  127. MATERIAL_QUEUED_SINGLE_THREADED,
  128. MATERIAL_QUEUED_THREADED
  129. };
  130.  
  131. enum MaterialContextType_t
  132. {
  133. MATERIAL_HARDWARE_CONTEXT,
  134. MATERIAL_QUEUED_CONTEXT,
  135. MATERIAL_NULL_CONTEXT
  136. };
  137.  
  138. enum
  139. {
  140. MATERIAL_ADAPTER_NAME_LENGTH = 512
  141. };
  142.  
  143. struct MaterialTextureInfo_t
  144. {
  145. int iExcludeInformation;
  146. };
  147.  
  148. struct ApplicationPerformanceCountersInfo_t
  149. {
  150. float msMain;
  151. float msMST;
  152. float msGPU;
  153. float msFlip;
  154. float msTotal;
  155. };
  156.  
  157. struct ApplicationInstantCountersInfo_t
  158. {
  159. uint32_t m_nCpuActivityMask;
  160. uint32_t m_nDeferredWordsAllocated;
  161. };
  162. struct MaterialAdapterInfo_t
  163. {
  164. char m_pDriverName[MATERIAL_ADAPTER_NAME_LENGTH];
  165. unsigned int m_VendorID;
  166. unsigned int m_DeviceID;
  167. unsigned int m_SubSysID;
  168. unsigned int m_Revision;
  169. int m_nDXSupportLevel; // This is the *preferred* dx support level
  170. int m_nMinDXSupportLevel;
  171. int m_nMaxDXSupportLevel;
  172. unsigned int m_nDriverVersionHigh;
  173. unsigned int m_nDriverVersionLow;
  174. };
  175.  
  176. struct MaterialVideoMode_t
  177. {
  178. int m_Width; // if width and height are 0 and you select
  179. int m_Height; // windowed mode, it'll use the window size
  180. ImageFormat m_Format; // use ImageFormats (ignored for windowed mode)
  181. int m_RefreshRate; // 0 == default (ignored for windowed mode)
  182. };
  183. enum HDRType_t
  184. {
  185. HDR_TYPE_NONE,
  186. HDR_TYPE_INTEGER,
  187. HDR_TYPE_FLOAT,
  188. };
  189.  
  190. enum RestoreChangeFlags_t
  191. {
  192. MATERIAL_RESTORE_VERTEX_FORMAT_CHANGED = 0x1,
  193. MATERIAL_RESTORE_RELEASE_MANAGED_RESOURCES = 0x2,
  194. };
  195.  
  196. enum RenderTargetSizeMode_t
  197. {
  198. RT_SIZE_NO_CHANGE = 0,
  199. RT_SIZE_DEFAULT = 1,
  200. RT_SIZE_PICMIP = 2,
  201. RT_SIZE_HDR = 3,
  202. RT_SIZE_FULL_FRAME_BUFFER = 4,
  203. RT_SIZE_OFFSCREEN = 5,
  204. RT_SIZE_FULL_FRAME_BUFFER_ROUNDED_UP = 6
  205. };
  206.  
  207. enum MaterialRenderTargetDepth_t
  208. {
  209. MATERIAL_RT_DEPTH_SHARED = 0x0,
  210. MATERIAL_RT_DEPTH_SEPARATE = 0x1,
  211. MATERIAL_RT_DEPTH_NONE = 0x2,
  212. MATERIAL_RT_DEPTH_ONLY = 0x3,
  213. };
  214.  
  215. typedef void(*MaterialBufferReleaseFunc_t)(int nChangeFlags); // see RestoreChangeFlags_t
  216. typedef void(*MaterialBufferRestoreFunc_t)(int nChangeFlags); // see RestoreChangeFlags_t
  217. typedef void(*ModeChangeCallbackFunc_t)(void);
  218. typedef void(*EndFrameCleanupFunc_t)(void);
  219. typedef bool(*EndFramePriorToNextContextFunc_t)(void);
  220. typedef void(*OnLevelShutdownFunc_t)(void* pUserData);
  221.  
  222. typedef unsigned short MaterialHandle_t;
  223. DECLARE_POINTER_HANDLE(MaterialLock_t);
  224.  
  225. class IMaterialSystem : public IAppSystem
  226. {
  227. public:
  228.  
  229. virtual CreateInterfaceFn Init(char const* pShaderAPIDLL, IMaterialProxyFactory* pMaterialProxyFactory, CreateInterfaceFn fileSystemFactory, CreateInterfaceFn cvarFactory = NULL) = 0;
  230. virtual void SetShaderAPI(char const* pShaderAPIDLL) = 0;
  231. virtual void SetAdapter(int nAdapter, int nFlags) = 0;
  232. virtual void ModInit() = 0;
  233. virtual void ModShutdown() = 0;
  234. virtual void SetThreadMode(MaterialThreadMode_t mode, int nServiceThread = -1) = 0;
  235. virtual MaterialThreadMode_t GetThreadMode() = 0;
  236. virtual void ExecuteQueued() = 0;
  237. virtual void OnDebugEvent(const char* pEvent) = 0;
  238. virtual IMaterialSystemHardwareConfig* GetHardwareConfig(const char* pVersion, int* returnCode) = 0;
  239. virtual void __unknown() = 0;
  240. virtual bool UpdateConfig(bool bForceUpdate) = 0; //20
  241. virtual bool OverrideConfig(const MaterialSystem_Config_t& config, bool bForceUpdate) = 0;
  242. virtual const MaterialSystem_Config_t& GetCurrentConfigForVideoCard() const = 0;
  243. virtual bool GetRecommendedConfigurationInfo(int nDXLevel, KeyValues* pKeyValues) = 0;
  244. virtual int GetDisplayAdapterCount() const = 0;
  245. virtual int GetCurrentAdapter() const = 0;
  246. virtual void GetDisplayAdapterInfo(int adapter, MaterialAdapterInfo_t& info) const = 0;
  247. virtual int GetModeCount(int adapter) const = 0;
  248. virtual void GetModeInfo(int adapter, int mode, MaterialVideoMode_t& info) const = 0;
  249. virtual void AddModeChangeCallBack(ModeChangeCallbackFunc_t func) = 0;
  250. virtual void GetDisplayMode(MaterialVideoMode_t& mode) const = 0; //30
  251. virtual bool SetMode(PVOID hwnd, const MaterialSystem_Config_t& config) = 0;
  252. virtual bool SupportsMSAAMode(int nMSAAMode) = 0;
  253. virtual const MaterialSystemHWID_t& GetVideoCardIdentifier(void) const = 0;
  254. virtual void SpewDriverInfo() const = 0;
  255. virtual void GetBackBufferDimensions(int& width, int& height) const = 0;
  256. virtual ImageFormat GetBackBufferFormat() const = 0;
  257. virtual const AspectRatioInfo_t& GetAspectRatioInfo() const = 0;
  258. virtual bool SupportsHDRMode(HDRType_t nHDRModede) = 0;
  259. virtual bool AddView(PVOID hwnd) = 0;
  260. virtual void RemoveView(PVOID hwnd) = 0; //40
  261. virtual void SetView(PVOID hwnd) = 0;
  262. virtual void BeginFrame(float frameTime) = 0;
  263. virtual void EndFrame() = 0;
  264. virtual void Flush(bool flushHardware = false) = 0;
  265. virtual unsigned int GetCurrentFrameCount() = 0;
  266. virtual void SwapBuffers() = 0;
  267. virtual void EvictManagedResources() = 0;
  268. virtual void ReleaseResources(void) = 0;
  269. virtual void ReacquireResources(void) = 0;
  270. virtual void AddReleaseFunc(MaterialBufferReleaseFunc_t func) = 0; //50
  271. virtual void RemoveReleaseFunc(MaterialBufferReleaseFunc_t func) = 0;
  272. virtual void AddRestoreFunc(MaterialBufferRestoreFunc_t func) = 0;
  273. virtual void RemoveRestoreFunc(MaterialBufferRestoreFunc_t func) = 0;
  274. virtual void AddEndFrameCleanupFunc(EndFrameCleanupFunc_t func) = 0;
  275. virtual void RemoveEndFrameCleanupFunc(EndFrameCleanupFunc_t func) = 0;
  276. virtual void OnLevelShutdown() = 0;
  277. virtual bool AddOnLevelShutdownFunc(OnLevelShutdownFunc_t func, void* pUserData) = 0;
  278. virtual bool RemoveOnLevelShutdownFunc(OnLevelShutdownFunc_t func, void* pUserData) = 0;
  279. virtual void OnLevelLoadingComplete() = 0;
  280. virtual void ResetTempHWMemory(bool bExitingLevel = false) = 0; //60
  281. virtual void HandleDeviceLost() = 0;
  282. virtual int ShaderCount() const = 0;
  283. virtual int GetShaders(int nFirstShader, int nMaxCount, IShader** ppShaderList) const = 0;
  284. virtual int ShaderFlagCount() const = 0;
  285. virtual const char* ShaderFlagName(int nIndex) const = 0;
  286. virtual void GetShaderFallback(const char* pShaderName, char* pFallbackShader, int nFallbackLength) = 0;
  287. virtual IMaterialProxyFactory* GetMaterialProxyFactory() = 0;
  288. virtual void SetMaterialProxyFactory(IMaterialProxyFactory* pFactory) = 0;
  289. virtual void EnableEditorMaterials() = 0;
  290. virtual void EnableGBuffers() = 0; //70
  291. virtual void SetInStubMode(bool bInStubMode) = 0;
  292. virtual void DebugPrintUsedMaterials(const char* pSearchSubString, bool bVerbose) = 0;
  293. virtual void DebugPrintUsedTextures(void) = 0;
  294. virtual void ToggleSuppressMaterial(char const* pMaterialName) = 0;
  295. virtual void ToggleDebugMaterial(char const* pMaterialName) = 0;
  296. virtual bool UsingFastClipping(void) = 0;
  297. virtual int StencilBufferBits(void) = 0; //number of bits per pixel in the stencil buffer
  298. virtual void UncacheAllMaterials() = 0;
  299. virtual void UncacheUnusedMaterials(bool bRecomputeStateSnapshots = false) = 0;
  300. virtual void CacheUsedMaterials() = 0; //80
  301. virtual void ReloadTextures() = 0;
  302. virtual void ReloadMaterials(const char* pSubString = NULL) = 0;
  303. virtual IMaterial* CreateMaterial(const char* pMaterialName, KeyValues* pVMTKeyValues) = 0;
  304. virtual IMaterial* FindMaterial(char const* pMaterialName, const char* pTextureGroupName, bool complain = true, const char* pComplainPrefix = NULL) = 0;
  305. virtual void LoadKeyValuesFromVMTFile(KeyValues& values, const char* name, bool somebool) const = 0;
  306. virtual MaterialHandle_t FirstMaterial() const = 0;
  307. virtual MaterialHandle_t NextMaterial(MaterialHandle_t h) const = 0;
  308. virtual MaterialHandle_t InvalidMaterial() const = 0;
  309. virtual IMaterial* GetMaterial(MaterialHandle_t h) const = 0;
  310. virtual int GetNumMaterials() const = 0;
  311. virtual ITexture* FindTexture(char const* pTextureName, const char* pTextureGroupName, bool complain = true) = 0;
  312. virtual bool IsTextureLoaded(char const* pTextureName) const = 0;
  313. virtual ITexture* CreateProceduralTexture(const char* pTextureName, const char* pTextureGroupName, int w, int h, ImageFormat fmt, int nFlags) = 0;
  314. virtual void BeginRenderTargetAllocation() = 0;
  315. virtual void EndRenderTargetAllocation() = 0; // Simulate an Alt-Tab in here, which causes a release/restore of all resources
  316. virtual ITexture* CreateRenderTargetTexture(int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED) = 0;
  317. virtual ITexture* CreateNamedRenderTargetTextureEx(const char* pRTName, int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, unsigned int renderTargetFlags = 0) = 0;
  318. virtual ITexture* CreateNamedRenderTargetTexture(const char* pRTName, int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, bool bClampTexCoords = true, bool bAutoMipMap = false) = 0;
  319. virtual ITexture* CreateNamedRenderTargetTextureEx2(const char* pRTName, int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, unsigned int renderTargetFlags = 0) = 0;
  320.  
  321. };
RAW Paste Data