BsCorePrerequisites.h 16 KB

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