BsCorePrerequisites.h 17 KB

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