BsCorePrerequisites.h 12 KB

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