BsCorePrerequisites.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. /** @defgroup Core Core
  6. * Second lowest layer that provides some very game-specific modules tied into a coherent whole, but it tries to be very
  7. * generic and offer something that every engine might need instead of focusing on very specialized techniques.
  8. * @{
  9. */
  10. /** @defgroup CoreThread Core thread
  11. * Functionality for dealing with core objects and interaction with the core thread.
  12. */
  13. /** @defgroup Importer Importer
  14. * Functionality for dealing with import of resources into engine friendly format.
  15. */
  16. /** @defgroup Input Input
  17. * Functionality for dealing with input (mouse, keyboard, gamepad, etc.).
  18. */
  19. /** @defgroup Localization Localization
  20. * Functionality for dealing with GUI localization.
  21. */
  22. /** @defgroup Material Material
  23. * Functionality for dealing with materials, shaders, and in general how objects are rendered.
  24. */
  25. /** @defgroup Platform Platform
  26. * Functionality specific for some platform (e.g. Windows, Mac).
  27. */
  28. /** @defgroup Profiling Profiling
  29. * Functionality for measuring CPU and GPU execution times and memory usage.
  30. */
  31. /** @defgroup RenderAPI RenderAPI
  32. * Functionality for interacting with underlying render API (e.g. DirectX, OpenGL).
  33. */
  34. /** @defgroup Renderer Renderer
  35. * Abstract interface and helper functionality for rendering scene objects.
  36. */
  37. /** @defgroup Resources Resources
  38. * Contains core resource types and resource management functionality (loading, saving, etc.).
  39. */
  40. /** @defgroup RTTI-Impl-Core RTTI types
  41. * Types containing RTTI for specific classes.
  42. */
  43. /** @defgroup Scene Scene
  44. * Functionality for managing scene objects and their hierarchy.
  45. */
  46. /** @defgroup Text Text
  47. * Functionality for rendering text.
  48. */
  49. /** @defgroup Utility-Core Utility
  50. * Various utility methods and types used by the core layer.
  51. */
  52. /** @defgroup Application-Core Application
  53. * Entry point into the application.
  54. */
  55. /** @} */
  56. #define BS_MAX_MULTIPLE_RENDER_TARGETS 8
  57. #define BS_FORCE_SINGLETHREADED_RENDERING 0
  58. // Windows Settings
  59. #if BS_PLATFORM == BS_PLATFORM_WIN32
  60. // If we're not including this from a client build, specify that the stuff
  61. // should get exported. Otherwise, import it.
  62. # if defined(BS_STATIC_LIB)
  63. // Linux compilers don't have symbol import/export directives.
  64. # define BS_CORE_EXPORT
  65. # else
  66. # if defined(BS_CORE_EXPORTS)
  67. # define BS_CORE_EXPORT __declspec( dllexport )
  68. # else
  69. # if defined( __MINGW32__ )
  70. # define BS_CORE_EXPORT
  71. # else
  72. # define BS_CORE_EXPORT __declspec( dllimport )
  73. # endif
  74. # endif
  75. # endif
  76. #endif
  77. // Linux/Apple Settings
  78. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
  79. // Enable GCC symbol visibility
  80. # if defined( BS_GCC_VISIBILITY )
  81. # define BS_CORE_EXPORT __attribute__ ((visibility("default")))
  82. # define BS_HIDDEN __attribute__ ((visibility("hidden")))
  83. # else
  84. # define BS_CORE_EXPORT
  85. # define BS_HIDDEN
  86. # endif
  87. #endif
  88. #include "BsHString.h"
  89. namespace BansheeEngine
  90. {
  91. static const StringID RenderAPIAny = "AnyRenderAPI";
  92. static const StringID RendererAny = "AnyRenderer";
  93. class Color;
  94. class GpuProgram;
  95. class GpuProgramManager;
  96. class IndexBuffer;
  97. class IndexBufferCore;
  98. class OcclusionQuery;
  99. class VertexBuffer;
  100. class VertexBufferCore;
  101. class PixelBuffer;
  102. class GpuBuffer;
  103. class HighLevelGpuProgram;
  104. class GpuProgramManager;
  105. class GpuProgramFactory;
  106. class IndexData;
  107. class Pass;
  108. class Technique;
  109. class Shader;
  110. class Material;
  111. class RenderAPICore;
  112. class RenderAPICapabilities;
  113. class RenderTarget;
  114. class RenderTargetCore;
  115. class RenderTexture;
  116. class RenderTextureCore;
  117. class MultiRenderTexture;
  118. class MultiRenderTextureCore;
  119. class RenderWindow;
  120. class RenderWindowCore;
  121. class RenderTargetProperties;
  122. struct RenderOpMesh;
  123. class StringInterface;
  124. class SamplerState;
  125. class SamplerStateCore;
  126. class TextureManager;
  127. class Viewport;
  128. class VertexData;
  129. class VertexDeclaration;
  130. class Input;
  131. struct PointerEvent;
  132. class RawInputHandler;
  133. class CoreRenderer;
  134. class RendererFactory;
  135. class AsyncOp;
  136. class HardwareBufferManager;
  137. class FontManager;
  138. class DepthStencilState;
  139. class DepthStencilStateCore;
  140. class RenderStateManager;
  141. class RasterizerState;
  142. class RasterizerStateCore;
  143. class BlendState;
  144. class BlendStateCore;
  145. class GpuParamBlock;
  146. class GpuParamBlockBuffer;
  147. class GpuParams;
  148. struct GpuParamDesc;
  149. struct GpuParamDataDesc;
  150. struct GpuParamObjectDesc;
  151. struct GpuParamBlockDesc;
  152. class ShaderInclude;
  153. class TextureView;
  154. class CoreObject;
  155. class CoreObjectCore;
  156. class ImportOptions;
  157. class TextureImportOptions;
  158. class FontImportOptions;
  159. class GpuProgramImportOptions;
  160. class MeshImportOptions;
  161. struct FontBitmap;
  162. class GameObject;
  163. class GpuResourceData;
  164. struct RenderOperation;
  165. class RenderQueue;
  166. struct ProfilerReport;
  167. class VertexDataDesc;
  168. class EventQuery;
  169. class TimerQuery;
  170. class OcclusionQuery;
  171. class FrameAlloc;
  172. class FolderMonitor;
  173. class VideoMode;
  174. class VideoOutputInfo;
  175. class VideoModeInfo;
  176. class RenderableElement;
  177. class CameraCore;
  178. class MeshCoreBase;
  179. class MeshCore;
  180. struct SubMesh;
  181. class TransientMeshCore;
  182. class TextureCore;
  183. class MeshHeapCore;
  184. class VertexDeclarationCore;
  185. class GpuBufferCore;
  186. class GpuParamBlockBufferCore;
  187. class GpuParamsCore;
  188. class ShaderCore;
  189. class ViewportCore;
  190. class PassCore;
  191. class PassParametersCore;
  192. class TechniqueCore;
  193. class MaterialCore;
  194. class GpuProgramCore;
  195. class IResourceListener;
  196. class TextureProperties;
  197. class IShaderIncludeHandler;
  198. class Prefab;
  199. class PrefabDiff;
  200. class RendererMeshData;
  201. class LightCore;
  202. class Light;
  203. class Win32Window;
  204. class RenderAPIFactory;
  205. class PhysicsManager;
  206. class Physics;
  207. class Collider;
  208. class Rigidbody;
  209. class PhysicsMaterial;
  210. // Asset import
  211. class SpecificImporter;
  212. class Importer;
  213. // Resources
  214. class Resource;
  215. class Resources;
  216. class ResourceManifest;
  217. class Texture;
  218. class Mesh;
  219. class MeshBase;
  220. class TransientMesh;
  221. class MeshHeap;
  222. class Font;
  223. class ResourceMetaData;
  224. class OSDropTarget;
  225. class StringTable;
  226. class PhysicsMaterial;
  227. // Scene
  228. class SceneObject;
  229. class Component;
  230. class SceneManager;
  231. // RTTI
  232. class MeshRTTI;
  233. // Desc structs
  234. struct SAMPLER_STATE_DESC;
  235. struct DEPTH_STENCIL_STATE_DESC;
  236. struct RASTERIZER_STATE_DESC;
  237. struct BLEND_STATE_DESC;
  238. struct RENDER_TARGET_BLEND_STATE_DESC;
  239. struct RENDER_TEXTURE_DESC;
  240. struct RENDER_WINDOW_DESC;
  241. struct FONT_DESC;
  242. template<class T>
  243. class CoreThreadAccessor;
  244. class CommandQueueNoSync;
  245. class CommandQueueSync;
  246. }
  247. /************************************************************************/
  248. /* Shared pointer typedefs */
  249. /************************************************************************/
  250. namespace BansheeEngine
  251. {
  252. typedef std::shared_ptr<RenderAPICore> RenderAPIPtr;
  253. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  254. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  255. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  256. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  257. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  258. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  259. typedef std::shared_ptr<Mesh> MeshPtr;
  260. typedef std::shared_ptr<MeshBase> MeshBasePtr;
  261. typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
  262. typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
  263. typedef std::shared_ptr<Texture> TexturePtr;
  264. typedef std::shared_ptr<Resource> ResourcePtr;
  265. typedef std::shared_ptr<Technique> TechniquePtr;
  266. typedef std::shared_ptr<Pass> PassPtr;
  267. typedef std::shared_ptr<Shader> ShaderPtr;
  268. typedef std::shared_ptr<Material> MaterialPtr;
  269. typedef std::shared_ptr<CoreRenderer> CoreRendererPtr;
  270. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  271. typedef std::shared_ptr<Component> ComponentPtr;
  272. typedef std::shared_ptr<GameObject> GameObjectPtr;
  273. typedef std::shared_ptr<SceneObject> SceneObjectPtr;
  274. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  275. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  276. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  277. typedef std::shared_ptr<BlendState> BlendStatePtr;
  278. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  279. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  280. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  281. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  282. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  283. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  284. typedef std::shared_ptr<TextureView> TextureViewPtr;
  285. typedef std::shared_ptr<Viewport> ViewportPtr;
  286. typedef std::shared_ptr<ShaderInclude> ShaderIncludePtr;
  287. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  288. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  289. typedef std::shared_ptr<Font> FontPtr;
  290. typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
  291. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  292. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  293. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  294. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  295. typedef std::shared_ptr<EventQuery> EventQueryPtr;
  296. typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
  297. typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
  298. typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
  299. typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
  300. typedef std::shared_ptr<RenderQueue> RenderQueuePtr;
  301. typedef std::shared_ptr<GpuParamDesc> GpuParamDescPtr;
  302. typedef std::shared_ptr<ResourceMetaData> ResourceMetaDataPtr;
  303. typedef std::shared_ptr<IShaderIncludeHandler> ShaderIncludeHandlerPtr;
  304. typedef std::shared_ptr<Prefab> PrefabPtr;
  305. typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
  306. typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
  307. typedef std::shared_ptr<RenderAPIFactory> RenderAPIFactoryPtr;
  308. typedef std::shared_ptr<PhysicsMaterial> PhysicsMaterialPtr;
  309. }
  310. /************************************************************************/
  311. /* RTTI */
  312. /************************************************************************/
  313. namespace BansheeEngine
  314. {
  315. enum TypeID_Core
  316. {
  317. TID_Texture = 1001,
  318. TID_Mesh = 1002,
  319. TID_MeshData = 1003,
  320. TID_VertexDeclaration = 1004,
  321. TID_VertexElementData = 1005,
  322. TID_Component = 1006,
  323. TID_ResourceHandle = 1009,
  324. TID_GpuProgram = 1010,
  325. TID_ResourceHandleData = 1011,
  326. TID_CgProgram = 1012,
  327. TID_Pass = 1014,
  328. TID_Technique = 1015,
  329. TID_Shader = 1016,
  330. TID_Material = 1017,
  331. TID_SamplerState = 1021,
  332. TID_BlendState = 1023,
  333. TID_RasterizerState = 1024,
  334. TID_DepthStencilState = 1025,
  335. TID_BLEND_STATE_DESC = 1034,
  336. TID_SHADER_DATA_PARAM_DESC = 1035,
  337. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  338. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  339. TID_ImportOptions = 1048,
  340. TID_Font = 1051,
  341. TID_FONT_DESC = 1052,
  342. TID_CHAR_DESC = 1053,
  343. TID_FontImportOptions = 1056,
  344. TID_FontBitmap = 1057,
  345. TID_SceneObject = 1059,
  346. TID_GameObject = 1060,
  347. TID_PixelData = 1062,
  348. TID_GpuResourceData = 1063,
  349. TID_VertexDataDesc = 1064,
  350. TID_MeshBase = 1065,
  351. TID_GameObjectHandleBase = 1066,
  352. TID_ResourceManifest = 1067,
  353. TID_ResourceManifestEntry = 1068,
  354. TID_EmulatedParamBlock = 1069,
  355. TID_TextureImportOptions = 1070,
  356. TID_ResourceMetaData = 1071,
  357. TID_ShaderInclude = 1072,
  358. TID_Viewport = 1073,
  359. TID_ResourceDependencies = 1074,
  360. TID_ShaderMetaData = 1075,
  361. TID_MeshImportOptions = 1076,
  362. TID_Prefab = 1077,
  363. TID_PrefabDiff = 1078,
  364. TID_PrefabObjectDiff = 1079,
  365. TID_PrefabComponentDiff = 1080,
  366. TID_CGUIWidget = 1081,
  367. TID_ProfilerOverlay = 1082,
  368. TID_StringTable = 1083,
  369. TID_LanguageData = 1084,
  370. TID_LocalizedStringData = 1085,
  371. TID_MaterialParamColor = 1086,
  372. TID_WeakResourceHandle = 1087,
  373. TID_TextureParamData = 1088,
  374. TID_StructParamData = 1089,
  375. TID_MaterialParams = 1090,
  376. TID_MaterialRTTIParam = 1091,
  377. TID_PhysicsMaterial = 1092
  378. };
  379. }
  380. /************************************************************************/
  381. /* Resource references */
  382. /************************************************************************/
  383. #include "BsResourceHandle.h"
  384. namespace BansheeEngine
  385. {
  386. // Resource handles
  387. typedef ResourceHandle<Resource> HResource;
  388. typedef ResourceHandle<Texture> HTexture;
  389. typedef ResourceHandle<Mesh> HMesh;
  390. typedef ResourceHandle<Material> HMaterial;
  391. typedef ResourceHandle<ShaderInclude> HShaderInclude;
  392. typedef ResourceHandle<Font> HFont;
  393. typedef ResourceHandle<Shader> HShader;
  394. typedef ResourceHandle<Prefab> HPrefab;
  395. typedef ResourceHandle<StringTable> HStringTable;
  396. typedef ResourceHandle<PhysicsMaterial> HPhysicsMaterial;
  397. }
  398. namespace BansheeEngine
  399. {
  400. /**
  401. * @brief Defers function execution until the next frame. If this function is called
  402. * within another deferred call, then it will be executed the same frame,
  403. * but only after all existing deferred calls are done.
  404. *
  405. * @note This method can be used for breaking dependencies among other things. If a class
  406. * A depends on class B having something done, but class B also depends in some way on class A,
  407. * you can break up the initialization into two separate steps, queuing the second step
  408. * using this method.
  409. *
  410. * Similar situation can happen if you have multiple classes being initialized in an undefined order
  411. * but some of them depend on others. Using this method you can defer the dependent step until next frame,
  412. * which will ensure everything was initialized.
  413. *
  414. * @param callback The callback.
  415. */
  416. void BS_CORE_EXPORT deferredCall(std::function<void()> callback);
  417. // Special types for use by profilers
  418. typedef std::basic_string<char, std::char_traits<char>, StdAlloc<char, ProfilerAlloc>> ProfilerString;
  419. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  420. using ProfilerVector = std::vector<T, A>;
  421. template <typename T, typename A = StdAlloc<T, ProfilerAlloc>>
  422. using ProfilerStack = std::stack<T, std::deque<T, A>>;
  423. /**
  424. * @brief Banshee thread policy that performs special startup/shutdown on threads
  425. * managed by thread pool.
  426. */
  427. class BS_CORE_EXPORT ThreadBansheePolicy
  428. {
  429. public:
  430. static void onThreadStarted(const String& name)
  431. {
  432. MemStack::beginThread();
  433. }
  434. static void onThreadEnded(const String& name)
  435. {
  436. MemStack::endThread();
  437. }
  438. };
  439. }
  440. #include "BsCommonTypes.h"