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
\param flag When true the feature is disabled, otherwise it is enabled. */
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.
/** For d3d devices you will need to recreate the RTTs if the
driver was reset. Should be queried right after beginScene().
......@@ -1421,4 +1439,3 @@ namespace video
#endif
......@@ -391,6 +391,16 @@ bool CD3D8Driver::initDriver(const core::dimension2d<u32>& screenSize,
MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES);
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
setRenderStates3DMode();
......
......@@ -443,6 +443,18 @@ bool CD3D9Driver::initDriver(const core::dimension2d<u32>& screenSize,
D3DFMT_X8R8G8B8, 0,D3DRTYPE_SURFACE,
(D3DFORMAT)MAKEFOURCC('A','2','M','1')) == S_OK);
#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
setRenderStates3DMode();
......
......@@ -90,6 +90,21 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
setDebugName("CNullDriver");
#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();
setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true);
......@@ -207,6 +222,7 @@ CNullDriver::~CNullDriver()
// delete hardware mesh buffers
removeAllHardwareBuffers();
DriverAttributes->drop();
}
......@@ -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
void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat)
{
......
......@@ -57,6 +57,9 @@ namespace video
//! queries the features of the driver, returns true if feature is available
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const;
//! Get attributes of the actual video driver
const io::IAttributes& getDriverAttributes() const;
//! sets transformation
virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
......@@ -816,6 +819,8 @@ namespace video
SColor FogColor;
SExposedVideoData ExposedData;
io::IAttributes* DriverAttributes;
SOverrideMaterial OverrideMaterial;
SMaterial OverrideMaterial2D;
SMaterial InitMaterial2D;
......
......@@ -649,6 +649,19 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<u32>& screenSize,
}
else
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);
......
......@@ -38,6 +38,11 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool
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
TriangleRenderers[ETR_FLAT] = createTriangleRendererFlat(ZBuffer);
......
......@@ -206,7 +206,6 @@ vec3 fnormal(void)
}
struct program1
{
vec4 Ambient;
......@@ -358,6 +357,12 @@ CBurningVideoDriver::CBurningVideoDriver(const irr::SIrrlichtCreationParameters&
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
irr::memset32 ( BurningShader, 0, sizeof ( BurningShader ) );
......
......@@ -732,6 +732,10 @@
<Filter
Name="video"
>
<File
RelativePath="..\..\include\EDriverFeatures.h"
>
</File>
<File
RelativePath="..\..\include\EDriverTypes.h"
>
......
......@@ -98,6 +98,7 @@ int main(int argumentCount, char * arguments[])
TEST(meshTransform);
TEST(createImage);
// all driver checks
TEST(videoDriver);
TEST(drawPixel);
TEST(guiDisabledMenu);
TEST(makeColorKeyTexture);
......@@ -113,8 +114,8 @@ int main(int argumentCount, char * arguments[])
// TEST(projectionMatrix);
// large scenes/long rendering
// shadows are slow
TEST(orthoCam);
TEST(stencilShadow);
// TEST(orthoCam);
// TEST(stencilShadow);
// q3 maps are slow
TEST(planeMatrix);
TEST(terrainSceneNode);
......
Tests finished. 55 tests of 55 passed.
Tests finished. 56 tests of 56 passed.
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 @@
<Unit filename="textureRenderStates.cpp" />
<Unit filename="transparentMaterials.cpp" />
<Unit filename="vectorPositionDimension2d.cpp" />
<Unit filename="videoDriver.cpp" />
<Unit filename="writeImageToFile.cpp" />
<Unit filename="zipReader.cpp" />
<Extensions>
......
......@@ -139,6 +139,7 @@
<ClCompile Include="timer.cpp" />
<ClCompile Include="transparentAlphaChannelRef.cpp" />
<ClCompile Include="vectorPositionDimension2d.cpp" />
<ClCompile Include="videoDriver.cpp" />
<ClCompile Include="writeImageToFile.cpp" />
</ItemGroup>
<ItemGroup>
......@@ -153,4 +154,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
......@@ -324,6 +324,10 @@
RelativePath=".\vectorPositionDimension2d.cpp"
>
</File>
<File
RelativePath=".\videoDriver.cpp"
>
</File>
<File
RelativePath=".\writeImageToFile.cpp"
>
......
......@@ -403,6 +403,10 @@
RelativePath=".\vectorPositionDimension2d.cpp"
>
</File>
<File
RelativePath=".\videoDriver.cpp"
>
</File>
<File
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