BsCorePrerequisites.h 16 KB

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