CmRenderSystemCapabilities.h 26 KB

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