CmPrerequisites.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. enum HeapID
  53. {
  54. HID_Main = 0,
  55. HID_Render = 1
  56. };
  57. // Pre-declare classes
  58. // Allows use of pointers in header files without including individual .h
  59. // so decreases dependencies between files
  60. class Color;
  61. class GpuProgram;
  62. class GpuProgramManager;
  63. class IndexBuffer;
  64. class OcclusionQuery;
  65. class VertexBuffer;
  66. class PixelBuffer;
  67. class GpuBuffer;
  68. class HighLevelGpuProgram;
  69. class HighLevelGpuProgramManager;
  70. class HighLevelGpuProgramFactory;
  71. class IndexData;
  72. class Pass;
  73. class Technique;
  74. class Shader;
  75. class Material;
  76. class RenderSystem;
  77. class RenderSystemCapabilities;
  78. class RenderTarget;
  79. class RenderTexture;
  80. class MultiRenderTexture;
  81. class RenderWindow;
  82. struct RenderOpMesh;
  83. class StringInterface;
  84. class SamplerState;
  85. class TextureManager;
  86. class Viewport;
  87. class VertexData;
  88. class VertexDeclaration;
  89. class Input;
  90. struct PositionalInputEvent;
  91. class RawInputHandler;
  92. class Renderer;
  93. class RendererFactory;
  94. class WorkQueue;
  95. class PassParameters;
  96. class AsyncOp;
  97. class HardwareBufferManager;
  98. class FontManager;
  99. class DepthStencilState;
  100. class RenderStateManager;
  101. class RasterizerState;
  102. class BlendState;
  103. class GpuParamBlock;
  104. class GpuParamBlockBuffer;
  105. class GpuParams;
  106. struct GpuParamDesc;
  107. struct GpuParamDataDesc;
  108. struct GpuParamObjectDesc;
  109. struct GpuParamBlockDesc;
  110. class GpuProgInclude;
  111. class TextureView;
  112. class CoreObject;
  113. class ImportOptions;
  114. struct FontData;
  115. class GameObject;
  116. class GpuResource;
  117. class GpuResourceData;
  118. class BindableGpuParams;
  119. class BindableGpuParamBlock;
  120. struct RenderOperation;
  121. class RenderQueue;
  122. struct ProfilerReport;
  123. // Asset import
  124. class SpecificImporter;
  125. class Importer;
  126. // Resources
  127. class Resource;
  128. class Resources;
  129. class Texture;
  130. class Mesh;
  131. class Font;
  132. class OSDropTarget;
  133. // Scene
  134. class SceneObject;
  135. class Component;
  136. class SceneManager;
  137. // RTTI
  138. class MeshRTTI;
  139. // Desc structs
  140. struct SAMPLER_STATE_DESC;
  141. struct DEPTH_STENCIL_STATE_DESC;
  142. struct RASTERIZER_STATE_DESC;
  143. struct BLEND_STATE_DESC;
  144. struct RENDER_TARGET_BLEND_STATE_DESC;
  145. struct RENDER_TEXTURE_DESC;
  146. struct RENDER_WINDOW_DESC;
  147. struct FONT_DESC;
  148. template<class T>
  149. class CoreThreadAccessor;
  150. class CommandQueueNoSync;
  151. class CommandQueueSync;
  152. }
  153. /************************************************************************/
  154. /* Shared pointer typedefs */
  155. /************************************************************************/
  156. namespace CamelotFramework
  157. {
  158. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  159. typedef std::shared_ptr<HighLevelGpuProgram> HighLevelGpuProgramPtr;
  160. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  161. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  162. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  163. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  164. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  165. typedef std::shared_ptr<Mesh> MeshPtr;
  166. typedef std::shared_ptr<Texture> TexturePtr;
  167. typedef std::shared_ptr<Resource> ResourcePtr;
  168. typedef std::shared_ptr<Technique> TechniquePtr;
  169. typedef std::shared_ptr<Pass> PassPtr;
  170. typedef std::shared_ptr<Shader> ShaderPtr;
  171. typedef std::shared_ptr<Material> MaterialPtr;
  172. typedef std::shared_ptr<Renderer> RendererPtr;
  173. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  174. typedef std::shared_ptr<WorkQueue> WorkQueuePtr;
  175. typedef std::shared_ptr<PassParameters> PassParametersPtr;
  176. typedef std::shared_ptr<Component> ComponentPtr;
  177. typedef std::shared_ptr<SceneObject> GameObjectPtr;
  178. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  179. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  180. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  181. typedef std::shared_ptr<BlendState> BlendStatePtr;
  182. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  183. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  184. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  185. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  186. typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
  187. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  188. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  189. typedef std::shared_ptr<TextureView> TextureViewPtr;
  190. typedef std::shared_ptr<Viewport> ViewportPtr;
  191. typedef std::shared_ptr<GpuProgInclude> GpuProgIncludePtr;
  192. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  193. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  194. typedef std::shared_ptr<Font> FontPtr;
  195. typedef std::shared_ptr<GpuResource> GpuResourcePtr;
  196. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  197. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  198. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  199. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  200. }
  201. /************************************************************************/
  202. /* RTTI */
  203. /************************************************************************/
  204. namespace CamelotFramework
  205. {
  206. enum TypeID_Core
  207. {
  208. TID_Texture = 1001,
  209. TID_Mesh = 1002,
  210. TID_MeshData = 1003,
  211. TID_VertexDeclaration = 1004,
  212. TID_VertexElementData = 1005,
  213. TID_Component = 1006,
  214. TID_ResourceHandle = 1009,
  215. TID_GpuProgram = 1010,
  216. TID_ResourceHandleData = 1011,
  217. TID_CgProgram = 1012,
  218. TID_ResourceMetaData = 1013,
  219. TID_Pass = 1014,
  220. TID_Technique = 1015,
  221. TID_Shader = 1016,
  222. TID_Material = 1017,
  223. TID_MaterialParams = 1018,
  224. TID_FloatParamKVP = 1019,
  225. TID_MaterialTexParamKVP = 1020,
  226. TID_SamplerState = 1021,
  227. TID_SamplerStateParamKVP = 1022,
  228. TID_BlendState = 1023,
  229. TID_RasterizerState = 1024,
  230. TID_DepthStencilState = 1025,
  231. TID_MaterialParamFloat = 1026,
  232. TID_MaterialParamVec2 = 1027,
  233. TID_MaterialParamVec3 = 1028,
  234. TID_MaterialParamVec4 = 1029,
  235. TID_MaterialParamMat3 = 1030,
  236. TID_MaterialParamMat4 = 1031,
  237. TID_MaterialParamTexture = 1032,
  238. TID_MaterialParamSamplerState = 1033,
  239. TID_BLEND_STATE_DESC = 1034,
  240. TID_SHADER_DATA_PARAM_DESC = 1035,
  241. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  242. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  243. TID_ImportOptions = 1048,
  244. TID_GpuProgramImportOptions = 1049,
  245. TID_MaterialParamStruct = 1050,
  246. TID_Font = 1051,
  247. TID_FONT_DESC = 1052,
  248. TID_CHAR_DESC = 1053,
  249. TID_STDVECTOR = 1054,
  250. TID_STDMAP = 1055,
  251. TID_FontImportOptions = 1056,
  252. TID_FontData = 1057,
  253. TID_SceneObject = 1059,
  254. TID_GameObject = 1060,
  255. TID_GpuResource = 1061,
  256. TID_PixelData = 1062,
  257. TID_GpuResourceData = 1063
  258. };
  259. }
  260. /************************************************************************/
  261. /* Resource references */
  262. /************************************************************************/
  263. #include "CmResourceHandle.h"
  264. namespace CamelotFramework
  265. {
  266. // Resource handles
  267. typedef ResourceHandle<Resource> HResource;
  268. typedef ResourceHandle<Texture> HTexture;
  269. typedef ResourceHandle<Mesh> HMesh;
  270. typedef ResourceHandle<GpuProgram> HGpuProgram;
  271. typedef ResourceHandle<HighLevelGpuProgram> HHighLevelGpuProgram;
  272. typedef ResourceHandle<Material> HMaterial;
  273. typedef ResourceHandle<SamplerState> HSamplerState;
  274. typedef ResourceHandle<RasterizerState> HRasterizerState;
  275. typedef ResourceHandle<DepthStencilState> HDepthStencilState;
  276. typedef ResourceHandle<BlendState> HBlendState;
  277. typedef ResourceHandle<GpuProgInclude> HGpuProgInclude;
  278. typedef ResourceHandle<Font> HFont;
  279. }
  280. namespace CamelotFramework
  281. {
  282. /**
  283. * @brief Defers function execution until the next frame. If this function is called
  284. * within another deferred call, then it will be executed the same frame,
  285. * but only after all existing deferred calls are done.
  286. *
  287. * @note This method can be used for breaking dependencies among other things. If a class
  288. * A depends on class B having something done, but class B also depends in some way on class A,
  289. * you can break up the initialization into two separate steps, queuing the second step
  290. * using this method.
  291. *
  292. * Similar situation can happen if you have multiple classes being initialized in an undefined order
  293. * but some of them depend on others. Using this method you can defer the dependent step until next frame,
  294. * which will ensure everything was initialized.
  295. *
  296. * @param callback The callback.
  297. */
  298. void CM_EXPORT deferredCall(std::function<void()> callback);
  299. }