Commit d6eb580f authored by hybrid's avatar hybrid

Add a generic attribute interface for querying video driver attributes which...

Add a generic attribute interface for querying video driver attributes which are not necessarily of type bool. This interface allows to check certain supported features, such as the number of user clip planes, supported lights and textures, MRTs, and other things. The interface might change in the future, but it's fully functional already. The supported attributes are listed in the API docs of the function.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3408 dfc29bdd-3216-0410-991c-e03cc46cb475
parent c4d88dbd
...@@ -284,6 +284,24 @@ namespace video ...@@ -284,6 +284,24 @@ namespace video
\param flag When true the feature is disabled, otherwise it is enabled. */ \param flag When true the feature is disabled, otherwise it is enabled. */
virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0; virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
//! Get attributes of the actual video driver
/** The following names can be queried for the given types:
MaxTextures (int) The maximum number of simultaneous textures supported by the driver. This can be less than the supported number of textures of the driver. Use _IRR_MATERIAL_MAX_TEXTURES_ to adapt the number.
MaxSupportedTextures (int) The maximum number of simultaneous textures supported by the fixed function pipeline of the (hw) driver. The actual supported number of textures supported by the engine can be lower.
MaxLights (int) Number of hardware lights supported in the fixed function pipieline of the driver, typically 6-8. Use light manager or deferred shading for more.
MaxAnisotropy (int) Number of anisotropy levels supported for filtering. At least 1, max is typically at 16 or 32.
MaxUserClipPlanes (int) Number of additional clip planes, which can be set by the user via dedicated driver methods.
MaxAuxBuffers (int) Special render buffers, which are currently not really usable inside Irrlicht. Only supported by OpenGL
MaxMultipleRenderTargets (int) Number of render targets which can be bound simultaneously. Rendering to MRTs is done via shaders.
MaxIndices (int) Number of indices which can be used in one render call (i.e. one mesh buffer).
MaxTextureSize (int) Dimension that a texture may have, both in width and height.
MaxGeometryVerticesOut (int) Number of vertices the geometry shader can output in one pass. Only OpenGL so far.
MaxTextureLODBias (float) Maximum value for LOD bias. Is usually at around 16, but can be lower on some systems.
Version (int) Version of the driver. Should be Major*100+Minor
ShaderLanguageVersion (int) Version of the high level shader language. Should be Major*100+Minor.
*/
virtual const io::IAttributes& getDriverAttributes() const=0;
//! Check if the driver was recently reset. //! Check if the driver was recently reset.
/** For d3d devices you will need to recreate the RTTs if the /** For d3d devices you will need to recreate the RTTs if the
driver was reset. Should be queried right after beginScene(). driver was reset. Should be queried right after beginScene().
...@@ -1421,4 +1439,3 @@ namespace video ...@@ -1421,4 +1439,3 @@ namespace video
#endif #endif
...@@ -391,6 +391,16 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize, ...@@ -391,6 +391,16 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize,
MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES); MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES);
MaxUserClipPlanes = (u32)Caps.MaxUserClipPlanes; MaxUserClipPlanes = (u32)Caps.MaxUserClipPlanes;
DriverAttributes->addInt("MaxTextures", MaxTextureUnits);
DriverAttributes->addInt("MaxSupportedTextures", Caps.MaxSimultaneousTextures);
DriverAttributes->addInt("MaxAnisotropy", Caps.MaxAnisotropy);
DriverAttributes->addInt("MaxUserClipPlanes", Caps.MaxUserClipPlanes);
DriverAttributes->addInt("MaxIndices", Caps.MaxVertexIndex);
DriverAttributes->addInt("MaxTextureSize", core::min_(Caps.MaxTextureHeight,Caps.MaxTextureWidth));
DriverAttributes->addFloat("MaxTextureLODBias", 16.f);
DriverAttributes->addInt("Version", 901);
DriverAttributes->addInt("ShaderLanguageVersion", Caps.VertexShaderVersion*100);
// set the renderstates // set the renderstates
setRenderStates3DMode(); setRenderStates3DMode();
......
...@@ -443,6 +443,18 @@ bool CD3D9Driver::initDriver(const core::dimension2d<u32>& screenSize, ...@@ -443,6 +443,18 @@ bool CD3D9Driver::initDriver(const core::dimension2d<u32>& screenSize,
D3DFMT_X8R8G8B8, 0,D3DRTYPE_SURFACE, D3DFMT_X8R8G8B8, 0,D3DRTYPE_SURFACE,
(D3DFORMAT)MAKEFOURCC('A','2','M','1')) == S_OK); (D3DFORMAT)MAKEFOURCC('A','2','M','1')) == S_OK);
#endif #endif
DriverAttributes->addInt("MaxTextures", MaxTextureUnits);
DriverAttributes->addInt("MaxSupportedTextures", Caps.MaxSimultaneousTextures);
DriverAttributes->addInt("MaxAnisotropy", Caps.MaxAnisotropy);
DriverAttributes->addInt("MaxUserClipPlanes", Caps.MaxUserClipPlanes);
DriverAttributes->addInt("MaxMultipleRenderTargets", Caps.NumSimultaneousRTs);
DriverAttributes->addInt("MaxIndices", Caps.MaxVertexIndex);
DriverAttributes->addInt("MaxTextureSize", core::min_(Caps.MaxTextureHeight,Caps.MaxTextureWidth));
DriverAttributes->addFloat("MaxTextureLODBias", 16);
DriverAttributes->addInt("Version", 901);
DriverAttributes->addInt("ShaderLanguageVersion", Caps.VertexShaderVersion*100);
// set the renderstates // set the renderstates
setRenderStates3DMode(); setRenderStates3DMode();
......
...@@ -90,6 +90,21 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre ...@@ -90,6 +90,21 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
setDebugName("CNullDriver"); setDebugName("CNullDriver");
#endif #endif
DriverAttributes = new io::CAttributes(this);
DriverAttributes->addInt("MaxTextures", _IRR_MATERIAL_MAX_TEXTURES_);
DriverAttributes->addInt("MaxSupportedTextures", _IRR_MATERIAL_MAX_TEXTURES_);
DriverAttributes->addInt("MaxLights", getMaximalDynamicLightAmount());
DriverAttributes->addInt("MaxAnisotropy", 1);
// DriverAttributes->addInt("MaxUserClipPlanes", 0);
// DriverAttributes->addInt("MaxAuxBuffers", 0);
// DriverAttributes->addInt("MaxMultipleRenderTargets", 0);
DriverAttributes->addInt("MaxIndices", -1);
DriverAttributes->addInt("MaxTextureSize", -1);
// DriverAttributes->addInt("MaxGeometryVerticesOut", 0);
// DriverAttributes->addFloat("MaxTextureLODBias", 0.f);
DriverAttributes->addInt("Version", 1);
// DriverAttributes->addInt("ShaderLanguageVersion", 0);
setFog(); setFog();
setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true); setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true);
...@@ -207,6 +222,7 @@ CNullDriver::~CNullDriver() ...@@ -207,6 +222,7 @@ CNullDriver::~CNullDriver()
// delete hardware mesh buffers // delete hardware mesh buffers
removeAllHardwareBuffers(); removeAllHardwareBuffers();
DriverAttributes->drop();
} }
...@@ -313,6 +329,13 @@ bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const ...@@ -313,6 +329,13 @@ bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
} }
//! Get attributes of the actual video driver
const io::IAttributes& CNullDriver::getDriverAttributes() const
{
return *DriverAttributes;
}
//! sets transformation //! sets transformation
void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat)
{ {
......
...@@ -57,6 +57,9 @@ namespace video ...@@ -57,6 +57,9 @@ namespace video
//! queries the features of the driver, returns true if feature is available //! queries the features of the driver, returns true if feature is available
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const;
//! Get attributes of the actual video driver
const io::IAttributes& getDriverAttributes() const;
//! sets transformation //! sets transformation
virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
...@@ -816,6 +819,8 @@ namespace video ...@@ -816,6 +819,8 @@ namespace video
SColor FogColor; SColor FogColor;
SExposedVideoData ExposedData; SExposedVideoData ExposedData;
io::IAttributes* DriverAttributes;
SOverrideMaterial OverrideMaterial; SOverrideMaterial OverrideMaterial;
SMaterial OverrideMaterial2D; SMaterial OverrideMaterial2D;
SMaterial InitMaterial2D; SMaterial InitMaterial2D;
......
...@@ -649,6 +649,19 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<u32>& screenSize, ...@@ -649,6 +649,19 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<u32>& screenSize,
} }
else else
os::Printer::log("GLSL not available.", ELL_INFORMATION); os::Printer::log("GLSL not available.", ELL_INFORMATION);
DriverAttributes->addInt("MaxTextures", MaxTextureUnits);
DriverAttributes->addInt("MaxSupportedTextures", MaxSupportedTextures);
// DriverAttributes->addInt("MaxLights", MaxLights);
DriverAttributes->addInt("MaxAnisotropy", MaxAnisotropy);
DriverAttributes->addInt("MaxUserClipPlanes", MaxUserClipPlanes);
DriverAttributes->addInt("MaxAuxBuffers", MaxAuxBuffers);
DriverAttributes->addInt("MaxMultipleRenderTargets", MaxMultipleRenderTargets);
DriverAttributes->addInt("MaxIndices", MaxIndices);
DriverAttributes->addInt("MaxTextureSize", MaxTextureSize);
DriverAttributes->addInt("MaxGeometryVerticesOut", MaxGeometryVerticesOut);
DriverAttributes->addFloat("MaxTextureLODBias", MaxTextureLODBias);
DriverAttributes->addInt("Version", Version);
DriverAttributes->addInt("ShaderLanguageVersion", ShaderLanguageVersion);
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
......
...@@ -38,6 +38,11 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool ...@@ -38,6 +38,11 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool
ZBuffer = video::createZBuffer(BackBuffer->getDimension()); ZBuffer = video::createZBuffer(BackBuffer->getDimension());
} }
DriverAttributes->addInt("MaxTextures", 1);
DriverAttributes->addInt("MaxIndices", 1<<16);
DriverAttributes->addInt("MaxTextureSize", 1024);
DriverAttributes->addInt("Version", 1);
// create triangle renderers // create triangle renderers
TriangleRenderers[ETR_FLAT] = createTriangleRendererFlat(ZBuffer); TriangleRenderers[ETR_FLAT] = createTriangleRendererFlat(ZBuffer);
......
...@@ -206,7 +206,6 @@ vec3 fnormal(void) ...@@ -206,7 +206,6 @@ vec3 fnormal(void)
} }
struct program1 struct program1
{ {
vec4 Ambient; vec4 Ambient;
...@@ -358,6 +357,12 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters& ...@@ -358,6 +357,12 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters&
StencilBuffer = video::createStencilBuffer(BackBuffer->getDimension()); StencilBuffer = video::createStencilBuffer(BackBuffer->getDimension());
} }
DriverAttributes->addInt("MaxTextures", 2);
DriverAttributes->addInt("MaxIndices", 1<<16);
DriverAttributes->addInt("MaxTextureSize", 1024);
DriverAttributes->addFloat("MaxTextureLODBias", 16.f);
DriverAttributes->addInt("Version", 45);
// create triangle renderers // create triangle renderers
irr::memset32 ( BurningShader, 0, sizeof ( BurningShader ) ); irr::memset32 ( BurningShader, 0, sizeof ( BurningShader ) );
......
...@@ -732,6 +732,10 @@ ...@@ -732,6 +732,10 @@
<Filter <Filter
Name="video" Name="video"
> >
<File
RelativePath="..\..\include\EDriverFeatures.h"
>
</File>
<File <File
RelativePath="..\..\include\EDriverTypes.h" RelativePath="..\..\include\EDriverTypes.h"
> >
......
...@@ -98,6 +98,7 @@ int main(int argumentCount, char * arguments[]) ...@@ -98,6 +98,7 @@ int main(int argumentCount, char * arguments[])
TEST(meshTransform); TEST(meshTransform);
TEST(createImage); TEST(createImage);
// all driver checks // all driver checks
TEST(videoDriver);
TEST(drawPixel); TEST(drawPixel);
TEST(guiDisabledMenu); TEST(guiDisabledMenu);
TEST(makeColorKeyTexture); TEST(makeColorKeyTexture);
...@@ -113,8 +114,8 @@ int main(int argumentCount, char * arguments[]) ...@@ -113,8 +114,8 @@ int main(int argumentCount, char * arguments[])
// TEST(projectionMatrix); // TEST(projectionMatrix);
// large scenes/long rendering // large scenes/long rendering
// shadows are slow // shadows are slow
TEST(orthoCam); // TEST(orthoCam);
TEST(stencilShadow); // TEST(stencilShadow);
// q3 maps are slow // q3 maps are slow
TEST(planeMatrix); TEST(planeMatrix);
TEST(terrainSceneNode); TEST(terrainSceneNode);
......
Tests finished. 55 tests of 55 passed. Tests finished. 56 tests of 56 passed.
Compiled as DEBUG Compiled as DEBUG
Test suite pass at GMT Sun Jul 18 15:41:35 2010 Test suite pass at GMT Sun Sep 12 09:38:37 2010
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
<Unit filename="textureRenderStates.cpp" /> <Unit filename="textureRenderStates.cpp" />
<Unit filename="transparentMaterials.cpp" /> <Unit filename="transparentMaterials.cpp" />
<Unit filename="vectorPositionDimension2d.cpp" /> <Unit filename="vectorPositionDimension2d.cpp" />
<Unit filename="videoDriver.cpp" />
<Unit filename="writeImageToFile.cpp" /> <Unit filename="writeImageToFile.cpp" />
<Unit filename="zipReader.cpp" /> <Unit filename="zipReader.cpp" />
<Extensions> <Extensions>
......
...@@ -139,6 +139,7 @@ ...@@ -139,6 +139,7 @@
<ClCompile Include="timer.cpp" /> <ClCompile Include="timer.cpp" />
<ClCompile Include="transparentAlphaChannelRef.cpp" /> <ClCompile Include="transparentAlphaChannelRef.cpp" />
<ClCompile Include="vectorPositionDimension2d.cpp" /> <ClCompile Include="vectorPositionDimension2d.cpp" />
<ClCompile Include="videoDriver.cpp" />
<ClCompile Include="writeImageToFile.cpp" /> <ClCompile Include="writeImageToFile.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
...@@ -153,4 +154,4 @@ ...@@ -153,4 +154,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -324,6 +324,10 @@ ...@@ -324,6 +324,10 @@
RelativePath=".\vectorPositionDimension2d.cpp" RelativePath=".\vectorPositionDimension2d.cpp"
> >
</File> </File>
<File
RelativePath=".\videoDriver.cpp"
>
</File>
<File <File
RelativePath=".\writeImageToFile.cpp" RelativePath=".\writeImageToFile.cpp"
> >
......
...@@ -403,6 +403,10 @@ ...@@ -403,6 +403,10 @@
RelativePath=".\vectorPositionDimension2d.cpp" RelativePath=".\vectorPositionDimension2d.cpp"
> >
</File> </File>
<File
RelativePath=".\videoDriver.cpp"
>
</File>
<File <File
RelativePath=".\writeImageToFile.cpp" RelativePath=".\writeImageToFile.cpp"
> >
......
// Copyright (C) 2008-2009 Colin MacDonald, Christian Stehno
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
using namespace irr;
using namespace core;
/** Test various things in video drivers. */
bool testVideoDriver(video::E_DRIVER_TYPE driverType)
{
IrrlichtDevice *device =
createDevice(driverType, dimension2d<u32>(160, 120));
if (!device)
return true;
video::IVideoDriver* driver = device->getVideoDriver();
logTestString("MaxTextures: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxTextures"));
logTestString("MaxLights: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxLights"));
logTestString("MaxAnisotropy: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxAnisotropy"));
logTestString("MaxUserClipPlanes: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxUserClipPlanes"));
logTestString("MaxAuxBuffers: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxAuxBuffers"));
logTestString("MaxMultipleRenderTargets: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxMultipleRenderTargets"));
logTestString("MaxIndices: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxIndices"));
logTestString("MaxTextureSize: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxTextureSize"));
logTestString("MaxGeometryVerticesOut: %d\n", driver->getDriverAttributes().getAttributeAsInt("MaxGeometryVerticesOut"));
logTestString("Version: %d\n", driver->getDriverAttributes().getAttributeAsInt("Version"));
logTestString("ShaderLanguageVersion: %d\n", driver->getDriverAttributes().getAttributeAsInt("ShaderLanguageVersion"));
device->drop();
return true;
}
bool videoDriver()
{
bool result = testVideoDriver(video::EDT_OPENGL);
result &= testVideoDriver(video::EDT_DIRECT3D9);
result &= testVideoDriver(video::EDT_DIRECT3D8);
result &= testVideoDriver(video::EDT_BURNINGSVIDEO);
result &= testVideoDriver(video::EDT_SOFTWARE);
result &= testVideoDriver(video::EDT_NULL);
return result;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment