BsCorePrerequisites.h 12 KB

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