BsCorePrerequisites.h 16 KB

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