CmRenderSystemCapabilities.h 26 KB

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