BsCorePrerequisites.h 11 KB

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