BsCorePrerequisites.h 13 KB

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