BsCorePrerequisites.h 16 KB

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