| 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-2006 Torus Knot Software Ltd |
|---|
| 8 | Also see acknowledgements in Readme.html |
|---|
| 9 | |
|---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
|---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
|---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 13 | version. |
|---|
| 14 | |
|---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
|---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
|---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
|---|
| 23 | |
|---|
| 24 | You may alternatively use this source under the terms of a specific version of |
|---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
|---|
| 26 | Torus Knot Software Ltd. |
|---|
| 27 | ----------------------------------------------------------------------------- |
|---|
| 28 | */ |
|---|
| 29 | #ifndef __RenderSystemCapabilities__ |
|---|
| 30 | #define __RenderSystemCapabilities__ 1 |
|---|
| 31 | |
|---|
| 32 | // Precompiler options |
|---|
| 33 | #include "OgrePrerequisites.h" |
|---|
| 34 | #include "OgreString.h" |
|---|
| 35 | |
|---|
| 36 | namespace Ogre { |
|---|
| 37 | |
|---|
| 38 | /// Enum describing the different hardware capabilities we want to check for |
|---|
| 39 | enum Capabilities |
|---|
| 40 | { |
|---|
| 41 | //RSC_MULTITEXTURE = 0x00000001, |
|---|
| 42 | /// Supporta generating mipmaps in hardware |
|---|
| 43 | RSC_AUTOMIPMAP = 0x00000002, |
|---|
| 44 | RSC_BLENDING = 0x00000004, |
|---|
| 45 | /// Supports anisotropic texture filtering |
|---|
| 46 | RSC_ANISOTROPY = 0x00000008, |
|---|
| 47 | /// Supports fixed-function DOT3 texture blend |
|---|
| 48 | RSC_DOT3 = 0x00000010, |
|---|
| 49 | /// Supports cube mapping |
|---|
| 50 | RSC_CUBEMAPPING = 0x00000020, |
|---|
| 51 | /// Supports hardware stencil buffer |
|---|
| 52 | RSC_HWSTENCIL = 0x00000040, |
|---|
| 53 | /// Supports hardware vertex and index buffers |
|---|
| 54 | RSC_VBO = 0x00000080, |
|---|
| 55 | /// Supports vertex programs (vertex shaders) |
|---|
| 56 | RSC_VERTEX_PROGRAM = 0x00000200, |
|---|
| 57 | /// Supports fragment programs (pixel shaders) |
|---|
| 58 | RSC_FRAGMENT_PROGRAM = 0x00000400, |
|---|
| 59 | /// Supports compressed textures |
|---|
| 60 | RSC_TEXTURE_COMPRESSION = 0x00000800, |
|---|
| 61 | /// Supports compressed textures in the DXT/ST3C formats |
|---|
| 62 | RSC_TEXTURE_COMPRESSION_DXT = 0x00001000, |
|---|
| 63 | /// Supports compressed textures in the VTC format |
|---|
| 64 | RSC_TEXTURE_COMPRESSION_VTC = 0x00002000, |
|---|
| 65 | /// Supports performing a scissor test to exclude areas of the screen |
|---|
| 66 | RSC_SCISSOR_TEST = 0x00004000, |
|---|
| 67 | /// Supports separate stencil updates for both front and back faces |
|---|
| 68 | RSC_TWO_SIDED_STENCIL = 0x00008000, |
|---|
| 69 | /// Supports wrapping the stencil value at the range extremeties |
|---|
| 70 | RSC_STENCIL_WRAP = 0x00010000, |
|---|
| 71 | /// Supports hardware occlusion queries |
|---|
| 72 | RSC_HWOCCLUSION = 0x00020000, |
|---|
| 73 | /// Supports user clipping planes |
|---|
| 74 | RSC_USER_CLIP_PLANES = 0x00040000, |
|---|
| 75 | /// Supports the VET_UBYTE4 vertex element type |
|---|
| 76 | RSC_VERTEX_FORMAT_UBYTE4 = 0x00080000, |
|---|
| 77 | /// Supports infinite far plane projection |
|---|
| 78 | RSC_INFINITE_FAR_PLANE = 0x00100000, |
|---|
| 79 | /// Supports hardware render-to-texture (bigger than framebuffer) |
|---|
| 80 | RSC_HWRENDER_TO_TEXTURE = 0x00200000, |
|---|
| 81 | /// Supports float textures and render targets |
|---|
| 82 | RSC_TEXTURE_FLOAT = 0x00400000, |
|---|
| 83 | /// Supports non-power of two textures |
|---|
| 84 | RSC_NON_POWER_OF_2_TEXTURES = 0x00800000, |
|---|
| 85 | /// Supports 3d (volume) textures |
|---|
| 86 | RSC_TEXTURE_3D = 0x01000000, |
|---|
| 87 | /// Supports basic point sprite rendering |
|---|
| 88 | RSC_POINT_SPRITES = 0x02000000, |
|---|
| 89 | /// Supports extra point parameters (minsize, maxsize, attenuation) |
|---|
| 90 | RSC_POINT_EXTENDED_PARAMETERS = 0x04000000, |
|---|
| 91 | /// Supports vertex texture fetch |
|---|
| 92 | RSC_VERTEX_TEXTURE_FETCH = 0x08000000, |
|---|
| 93 | /// Supports mipmap LOD biasing |
|---|
| 94 | RSC_MIPMAP_LOD_BIAS = 0x10000000 |
|---|
| 95 | |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | /** singleton class for storing the capabilities of the graphics card. |
|---|
| 99 | @remarks |
|---|
| 100 | This class stores the capabilities of the graphics card. This |
|---|
| 101 | information is set by the individual render systems. |
|---|
| 102 | */ |
|---|
| 103 | class _OgreExport RenderSystemCapabilities |
|---|
| 104 | { |
|---|
| 105 | private: |
|---|
| 106 | /// The number of world matricies available |
|---|
| 107 | ushort mNumWorldMatrices; |
|---|
| 108 | /// The number of texture units available |
|---|
| 109 | ushort mNumTextureUnits; |
|---|
| 110 | /// The stencil buffer bit depth |
|---|
| 111 | ushort mStencilBufferBitDepth; |
|---|
| 112 | /// The number of matrices available for hardware blending |
|---|
| 113 | ushort mNumVertexBlendMatrices; |
|---|
| 114 | /// Stores the capabilities flags. |
|---|
| 115 | int mCapabilities; |
|---|
| 116 | /// The best vertex program that this card / rendersystem supports |
|---|
| 117 | String mMaxVertexProgramVersion; |
|---|
| 118 | /// The best fragment program that this card / rendersystem supports |
|---|
| 119 | String mMaxFragmentProgramVersion; |
|---|
| 120 | /// The number of floating-point constants vertex programs support |
|---|
| 121 | ushort mVertexProgramConstantFloatCount; |
|---|
| 122 | /// The number of integer constants vertex programs support |
|---|
| 123 | ushort mVertexProgramConstantIntCount; |
|---|
| 124 | /// The number of boolean constants vertex programs support |
|---|
| 125 | ushort mVertexProgramConstantBoolCount; |
|---|
| 126 | /// The number of floating-point constants fragment programs support |
|---|
| 127 | ushort mFragmentProgramConstantFloatCount; |
|---|
| 128 | /// The number of integer constants fragment programs support |
|---|
| 129 | ushort mFragmentProgramConstantIntCount; |
|---|
| 130 | /// The number of boolean constants fragment programs support |
|---|
| 131 | ushort mFragmentProgramConstantBoolCount; |
|---|
| 132 | /// The number of simultaneous render targets supported |
|---|
| 133 | ushort mNumMultiRenderTargets; |
|---|
| 134 | /// The maximum point size |
|---|
| 135 | Real mMaxPointSize; |
|---|
| 136 | /// Are non-POW2 textures feature-limited? |
|---|
| 137 | bool mNonPOW2TexturesLimited; |
|---|
| 138 | /// The number of vertex texture units supported |
|---|
| 139 | ushort mNumVertexTextureUnits; |
|---|
| 140 | /// Are vertex texture units shared with fragment processor? |
|---|
| 141 | bool mVertexTextureUnitsShared; |
|---|
| 142 | |
|---|
| 143 | public: |
|---|
| 144 | RenderSystemCapabilities (); |
|---|
| 145 | ~RenderSystemCapabilities (); |
|---|
| 146 | |
|---|
| 147 | void setNumWorldMatricies(ushort num) |
|---|
| 148 | { |
|---|
| 149 | mNumWorldMatrices = num; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | void setNumTextureUnits(ushort num) |
|---|
| 153 | { |
|---|
| 154 | mNumTextureUnits = num; |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | void setStencilBufferBitDepth(ushort num) |
|---|
| 158 | { |
|---|
| 159 | mStencilBufferBitDepth = num; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | void setNumVertexBlendMatrices(ushort num) |
|---|
| 163 | { |
|---|
| 164 | mNumVertexBlendMatrices = num; |
|---|
| 165 | } |
|---|
| 166 | |
|---|
| 167 | /// The number of simultaneous render targets supported |
|---|
| 168 | void setNumMultiRenderTargets(ushort num) |
|---|
| 169 | { |
|---|
| 170 | mNumMultiRenderTargets = num; |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | ushort getNumWorldMatricies(void) const |
|---|
| 174 | { |
|---|
| 175 | return mNumWorldMatrices; |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | /** Returns the number of texture units the current output hardware |
|---|
| 179 | supports. |
|---|
| 180 | |
|---|
| 181 | For use in rendering, this determines how many texture units the |
|---|
| 182 | are available for multitexturing (i.e. rendering multiple |
|---|
| 183 | textures in a single pass). Where a Material has multiple |
|---|
| 184 | texture layers, it will try to use multitexturing where |
|---|
| 185 | available, and where it is not available, will perform multipass |
|---|
| 186 | rendering to achieve the same effect. This property only applies |
|---|
| 187 | to the fixed-function pipeline, the number available to the |
|---|
| 188 | programmable pipeline depends on the shader model in use. |
|---|
| 189 | */ |
|---|
| 190 | ushort getNumTextureUnits(void) const |
|---|
| 191 | { |
|---|
| 192 | return mNumTextureUnits; |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | /** Determines the bit depth of the hardware accelerated stencil |
|---|
| 196 | buffer, if supported. |
|---|
| 197 | @remarks |
|---|
| 198 | If hardware stencilling is not supported, the software will |
|---|
| 199 | provide an 8-bit software stencil. |
|---|
| 200 | */ |
|---|
| 201 | ushort getStencilBufferBitDepth(void) const |
|---|
| 202 | { |
|---|
| 203 | return mStencilBufferBitDepth; |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | /** Returns the number of matrices available to hardware vertex |
|---|
| 207 | blending for this rendering system. */ |
|---|
| 208 | ushort numVertexBlendMatrices(void) const |
|---|
| 209 | { |
|---|
| 210 | return mNumVertexBlendMatrices; |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | /// The number of simultaneous render targets supported |
|---|
| 214 | ushort numMultiRenderTargets(void) const |
|---|
| 215 | { |
|---|
| 216 | return mNumMultiRenderTargets; |
|---|
| 217 | } |
|---|
| 218 | |
|---|
| 219 | /** Adds a capability flag to mCapabilities |
|---|
| 220 | */ |
|---|
| 221 | void setCapability(const Capabilities c) |
|---|
| 222 | { |
|---|
| 223 | mCapabilities |= c; |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | /** Checks for a capability |
|---|
| 227 | */ |
|---|
| 228 | bool hasCapability(const Capabilities c) const |
|---|
| 229 | { |
|---|
| 230 | if(mCapabilities & c) |
|---|
| 231 | { |
|---|
| 232 | return true; |
|---|
| 233 | } |
|---|
| 234 | else |
|---|
| 235 | { |
|---|
| 236 | return false; |
|---|
| 237 | } |
|---|
| 238 | } |
|---|
| 239 | /// Gets the best low-level vertex program version supported |
|---|
| 240 | const String& getMaxVertexProgramVersion(void) const |
|---|
| 241 | { |
|---|
| 242 | return mMaxVertexProgramVersion; |
|---|
| 243 | } |
|---|
| 244 | /// Gets the best fragment program that this card / rendersystem supports |
|---|
| 245 | const String& getMaxFragmentProgramVersion(void) const |
|---|
| 246 | { |
|---|
| 247 | return mMaxFragmentProgramVersion; |
|---|
| 248 | } |
|---|
| 249 | /// The number of floating-point constants vertex programs support |
|---|
| 250 | ushort getVertexProgramConstantFloatCount(void) const |
|---|
| 251 | { |
|---|
| 252 | return mVertexProgramConstantFloatCount; |
|---|
| 253 | } |
|---|
| 254 | /// The number of integer constants vertex programs support |
|---|
| 255 | ushort getVertexProgramConstantIntCount(void) const |
|---|
| 256 | { |
|---|
| 257 | return mVertexProgramConstantIntCount; |
|---|
| 258 | } |
|---|
| 259 | /// The number of boolean constants vertex programs support |
|---|
| 260 | ushort getVertexProgramConstantBoolCount(void) const |
|---|
| 261 | { |
|---|
| 262 | return mVertexProgramConstantBoolCount; |
|---|
| 263 | } |
|---|
| 264 | /// The number of floating-point constants fragment programs support |
|---|
| 265 | ushort getFragmentProgramConstantFloatCount(void) const |
|---|
| 266 | { |
|---|
| 267 | return mFragmentProgramConstantFloatCount; |
|---|
| 268 | } |
|---|
| 269 | /// The number of integer constants fragment programs support |
|---|
| 270 | ushort getFragmentProgramConstantIntCount(void) const |
|---|
| 271 | { |
|---|
| 272 | return mFragmentProgramConstantIntCount; |
|---|
| 273 | } |
|---|
| 274 | /// The number of boolean constants fragment programs support |
|---|
| 275 | ushort getFragmentProgramConstantBoolCount(void) const |
|---|
| 276 | { |
|---|
| 277 | return mFragmentProgramConstantBoolCount; |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | /// sets the best low-level vertex program version supported |
|---|
| 283 | void setMaxVertexProgramVersion(const String& ver) |
|---|
| 284 | { |
|---|
| 285 | mMaxVertexProgramVersion = ver; |
|---|
| 286 | } |
|---|
| 287 | /// sets the best fragment program that this card / rendersystem supports |
|---|
| 288 | void setMaxFragmentProgramVersion(const String& ver) |
|---|
| 289 | { |
|---|
| 290 | mMaxFragmentProgramVersion = ver; |
|---|
| 291 | } |
|---|
| 292 | /// The number of floating-point constants vertex programs support |
|---|
| 293 | void setVertexProgramConstantFloatCount(ushort c) |
|---|
| 294 | { |
|---|
| 295 | mVertexProgramConstantFloatCount = c; |
|---|
| 296 | } |
|---|
| 297 | /// The number of integer constants vertex programs support |
|---|
| 298 | void setVertexProgramConstantIntCount(ushort c) |
|---|
| 299 | { |
|---|
| 300 | mVertexProgramConstantIntCount = c; |
|---|
| 301 | } |
|---|
| 302 | /// The number of boolean constants vertex programs support |
|---|
| 303 | void setVertexProgramConstantBoolCount(ushort c) |
|---|
| 304 | { |
|---|
| 305 | mVertexProgramConstantBoolCount = c; |
|---|
| 306 | } |
|---|
| 307 | /// The number of floating-point constants fragment programs support |
|---|
| 308 | void setFragmentProgramConstantFloatCount(ushort c) |
|---|
| 309 | { |
|---|
| 310 | mFragmentProgramConstantFloatCount = c; |
|---|
| 311 | } |
|---|
| 312 | /// The number of integer constants fragment programs support |
|---|
| 313 | void setFragmentProgramConstantIntCount(ushort c) |
|---|
| 314 | { |
|---|
| 315 | mFragmentProgramConstantIntCount = c; |
|---|
| 316 | } |
|---|
| 317 | /// The number of boolean constants fragment programs support |
|---|
| 318 | void setFragmentProgramConstantBoolCount(ushort c) |
|---|
| 319 | { |
|---|
| 320 | mFragmentProgramConstantBoolCount = c; |
|---|
| 321 | } |
|---|
| 322 | /// Maximum point screen size in pixels |
|---|
| 323 | void setMaxPointSize(Real s) |
|---|
| 324 | { |
|---|
| 325 | mMaxPointSize = s; |
|---|
| 326 | } |
|---|
| 327 | /// Maximum point screen size in pixels |
|---|
| 328 | Real getMaxPointSize(void) const |
|---|
| 329 | { |
|---|
| 330 | return mMaxPointSize; |
|---|
| 331 | } |
|---|
| 332 | /// Non-POW2 textures limited |
|---|
| 333 | void setNonPOW2TexturesLimited(bool l) |
|---|
| 334 | { |
|---|
| 335 | mNonPOW2TexturesLimited = l; |
|---|
| 336 | } |
|---|
| 337 | /** Are non-power of two textures limited in features? |
|---|
| 338 | @remarks |
|---|
| 339 | If the RSC_NON_POWER_OF_2_TEXTURES capability is set, but this |
|---|
| 340 | method returns true, you can use non power of 2 textures only if: |
|---|
| 341 | <ul><li>You load them explicitly with no mip maps</li> |
|---|
| 342 | <li>You don't use DXT texture compression</li> |
|---|
| 343 | <li>You use clamp texture addressing</li></ul> |
|---|
| 344 | */ |
|---|
| 345 | bool getNonPOW2TexturesLimited(void) const |
|---|
| 346 | { |
|---|
| 347 | return mNonPOW2TexturesLimited; |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | /// Set the number of vertex texture units supported |
|---|
| 351 | void setNumVertexTextureUnits(ushort n) |
|---|
| 352 | { |
|---|
| 353 | mNumVertexTextureUnits = n; |
|---|
| 354 | } |
|---|
| 355 | /// Get the number of vertex texture units supported |
|---|
| 356 | ushort getNumVertexTextureUnits(void) const |
|---|
| 357 | { |
|---|
| 358 | return mNumVertexTextureUnits; |
|---|
| 359 | } |
|---|
| 360 | /// Set whether the vertex texture units are shared with the fragment processor |
|---|
| 361 | void setVertexTextureUnitsShared(bool shared) |
|---|
| 362 | { |
|---|
| 363 | mVertexTextureUnitsShared = shared; |
|---|
| 364 | } |
|---|
| 365 | /// Get whether the vertex texture units are shared with the fragment processor |
|---|
| 366 | bool getVertexTextureUnitsShared(void) const |
|---|
| 367 | { |
|---|
| 368 | return mVertexTextureUnitsShared; |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | /** Write the capabilities to the pass in Log */ |
|---|
| 373 | void log(Log* pLog); |
|---|
| 374 | |
|---|
| 375 | |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | }; |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | #endif // __RenderSystemCapabilities__ |
|---|
| 382 | |
|---|