BsCorePrerequisites.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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. class CJoint;
  238. class CHingeJoint;
  239. class CDistanceJoint;
  240. class CFixedJoint;
  241. class CSphericalJoint;
  242. class CSliderJoint;
  243. class CD6Joint;
  244. class CCharacterController;
  245. // Asset import
  246. class SpecificImporter;
  247. class Importer;
  248. // Resources
  249. class Resource;
  250. class Resources;
  251. class ResourceManifest;
  252. class Texture;
  253. class Mesh;
  254. class MeshBase;
  255. class TransientMesh;
  256. class MeshHeap;
  257. class Font;
  258. class ResourceMetaData;
  259. class OSDropTarget;
  260. class StringTable;
  261. class PhysicsMaterial;
  262. class PhysicsMesh;
  263. // Scene
  264. class SceneObject;
  265. class Component;
  266. class SceneManager;
  267. // RTTI
  268. class MeshRTTI;
  269. // Desc structs
  270. struct SAMPLER_STATE_DESC;
  271. struct DEPTH_STENCIL_STATE_DESC;
  272. struct RASTERIZER_STATE_DESC;
  273. struct BLEND_STATE_DESC;
  274. struct RENDER_TARGET_BLEND_STATE_DESC;
  275. struct RENDER_TEXTURE_DESC;
  276. struct RENDER_WINDOW_DESC;
  277. struct FONT_DESC;
  278. struct CHAR_CONTROLLER_DESC;
  279. template<class T>
  280. class CoreThreadAccessor;
  281. class CommandQueueNoSync;
  282. class CommandQueueSync;
  283. }
  284. /************************************************************************/
  285. /* Shared pointer typedefs */
  286. /************************************************************************/
  287. namespace BansheeEngine
  288. {
  289. typedef std::shared_ptr<RenderAPICore> RenderAPIPtr;
  290. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  291. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  292. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  293. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  294. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  295. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  296. typedef std::shared_ptr<Mesh> MeshPtr;
  297. typedef std::shared_ptr<MeshBase> MeshBasePtr;
  298. typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
  299. typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
  300. typedef std::shared_ptr<Texture> TexturePtr;
  301. typedef std::shared_ptr<Resource> ResourcePtr;
  302. typedef std::shared_ptr<Technique> TechniquePtr;
  303. typedef std::shared_ptr<Pass> PassPtr;
  304. typedef std::shared_ptr<Shader> ShaderPtr;
  305. typedef std::shared_ptr<Material> MaterialPtr;
  306. typedef std::shared_ptr<CoreRenderer> CoreRendererPtr;
  307. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  308. typedef std::shared_ptr<Component> ComponentPtr;
  309. typedef std::shared_ptr<GameObject> GameObjectPtr;
  310. typedef std::shared_ptr<SceneObject> SceneObjectPtr;
  311. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  312. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  313. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  314. typedef std::shared_ptr<BlendState> BlendStatePtr;
  315. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  316. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  317. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  318. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  319. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  320. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  321. typedef std::shared_ptr<TextureView> TextureViewPtr;
  322. typedef std::shared_ptr<Viewport> ViewportPtr;
  323. typedef std::shared_ptr<ShaderInclude> ShaderIncludePtr;
  324. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  325. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  326. typedef std::shared_ptr<Font> FontPtr;
  327. typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
  328. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  329. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  330. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  331. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  332. typedef std::shared_ptr<EventQuery> EventQueryPtr;
  333. typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
  334. typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
  335. typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
  336. typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
  337. typedef std::shared_ptr<RenderQueue> RenderQueuePtr;
  338. typedef std::shared_ptr<GpuParamDesc> GpuParamDescPtr;
  339. typedef std::shared_ptr<ResourceMetaData> ResourceMetaDataPtr;
  340. typedef std::shared_ptr<IShaderIncludeHandler> ShaderIncludeHandlerPtr;
  341. typedef std::shared_ptr<Prefab> PrefabPtr;
  342. typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
  343. typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
  344. typedef std::shared_ptr<RenderAPIFactory> RenderAPIFactoryPtr;
  345. typedef std::shared_ptr<PhysicsMaterial> PhysicsMaterialPtr;
  346. typedef std::shared_ptr<PhysicsMesh> PhysicsMeshPtr;
  347. }
  348. /************************************************************************/
  349. /* RTTI */
  350. /************************************************************************/
  351. namespace BansheeEngine
  352. {
  353. enum TypeID_Core
  354. {
  355. TID_Texture = 1001,
  356. TID_Mesh = 1002,
  357. TID_MeshData = 1003,
  358. TID_VertexDeclaration = 1004,
  359. TID_VertexElementData = 1005,
  360. TID_Component = 1006,
  361. TID_ResourceHandle = 1009,
  362. TID_GpuProgram = 1010,
  363. TID_ResourceHandleData = 1011,
  364. TID_CgProgram = 1012,
  365. TID_Pass = 1014,
  366. TID_Technique = 1015,
  367. TID_Shader = 1016,
  368. TID_Material = 1017,
  369. TID_SamplerState = 1021,
  370. TID_BlendState = 1023,
  371. TID_RasterizerState = 1024,
  372. TID_DepthStencilState = 1025,
  373. TID_BLEND_STATE_DESC = 1034,
  374. TID_SHADER_DATA_PARAM_DESC = 1035,
  375. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  376. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  377. TID_ImportOptions = 1048,
  378. TID_Font = 1051,
  379. TID_FONT_DESC = 1052,
  380. TID_CHAR_DESC = 1053,
  381. TID_FontImportOptions = 1056,
  382. TID_FontBitmap = 1057,
  383. TID_SceneObject = 1059,
  384. TID_GameObject = 1060,
  385. TID_PixelData = 1062,
  386. TID_GpuResourceData = 1063,
  387. TID_VertexDataDesc = 1064,
  388. TID_MeshBase = 1065,
  389. TID_GameObjectHandleBase = 1066,
  390. TID_ResourceManifest = 1067,
  391. TID_ResourceManifestEntry = 1068,
  392. TID_EmulatedParamBlock = 1069,
  393. TID_TextureImportOptions = 1070,
  394. TID_ResourceMetaData = 1071,
  395. TID_ShaderInclude = 1072,
  396. TID_Viewport = 1073,
  397. TID_ResourceDependencies = 1074,
  398. TID_ShaderMetaData = 1075,
  399. TID_MeshImportOptions = 1076,
  400. TID_Prefab = 1077,
  401. TID_PrefabDiff = 1078,
  402. TID_PrefabObjectDiff = 1079,
  403. TID_PrefabComponentDiff = 1080,
  404. TID_CGUIWidget = 1081,
  405. TID_ProfilerOverlay = 1082,
  406. TID_StringTable = 1083,
  407. TID_LanguageData = 1084,
  408. TID_LocalizedStringData = 1085,
  409. TID_MaterialParamColor = 1086,
  410. TID_WeakResourceHandle = 1087,
  411. TID_TextureParamData = 1088,
  412. TID_StructParamData = 1089,
  413. TID_MaterialParams = 1090,
  414. TID_MaterialRTTIParam = 1091,
  415. TID_PhysicsMaterial = 1092,
  416. TID_CCollider = 1093,
  417. TID_CBoxCollider = 1094,
  418. TID_CSphereCollider = 1095,
  419. TID_CCapsuleCollider = 1096,
  420. TID_CPlaneCollider = 1097,
  421. TID_CRigidbody = 1098,
  422. TID_PhysicsMesh = 1099,
  423. TID_CMeshCollider = 1100,
  424. TID_CJoint = 1101,
  425. TID_CFixedJoint = 1102,
  426. TID_CDistanceJoint = 1103,
  427. TID_CHingeJoint = 1104,
  428. TID_CSphericalJoint = 1105,
  429. TID_CSliderJoint = 1106,
  430. TID_CD6Joint = 1107,
  431. TID_CCharacterController = 1108
  432. };
  433. }
  434. /************************************************************************/
  435. /* Resource references */
  436. /************************************************************************/
  437. #include "BsResourceHandle.h"
  438. namespace BansheeEngine
  439. {
  440. /** @addtogroup Resources
  441. * @{
  442. */
  443. typedef ResourceHandle<Resource> HResource;
  444. typedef ResourceHandle<Texture> HTexture;
  445. typedef ResourceHandle<Mesh> HMesh;
  446. typedef ResourceHandle<Material> HMaterial;
  447. typedef ResourceHandle<ShaderInclude> HShaderInclude;
  448. typedef ResourceHandle<Font> HFont;
  449. typedef ResourceHandle<Shader> HShader;
  450. typedef ResourceHandle<Prefab> HPrefab;
  451. typedef ResourceHandle<StringTable> HStringTable;
  452. typedef ResourceHandle<PhysicsMaterial> HPhysicsMaterial;
  453. typedef ResourceHandle<PhysicsMesh> HPhysicsMesh;
  454. /** @} */
  455. }
  456. #include "BsGameObjectHandle.h"
  457. namespace BansheeEngine
  458. {
  459. /** @addtogroup Scene
  460. * @{
  461. */
  462. // Game object handles
  463. typedef GameObjectHandle<GameObject> HGameObject;
  464. typedef GameObjectHandle<SceneObject> HSceneObject;
  465. typedef GameObjectHandle<Component> HComponent;
  466. typedef GameObjectHandle<CRigidbody> HRigidbody;
  467. typedef GameObjectHandle<CCollider> HCollider;
  468. typedef GameObjectHandle<CBoxCollider> HBoxCollider;
  469. typedef GameObjectHandle<CSphereCollider> HSphereCollider;
  470. typedef GameObjectHandle<CCapsuleCollider> HCapsuleCollider;
  471. typedef GameObjectHandle<CPlaneCollider> HPlaneCollider;
  472. typedef GameObjectHandle<CJoint> HJoint;
  473. typedef GameObjectHandle<CHingeJoint> HHingeJoint;
  474. typedef GameObjectHandle<CSliderJoint> HSliderJoint;
  475. typedef GameObjectHandle<CDistanceJoint> HDistanceJoint;
  476. typedef GameObjectHandle<CSphericalJoint> HSphericalJoint;
  477. typedef GameObjectHandle<CFixedJoint> HFixedJoint;
  478. typedef GameObjectHandle<CD6Joint> HD6Joint;
  479. typedef GameObjectHandle<CCharacterController> HCharacterController;
  480. /** @} */
  481. }
  482. namespace BansheeEngine
  483. {
  484. /**
  485. * @brief Defers function execution until the next frame. If this function is called
  486. * within another deferred call, then it will be executed the same frame,
  487. * but only after all existing deferred calls are done.
  488. *
  489. * @note This method can be used for breaking dependencies among other things. If a class
  490. * A depends on class B having something done, but class B also depends in some way on class A,
  491. * you can break up the initialization into two separate steps, queuing the second step
  492. * using this method.
  493. *
  494. * Similar situation can happen if you have multiple classes being initialized in an undefined order
  495. * but some of them depend on others. Using this method you can defer the dependent step until next frame,
  496. * which will ensure everything was initialized.
  497. *
  498. * @param callback The callback.
  499. */
  500. void BS_CORE_EXPORT deferredCall(std::function<void()> callback);
  501. // Special types for use by profilers
  502. typedef std::basic_string<char, std::char_traits<char>, StdAlloc<char, ProfilerAlloc>> ProfilerString;
  503. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  504. using ProfilerVector = std::vector<T, A>;
  505. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  506. using ProfilerStack = std::stack<T, std::deque<T, A>>;
  507. /**
  508. * @brief Banshee thread policy that performs special startup/shutdown on threads
  509. * managed by thread pool.
  510. */
  511. class BS_CORE_EXPORT ThreadBansheePolicy
  512. {
  513. public:
  514. static void onThreadStarted(const String& name)
  515. {
  516. MemStack::beginThread();
  517. }
  518. static void onThreadEnded(const String& name)
  519. {
  520. MemStack::endThread();
  521. }
  522. };
  523. #define BS_ALL_LAYERS 0xFFFFFFFFFFFFFFFF
  524. }
  525. #include "BsCommonTypes.h"