BsCorePrerequisites.h 11 KB

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