BsCorePrerequisites.h 15 KB

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