BsCorePrerequisites.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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. // Asset import
  306. class SpecificImporter;
  307. class Importer;
  308. // Resources
  309. class Resource;
  310. class Resources;
  311. class ResourceManifest;
  312. class Texture;
  313. class Mesh;
  314. class MeshBase;
  315. class TransientMesh;
  316. class MeshHeap;
  317. class Font;
  318. class ResourceMetaData;
  319. class OSDropTarget;
  320. class StringTable;
  321. class PhysicsMaterial;
  322. class PhysicsMesh;
  323. class AudioClip;
  324. struct CollisionData;
  325. // Scene
  326. class SceneObject;
  327. class Component;
  328. class SceneManager;
  329. // RTTI
  330. class MeshRTTI;
  331. // Desc structs
  332. struct SAMPLER_STATE_DESC;
  333. struct DEPTH_STENCIL_STATE_DESC;
  334. struct RASTERIZER_STATE_DESC;
  335. struct BLEND_STATE_DESC;
  336. struct RENDER_TARGET_BLEND_STATE_DESC;
  337. struct RENDER_TEXTURE_DESC;
  338. struct RENDER_WINDOW_DESC;
  339. struct FONT_DESC;
  340. struct CHAR_CONTROLLER_DESC;
  341. struct JOINT_DESC;
  342. struct FIXED_JOINT_DESC;
  343. struct DISTANCE_JOINT_DESC;
  344. struct HINGE_JOINT_DESC;
  345. struct SLIDER_JOINT_DESC;
  346. struct SPHERICAL_JOINT_DESC;
  347. struct D6_JOINT_DESC;
  348. struct AUDIO_CLIP_DESC;
  349. template<class T>
  350. class CoreThreadAccessor;
  351. class CommandQueueNoSync;
  352. class CommandQueueSync;
  353. }
  354. /************************************************************************/
  355. /* Typedefs */
  356. /************************************************************************/
  357. namespace BansheeEngine
  358. {
  359. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  360. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  361. }
  362. /************************************************************************/
  363. /* RTTI */
  364. /************************************************************************/
  365. namespace BansheeEngine
  366. {
  367. enum TypeID_Core
  368. {
  369. TID_Texture = 1001,
  370. TID_Mesh = 1002,
  371. TID_MeshData = 1003,
  372. TID_VertexDeclaration = 1004,
  373. TID_VertexElementData = 1005,
  374. TID_Component = 1006,
  375. TID_ResourceHandle = 1009,
  376. TID_GpuProgram = 1010,
  377. TID_ResourceHandleData = 1011,
  378. TID_CgProgram = 1012,
  379. TID_Pass = 1014,
  380. TID_Technique = 1015,
  381. TID_Shader = 1016,
  382. TID_Material = 1017,
  383. TID_SamplerState = 1021,
  384. TID_BlendState = 1023,
  385. TID_RasterizerState = 1024,
  386. TID_DepthStencilState = 1025,
  387. TID_BLEND_STATE_DESC = 1034,
  388. TID_SHADER_DATA_PARAM_DESC = 1035,
  389. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  390. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  391. TID_ImportOptions = 1048,
  392. TID_Font = 1051,
  393. TID_FONT_DESC = 1052,
  394. TID_CHAR_DESC = 1053,
  395. TID_FontImportOptions = 1056,
  396. TID_FontBitmap = 1057,
  397. TID_SceneObject = 1059,
  398. TID_GameObject = 1060,
  399. TID_PixelData = 1062,
  400. TID_GpuResourceData = 1063,
  401. TID_VertexDataDesc = 1064,
  402. TID_MeshBase = 1065,
  403. TID_GameObjectHandleBase = 1066,
  404. TID_ResourceManifest = 1067,
  405. TID_ResourceManifestEntry = 1068,
  406. TID_EmulatedParamBlock = 1069,
  407. TID_TextureImportOptions = 1070,
  408. TID_ResourceMetaData = 1071,
  409. TID_ShaderInclude = 1072,
  410. TID_Viewport = 1073,
  411. TID_ResourceDependencies = 1074,
  412. TID_ShaderMetaData = 1075,
  413. TID_MeshImportOptions = 1076,
  414. TID_Prefab = 1077,
  415. TID_PrefabDiff = 1078,
  416. TID_PrefabObjectDiff = 1079,
  417. TID_PrefabComponentDiff = 1080,
  418. TID_CGUIWidget = 1081,
  419. TID_ProfilerOverlay = 1082,
  420. TID_StringTable = 1083,
  421. TID_LanguageData = 1084,
  422. TID_LocalizedStringData = 1085,
  423. TID_MaterialParamColor = 1086,
  424. TID_WeakResourceHandle = 1087,
  425. TID_TextureParamData = 1088,
  426. TID_StructParamData = 1089,
  427. TID_MaterialParams = 1090,
  428. TID_MaterialRTTIParam = 1091,
  429. TID_PhysicsMaterial = 1092,
  430. TID_CCollider = 1093,
  431. TID_CBoxCollider = 1094,
  432. TID_CSphereCollider = 1095,
  433. TID_CCapsuleCollider = 1096,
  434. TID_CPlaneCollider = 1097,
  435. TID_CRigidbody = 1098,
  436. TID_PhysicsMesh = 1099,
  437. TID_CMeshCollider = 1100,
  438. TID_CJoint = 1101,
  439. TID_CFixedJoint = 1102,
  440. TID_CDistanceJoint = 1103,
  441. TID_CHingeJoint = 1104,
  442. TID_CSphericalJoint = 1105,
  443. TID_CSliderJoint = 1106,
  444. TID_CD6Joint = 1107,
  445. TID_CCharacterController = 1108,
  446. TID_FPhysicsMesh = 1109,
  447. TID_ShaderImportOptions = 1110,
  448. TID_AudioClip = 1111,
  449. TID_AudioClipImportOptions = 1112
  450. };
  451. }
  452. /************************************************************************/
  453. /* Resource references */
  454. /************************************************************************/
  455. #include "BsResourceHandle.h"
  456. namespace BansheeEngine
  457. {
  458. /** @addtogroup Resources
  459. * @{
  460. */
  461. typedef ResourceHandle<Resource> HResource;
  462. typedef ResourceHandle<Texture> HTexture;
  463. typedef ResourceHandle<Mesh> HMesh;
  464. typedef ResourceHandle<Material> HMaterial;
  465. typedef ResourceHandle<ShaderInclude> HShaderInclude;
  466. typedef ResourceHandle<Font> HFont;
  467. typedef ResourceHandle<Shader> HShader;
  468. typedef ResourceHandle<Prefab> HPrefab;
  469. typedef ResourceHandle<StringTable> HStringTable;
  470. typedef ResourceHandle<PhysicsMaterial> HPhysicsMaterial;
  471. typedef ResourceHandle<PhysicsMesh> HPhysicsMesh;
  472. typedef ResourceHandle<AudioClip> HAudioClip;
  473. /** @} */
  474. }
  475. #include "BsGameObjectHandle.h"
  476. namespace BansheeEngine
  477. {
  478. /** @addtogroup Scene
  479. * @{
  480. */
  481. // Game object handles
  482. typedef GameObjectHandle<GameObject> HGameObject;
  483. typedef GameObjectHandle<SceneObject> HSceneObject;
  484. typedef GameObjectHandle<Component> HComponent;
  485. typedef GameObjectHandle<CRigidbody> HRigidbody;
  486. typedef GameObjectHandle<CCollider> HCollider;
  487. typedef GameObjectHandle<CBoxCollider> HBoxCollider;
  488. typedef GameObjectHandle<CSphereCollider> HSphereCollider;
  489. typedef GameObjectHandle<CCapsuleCollider> HCapsuleCollider;
  490. typedef GameObjectHandle<CPlaneCollider> HPlaneCollider;
  491. typedef GameObjectHandle<CJoint> HJoint;
  492. typedef GameObjectHandle<CHingeJoint> HHingeJoint;
  493. typedef GameObjectHandle<CSliderJoint> HSliderJoint;
  494. typedef GameObjectHandle<CDistanceJoint> HDistanceJoint;
  495. typedef GameObjectHandle<CSphericalJoint> HSphericalJoint;
  496. typedef GameObjectHandle<CFixedJoint> HFixedJoint;
  497. typedef GameObjectHandle<CD6Joint> HD6Joint;
  498. typedef GameObjectHandle<CCharacterController> HCharacterController;
  499. /** @} */
  500. }
  501. namespace BansheeEngine
  502. {
  503. /**
  504. * Defers function execution until the next frame. If this function is called within another deferred call, then it will
  505. * be executed the same frame, but only after all existing deferred calls are done.
  506. *
  507. * @note
  508. * This method can be used for breaking dependencies among other things. If a class A depends on class B having
  509. * something done, but class B also depends in some way on class A, you can break up the initialization into two
  510. * separate steps, queuing the second step using this method.
  511. * @note
  512. * Similar situation can happen if you have multiple classes being initialized in an undefined order but some of them
  513. * depend on others. Using this method you can defer the dependent step until next frame, which will ensure everything
  514. * was initialized.
  515. *
  516. * @param[in] callback The callback.
  517. */
  518. void BS_CORE_EXPORT deferredCall(std::function<void()> callback);
  519. // Special types for use by profilers
  520. typedef std::basic_string<char, std::char_traits<char>, StdAlloc<char, ProfilerAlloc>> ProfilerString;
  521. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  522. using ProfilerVector = std::vector<T, A>;
  523. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  524. using ProfilerStack = std::stack<T, std::deque<T, A>>;
  525. /** Banshee thread policy that performs special startup/shutdown on threads managed by thread pool. */
  526. class BS_CORE_EXPORT ThreadBansheePolicy
  527. {
  528. public:
  529. static void onThreadStarted(const String& name)
  530. {
  531. MemStack::beginThread();
  532. }
  533. static void onThreadEnded(const String& name)
  534. {
  535. MemStack::endThread();
  536. }
  537. };
  538. #define BS_ALL_LAYERS 0xFFFFFFFFFFFFFFFF
  539. }
  540. #include "BsCommonTypes.h"