BsCorePrerequisites.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. #pragma once
  2. #include "BsPrerequisitesUtil.h"
  3. /** @defgroup Core Core
  4. * Second lowest layer that provides some very game-specific modules tied into a coherent whole, but it tries to be very
  5. * generic and offer something that every engine might need instead of focusing on very specialized techniques.
  6. * @{
  7. */
  8. /** @defgroup CoreThread Core thread
  9. * Functionality for dealing with core objects and interaction with the core thread.
  10. */
  11. /** @defgroup Importer Importer
  12. * Functionality for dealing with import of resources into engine friendly format.
  13. */
  14. /** @defgroup Input Input
  15. * Functionality for dealing with input (mouse, keyboard, gamepad, etc.).
  16. */
  17. /** @defgroup Localization Localization
  18. * Functionality for dealing with GUI localization.
  19. */
  20. /** @defgroup Material Material
  21. * Functionality for dealing with materials, shaders, and in general how objects are rendered.
  22. */
  23. /** @defgroup Platform Platform
  24. * Functionality specific for some platform (e.g. Windows, Mac).
  25. */
  26. /** @defgroup Profiling Profiling
  27. * Functionality for measuring CPU and GPU execution times and memory usage.
  28. */
  29. /** @defgroup RenderAPI RenderAPI
  30. * Functionality for interacting with underlying render API (e.g. DirectX, OpenGL).
  31. */
  32. /** @defgroup Renderer Renderer
  33. * Abstract interface and helper functionality for rendering scene objects.
  34. */
  35. /** @defgroup Resources Resources
  36. * Contains core resource types and resource management functionality (loading, saving, etc.).
  37. */
  38. /** @defgroup RTTI-Impl-Core RTTI types
  39. * Types containing RTTI for specific classes.
  40. */
  41. /** @defgroup Scene Scene
  42. * Functionality for managing scene objects and their hierarchy.
  43. */
  44. /** @defgroup Text Text
  45. * Functionality for rendering text.
  46. */
  47. /** @defgroup Utility-Core Utility
  48. * Various utility methods and types used by the core layer.
  49. */
  50. /** @defgroup Platform-Core Platform
  51. * Platform specific functionality.
  52. */
  53. /** @defgroup Application-Core Application
  54. * Entry point into the application.
  55. */
  56. /** @} */
  57. #define BS_MAX_MULTIPLE_RENDER_TARGETS 8
  58. #define BS_FORCE_SINGLETHREADED_RENDERING 0
  59. // Windows Settings
  60. #if BS_PLATFORM == BS_PLATFORM_WIN32
  61. // If we're not including this from a client build, specify that the stuff
  62. // should get exported. Otherwise, import it.
  63. # if defined(BS_STATIC_LIB)
  64. // Linux compilers don't have symbol import/export directives.
  65. # define BS_CORE_EXPORT
  66. # else
  67. # if defined(BS_CORE_EXPORTS)
  68. # define BS_CORE_EXPORT __declspec( dllexport )
  69. # else
  70. # if defined( __MINGW32__ )
  71. # define BS_CORE_EXPORT
  72. # else
  73. # define BS_CORE_EXPORT __declspec( dllimport )
  74. # endif
  75. # endif
  76. # endif
  77. // Win32 compilers use _DEBUG for specifying debug builds.
  78. // for MinGW, we set DEBUG
  79. # if defined(_DEBUG) || defined(DEBUG)
  80. # define BS_DEBUG_MODE 1
  81. # else
  82. # define BS_DEBUG_MODE 0
  83. # endif
  84. #endif
  85. // Linux/Apple Settings
  86. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_APPLE
  87. // Enable GCC symbol visibility
  88. # if defined( BS_GCC_VISIBILITY )
  89. # define BS_CORE_EXPORT __attribute__ ((visibility("default")))
  90. # define BS_HIDDEN __attribute__ ((visibility("hidden")))
  91. # else
  92. # define BS_CORE_EXPORT
  93. # define BS_HIDDEN
  94. # endif
  95. // A quick define to overcome different names for the same function
  96. # define stricmp strcasecmp
  97. # ifdef DEBUG
  98. # define BS_DEBUG_MODE 1
  99. # else
  100. # define BS_DEBUG_MODE 0
  101. # endif
  102. #endif
  103. #if BS_DEBUG_MODE
  104. #define BS_DEBUG_ONLY(x) x
  105. #define BS_ASSERT(x) assert(x)
  106. #else
  107. #define BS_DEBUG_ONLY(x)
  108. #define BS_ASSERT(x)
  109. #endif
  110. #include "BsHString.h"
  111. namespace BansheeEngine
  112. {
  113. static const StringID RenderAPIAny = "AnyRenderAPI";
  114. static const StringID RendererAny = "AnyRenderer";
  115. class Color;
  116. class GpuProgram;
  117. class GpuProgramManager;
  118. class IndexBuffer;
  119. class IndexBufferCore;
  120. class OcclusionQuery;
  121. class VertexBuffer;
  122. class VertexBufferCore;
  123. class PixelBuffer;
  124. class GpuBuffer;
  125. class HighLevelGpuProgram;
  126. class GpuProgramManager;
  127. class GpuProgramFactory;
  128. class IndexData;
  129. class Pass;
  130. class Technique;
  131. class Shader;
  132. class Material;
  133. class RenderAPICore;
  134. class RenderAPICapabilities;
  135. class RenderTarget;
  136. class RenderTargetCore;
  137. class RenderTexture;
  138. class RenderTextureCore;
  139. class MultiRenderTexture;
  140. class MultiRenderTextureCore;
  141. class RenderWindow;
  142. class RenderWindowCore;
  143. class RenderTargetProperties;
  144. struct RenderOpMesh;
  145. class StringInterface;
  146. class SamplerState;
  147. class SamplerStateCore;
  148. class TextureManager;
  149. class Viewport;
  150. class VertexData;
  151. class VertexDeclaration;
  152. class Input;
  153. struct PointerEvent;
  154. class RawInputHandler;
  155. class CoreRenderer;
  156. class RendererFactory;
  157. class AsyncOp;
  158. class HardwareBufferManager;
  159. class FontManager;
  160. class DepthStencilState;
  161. class DepthStencilStateCore;
  162. class RenderStateManager;
  163. class RasterizerState;
  164. class RasterizerStateCore;
  165. class BlendState;
  166. class BlendStateCore;
  167. class GpuParamBlock;
  168. class GpuParamBlockBuffer;
  169. class GpuParams;
  170. struct GpuParamDesc;
  171. struct GpuParamDataDesc;
  172. struct GpuParamObjectDesc;
  173. struct GpuParamBlockDesc;
  174. class ShaderInclude;
  175. class TextureView;
  176. class CoreObject;
  177. class CoreObjectCore;
  178. class ImportOptions;
  179. class TextureImportOptions;
  180. class FontImportOptions;
  181. class GpuProgramImportOptions;
  182. class MeshImportOptions;
  183. struct FontBitmap;
  184. class GameObject;
  185. class GpuResourceData;
  186. struct RenderOperation;
  187. class RenderQueue;
  188. struct ProfilerReport;
  189. class VertexDataDesc;
  190. class EventQuery;
  191. class TimerQuery;
  192. class OcclusionQuery;
  193. class FrameAlloc;
  194. class FolderMonitor;
  195. class VideoMode;
  196. class VideoOutputInfo;
  197. class VideoModeInfo;
  198. class RenderableElement;
  199. class CameraCore;
  200. class MeshCoreBase;
  201. class MeshCore;
  202. struct SubMesh;
  203. class TransientMeshCore;
  204. class TextureCore;
  205. class MeshHeapCore;
  206. class VertexDeclarationCore;
  207. class GpuBufferCore;
  208. class GpuParamBlockBufferCore;
  209. class GpuParamsCore;
  210. class ShaderCore;
  211. class ViewportCore;
  212. class PassCore;
  213. class PassParametersCore;
  214. class TechniqueCore;
  215. class MaterialCore;
  216. class GpuProgramCore;
  217. class IResourceListener;
  218. class TextureProperties;
  219. class IShaderIncludeHandler;
  220. class Prefab;
  221. class PrefabDiff;
  222. class RendererMeshData;
  223. class LightCore;
  224. class Light;
  225. class Win32Window;
  226. class RenderAPIFactory;
  227. // Asset import
  228. class SpecificImporter;
  229. class Importer;
  230. // Resources
  231. class Resource;
  232. class Resources;
  233. class ResourceManifest;
  234. class Texture;
  235. class Mesh;
  236. class MeshBase;
  237. class TransientMesh;
  238. class MeshHeap;
  239. class Font;
  240. class ResourceMetaData;
  241. class OSDropTarget;
  242. class StringTable;
  243. // Scene
  244. class SceneObject;
  245. class Component;
  246. class SceneManager;
  247. // RTTI
  248. class MeshRTTI;
  249. // Desc structs
  250. struct SAMPLER_STATE_DESC;
  251. struct DEPTH_STENCIL_STATE_DESC;
  252. struct RASTERIZER_STATE_DESC;
  253. struct BLEND_STATE_DESC;
  254. struct RENDER_TARGET_BLEND_STATE_DESC;
  255. struct RENDER_TEXTURE_DESC;
  256. struct RENDER_WINDOW_DESC;
  257. struct FONT_DESC;
  258. template<class T>
  259. class CoreThreadAccessor;
  260. class CommandQueueNoSync;
  261. class CommandQueueSync;
  262. }
  263. /************************************************************************/
  264. /* Shared pointer typedefs */
  265. /************************************************************************/
  266. namespace BansheeEngine
  267. {
  268. typedef std::shared_ptr<RenderAPICore> RenderAPIPtr;
  269. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  270. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  271. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  272. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  273. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  274. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  275. typedef std::shared_ptr<Mesh> MeshPtr;
  276. typedef std::shared_ptr<MeshBase> MeshBasePtr;
  277. typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
  278. typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
  279. typedef std::shared_ptr<Texture> TexturePtr;
  280. typedef std::shared_ptr<Resource> ResourcePtr;
  281. typedef std::shared_ptr<Technique> TechniquePtr;
  282. typedef std::shared_ptr<Pass> PassPtr;
  283. typedef std::shared_ptr<Shader> ShaderPtr;
  284. typedef std::shared_ptr<Material> MaterialPtr;
  285. typedef std::shared_ptr<CoreRenderer> CoreRendererPtr;
  286. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  287. typedef std::shared_ptr<Component> ComponentPtr;
  288. typedef std::shared_ptr<GameObject> GameObjectPtr;
  289. typedef std::shared_ptr<SceneObject> SceneObjectPtr;
  290. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  291. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  292. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  293. typedef std::shared_ptr<BlendState> BlendStatePtr;
  294. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  295. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  296. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  297. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  298. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  299. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  300. typedef std::shared_ptr<TextureView> TextureViewPtr;
  301. typedef std::shared_ptr<Viewport> ViewportPtr;
  302. typedef std::shared_ptr<ShaderInclude> ShaderIncludePtr;
  303. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  304. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  305. typedef std::shared_ptr<Font> FontPtr;
  306. typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
  307. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  308. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  309. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  310. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  311. typedef std::shared_ptr<EventQuery> EventQueryPtr;
  312. typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
  313. typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
  314. typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
  315. typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
  316. typedef std::shared_ptr<RenderQueue> RenderQueuePtr;
  317. typedef std::shared_ptr<GpuParamDesc> GpuParamDescPtr;
  318. typedef std::shared_ptr<ResourceMetaData> ResourceMetaDataPtr;
  319. typedef std::shared_ptr<IShaderIncludeHandler> ShaderIncludeHandlerPtr;
  320. typedef std::shared_ptr<Prefab> PrefabPtr;
  321. typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
  322. typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
  323. typedef std::shared_ptr<RenderAPIFactory> RenderAPIFactoryPtr;
  324. }
  325. /************************************************************************/
  326. /* RTTI */
  327. /************************************************************************/
  328. namespace BansheeEngine
  329. {
  330. enum TypeID_Core
  331. {
  332. TID_Texture = 1001,
  333. TID_Mesh = 1002,
  334. TID_MeshData = 1003,
  335. TID_VertexDeclaration = 1004,
  336. TID_VertexElementData = 1005,
  337. TID_Component = 1006,
  338. TID_ResourceHandle = 1009,
  339. TID_GpuProgram = 1010,
  340. TID_ResourceHandleData = 1011,
  341. TID_CgProgram = 1012,
  342. TID_Pass = 1014,
  343. TID_Technique = 1015,
  344. TID_Shader = 1016,
  345. TID_Material = 1017,
  346. TID_SamplerState = 1021,
  347. TID_BlendState = 1023,
  348. TID_RasterizerState = 1024,
  349. TID_DepthStencilState = 1025,
  350. TID_BLEND_STATE_DESC = 1034,
  351. TID_SHADER_DATA_PARAM_DESC = 1035,
  352. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  353. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  354. TID_ImportOptions = 1048,
  355. TID_Font = 1051,
  356. TID_FONT_DESC = 1052,
  357. TID_CHAR_DESC = 1053,
  358. TID_FontImportOptions = 1056,
  359. TID_FontBitmap = 1057,
  360. TID_SceneObject = 1059,
  361. TID_GameObject = 1060,
  362. TID_PixelData = 1062,
  363. TID_GpuResourceData = 1063,
  364. TID_VertexDataDesc = 1064,
  365. TID_MeshBase = 1065,
  366. TID_GameObjectHandleBase = 1066,
  367. TID_ResourceManifest = 1067,
  368. TID_ResourceManifestEntry = 1068,
  369. TID_EmulatedParamBlock = 1069,
  370. TID_TextureImportOptions = 1070,
  371. TID_ResourceMetaData = 1071,
  372. TID_ShaderInclude = 1072,
  373. TID_Viewport = 1073,
  374. TID_ResourceDependencies = 1074,
  375. TID_ShaderMetaData = 1075,
  376. TID_MeshImportOptions = 1076,
  377. TID_Prefab = 1077,
  378. TID_PrefabDiff = 1078,
  379. TID_PrefabObjectDiff = 1079,
  380. TID_PrefabComponentDiff = 1080,
  381. TID_CGUIWidget = 1081,
  382. TID_ProfilerOverlay = 1082,
  383. TID_StringTable = 1083,
  384. TID_LanguageData = 1084,
  385. TID_LocalizedStringData = 1085,
  386. TID_MaterialParamColor = 1086,
  387. TID_WeakResourceHandle = 1087,
  388. TID_TextureParamData = 1088,
  389. TID_StructParamData = 1089,
  390. TID_MaterialParams = 1090,
  391. TID_MaterialRTTIParam = 1091
  392. };
  393. }
  394. /************************************************************************/
  395. /* Resource references */
  396. /************************************************************************/
  397. #include "BsResourceHandle.h"
  398. namespace BansheeEngine
  399. {
  400. // Resource handles
  401. typedef ResourceHandle<Resource> HResource;
  402. typedef ResourceHandle<Texture> HTexture;
  403. typedef ResourceHandle<Mesh> HMesh;
  404. typedef ResourceHandle<Material> HMaterial;
  405. typedef ResourceHandle<ShaderInclude> HShaderInclude;
  406. typedef ResourceHandle<Font> HFont;
  407. typedef ResourceHandle<Shader> HShader;
  408. typedef ResourceHandle<Prefab> HPrefab;
  409. typedef ResourceHandle<StringTable> HStringTable;
  410. }
  411. namespace BansheeEngine
  412. {
  413. /**
  414. * @brief Defers function execution until the next frame. If this function is called
  415. * within another deferred call, then it will be executed the same frame,
  416. * but only after all existing deferred calls are done.
  417. *
  418. * @note This method can be used for breaking dependencies among other things. If a class
  419. * A depends on class B having something done, but class B also depends in some way on class A,
  420. * you can break up the initialization into two separate steps, queuing the second step
  421. * using this method.
  422. *
  423. * Similar situation can happen if you have multiple classes being initialized in an undefined order
  424. * but some of them depend on others. Using this method you can defer the dependent step until next frame,
  425. * which will ensure everything was initialized.
  426. *
  427. * @param callback The callback.
  428. */
  429. void BS_CORE_EXPORT deferredCall(std::function<void()> callback);
  430. // Special types for use by profilers
  431. typedef std::basic_string<char, std::char_traits<char>, StdAlloc<char, ProfilerAlloc>> ProfilerString;
  432. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  433. using ProfilerVector = std::vector<T, A>;
  434. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  435. using ProfilerStack = std::stack<T, std::deque<T, A>>;
  436. /**
  437. * @brief Banshee thread policy that performs special startup/shutdown on threads
  438. * managed by thread pool.
  439. */
  440. class BS_CORE_EXPORT ThreadBansheePolicy
  441. {
  442. public:
  443. static void onThreadStarted(const String& name)
  444. {
  445. MemStack::beginThread();
  446. }
  447. static void onThreadEnded(const String& name)
  448. {
  449. MemStack::endThread();
  450. }
  451. };
  452. }
  453. #include "BsCommonTypes.h"