BsCorePrerequisites.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. /** @} */
  24. #define BS_MAX_MULTIPLE_RENDER_TARGETS 8
  25. #define BS_FORCE_SINGLETHREADED_RENDERING 0
  26. // Windows Settings
  27. #if BS_PLATFORM == BS_PLATFORM_WIN32
  28. // If we're not including this from a client build, specify that the stuff
  29. // should get exported. Otherwise, import it.
  30. # if defined(BS_STATIC_LIB)
  31. // Linux compilers don't have symbol import/export directives.
  32. # define BS_CORE_EXPORT
  33. # else
  34. # if defined(BS_CORE_EXPORTS)
  35. # define BS_CORE_EXPORT __declspec( dllexport )
  36. # else
  37. # if defined( __MINGW32__ )
  38. # define BS_CORE_EXPORT
  39. # else
  40. # define BS_CORE_EXPORT __declspec( dllimport )
  41. # endif
  42. # endif
  43. # endif
  44. // Win32 compilers use _DEBUG for specifying debug builds.
  45. // for MinGW, we set DEBUG
  46. # if defined(_DEBUG) || defined(DEBUG)
  47. # define BS_DEBUG_MODE 1
  48. # else
  49. # define BS_DEBUG_MODE 0
  50. # endif
  51. #endif
  52. // Linux/Apple Settings
  53. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_APPLE
  54. // Enable GCC symbol visibility
  55. # if defined( BS_GCC_VISIBILITY )
  56. # define BS_CORE_EXPORT __attribute__ ((visibility("default")))
  57. # define BS_HIDDEN __attribute__ ((visibility("hidden")))
  58. # else
  59. # define BS_CORE_EXPORT
  60. # define BS_HIDDEN
  61. # endif
  62. // A quick define to overcome different names for the same function
  63. # define stricmp strcasecmp
  64. # ifdef DEBUG
  65. # define BS_DEBUG_MODE 1
  66. # else
  67. # define BS_DEBUG_MODE 0
  68. # endif
  69. #endif
  70. #if BS_DEBUG_MODE
  71. #define BS_DEBUG_ONLY(x) x
  72. #define BS_ASSERT(x) assert(x)
  73. #else
  74. #define BS_DEBUG_ONLY(x)
  75. #define BS_ASSERT(x)
  76. #endif
  77. #include "BsHString.h"
  78. namespace BansheeEngine
  79. {
  80. static const StringID RenderAPIAny = "AnyRenderAPI";
  81. static const StringID RendererAny = "AnyRenderer";
  82. class Color;
  83. class GpuProgram;
  84. class GpuProgramManager;
  85. class IndexBuffer;
  86. class IndexBufferCore;
  87. class OcclusionQuery;
  88. class VertexBuffer;
  89. class VertexBufferCore;
  90. class PixelBuffer;
  91. class GpuBuffer;
  92. class HighLevelGpuProgram;
  93. class GpuProgramManager;
  94. class GpuProgramFactory;
  95. class IndexData;
  96. class Pass;
  97. class Technique;
  98. class Shader;
  99. class Material;
  100. class RenderAPICore;
  101. class RenderAPICapabilities;
  102. class RenderTarget;
  103. class RenderTargetCore;
  104. class RenderTexture;
  105. class RenderTextureCore;
  106. class MultiRenderTexture;
  107. class MultiRenderTextureCore;
  108. class RenderWindow;
  109. class RenderWindowCore;
  110. class RenderTargetProperties;
  111. struct RenderOpMesh;
  112. class StringInterface;
  113. class SamplerState;
  114. class SamplerStateCore;
  115. class TextureManager;
  116. class Viewport;
  117. class VertexData;
  118. class VertexDeclaration;
  119. class Input;
  120. struct PointerEvent;
  121. class RawInputHandler;
  122. class CoreRenderer;
  123. class RendererFactory;
  124. class AsyncOp;
  125. class HardwareBufferManager;
  126. class FontManager;
  127. class DepthStencilState;
  128. class DepthStencilStateCore;
  129. class RenderStateManager;
  130. class RasterizerState;
  131. class RasterizerStateCore;
  132. class BlendState;
  133. class BlendStateCore;
  134. class GpuParamBlock;
  135. class GpuParamBlockBuffer;
  136. class GpuParams;
  137. struct GpuParamDesc;
  138. struct GpuParamDataDesc;
  139. struct GpuParamObjectDesc;
  140. struct GpuParamBlockDesc;
  141. class ShaderInclude;
  142. class TextureView;
  143. class CoreObject;
  144. class CoreObjectCore;
  145. class ImportOptions;
  146. class TextureImportOptions;
  147. class FontImportOptions;
  148. class GpuProgramImportOptions;
  149. class MeshImportOptions;
  150. struct FontBitmap;
  151. class GameObject;
  152. class GpuResourceData;
  153. struct RenderOperation;
  154. class RenderQueue;
  155. struct ProfilerReport;
  156. class VertexDataDesc;
  157. class EventQuery;
  158. class TimerQuery;
  159. class OcclusionQuery;
  160. class FrameAlloc;
  161. class FolderMonitor;
  162. class VideoMode;
  163. class VideoOutputInfo;
  164. class VideoModeInfo;
  165. class RenderableElement;
  166. class CameraCore;
  167. class MeshCoreBase;
  168. class MeshCore;
  169. struct SubMesh;
  170. class TransientMeshCore;
  171. class TextureCore;
  172. class MeshHeapCore;
  173. class VertexDeclarationCore;
  174. class GpuBufferCore;
  175. class GpuParamBlockBufferCore;
  176. class GpuParamsCore;
  177. class ShaderCore;
  178. class ViewportCore;
  179. class PassCore;
  180. class PassParametersCore;
  181. class TechniqueCore;
  182. class MaterialCore;
  183. class GpuProgramCore;
  184. class IResourceListener;
  185. class TextureProperties;
  186. class IShaderIncludeHandler;
  187. class Prefab;
  188. class PrefabDiff;
  189. class RendererMeshData;
  190. class LightCore;
  191. class Light;
  192. class Win32Window;
  193. // Asset import
  194. class SpecificImporter;
  195. class Importer;
  196. // Resources
  197. class Resource;
  198. class Resources;
  199. class ResourceManifest;
  200. class Texture;
  201. class Mesh;
  202. class MeshBase;
  203. class TransientMesh;
  204. class MeshHeap;
  205. class Font;
  206. class ResourceMetaData;
  207. class OSDropTarget;
  208. class StringTable;
  209. // Scene
  210. class SceneObject;
  211. class Component;
  212. class SceneManager;
  213. // RTTI
  214. class MeshRTTI;
  215. // Desc structs
  216. struct SAMPLER_STATE_DESC;
  217. struct DEPTH_STENCIL_STATE_DESC;
  218. struct RASTERIZER_STATE_DESC;
  219. struct BLEND_STATE_DESC;
  220. struct RENDER_TARGET_BLEND_STATE_DESC;
  221. struct RENDER_TEXTURE_DESC;
  222. struct RENDER_WINDOW_DESC;
  223. struct FONT_DESC;
  224. template<class T>
  225. class CoreThreadAccessor;
  226. class CommandQueueNoSync;
  227. class CommandQueueSync;
  228. }
  229. /************************************************************************/
  230. /* Shared pointer typedefs */
  231. /************************************************************************/
  232. namespace BansheeEngine
  233. {
  234. typedef std::shared_ptr<RenderAPICore> RenderAPIPtr;
  235. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  236. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  237. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  238. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  239. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  240. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  241. typedef std::shared_ptr<Mesh> MeshPtr;
  242. typedef std::shared_ptr<MeshBase> MeshBasePtr;
  243. typedef std::shared_ptr<MeshHeap> MeshHeapPtr;
  244. typedef std::shared_ptr<TransientMesh> TransientMeshPtr;
  245. typedef std::shared_ptr<Texture> TexturePtr;
  246. typedef std::shared_ptr<Resource> ResourcePtr;
  247. typedef std::shared_ptr<Technique> TechniquePtr;
  248. typedef std::shared_ptr<Pass> PassPtr;
  249. typedef std::shared_ptr<Shader> ShaderPtr;
  250. typedef std::shared_ptr<Material> MaterialPtr;
  251. typedef std::shared_ptr<CoreRenderer> CoreRendererPtr;
  252. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  253. typedef std::shared_ptr<Component> ComponentPtr;
  254. typedef std::shared_ptr<GameObject> GameObjectPtr;
  255. typedef std::shared_ptr<SceneObject> SceneObjectPtr;
  256. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  257. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  258. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  259. typedef std::shared_ptr<BlendState> BlendStatePtr;
  260. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  261. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  262. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  263. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  264. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  265. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  266. typedef std::shared_ptr<TextureView> TextureViewPtr;
  267. typedef std::shared_ptr<Viewport> ViewportPtr;
  268. typedef std::shared_ptr<ShaderInclude> ShaderIncludePtr;
  269. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  270. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  271. typedef std::shared_ptr<Font> FontPtr;
  272. typedef std::shared_ptr<VertexDataDesc> VertexDataDescPtr;
  273. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  274. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  275. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  276. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  277. typedef std::shared_ptr<EventQuery> EventQueryPtr;
  278. typedef std::shared_ptr<TimerQuery> TimerQueryPtr;
  279. typedef std::shared_ptr<OcclusionQuery> OcclusionQueryPtr;
  280. typedef std::shared_ptr<ResourceManifest> ResourceManifestPtr;
  281. typedef std::shared_ptr<VideoModeInfo> VideoModeInfoPtr;
  282. typedef std::shared_ptr<RenderQueue> RenderQueuePtr;
  283. typedef std::shared_ptr<GpuParamDesc> GpuParamDescPtr;
  284. typedef std::shared_ptr<ResourceMetaData> ResourceMetaDataPtr;
  285. typedef std::shared_ptr<IShaderIncludeHandler> ShaderIncludeHandlerPtr;
  286. typedef std::shared_ptr<Prefab> PrefabPtr;
  287. typedef std::shared_ptr<PrefabDiff> PrefabDiffPtr;
  288. typedef std::shared_ptr<RendererMeshData> RendererMeshDataPtr;
  289. }
  290. /************************************************************************/
  291. /* RTTI */
  292. /************************************************************************/
  293. namespace BansheeEngine
  294. {
  295. enum TypeID_Core
  296. {
  297. TID_Texture = 1001,
  298. TID_Mesh = 1002,
  299. TID_MeshData = 1003,
  300. TID_VertexDeclaration = 1004,
  301. TID_VertexElementData = 1005,
  302. TID_Component = 1006,
  303. TID_ResourceHandle = 1009,
  304. TID_GpuProgram = 1010,
  305. TID_ResourceHandleData = 1011,
  306. TID_CgProgram = 1012,
  307. TID_Pass = 1014,
  308. TID_Technique = 1015,
  309. TID_Shader = 1016,
  310. TID_Material = 1017,
  311. TID_MaterialParams = 1018,
  312. TID_FloatParamKVP = 1019,
  313. TID_MaterialTexParamKVP = 1020,
  314. TID_SamplerState = 1021,
  315. TID_SamplerStateParamKVP = 1022,
  316. TID_BlendState = 1023,
  317. TID_RasterizerState = 1024,
  318. TID_DepthStencilState = 1025,
  319. TID_MaterialParamFloat = 1026,
  320. TID_MaterialParamVec2 = 1027,
  321. TID_MaterialParamVec3 = 1028,
  322. TID_MaterialParamVec4 = 1029,
  323. TID_MaterialParamMat3 = 1030,
  324. TID_MaterialParamMat4 = 1031,
  325. TID_MaterialParamTexture = 1032,
  326. TID_MaterialParamSamplerState = 1033,
  327. TID_BLEND_STATE_DESC = 1034,
  328. TID_SHADER_DATA_PARAM_DESC = 1035,
  329. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  330. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  331. TID_ImportOptions = 1048,
  332. TID_MaterialParamStruct = 1050,
  333. TID_Font = 1051,
  334. TID_FONT_DESC = 1052,
  335. TID_CHAR_DESC = 1053,
  336. TID_FontImportOptions = 1056,
  337. TID_FontBitmap = 1057,
  338. TID_SceneObject = 1059,
  339. TID_GameObject = 1060,
  340. TID_PixelData = 1062,
  341. TID_GpuResourceData = 1063,
  342. TID_VertexDataDesc = 1064,
  343. TID_MeshBase = 1065,
  344. TID_GameObjectHandleBase = 1066,
  345. TID_ResourceManifest = 1067,
  346. TID_ResourceManifestEntry = 1068,
  347. TID_EmulatedParamBlock = 1069,
  348. TID_TextureImportOptions = 1070,
  349. TID_ResourceMetaData = 1071,
  350. TID_ShaderInclude = 1072,
  351. TID_Viewport = 1073,
  352. TID_ResourceDependencies = 1074,
  353. TID_ShaderMetaData = 1075,
  354. TID_MeshImportOptions = 1076,
  355. TID_Prefab = 1077,
  356. TID_PrefabDiff = 1078,
  357. TID_PrefabObjectDiff = 1079,
  358. TID_PrefabComponentDiff = 1080,
  359. TID_CGUIWidget = 1081,
  360. TID_ProfilerOverlay = 1082,
  361. TID_StringTable = 1083,
  362. TID_LanguageData = 1084,
  363. TID_LocalizedStringData = 1085,
  364. TID_MaterialParamColor = 1086,
  365. TID_WeakResourceHandle = 1087,
  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"