BsCorePrerequisites.h 12 KB

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