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 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __RenderSystemCapabilities__
29 #define __RenderSystemCapabilities__
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 #include "OgreStringVector.h"
34 #include "OgreStringConverter.h"
35 #include "OgreHeaderPrefix.h"
36 
37 // Because there are more than 32 possible Capabilities, more than 1 int is needed to store them all.
38 // In fact, an array of integers is used to store capabilities. However all the capabilities are defined in the single
39 // enum. The only way to know which capabilities should be stored where in the array is to use some of the 32 bits
40 // to record the category of the capability.  These top few bits are used as an index into mCapabilities array
41 // The lower bits are used to identify each capability individually by setting 1 bit for each
42 
43 // Identifies how many bits are reserved for categories
44 // NOTE: Although 4 bits (currently) are enough
45 #define CAPS_CATEGORY_SIZE 4
46 #define OGRE_CAPS_BITSHIFT (32 - CAPS_CATEGORY_SIZE)
47 #define CAPS_CATEGORY_MASK (((1 << CAPS_CATEGORY_SIZE) - 1) << OGRE_CAPS_BITSHIFT)
48 #define OGRE_CAPS_VALUE(cat, val) ((cat << OGRE_CAPS_BITSHIFT) | (1 << val))
49 
50 namespace Ogre
51 {
52     /** \addtogroup Core
53     *  @{
54     */
55     /** \addtogroup RenderSystem
56     *  @{
57     */
58 
59     /// Enumerates the categories of capabilities
60     enum CapabilitiesCategory
61     {
62         CAPS_CATEGORY_COMMON = 0,
63         CAPS_CATEGORY_COMMON_2 = 1,
64         CAPS_CATEGORY_D3D9 = 2,
65         CAPS_CATEGORY_GL = 3,
66         CAPS_CATEGORY_COMMON_3 = 4,
67         /// Placeholder for max value
68         CAPS_CATEGORY_COUNT = 5
69     };
70 
71     /// Enum describing the different hardware capabilities we want to check for
72     /// OGRE_CAPS_VALUE(a, b) defines each capability
73     /// a is the category (which can be from 0 to 15)
74     /// b is the value (from 0 to 27)
75     enum Capabilities
76     {
77         /// specifying a "-1" in the index buffer starts a new draw command.
78         RSC_PRIMITIVE_RESTART = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 0),
79         /// GL ES2/ES3 does not support generating mipmaps for compressed formats in hardware
80         RSC_AUTOMIPMAP_COMPRESSED = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 1),
81         /// Supports anisotropic texture filtering
82         RSC_ANISOTROPY              = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 2),
83         /// Supports fixed-function DOT3 texture blend
84         /// @deprecated All targetted APIs by Ogre support this feature
85         RSC_DOT3                    = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 3),
86         /// Supports cube mapping
87         RSC_CUBEMAPPING             = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 4),
88         /// Supports hardware stencil buffer
89         RSC_HWSTENCIL               = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 5),
90         /// @deprecated use RenderSystemCapabilities::getVertexTextureUnitsShared
91         RSC_COMPLETE_TEXTURE_BINDING = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 6),
92         /// Supports compressed textures in the ASTC format
93         RSC_TEXTURE_COMPRESSION_ASTC = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 7),
94         /// Supports 32bit hardware index buffers
95         RSC_32BIT_INDEX             = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 8),
96         /// Supports vertex programs (vertex shaders)
97         RSC_VERTEX_PROGRAM          = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 9),
98         /// Supports fragment programs (pixel shaders)
99         RSC_FRAGMENT_PROGRAM        = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 10),
100         /// Supports performing a scissor test to exclude areas of the screen
101 		/// @deprecated All targetted APIs by Ogre support this feature
102         RSC_SCISSOR_TEST            = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 11),
103         /// Supports separate stencil updates for both front and back faces
104         RSC_TWO_SIDED_STENCIL       = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 12),
105         /// Supports wrapping the stencil value at the range extremeties
106         RSC_STENCIL_WRAP            = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 13),
107         /// Supports hardware occlusion queries
108         RSC_HWOCCLUSION             = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 14),
109         /// Supports user clipping planes
110         RSC_USER_CLIP_PLANES        = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 15),
111         /// Supports the VET_UBYTE4 vertex element type
112         RSC_VERTEX_FORMAT_UBYTE4    = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 16),
113         /// Supports infinite far plane projection
114         RSC_INFINITE_FAR_PLANE      = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 17),
115         /// Supports hardware render-to-texture (bigger than framebuffer)
116         RSC_HWRENDER_TO_TEXTURE     = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 18),
117         /// Supports float textures and render targets
118         RSC_TEXTURE_FLOAT           = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 19),
119         /// Supports non-power of two textures
120         RSC_NON_POWER_OF_2_TEXTURES = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 20),
121         /// Supports 3d (volume) textures
122         RSC_TEXTURE_3D              = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 21),
123         /// Supports basic point sprite rendering
124         RSC_POINT_SPRITES           = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 22),
125         /// Supports extra point parameters (minsize, maxsize, attenuation)
126         RSC_POINT_EXTENDED_PARAMETERS = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 23),
127         /// Supports vertex texture fetch
128         RSC_VERTEX_TEXTURE_FETCH = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 24),
129         /// Supports mipmap LOD biasing
130         RSC_MIPMAP_LOD_BIAS = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 25),
131         /// Supports hardware geometry programs
132         RSC_GEOMETRY_PROGRAM = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 26),
133         /// Supports rendering to vertex buffers
134         RSC_HWRENDER_TO_VERTEX_BUFFER = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON, 27),
135 
136         /// Supports compressed textures
137         RSC_TEXTURE_COMPRESSION = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 0),
138         /// Supports compressed textures in the DXT/ST3C formats
139         RSC_TEXTURE_COMPRESSION_DXT = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 1),
140         /// Supports compressed textures in the VTC format
141         RSC_TEXTURE_COMPRESSION_VTC = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 2),
142         /// Supports compressed textures in the PVRTC format
143         RSC_TEXTURE_COMPRESSION_PVRTC = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 3),
144         /// Supports compressed textures in the ATC format
145         RSC_TEXTURE_COMPRESSION_ATC = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 4),
146         /// Supports compressed textures in the ETC1 format
147         RSC_TEXTURE_COMPRESSION_ETC1 = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 5),
148         /// Supports compressed textures in the ETC2 format
149         RSC_TEXTURE_COMPRESSION_ETC2 = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 6),
150         /// Supports compressed textures in BC4 and BC5 format (DirectX feature level 10_0)
151         RSC_TEXTURE_COMPRESSION_BC4_BC5 = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 7),
152         /// Supports compressed textures in BC6H and BC7 format (DirectX feature level 11_0)
153         RSC_TEXTURE_COMPRESSION_BC6H_BC7 = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 8),
154         /// Supports fixed-function pipeline
155         RSC_FIXED_FUNCTION = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 9),
156         /// Supports MRTs with different bit depths
157         RSC_MRT_DIFFERENT_BIT_DEPTHS = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 10),
158         /// Supports Alpha to Coverage (A2C)
159         RSC_ALPHA_TO_COVERAGE = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 11),
160         /// Supports Blending operations other than +
161 		/// @deprecated All targetted APIs by Ogre support this feature.
162         RSC_ADVANCED_BLEND_OPERATIONS = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 12),
163         /// Supports HW gamma, both in the framebuffer and as texture.
164         RSC_HW_GAMMA = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 13),
165         /// Supports using the MAIN depth buffer for RTTs. D3D 9&10, OGL w/FBO support unknown
166         /// (undefined behavior?), OGL w/ copy supports it
167         RSC_RTT_MAIN_DEPTHBUFFER_ATTACHABLE = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 14),
168         /// Supports attaching a depth buffer to an RTT that has width & height less or equal than RTT's.
169         /// Otherwise must be of _exact_ same resolution. D3D 9, OGL 3.0 (not 2.0, not D3D10)
170         RSC_RTT_DEPTHBUFFER_RESOLUTION_LESSEQUAL = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 15),
171         /// Supports using vertex buffers for instance data
172         RSC_VERTEX_BUFFER_INSTANCE_DATA = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 16),
173         /// Supports using vertex buffers for instance data
174         RSC_CAN_GET_COMPILED_SHADER_BUFFER = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 17),
175         /// Supports dynamic linkage/shader subroutine
176         RSC_SHADER_SUBROUTINE = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 18),
177 
178         RSC_HWRENDER_TO_TEXTURE_3D = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 19),
179         /// Supports 1d textures
180         RSC_TEXTURE_1D              = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 20),
181         /// Supports hardware tessellation hull programs
182         RSC_TESSELLATION_HULL_PROGRAM = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 21),
183         /// Supports hardware tessellation domain programs
184         RSC_TESSELLATION_DOMAIN_PROGRAM = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 22),
185         /// Supports hardware compute programs
186         RSC_COMPUTE_PROGRAM = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 23),
187         /// Supports asynchronous hardware occlusion queries
188         RSC_HWOCCLUSION_ASYNCHRONOUS = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 24),
189         /// Supports asynchronous hardware occlusion queries
190         RSC_ATOMIC_COUNTERS = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 25),
191         /// Supports linewidth != 1.0
192         RSC_WIDE_LINES = OGRE_CAPS_VALUE(CAPS_CATEGORY_COMMON_2, 26),
193 
194         // ***** DirectX specific caps *****
195         /// Is DirectX feature "per stage constants" supported
196         RSC_PERSTAGECONSTANT = OGRE_CAPS_VALUE(CAPS_CATEGORY_D3D9, 0),
197         /// D3D11: supports reading back the inactive depth-stencil buffer as texture
198         RSC_READ_BACK_AS_TEXTURE = OGRE_CAPS_VALUE(CAPS_CATEGORY_D3D9, 1),
199         /// the renderer will try to use W-buffers when available
200         /// W-buffers are enabled by default for 16bit depth buffers and disabled for all other
201         /// depths.
202         RSC_WBUFFER              = OGRE_CAPS_VALUE(CAPS_CATEGORY_D3D9, 2),
203 
204         // ***** GL Specific Caps *****
205         /// Support for PBuffer
206         RSC_PBUFFER          = OGRE_CAPS_VALUE(CAPS_CATEGORY_GL, 0),
207         /// Support for Separate Shader Objects
208         RSC_SEPARATE_SHADER_OBJECTS = OGRE_CAPS_VALUE(CAPS_CATEGORY_GL, 1),
209         /// Support for Vertex Array Objects (VAOs)
210         RSC_VAO              = OGRE_CAPS_VALUE(CAPS_CATEGORY_GL, 2),
211         /// with Separate Shader Objects the gl_PerVertex interface block must be redeclared
212         /// but some drivers misbehave and do not compile if we do so
213         RSC_GLSL_SSO_REDECLARE = OGRE_CAPS_VALUE(CAPS_CATEGORY_GL, 3),
214         /// Supports debugging/ profiling events
215         RSC_DEBUG = OGRE_CAPS_VALUE(CAPS_CATEGORY_GL, 4),
216         /// RS can map driver buffer storage directly instead of using a shadow buffer
217         RSC_MAPBUFFER = OGRE_CAPS_VALUE(CAPS_CATEGORY_GL, 5),
218     };
219 
220     /// DriverVersion is used by RenderSystemCapabilities and both GL and D3D9
221     /// to store the version of the current GPU driver
222     struct _OgreExport DriverVersion
223     {
224         int major;
225         int minor;
226         int release;
227         int build;
228 
DriverVersionDriverVersion229         DriverVersion()
230         {
231             major = minor = release = build = 0;
232         }
233 
toStringDriverVersion234         String toString() const
235         {
236             StringStream str;
237             str << major << "." << minor << "." << release << "." << build;
238             return str.str();
239         }
240 
fromStringDriverVersion241         void fromString(const String& versionString)
242         {
243             StringVector tokens = StringUtil::split(versionString, ".");
244             if(!tokens.empty())
245             {
246                 major = StringConverter::parseInt(tokens[0]);
247                 if (tokens.size() > 1)
248                     minor = StringConverter::parseInt(tokens[1]);
249                 if (tokens.size() > 2)
250                     release = StringConverter::parseInt(tokens[2]);
251                 if (tokens.size() > 3)
252                     build = StringConverter::parseInt(tokens[3]);
253             }
254 
255         }
256     };
257 
258     /** Enumeration of GPU vendors. */
259     enum GPUVendor
260     {
261         GPU_UNKNOWN = 0,
262         GPU_NVIDIA,
263         GPU_AMD,
264         GPU_INTEL,
265         GPU_IMAGINATION_TECHNOLOGIES,
266         GPU_APPLE,  //!< Apple Software Renderer
267         GPU_NOKIA,
268         GPU_MS_SOFTWARE, //!< Microsoft software device
269         GPU_MS_WARP, //!< Microsoft WARP (Windows Advanced Rasterization Platform) software device - http://msdn.microsoft.com/en-us/library/dd285359.aspx
270         GPU_ARM, //!< For the Mali chipsets
271         GPU_QUALCOMM,
272         GPU_MOZILLA, //!<  WebGL on Mozilla/Firefox based browser
273         GPU_WEBKIT, //!< WebGL on WebKit/Chrome base browser
274         /// placeholder
275         GPU_VENDOR_COUNT
276     };
277 
278     /** This class stores the capabilities of the graphics card.
279     @remarks
280     This information is set by the individual render systems.
281     */
282     class _OgreExport RenderSystemCapabilities : public RenderSysAlloc
283     {
284 
285     public:
286 
287         typedef std::set<String> ShaderProfiles;
288     private:
289         /// This is used to build a database of RSC's
290         /// if a RSC with same name, but newer version is introduced, the older one
291         /// will be removed
292         DriverVersion mDriverVersion;
293         /// GPU Vendor
294         GPUVendor mVendor;
295 
296         static String msGPUVendorStrings[GPU_VENDOR_COUNT];
297         static void initVendorStrings();
298 
299         /// The number of texture units available
300         ushort mNumTextureUnits;
301         /// The stencil buffer bit depth
302         ushort mStencilBufferBitDepth;
303         /// The number of matrices available for hardware blending
304         ushort mNumVertexBlendMatrices;
305         /// Stores the capabilities flags.
306         int mCapabilities[CAPS_CATEGORY_COUNT];
307         /// Which categories are relevant
308         bool mCategoryRelevant[CAPS_CATEGORY_COUNT];
309         /// The name of the device as reported by the render system
310         String mDeviceName;
311         /// The identifier associated with the render system for which these capabilities are valid
312         String mRenderSystemName;
313 
314         /// The number of floating-point constants vertex programs support
315         ushort mVertexProgramConstantFloatCount;
316         /// The number of integer constants vertex programs support
317         ushort mVertexProgramConstantIntCount;
318         /// The number of boolean constants vertex programs support
319         ushort mVertexProgramConstantBoolCount;
320         /// The number of floating-point constants geometry programs support
321         ushort mGeometryProgramConstantFloatCount;
322         /// The number of integer constants vertex geometry support
323         ushort mGeometryProgramConstantIntCount;
324         /// The number of boolean constants vertex geometry support
325         ushort mGeometryProgramConstantBoolCount;
326         /// The number of floating-point constants fragment programs support
327         ushort mFragmentProgramConstantFloatCount;
328         /// The number of integer constants fragment programs support
329         ushort mFragmentProgramConstantIntCount;
330         /// The number of boolean constants fragment programs support
331         ushort mFragmentProgramConstantBoolCount;
332         /// The number of simultaneous render targets supported
333         ushort mNumMultiRenderTargets;
334         /// The maximum point size
335         Real mMaxPointSize;
336         /// Are non-POW2 textures feature-limited?
337         bool mNonPOW2TexturesLimited;
338         /// The maximum supported anisotropy
339         Real mMaxSupportedAnisotropy;
340         /// The number of vertex texture units supported
341         ushort mNumVertexTextureUnits;
342         /// Are vertex texture units shared with fragment processor?
343         bool mVertexTextureUnitsShared;
344         /// The number of vertices a geometry program can emit in a single run
345         int mGeometryProgramNumOutputVertices;
346 
347 
348         /// The list of supported shader profiles
349         ShaderProfiles mSupportedShaderProfiles;
350 
351         // Support for new shader stages in shader model 5.0
352         /// The number of floating-point constants tessellation Hull programs support
353         ushort mTessellationHullProgramConstantFloatCount;
354         /// The number of integer constants tessellation Hull programs support
355         ushort mTessellationHullProgramConstantIntCount;
356         /// The number of boolean constants tessellation Hull programs support
357         ushort mTessellationHullProgramConstantBoolCount;
358         /// The number of floating-point constants tessellation Domain programs support
359         ushort mTessellationDomainProgramConstantFloatCount;
360         /// The number of integer constants tessellation Domain programs support
361         ushort mTessellationDomainProgramConstantIntCount;
362         /// The number of boolean constants tessellation Domain programs support
363         ushort mTessellationDomainProgramConstantBoolCount;
364         /// The number of floating-point constants compute programs support
365         ushort mComputeProgramConstantFloatCount;
366         /// The number of integer constants compute programs support
367         ushort mComputeProgramConstantIntCount;
368         /// The number of boolean constants compute programs support
369         ushort mComputeProgramConstantBoolCount;
370 
371         /// The number of vertex attributes available
372         ushort mNumVertexAttributes;
373     public:
374         RenderSystemCapabilities ();
375 
376         /** Set the driver version. */
setDriverVersion(const DriverVersion & version)377         void setDriverVersion(const DriverVersion& version)
378         {
379             mDriverVersion = version;
380         }
381 
parseDriverVersionFromString(const String & versionString)382         void parseDriverVersionFromString(const String& versionString)
383         {
384             DriverVersion version;
385             version.fromString(versionString);
386             setDriverVersion(version);
387         }
388 
389 
getDriverVersion()390         DriverVersion getDriverVersion() const
391         {
392             return mDriverVersion;
393         }
394 
getVendor()395         GPUVendor getVendor() const
396         {
397             return mVendor;
398         }
399 
setVendor(GPUVendor v)400         void setVendor(GPUVendor v)
401         {
402             mVendor = v;
403         }
404 
405         /// Parse and set vendor
parseVendorFromString(const String & vendorString)406         void parseVendorFromString(const String& vendorString)
407         {
408             setVendor(vendorFromString(vendorString));
409         }
410 
411         /// Convert a vendor string to an enum
412         static GPUVendor vendorFromString(const String& vendorString);
413         /// Convert a vendor enum to a string
414         static const String& vendorToString(GPUVendor v);
415 
isDriverOlderThanVersion(const DriverVersion & v)416         bool isDriverOlderThanVersion(const DriverVersion &v) const
417         {
418             if (mDriverVersion.major < v.major)
419                 return true;
420             else if (mDriverVersion.major == v.major &&
421                 mDriverVersion.minor < v.minor)
422                 return true;
423             else if (mDriverVersion.major == v.major &&
424                 mDriverVersion.minor == v.minor &&
425                 mDriverVersion.release < v.release)
426                 return true;
427             else if (mDriverVersion.major == v.major &&
428                 mDriverVersion.minor == v.minor &&
429                 mDriverVersion.release == v.release &&
430                 mDriverVersion.build < v.build)
431                 return true;
432             return false;
433         }
434 
setNumTextureUnits(ushort num)435         void setNumTextureUnits(ushort num)
436         {
437             mNumTextureUnits = num;
438         }
439 
setStencilBufferBitDepth(ushort num)440         void setStencilBufferBitDepth(ushort num)
441         {
442             mStencilBufferBitDepth = num;
443         }
444 
setNumVertexBlendMatrices(ushort num)445         void setNumVertexBlendMatrices(ushort num)
446         {
447             mNumVertexBlendMatrices = num;
448         }
449 
450         /// The number of simultaneous render targets supported
setNumMultiRenderTargets(ushort num)451         void setNumMultiRenderTargets(ushort num)
452         {
453             mNumMultiRenderTargets = num;
454         }
455 
setNumVertexAttributes(ushort num)456         void setNumVertexAttributes(ushort num)
457         {
458             mNumVertexAttributes = num;
459         }
460 
getNumVertexAttributes(void)461         ushort getNumVertexAttributes(void) const
462         {
463             return mNumVertexAttributes;
464         }
465 
466         /** Returns the number of texture units the current output hardware
467         supports.
468 
469         For use in rendering, this determines how many texture units the
470         are available for multitexturing (i.e. rendering multiple
471         textures in a single pass). Where a Material has multiple
472         texture layers, it will try to use multitexturing where
473         available, and where it is not available, will perform multipass
474         rendering to achieve the same effect. This property only applies
475         to the fixed-function pipeline, the number available to the
476         programmable pipeline depends on the shader model in use.
477         */
getNumTextureUnits(void)478         ushort getNumTextureUnits(void) const
479         {
480             return mNumTextureUnits;
481         }
482 
483         /** Determines the bit depth of the hardware accelerated stencil
484         buffer, if supported.
485         @remarks
486         If hardware stencilling is not supported, the software will
487         provide an 8-bit software stencil.
488         */
getStencilBufferBitDepth(void)489         ushort getStencilBufferBitDepth(void) const
490         {
491             return mStencilBufferBitDepth;
492         }
493 
494         /** Returns the number of matrices available to hardware vertex
495         blending for this rendering system. */
getNumVertexBlendMatrices(void)496         ushort getNumVertexBlendMatrices(void) const
497         {
498             return mNumVertexBlendMatrices;
499         }
500 
501         /// The number of simultaneous render targets supported
getNumMultiRenderTargets(void)502         ushort getNumMultiRenderTargets(void) const
503         {
504             return mNumMultiRenderTargets;
505         }
506 
507         /** Returns true if capability is render system specific
508         */
isCapabilityRenderSystemSpecific(const Capabilities c)509         bool isCapabilityRenderSystemSpecific(const Capabilities c) const
510         {
511             int cat = c >> OGRE_CAPS_BITSHIFT;
512             if(cat == CAPS_CATEGORY_GL || cat == CAPS_CATEGORY_D3D9)
513                 return true;
514             return false;
515         }
516 
517         /** Adds a capability flag
518         */
setCapability(const Capabilities c)519         void setCapability(const Capabilities c)
520         {
521             int index = (CAPS_CATEGORY_MASK & c) >> OGRE_CAPS_BITSHIFT;
522             // zero out the index from the stored capability
523             mCapabilities[index] |= (c & ~CAPS_CATEGORY_MASK);
524         }
525 
526         /** Remove a capability flag
527         */
unsetCapability(const Capabilities c)528         void unsetCapability(const Capabilities c)
529         {
530             int index = (CAPS_CATEGORY_MASK & c) >> OGRE_CAPS_BITSHIFT;
531             // zero out the index from the stored capability
532             mCapabilities[index] &= (~c | CAPS_CATEGORY_MASK);
533         }
534 
535         /** Checks for a capability
536         */
hasCapability(const Capabilities c)537         bool hasCapability(const Capabilities c) const
538         {
539             int index = (CAPS_CATEGORY_MASK & c) >> OGRE_CAPS_BITSHIFT;
540             // test against
541             if(mCapabilities[index] & (c & ~CAPS_CATEGORY_MASK))
542             {
543                 return true;
544             }
545             else
546             {
547                 return false;
548             }
549         }
550 
551         /** Adds the profile to the list of supported profiles
552         */
addShaderProfile(const String & profile)553         void addShaderProfile(const String& profile)
554         {
555             mSupportedShaderProfiles.insert(profile);
556 
557         }
558 
559         /** Remove a given shader profile, if present.
560         */
removeShaderProfile(const String & profile)561         void removeShaderProfile(const String& profile)
562         {
563             mSupportedShaderProfiles.erase(profile);
564         }
565 
566         /** Returns true if profile is in the list of supported profiles
567         */
isShaderProfileSupported(const String & profile)568         bool isShaderProfileSupported(const String& profile) const
569         {
570             return (mSupportedShaderProfiles.end() != mSupportedShaderProfiles.find(profile));
571         }
572 
573 
574         /** Returns a set of all supported shader profiles
575         * */
getSupportedShaderProfiles()576         const ShaderProfiles& getSupportedShaderProfiles() const
577         {
578             return mSupportedShaderProfiles;
579         }
580 
581 
582         /// The number of floating-point constants vertex programs support
getVertexProgramConstantFloatCount(void)583         ushort getVertexProgramConstantFloatCount(void) const
584         {
585             return mVertexProgramConstantFloatCount;
586         }
587         /// The number of integer constants vertex programs support
getVertexProgramConstantIntCount(void)588         ushort getVertexProgramConstantIntCount(void) const
589         {
590             return mVertexProgramConstantIntCount;
591         }
592         /// The number of boolean constants vertex programs support
getVertexProgramConstantBoolCount(void)593         ushort getVertexProgramConstantBoolCount(void) const
594         {
595             return mVertexProgramConstantBoolCount;
596         }
597         /// The number of floating-point constants geometry programs support
getGeometryProgramConstantFloatCount(void)598         ushort getGeometryProgramConstantFloatCount(void) const
599         {
600             return mGeometryProgramConstantFloatCount;
601         }
602         /// The number of integer constants geometry programs support
getGeometryProgramConstantIntCount(void)603         ushort getGeometryProgramConstantIntCount(void) const
604         {
605             return mGeometryProgramConstantIntCount;
606         }
607         /// The number of boolean constants geometry programs support
getGeometryProgramConstantBoolCount(void)608         ushort getGeometryProgramConstantBoolCount(void) const
609         {
610             return mGeometryProgramConstantBoolCount;
611         }
612         /// The number of floating-point constants fragment programs support
getFragmentProgramConstantFloatCount(void)613         ushort getFragmentProgramConstantFloatCount(void) const
614         {
615             return mFragmentProgramConstantFloatCount;
616         }
617         /// The number of integer constants fragment programs support
getFragmentProgramConstantIntCount(void)618         ushort getFragmentProgramConstantIntCount(void) const
619         {
620             return mFragmentProgramConstantIntCount;
621         }
622         /// The number of boolean constants fragment programs support
getFragmentProgramConstantBoolCount(void)623         ushort getFragmentProgramConstantBoolCount(void) const
624         {
625             return mFragmentProgramConstantBoolCount;
626         }
627 
628         /// sets the device name for Render system
setDeviceName(const String & name)629         void setDeviceName(const String& name)
630         {
631             mDeviceName = name;
632         }
633 
634         /// gets the device name for render system
getDeviceName()635         String getDeviceName() const
636         {
637             return mDeviceName;
638         }
639 
640         /// The number of floating-point constants vertex programs support
setVertexProgramConstantFloatCount(ushort c)641         void setVertexProgramConstantFloatCount(ushort c)
642         {
643             mVertexProgramConstantFloatCount = c;
644         }
645         /// The number of integer constants vertex programs support
setVertexProgramConstantIntCount(ushort c)646         void setVertexProgramConstantIntCount(ushort c)
647         {
648             mVertexProgramConstantIntCount = c;
649         }
650         /// The number of boolean constants vertex programs support
setVertexProgramConstantBoolCount(ushort c)651         void setVertexProgramConstantBoolCount(ushort c)
652         {
653             mVertexProgramConstantBoolCount = c;
654         }
655         /// The number of floating-point constants geometry programs support
setGeometryProgramConstantFloatCount(ushort c)656         void setGeometryProgramConstantFloatCount(ushort c)
657         {
658             mGeometryProgramConstantFloatCount = c;
659         }
660         /// The number of integer constants geometry programs support
setGeometryProgramConstantIntCount(ushort c)661         void setGeometryProgramConstantIntCount(ushort c)
662         {
663             mGeometryProgramConstantIntCount = c;
664         }
665         /// The number of boolean constants geometry programs support
setGeometryProgramConstantBoolCount(ushort c)666         void setGeometryProgramConstantBoolCount(ushort c)
667         {
668             mGeometryProgramConstantBoolCount = c;
669         }
670         /// The number of floating-point constants fragment programs support
setFragmentProgramConstantFloatCount(ushort c)671         void setFragmentProgramConstantFloatCount(ushort c)
672         {
673             mFragmentProgramConstantFloatCount = c;
674         }
675         /// The number of integer constants fragment programs support
setFragmentProgramConstantIntCount(ushort c)676         void setFragmentProgramConstantIntCount(ushort c)
677         {
678             mFragmentProgramConstantIntCount = c;
679         }
680         /// The number of boolean constants fragment programs support
setFragmentProgramConstantBoolCount(ushort c)681         void setFragmentProgramConstantBoolCount(ushort c)
682         {
683             mFragmentProgramConstantBoolCount = c;
684         }
685         /// Maximum point screen size in pixels
setMaxPointSize(Real s)686         void setMaxPointSize(Real s)
687         {
688             mMaxPointSize = s;
689         }
690         /// Maximum point screen size in pixels
getMaxPointSize(void)691         Real getMaxPointSize(void) const
692         {
693             return mMaxPointSize;
694         }
695         /// Non-POW2 textures limited
setNonPOW2TexturesLimited(bool l)696         void setNonPOW2TexturesLimited(bool l)
697         {
698             mNonPOW2TexturesLimited = l;
699         }
700         /** Are non-power of two textures limited in features?
701         @remarks
702         If the RSC_NON_POWER_OF_2_TEXTURES capability is set, but this
703         method returns true, you can use non power of 2 textures only if:
704         <ul><li>You load them explicitly with no mip maps</li>
705         <li>You don't use DXT texture compression</li>
706         <li>You use clamp texture addressing</li></ul>
707         */
getNonPOW2TexturesLimited(void)708         bool getNonPOW2TexturesLimited(void) const
709         {
710             return mNonPOW2TexturesLimited;
711         }
712         /// Set the maximum supported anisotropic filtering
setMaxSupportedAnisotropy(Real s)713         void setMaxSupportedAnisotropy(Real s)
714         {
715             mMaxSupportedAnisotropy = s;
716         }
717         /// Get the maximum supported anisotropic filtering
getMaxSupportedAnisotropy()718         Real getMaxSupportedAnisotropy() const
719         {
720             return mMaxSupportedAnisotropy;
721         }
722 
723         /// Set the number of vertex texture units supported
setNumVertexTextureUnits(ushort n)724         void setNumVertexTextureUnits(ushort n)
725         {
726             mNumVertexTextureUnits = n;
727         }
728         /// Get the number of vertex texture units supported
getNumVertexTextureUnits(void)729         ushort getNumVertexTextureUnits(void) const
730         {
731             return mNumVertexTextureUnits;
732         }
733         /// Set whether the vertex texture units are shared with the fragment processor
setVertexTextureUnitsShared(bool shared)734         void setVertexTextureUnitsShared(bool shared)
735         {
736             mVertexTextureUnitsShared = shared;
737         }
738         /// Get whether the vertex texture units are shared with the fragment processor
739         /// @deprecated only needed for D3D9
getVertexTextureUnitsShared(void)740         bool getVertexTextureUnitsShared(void) const
741         {
742             return mVertexTextureUnitsShared;
743         }
744 
745         /// Set the number of vertices a single geometry program run can emit
setGeometryProgramNumOutputVertices(int numOutputVertices)746         void setGeometryProgramNumOutputVertices(int numOutputVertices)
747         {
748             mGeometryProgramNumOutputVertices = numOutputVertices;
749         }
750         /// Get the number of vertices a single geometry program run can emit
getGeometryProgramNumOutputVertices(void)751         int getGeometryProgramNumOutputVertices(void) const
752         {
753             return mGeometryProgramNumOutputVertices;
754         }
755 
756         /// Get the identifier of the rendersystem from which these capabilities were generated
getRenderSystemName(void)757         const String& getRenderSystemName(void) const
758         {
759             return mRenderSystemName;
760         }
761         ///  Set the identifier of the rendersystem from which these capabilities were generated
setRenderSystemName(const String & rs)762         void setRenderSystemName(const String& rs)
763         {
764             mRenderSystemName = rs;
765         }
766 
767         /// Mark a category as 'relevant' or not, ie will it be reported
setCategoryRelevant(CapabilitiesCategory cat,bool relevant)768         void setCategoryRelevant(CapabilitiesCategory cat, bool relevant)
769         {
770             mCategoryRelevant[cat] = relevant;
771         }
772 
773         /// Return whether a category is 'relevant' or not, ie will it be reported
isCategoryRelevant(CapabilitiesCategory cat)774         bool isCategoryRelevant(CapabilitiesCategory cat)
775         {
776             return mCategoryRelevant[cat];
777         }
778 
779 
780 
781         /** Write the capabilities to the pass in Log */
782         void log(Log* pLog) const;
783 
784         // Support for new shader stages in shader model 5.0
785         /// The number of floating-point constants tessellation Hull programs support
setTessellationHullProgramConstantFloatCount(ushort c)786         void setTessellationHullProgramConstantFloatCount(ushort c)
787         {
788             mTessellationHullProgramConstantFloatCount = c;
789         }
790         /// The number of integer constants tessellation Domain programs support
setTessellationHullProgramConstantIntCount(ushort c)791         void setTessellationHullProgramConstantIntCount(ushort c)
792         {
793             mTessellationHullProgramConstantIntCount = c;
794         }
795         /// The number of boolean constants tessellation Domain programs support
setTessellationHullProgramConstantBoolCount(ushort c)796         void setTessellationHullProgramConstantBoolCount(ushort c)
797         {
798             mTessellationHullProgramConstantBoolCount = c;
799         }
800         /// The number of floating-point constants fragment programs support
getTessellationHullProgramConstantFloatCount(void)801         ushort getTessellationHullProgramConstantFloatCount(void) const
802         {
803             return mTessellationHullProgramConstantFloatCount;
804         }
805         /// The number of integer constants fragment programs support
getTessellationHullProgramConstantIntCount(void)806         ushort getTessellationHullProgramConstantIntCount(void) const
807         {
808             return mTessellationHullProgramConstantIntCount;
809         }
810         /// The number of boolean constants fragment programs support
getTessellationHullProgramConstantBoolCount(void)811         ushort getTessellationHullProgramConstantBoolCount(void) const
812         {
813             return mTessellationHullProgramConstantBoolCount;
814         }
815 
816         /// The number of floating-point constants tessellation Domain programs support
setTessellationDomainProgramConstantFloatCount(ushort c)817         void setTessellationDomainProgramConstantFloatCount(ushort c)
818         {
819             mTessellationDomainProgramConstantFloatCount = c;
820         }
821         /// The number of integer constants tessellation Domain programs support
setTessellationDomainProgramConstantIntCount(ushort c)822         void setTessellationDomainProgramConstantIntCount(ushort c)
823         {
824             mTessellationDomainProgramConstantIntCount = c;
825         }
826         /// The number of boolean constants tessellation Domain programs support
setTessellationDomainProgramConstantBoolCount(ushort c)827         void setTessellationDomainProgramConstantBoolCount(ushort c)
828         {
829             mTessellationDomainProgramConstantBoolCount = c;
830         }
831         /// The number of floating-point constants fragment programs support
getTessellationDomainProgramConstantFloatCount(void)832         ushort getTessellationDomainProgramConstantFloatCount(void) const
833         {
834             return mTessellationDomainProgramConstantFloatCount;
835         }
836         /// The number of integer constants fragment programs support
getTessellationDomainProgramConstantIntCount(void)837         ushort getTessellationDomainProgramConstantIntCount(void) const
838         {
839             return mTessellationDomainProgramConstantIntCount;
840         }
841         /// The number of boolean constants fragment programs support
getTessellationDomainProgramConstantBoolCount(void)842         ushort getTessellationDomainProgramConstantBoolCount(void) const
843         {
844             return mTessellationDomainProgramConstantBoolCount;
845         }
846 
847         /// The number of floating-point constants compute programs support
setComputeProgramConstantFloatCount(ushort c)848         void setComputeProgramConstantFloatCount(ushort c)
849         {
850             mComputeProgramConstantFloatCount = c;
851         }
852         /// The number of integer constants compute programs support
setComputeProgramConstantIntCount(ushort c)853         void setComputeProgramConstantIntCount(ushort c)
854         {
855             mComputeProgramConstantIntCount = c;
856         }
857         /// The number of boolean constants compute programs support
setComputeProgramConstantBoolCount(ushort c)858         void setComputeProgramConstantBoolCount(ushort c)
859         {
860             mComputeProgramConstantBoolCount = c;
861         }
862         /// The number of floating-point constants fragment programs support
getComputeProgramConstantFloatCount(void)863         ushort getComputeProgramConstantFloatCount(void) const
864         {
865             return mComputeProgramConstantFloatCount;
866         }
867         /// The number of integer constants fragment programs support
getComputeProgramConstantIntCount(void)868         ushort getComputeProgramConstantIntCount(void) const
869         {
870             return mComputeProgramConstantIntCount;
871         }
872         /// The number of boolean constants fragment programs support
getComputeProgramConstantBoolCount(void)873         ushort getComputeProgramConstantBoolCount(void) const
874         {
875             return mComputeProgramConstantBoolCount;
876         }
877 
878     };
879 
880     /** @} */
881     /** @} */
882 } // namespace
883 
884 
885 #include "OgreHeaderSuffix.h"
886 
887 #endif // __RenderSystemCapabilities__
888 
889