BsCorePrerequisites.h 16 KB

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