BsCorePrerequisites.h 12 KB

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