BsCorePrerequisites.h 12 KB

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