BsCorePrerequisites.h 14 KB

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