BsCorePrerequisites.h 12 KB

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