BsCorePrerequisites.h 14 KB

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