BsCorePrerequisites.h 18 KB

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