CmPrerequisites.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. #pragma once
  2. #include "CmPrerequisitesUtil.h"
  3. #define CM_MAX_MULTIPLE_RENDER_TARGETS 8
  4. #define CM_FORCE_SINGLETHREADED_RENDERING 0
  5. //----------------------------------------------------------------------------
  6. // Windows Settings
  7. #if CM_PLATFORM == CM_PLATFORM_WIN32
  8. // If we're not including this from a client build, specify that the stuff
  9. // should get exported. Otherwise, import it.
  10. # if defined( CM_STATIC_LIB )
  11. // Linux compilers don't have symbol import/export directives.
  12. # define CM_EXPORT
  13. # else
  14. # if defined( CM_EXPORTS )
  15. # define CM_EXPORT __declspec( dllexport )
  16. # else
  17. # if defined( __MINGW32__ )
  18. # define CM_EXPORT
  19. # else
  20. # define CM_EXPORT __declspec( dllimport )
  21. # endif
  22. # endif
  23. # endif
  24. // Win32 compilers use _DEBUG for specifying debug builds.
  25. // for MinGW, we set DEBUG
  26. # if defined(_DEBUG) || defined(DEBUG)
  27. # define CM_DEBUG_MODE 1
  28. # else
  29. # define CM_DEBUG_MODE 0
  30. # endif
  31. #endif // CM_PLATFORM == CM_PLATFORM_WIN32
  32. // Linux/Apple Settings
  33. #if CM_PLATFORM == CM_PLATFORM_LINUX || CM_PLATFORM == CM_PLATFORM_APPLE
  34. // Enable GCC symbol visibility
  35. # if defined( CM_GCC_VISIBILITY )
  36. # define CM_EXPORT __attribute__ ((visibility("default")))
  37. # define CM_HIDDEN __attribute__ ((visibility("hidden")))
  38. # else
  39. # define CM_EXPORT
  40. # define CM_HIDDEN
  41. # endif
  42. // A quick define to overcome different names for the same function
  43. # define stricmp strcasecmp
  44. # ifdef DEBUG
  45. # define CM_DEBUG_MODE 1
  46. # else
  47. # define CM_DEBUG_MODE 0
  48. # endif
  49. #endif
  50. #include "CmMemAllocCategories.h"
  51. namespace CamelotFramework
  52. {
  53. // Pre-declare classes
  54. // Allows use of pointers in header files without including individual .h
  55. // so decreases dependencies between files
  56. class Color;
  57. class GpuProgram;
  58. class GpuProgramManager;
  59. class IndexBuffer;
  60. class OcclusionQuery;
  61. class VertexBuffer;
  62. class PixelBuffer;
  63. class GpuBuffer;
  64. class HighLevelGpuProgram;
  65. class HighLevelGpuProgramManager;
  66. class HighLevelGpuProgramFactory;
  67. class IndexData;
  68. class Pass;
  69. class Technique;
  70. class Shader;
  71. class Material;
  72. class RenderSystem;
  73. class RenderSystemCapabilities;
  74. class RenderTarget;
  75. class RenderTexture;
  76. class MultiRenderTexture;
  77. class RenderWindow;
  78. struct RenderOpMesh;
  79. class StringInterface;
  80. class SamplerState;
  81. class TextureManager;
  82. class Viewport;
  83. class VertexData;
  84. class VertexDeclaration;
  85. class Input;
  86. struct PositionalInputEvent;
  87. class RawInputHandler;
  88. class Renderer;
  89. class RendererFactory;
  90. class WorkQueue;
  91. class PassParameters;
  92. class AsyncOp;
  93. class HardwareBufferManager;
  94. class FontManager;
  95. class DepthStencilState;
  96. class RenderStateManager;
  97. class RasterizerState;
  98. class BlendState;
  99. class GpuParamBlock;
  100. class GpuParamBlockBuffer;
  101. class GpuParams;
  102. struct GpuParamDesc;
  103. struct GpuParamDataDesc;
  104. struct GpuParamObjectDesc;
  105. struct GpuParamBlockDesc;
  106. class GpuProgInclude;
  107. class TextureView;
  108. class CoreObject;
  109. class ImportOptions;
  110. struct FontData;
  111. class GameObject;
  112. class GpuResource;
  113. class GpuResourceData;
  114. class BindableGpuParams;
  115. class BindableGpuParamBlock;
  116. struct RenderOperation;
  117. class RenderQueue;
  118. struct ProfilerReport;
  119. class VertexDataDesc;
  120. class EventQuery;
  121. class TimerQuery;
  122. class FrameAlloc;
  123. class FolderMonitor;
  124. // Asset import
  125. class SpecificImporter;
  126. class Importer;
  127. // Resources
  128. class Resource;
  129. class Resources;
  130. class ResourceManifest;
  131. class Texture;
  132. class Mesh;
  133. class MeshBase;
  134. class TransientMesh;
  135. class MeshHeap;
  136. class Font;
  137. class OSDropTarget;
  138. // Scene
  139. class SceneObject;
  140. class Component;
  141. class SceneManager;
  142. // RTTI
  143. class MeshRTTI;
  144. // Desc structs
  145. struct SAMPLER_STATE_DESC;
  146. struct DEPTH_STENCIL_STATE_DESC;
  147. struct RASTERIZER_STATE_DESC;
  148. struct BLEND_STATE_DESC;
  149. struct RENDER_TARGET_BLEND_STATE_DESC;
  150. struct RENDER_TEXTURE_DESC;
  151. struct RENDER_WINDOW_DESC;
  152. struct FONT_DESC;
  153. template<class T>
  154. class CoreThreadAccessor;
  155. class CommandQueueNoSync;
  156. class CommandQueueSync;
  157. }
  158. /************************************************************************/
  159. /* Shared pointer typedefs */
  160. /************************************************************************/
  161. namespace CamelotFramework
  162. {
  163. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  164. typedef std::shared_ptr<HighLevelGpuProgram> HighLevelGpuProgramPtr;
  165. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  166. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  167. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  168. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  169. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  170. typedef std::shared_ptr<Mesh> MeshPtr;
  171. typedef std::shared_ptr<MeshBase> MeshBasePtr;
  172. typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
  173. typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
  174. typedef std::shared_ptr<Texture> TexturePtr;
  175. typedef std::shared_ptr<Resource> ResourcePtr;
  176. typedef std::shared_ptr<Technique> TechniquePtr;
  177. typedef std::shared_ptr<Pass> PassPtr;
  178. typedef std::shared_ptr<Shader> ShaderPtr;
  179. typedef std::shared_ptr<Material> MaterialPtr;
  180. typedef std::shared_ptr<Renderer> RendererPtr;
  181. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  182. typedef std::shared_ptr<WorkQueue> WorkQueuePtr;
  183. typedef std::shared_ptr<PassParameters> PassParametersPtr;
  184. typedef std::shared_ptr<Component> ComponentPtr;
  185. typedef std::shared_ptr<SceneObject> GameObjectPtr;
  186. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  187. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  188. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  189. typedef std::shared_ptr<BlendState> BlendStatePtr;
  190. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  191. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  192. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  193. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  194. typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
  195. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  196. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  197. typedef std::shared_ptr<TextureView> TextureViewPtr;
  198. typedef std::shared_ptr<Viewport> ViewportPtr;
  199. typedef std::shared_ptr<GpuProgInclude> GpuProgIncludePtr;
  200. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  201. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  202. typedef std::shared_ptr<Font> FontPtr;
  203. typedef std::shared_ptr<GpuResource> GpuResourcePtr;
  204. typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
  205. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  206. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  207. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  208. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  209. typedef std::shared_ptr<EventQuery> EventQueryPtr;
  210. typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
  211. typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
  212. }
  213. /************************************************************************/
  214. /* RTTI */
  215. /************************************************************************/
  216. namespace CamelotFramework
  217. {
  218. enum TypeID_Core
  219. {
  220. TID_Texture = 1001,
  221. TID_Mesh = 1002,
  222. TID_MeshData = 1003,
  223. TID_VertexDeclaration = 1004,
  224. TID_VertexElementData = 1005,
  225. TID_Component = 1006,
  226. TID_ResourceHandle = 1009,
  227. TID_GpuProgram = 1010,
  228. TID_ResourceHandleData = 1011,
  229. TID_CgProgram = 1012,
  230. TID_Pass = 1014,
  231. TID_Technique = 1015,
  232. TID_Shader = 1016,
  233. TID_Material = 1017,
  234. TID_MaterialParams = 1018,
  235. TID_FloatParamKVP = 1019,
  236. TID_MaterialTexParamKVP = 1020,
  237. TID_SamplerState = 1021,
  238. TID_SamplerStateParamKVP = 1022,
  239. TID_BlendState = 1023,
  240. TID_RasterizerState = 1024,
  241. TID_DepthStencilState = 1025,
  242. TID_MaterialParamFloat = 1026,
  243. TID_MaterialParamVec2 = 1027,
  244. TID_MaterialParamVec3 = 1028,
  245. TID_MaterialParamVec4 = 1029,
  246. TID_MaterialParamMat3 = 1030,
  247. TID_MaterialParamMat4 = 1031,
  248. TID_MaterialParamTexture = 1032,
  249. TID_MaterialParamSamplerState = 1033,
  250. TID_BLEND_STATE_DESC = 1034,
  251. TID_SHADER_DATA_PARAM_DESC = 1035,
  252. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  253. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  254. TID_ImportOptions = 1048,
  255. TID_GpuProgramImportOptions = 1049,
  256. TID_MaterialParamStruct = 1050,
  257. TID_Font = 1051,
  258. TID_FONT_DESC = 1052,
  259. TID_CHAR_DESC = 1053,
  260. TID_STDVECTOR = 1054,
  261. TID_STDMAP = 1055,
  262. TID_FontImportOptions = 1056,
  263. TID_FontData = 1057,
  264. TID_SceneObject = 1059,
  265. TID_GameObject = 1060,
  266. TID_GpuResource = 1061,
  267. TID_PixelData = 1062,
  268. TID_GpuResourceData = 1063,
  269. TID_VertexDataDesc = 1064,
  270. TID_MeshBase = 1065,
  271. TID_GameObjectHandleBase = 1066,
  272. TID_ResourceManifest = 1067,
  273. TID_ResourceManifestEntry = 1068,
  274. TID_STDPAIR = 1069
  275. };
  276. }
  277. /************************************************************************/
  278. /* Resource references */
  279. /************************************************************************/
  280. #include "CmResourceHandle.h"
  281. namespace CamelotFramework
  282. {
  283. // Resource handles
  284. typedef ResourceHandle<Resource> HResource;
  285. typedef ResourceHandle<Texture> HTexture;
  286. typedef ResourceHandle<Mesh> HMesh;
  287. typedef ResourceHandle<GpuProgram> HGpuProgram;
  288. typedef ResourceHandle<HighLevelGpuProgram> HHighLevelGpuProgram;
  289. typedef ResourceHandle<Material> HMaterial;
  290. typedef ResourceHandle<SamplerState> HSamplerState;
  291. typedef ResourceHandle<RasterizerState> HRasterizerState;
  292. typedef ResourceHandle<DepthStencilState> HDepthStencilState;
  293. typedef ResourceHandle<BlendState> HBlendState;
  294. typedef ResourceHandle<GpuProgInclude> HGpuProgInclude;
  295. typedef ResourceHandle<Font> HFont;
  296. }
  297. namespace CamelotFramework
  298. {
  299. /**
  300. * @brief Defers function execution until the next frame. If this function is called
  301. * within another deferred call, then it will be executed the same frame,
  302. * but only after all existing deferred calls are done.
  303. *
  304. * @note This method can be used for breaking dependencies among other things. If a class
  305. * A depends on class B having something done, but class B also depends in some way on class A,
  306. * you can break up the initialization into two separate steps, queuing the second step
  307. * using this method.
  308. *
  309. * Similar situation can happen if you have multiple classes being initialized in an undefined order
  310. * but some of them depend on others. Using this method you can defer the dependent step until next frame,
  311. * which will ensure everything was initialized.
  312. *
  313. * @param callback The callback.
  314. */
  315. void CM_EXPORT deferredCall(std::function<void()> callback);
  316. }