BsCorePrerequisites.h 16 KB

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