BsCorePrerequisites.h 13 KB

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