2
0

BsCorePrerequisites.h 14 KB

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