CmPrerequisites.h 10 KB

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