2
0

CmRenderSystemCapabilities.h 25 KB

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