BsCorePrerequisites.h 16 KB

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