CmRenderSystemCapabilities.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __RenderSystemCapabilities__
  25. #define __RenderSystemCapabilities__ 1
  26. // Precompiler options
  27. #include "CmPrerequisites.h"
  28. #include "CmString.h"
  29. #include "CmGpuProgram.h"
  30. // Because there are more than 32 possible Capabilities, more than 1 int is needed to store them all.
  31. // In fact, an array of integers is used to store capabilities. However all the capabilities are defined in the single
  32. // enum. The only way to know which capabilities should be stored where in the array is to use some of the 32 bits
  33. // to record the category of the capability. These top few bits are used as an index into mCapabilities array
  34. // The lower bits are used to identify each capability individually by setting 1 bit for each
  35. // Identifies how many bits are reserved for categories
  36. // NOTE: Although 4 bits (currently) are enough
  37. #define CAPS_CATEGORY_SIZE 4
  38. #define CM_CAPS_BITSHIFT (32 - CAPS_CATEGORY_SIZE)
  39. #define CAPS_CATEGORY_MASK (((1 << CAPS_CATEGORY_SIZE) - 1) << CM_CAPS_BITSHIFT)
  40. #define CM_CAPS_VALUE(cat, val) ((cat << CM_CAPS_BITSHIFT) | (1 << val))
  41. #define MAX_BOUND_VERTEX_BUFFERS 32
  42. namespace BansheeEngine
  43. {
  44. /** \addtogroup Core
  45. * @{
  46. */
  47. /** \addtogroup RenderSystem
  48. * @{
  49. */
  50. /// Enumerates the categories of capabilities
  51. enum CapabilitiesCategory
  52. {
  53. CAPS_CATEGORY_COMMON = 0,
  54. CAPS_CATEGORY_COMMON_2 = 1,
  55. CAPS_CATEGORY_D3D9 = 2,
  56. CAPS_CATEGORY_GL = 3,
  57. CAPS_CATEGORY_COMMON_3 = 4,
  58. CAPS_CATEGORY_D3D11 = 5,
  59. /// Placeholder for max value
  60. CAPS_CATEGORY_COUNT = 6
  61. };
  62. /// Enum describing the different hardware capabilities we want to check for
  63. /// OGRE_CAPS_VALUE(a, b) defines each capability
  64. // a is the category (which can be from 0 to 15)
  65. // b is the value (from 0 to 27)
  66. enum Capabilities
  67. {
  68. /// Supports generating mipmaps in hardware
  69. RSC_AUTOMIPMAP = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0),
  70. RSC_BLENDING = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 1),
  71. /// Supports anisotropic texture filtering
  72. RSC_ANISOTROPY = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 2),
  73. /// Supports fixed-function DOT3 texture blend
  74. RSC_DOT3 = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 3),
  75. /// Supports cube mapping
  76. RSC_CUBEMAPPING = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 4),
  77. /// Supports hardware stencil buffer
  78. RSC_HWSTENCIL = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 5),
  79. /// Supports hardware vertex and index buffers
  80. RSC_VBO = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 7),
  81. /// Supports vertex programs (vertex shaders)
  82. RSC_VERTEX_PROGRAM = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 9),
  83. /// Supports fragment programs (pixel shaders)
  84. RSC_FRAGMENT_PROGRAM = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 10),
  85. /// Supports performing a scissor test to exclude areas of the screen
  86. RSC_SCISSOR_TEST = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 11),
  87. /// Supports separate stencil updates for both front and back faces
  88. RSC_TWO_SIDED_STENCIL = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 12),
  89. /// Supports wrapping the stencil value at the range extremeties
  90. RSC_STENCIL_WRAP = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 13),
  91. /// Supports hardware occlusion queries
  92. RSC_HWOCCLUSION = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 14),
  93. /// Supports user clipping planes
  94. RSC_USER_CLIP_PLANES = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 15),
  95. /// Supports the VET_UBYTE4 vertex element type
  96. RSC_VERTEX_FORMAT_UBYTE4 = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 16),
  97. /// Supports infinite far plane projection
  98. RSC_INFINITE_FAR_PLANE = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 17),
  99. /// Supports hardware render-to-texture (bigger than framebuffer)
  100. RSC_HWRENDER_TO_TEXTURE = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 18),
  101. /// Supports float textures and render targets
  102. RSC_TEXTURE_FLOAT = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 19),
  103. /// Supports non-power of two textures
  104. RSC_NON_POWER_OF_2_TEXTURES = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 20),
  105. /// Supports 3d (volume) textures
  106. RSC_TEXTURE_3D = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 21),
  107. /// Supports basic point sprite rendering
  108. RSC_POINT_SPRITES = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 22),
  109. /// Supports extra point parameters (minsize, maxsize, attenuation)
  110. RSC_POINT_EXTENDED_PARAMETERS = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 23),
  111. /// Supports vertex texture fetch
  112. RSC_VERTEX_TEXTURE_FETCH = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 24),
  113. /// Supports mipmap LOD biasing
  114. RSC_MIPMAP_LOD_BIAS = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 25),
  115. /// Supports hardware geometry programs
  116. RSC_GEOMETRY_PROGRAM = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 26),
  117. /// Supports rendering to vertex buffers
  118. RSC_HWRENDER_TO_VERTEX_BUFFER = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 27),
  119. /// Support for async occlusion queries
  120. RSC_HWOCCLUSION_ASYNCHRONOUS = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 28),
  121. /// Supports dynamic shader linking
  122. RSC_SHADER_SUBROUTINE = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON, 29),
  123. /// Supports compressed textures
  124. RSC_TEXTURE_COMPRESSION = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 0),
  125. /// Supports compressed textures in the DXT/ST3C formats
  126. RSC_TEXTURE_COMPRESSION_DXT = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 1),
  127. /// Supports compressed textures in the VTC format
  128. RSC_TEXTURE_COMPRESSION_VTC = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 2),
  129. /// Supports compressed textures in the PVRTC format
  130. RSC_TEXTURE_COMPRESSION_PVRTC = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 3),
  131. /// Supports fixed-function pipeline
  132. RSC_FIXED_FUNCTION = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 4),
  133. /// Supports MRTs with different bit depths
  134. RSC_MRT_DIFFERENT_BIT_DEPTHS = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 5),
  135. /// Supports Alpha to Coverage (A2C)
  136. RSC_ALPHA_TO_COVERAGE = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 6),
  137. /// Supports Blending operations other than +
  138. RSC_ADVANCED_BLEND_OPERATIONS = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 7),
  139. // ***** DirectX specific caps *****
  140. /// Is DirectX feature "per stage constants" supported
  141. RSC_PERSTAGECONSTANT = CM_CAPS_VALUE(CAPS_CATEGORY_D3D9, 0),
  142. // ***** GL Specific Caps *****
  143. /// Supports openGL GLEW version 1.5
  144. RSC_GL1_5_NOVBO = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 1),
  145. /// Support for Frame Buffer Objects (FBOs)
  146. RSC_FBO = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 2),
  147. /// Support for Frame Buffer Objects ARB implementation (regular FBO is higher precedence)
  148. RSC_FBO_ARB = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 3),
  149. /// Support for Frame Buffer Objects ATI implementation (ARB FBO is higher precedence)
  150. RSC_FBO_ATI = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 4),
  151. /// Support for PBuffer
  152. RSC_PBUFFER = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 5),
  153. /// Support for GL 1.5 but without HW occlusion workaround
  154. RSC_GL1_5_NOHWOCCLUSION = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 6),
  155. /// Support for point parameters ARB implementation
  156. RSC_POINT_EXTENDED_PARAMETERS_ARB = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 7),
  157. /// Support for point parameters EXT implementation
  158. RSC_POINT_EXTENDED_PARAMETERS_EXT = CM_CAPS_VALUE(CAPS_CATEGORY_GL, 8),
  159. /// Supports hardware tessellation programs
  160. RSC_TESSELLATION_PROGRAM = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_3, 0),
  161. /// Supports hardware compute programs
  162. RSC_COMPUTE_PROGRAM = CM_CAPS_VALUE(CAPS_CATEGORY_COMMON_3, 1),
  163. };
  164. /// DriverVersion is used by RenderSystemCapabilities and both GL and D3D9
  165. /// to store the version of the current GPU driver
  166. struct CM_EXPORT DriverVersion
  167. {
  168. int major;
  169. int minor;
  170. int release;
  171. int build;
  172. DriverVersion()
  173. {
  174. major = minor = release = build = 0;
  175. }
  176. String toString() const
  177. {
  178. StringStream str;
  179. str << major << "." << minor << "." << release << "." << build;
  180. return str.str();
  181. }
  182. void fromString(const String& versionString)
  183. {
  184. Vector<BansheeEngine::String> tokens = StringUtil::split(versionString, ".");
  185. if(!tokens.empty())
  186. {
  187. major = parseInt(tokens[0]);
  188. if (tokens.size() > 1)
  189. minor = parseInt(tokens[1]);
  190. if (tokens.size() > 2)
  191. release = parseInt(tokens[2]);
  192. if (tokens.size() > 3)
  193. build = parseInt(tokens[3]);
  194. }
  195. }
  196. };
  197. /** Enumeration of GPU vendors. */
  198. enum GPUVendor
  199. {
  200. GPU_UNKNOWN = 0,
  201. GPU_NVIDIA = 1,
  202. GPU_AMD = 2,
  203. GPU_INTEL = 3,
  204. /// placeholder
  205. GPU_VENDOR_COUNT = 4
  206. };
  207. /** singleton class for storing the capabilities of the graphics card.
  208. @remarks
  209. This class stores the capabilities of the graphics card. This
  210. information is set by the individual render systems.
  211. */
  212. class CM_EXPORT RenderSystemCapabilities
  213. {
  214. public:
  215. typedef Set<String> ShaderProfiles;
  216. private:
  217. /// This is used to build a database of RSC's
  218. /// if a RSC with same name, but newer version is introduced, the older one
  219. /// will be removed
  220. DriverVersion mDriverVersion;
  221. /// GPU Vendor
  222. GPUVendor mVendor;
  223. static Vector<BansheeEngine::String> msGPUVendorStrings;
  224. static void initVendorStrings();
  225. /// The number of world matrices available
  226. UINT16 mNumWorldMatrices;
  227. /// The number of texture units available per stage
  228. Map<GpuProgramType, UINT16> mNumTextureUnitsPerStage;
  229. /// Total number of texture units available
  230. UINT16 mNumCombinedTextureUnits;
  231. /// The number of uniform blocks available per stage
  232. Map<GpuProgramType, UINT16> mNumUniformBlocksPerStage;
  233. /// Total number of uniform blocks available
  234. UINT16 mNumCombinedUniformBlocks;
  235. /// The stencil buffer bit depth
  236. UINT16 mStencilBufferBitDepth;
  237. /// Maximum number of vertex buffers we can bind at once
  238. UINT32 mMaxBoundVertexBuffers;
  239. /// The number of matrices available for hardware blending
  240. UINT16 mNumVertexBlendMatrices;
  241. /// Stores the capabilities flags.
  242. int mCapabilities[CAPS_CATEGORY_COUNT];
  243. /// Which categories are relevant
  244. bool mCategoryRelevant[CAPS_CATEGORY_COUNT];
  245. /// The name of the device as reported by the render system
  246. String mDeviceName;
  247. /// The identifier associated with the render system for which these capabilities are valid
  248. String mRenderSystemName;
  249. /// The number of floating-point constants vertex programs support
  250. UINT16 mVertexProgramConstantFloatCount;
  251. /// The number of integer constants vertex programs support
  252. UINT16 mVertexProgramConstantIntCount;
  253. /// The number of boolean constants vertex programs support
  254. UINT16 mVertexProgramConstantBoolCount;
  255. /// The number of floating-point constants geometry programs support
  256. UINT16 mGeometryProgramConstantFloatCount;
  257. /// The number of integer constants vertex geometry support
  258. UINT16 mGeometryProgramConstantIntCount;
  259. /// The number of boolean constants vertex geometry support
  260. UINT16 mGeometryProgramConstantBoolCount;
  261. /// The number of floating-point constants fragment programs support
  262. UINT16 mFragmentProgramConstantFloatCount;
  263. /// The number of integer constants fragment programs support
  264. UINT16 mFragmentProgramConstantIntCount;
  265. /// The number of boolean constants fragment programs support
  266. UINT16 mFragmentProgramConstantBoolCount;
  267. /// The number of simultaneous render targets supported
  268. UINT16 mNumMultiRenderTargets;
  269. /// The maximum point size
  270. float mMaxPointSize;
  271. /// Are non-POW2 textures feature-limited?
  272. bool mNonPOW2TexturesLimited;
  273. /// The number of vertices a geometry program can emit in a single run
  274. int mGeometryProgramNumOutputVertices;
  275. /// The list of supported shader profiles
  276. ShaderProfiles mSupportedShaderProfiles;
  277. // Allows us to convert a generic shader profile to a render-system specific one
  278. UnorderedMap<GpuProgramProfile, String> mGenericToSpecificShaderProfileMap;
  279. public:
  280. RenderSystemCapabilities ();
  281. virtual ~RenderSystemCapabilities ();
  282. virtual size_t calculateSize() const {return 0;}
  283. /** Set the driver version. */
  284. void setDriverVersion(const DriverVersion& version)
  285. {
  286. mDriverVersion = version;
  287. }
  288. void parseDriverVersionFromString(const String& versionString)
  289. {
  290. DriverVersion version;
  291. version.fromString(versionString);
  292. setDriverVersion(version);
  293. }
  294. DriverVersion getDriverVersion() const
  295. {
  296. return mDriverVersion;
  297. }
  298. GPUVendor getVendor() const
  299. {
  300. return mVendor;
  301. }
  302. void setVendor(GPUVendor v)
  303. {
  304. mVendor = v;
  305. }
  306. /// Parse and set vendor
  307. void parseVendorFromString(const String& vendorString)
  308. {
  309. setVendor(vendorFromString(vendorString));
  310. }
  311. /// Convert a vendor string to an enum
  312. static GPUVendor vendorFromString(const String& vendorString);
  313. /// Convert a vendor enum to a string
  314. static String vendorToString(GPUVendor v);
  315. bool isDriverOlderThanVersion(DriverVersion v) const
  316. {
  317. if (mDriverVersion.major < v.major)
  318. return true;
  319. else if (mDriverVersion.major == v.major &&
  320. mDriverVersion.minor < v.minor)
  321. return true;
  322. else if (mDriverVersion.major == v.major &&
  323. mDriverVersion.minor == v.minor &&
  324. mDriverVersion.release < v.release)
  325. return true;
  326. else if (mDriverVersion.major == v.major &&
  327. mDriverVersion.minor == v.minor &&
  328. mDriverVersion.release == v.release &&
  329. mDriverVersion.build < v.build)
  330. return true;
  331. return false;
  332. }
  333. void setNumWorldMatrices(UINT16 num)
  334. {
  335. mNumWorldMatrices = num;
  336. }
  337. void setNumTextureUnits(GpuProgramType type, UINT16 num)
  338. {
  339. mNumTextureUnitsPerStage[type] = num;
  340. }
  341. void setNumCombinedTextureUnits(UINT16 num)
  342. {
  343. mNumCombinedTextureUnits = num;
  344. }
  345. void setNumUniformBlockBuffers(GpuProgramType type, UINT16 num)
  346. {
  347. mNumUniformBlocksPerStage[type] = num;
  348. }
  349. void setNumCombinedUniformBlockBuffers(UINT16 num)
  350. {
  351. mNumCombinedUniformBlocks = num;
  352. }
  353. void setStencilBufferBitDepth(UINT16 num)
  354. {
  355. mStencilBufferBitDepth = num;
  356. }
  357. void setNumVertexBlendMatrices(UINT16 num)
  358. {
  359. mNumVertexBlendMatrices = num;
  360. }
  361. void setMaxBoundVertexBuffers(UINT32 num)
  362. {
  363. mMaxBoundVertexBuffers = num;
  364. }
  365. /// The number of simultaneous render targets supported
  366. void setNumMultiRenderTargets(UINT16 num)
  367. {
  368. mNumMultiRenderTargets = num;
  369. }
  370. UINT16 getNumWorldMatrices(void) const
  371. {
  372. return mNumWorldMatrices;
  373. }
  374. /** Returns the number of texture units the current output hardware
  375. supports, for the specified stage.
  376. */
  377. UINT16 getNumTextureUnits(GpuProgramType type) const
  378. {
  379. auto iterFind = mNumTextureUnitsPerStage.find(type);
  380. if(iterFind != mNumTextureUnitsPerStage.end())
  381. return iterFind->second;
  382. else
  383. return 0;
  384. }
  385. /** Returns the number of texture units the current output hardware
  386. supports, total for all stages combined.
  387. */
  388. UINT16 getNumCombinedTextureUnits() const
  389. {
  390. return mNumCombinedTextureUnits;
  391. }
  392. /** Returns the number of uniform buffer blocks the current output hardware
  393. supports, for the specified stage.
  394. */
  395. UINT16 getNumUniformBlockBuffers(GpuProgramType type) const
  396. {
  397. auto iterFind = mNumUniformBlocksPerStage.find(type);
  398. if(iterFind != mNumUniformBlocksPerStage.end())
  399. return iterFind->second;
  400. else
  401. return 0;
  402. }
  403. /** Returns the number of combined uniform buffers the current output hardware
  404. supports, total for all stages combined.
  405. */
  406. UINT16 getNumCombinedUniformBlockBuffers() const
  407. {
  408. return mNumCombinedUniformBlocks;
  409. }
  410. /** Determines the bit depth of the hardware accelerated stencil
  411. buffer, if supported.
  412. @remarks
  413. If hardware stencilling is not supported, the software will
  414. provide an 8-bit software stencil.
  415. */
  416. UINT16 getStencilBufferBitDepth(void) const
  417. {
  418. return mStencilBufferBitDepth;
  419. }
  420. /** Returns the number of matrices available to hardware vertex
  421. blending for this rendering system. */
  422. UINT16 getNumVertexBlendMatrices(void) const
  423. {
  424. return mNumVertexBlendMatrices;
  425. }
  426. /** Returns the maximum number of vertex buffers we can bind at once. */
  427. UINT32 getMaxBoundVertexBuffers() const
  428. {
  429. return mMaxBoundVertexBuffers;
  430. }
  431. /// The number of simultaneous render targets supported
  432. UINT16 getNumMultiRenderTargets(void) const
  433. {
  434. return mNumMultiRenderTargets;
  435. }
  436. /** Returns true if capability is render system specific
  437. */
  438. bool isCapabilityRenderSystemSpecific(const Capabilities c)
  439. {
  440. int cat = c >> CM_CAPS_BITSHIFT;
  441. if(cat == CAPS_CATEGORY_GL || cat == CAPS_CATEGORY_D3D9)
  442. return true;
  443. return false;
  444. }
  445. /** Adds a capability flag
  446. */
  447. void setCapability(const Capabilities c)
  448. {
  449. int index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
  450. // zero out the index from the stored capability
  451. mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
  452. }
  453. /** Remove a capability flag
  454. */
  455. void unsetCapability(const Capabilities c)
  456. {
  457. int index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
  458. // zero out the index from the stored capability
  459. mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
  460. }
  461. /** Checks for a capability
  462. */
  463. bool hasCapability(const Capabilities c) const
  464. {
  465. int index = (CAPS_CATEGORY_MASK & c) >> CM_CAPS_BITSHIFT;
  466. // test against
  467. if(mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK))
  468. {
  469. return true;
  470. }
  471. else
  472. {
  473. return false;
  474. }
  475. }
  476. /** Adds the profile to the list of supported profiles
  477. */
  478. void addShaderProfile(const String& profile)
  479. {
  480. mSupportedShaderProfiles.insert(profile);
  481. }
  482. /** Adds the profile to the list of supported profiles
  483. */
  484. void addGpuProgramProfile(GpuProgramProfile gpuProgProfile, const String& rsSpecificProfile)
  485. {
  486. mGenericToSpecificShaderProfileMap[gpuProgProfile] = rsSpecificProfile;
  487. }
  488. /** Remove a given shader profile, if present.
  489. */
  490. void removeShaderProfile(const String& profile)
  491. {
  492. mSupportedShaderProfiles.erase(profile);
  493. }
  494. /** Returns true if profile is in the list of supported profiles
  495. */
  496. bool isShaderProfileSupported(const String& profile) const
  497. {
  498. return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
  499. }
  500. /** Returns a set of all supported shader profiles
  501. * */
  502. const ShaderProfiles& getSupportedShaderProfiles() const
  503. {
  504. return mSupportedShaderProfiles;
  505. }
  506. /** Converts a generic GpuProgramProfile identifier into a render-system specific one.
  507. *
  508. * Returns an empty string if it can't convert it.
  509. */
  510. String gpuProgProfileToRSSpecificProfile(GpuProgramProfile gpuProgProfile) const
  511. {
  512. auto iterFind = mGenericToSpecificShaderProfileMap.find(gpuProgProfile);
  513. if(mGenericToSpecificShaderProfileMap.end() != iterFind)
  514. {
  515. return iterFind->second;
  516. }
  517. return "";
  518. }
  519. /// The number of floating-point constants vertex programs support
  520. UINT16 getVertexProgramConstantFloatCount(void) const
  521. {
  522. return mVertexProgramConstantFloatCount;
  523. }
  524. /// The number of integer constants vertex programs support
  525. UINT16 getVertexProgramConstantIntCount(void) const
  526. {
  527. return mVertexProgramConstantIntCount;
  528. }
  529. /// The number of boolean constants vertex programs support
  530. UINT16 getVertexProgramConstantBoolCount(void) const
  531. {
  532. return mVertexProgramConstantBoolCount;
  533. }
  534. /// The number of floating-point constants geometry programs support
  535. UINT16 getGeometryProgramConstantFloatCount(void) const
  536. {
  537. return mGeometryProgramConstantFloatCount;
  538. }
  539. /// The number of integer constants geometry programs support
  540. UINT16 getGeometryProgramConstantIntCount(void) const
  541. {
  542. return mGeometryProgramConstantIntCount;
  543. }
  544. /// The number of boolean constants geometry programs support
  545. UINT16 getGeometryProgramConstantBoolCount(void) const
  546. {
  547. return mGeometryProgramConstantBoolCount;
  548. }
  549. /// The number of floating-point constants fragment programs support
  550. UINT16 getFragmentProgramConstantFloatCount(void) const
  551. {
  552. return mFragmentProgramConstantFloatCount;
  553. }
  554. /// The number of integer constants fragment programs support
  555. UINT16 getFragmentProgramConstantIntCount(void) const
  556. {
  557. return mFragmentProgramConstantIntCount;
  558. }
  559. /// The number of boolean constants fragment programs support
  560. UINT16 getFragmentProgramConstantBoolCount(void) const
  561. {
  562. return mFragmentProgramConstantBoolCount;
  563. }
  564. /// sets the device name for Render system
  565. void setDeviceName(const String& name)
  566. {
  567. mDeviceName = name;
  568. }
  569. /// gets the device name for render system
  570. String getDeviceName() const
  571. {
  572. return mDeviceName;
  573. }
  574. /// The number of floating-point constants vertex programs support
  575. void setVertexProgramConstantFloatCount(UINT16 c)
  576. {
  577. mVertexProgramConstantFloatCount = c;
  578. }
  579. /// The number of integer constants vertex programs support
  580. void setVertexProgramConstantIntCount(UINT16 c)
  581. {
  582. mVertexProgramConstantIntCount = c;
  583. }
  584. /// The number of boolean constants vertex programs support
  585. void setVertexProgramConstantBoolCount(UINT16 c)
  586. {
  587. mVertexProgramConstantBoolCount = c;
  588. }
  589. /// The number of floating-point constants geometry programs support
  590. void setGeometryProgramConstantFloatCount(UINT16 c)
  591. {
  592. mGeometryProgramConstantFloatCount = c;
  593. }
  594. /// The number of integer constants geometry programs support
  595. void setGeometryProgramConstantIntCount(UINT16 c)
  596. {
  597. mGeometryProgramConstantIntCount = c;
  598. }
  599. /// The number of boolean constants geometry programs support
  600. void setGeometryProgramConstantBoolCount(UINT16 c)
  601. {
  602. mGeometryProgramConstantBoolCount = c;
  603. }
  604. /// The number of floating-point constants fragment programs support
  605. void setFragmentProgramConstantFloatCount(UINT16 c)
  606. {
  607. mFragmentProgramConstantFloatCount = c;
  608. }
  609. /// The number of integer constants fragment programs support
  610. void setFragmentProgramConstantIntCount(UINT16 c)
  611. {
  612. mFragmentProgramConstantIntCount = c;
  613. }
  614. /// The number of boolean constants fragment programs support
  615. void setFragmentProgramConstantBoolCount(UINT16 c)
  616. {
  617. mFragmentProgramConstantBoolCount = c;
  618. }
  619. /// Maximum point screen size in pixels
  620. void setMaxPointSize(float s)
  621. {
  622. mMaxPointSize = s;
  623. }
  624. /// Maximum point screen size in pixels
  625. float getMaxPointSize(void) const
  626. {
  627. return mMaxPointSize;
  628. }
  629. /// Non-POW2 textures limited
  630. void setNonPOW2TexturesLimited(bool l)
  631. {
  632. mNonPOW2TexturesLimited = l;
  633. }
  634. /** Are non-power of two textures limited in features?
  635. @remarks
  636. If the RSC_NON_POWER_OF_2_TEXTURES capability is set, but this
  637. method returns true, you can use non power of 2 textures only if:
  638. <ul><li>You load them explicitly with no mip maps</li>
  639. <li>You don't use DXT texture compression</li>
  640. <li>You use clamp texture addressing</li></ul>
  641. */
  642. bool getNonPOW2TexturesLimited(void) const
  643. {
  644. return mNonPOW2TexturesLimited;
  645. }
  646. /// Set the number of vertices a single geometry program run can emit
  647. void setGeometryProgramNumOutputVertices(int numOutputVertices)
  648. {
  649. mGeometryProgramNumOutputVertices = numOutputVertices;
  650. }
  651. /// Get the number of vertices a single geometry program run can emit
  652. int getGeometryProgramNumOutputVertices(void) const
  653. {
  654. return mGeometryProgramNumOutputVertices;
  655. }
  656. /// Get the identifier of the rendersystem from which these capabilities were generated
  657. String getRenderSystemName(void) const
  658. {
  659. return mRenderSystemName;
  660. }
  661. /// Set the identifier of the rendersystem from which these capabilities were generated
  662. void setRenderSystemName(const String& rs)
  663. {
  664. mRenderSystemName = rs;
  665. }
  666. /// Mark a category as 'relevant' or not, ie will it be reported
  667. void setCategoryRelevant(CapabilitiesCategory cat, bool relevant)
  668. {
  669. mCategoryRelevant[cat] = relevant;
  670. }
  671. /// Return whether a category is 'relevant' or not, ie will it be reported
  672. bool isCategoryRelevant(CapabilitiesCategory cat)
  673. {
  674. return mCategoryRelevant[cat];
  675. }
  676. };
  677. /** @} */
  678. /** @} */
  679. } // namespace
  680. #endif // __RenderSystemCapabilities__