Get rid of MATERIAL_MAX_TEXTURES_USED

Another configurable knob of questionable usefulness,
especially since this inhibits certain optimizations
by making loop length dependent on a global variable.
This commit is contained in:
sfan5 2021-11-19 20:16:57 +01:00
parent 6779cb7254
commit d322b73e4c
6 changed files with 7 additions and 29 deletions

View File

@ -282,23 +282,6 @@ namespace video
*/ */
const u32 MATERIAL_MAX_TEXTURES = _IRR_MATERIAL_MAX_TEXTURES_; const u32 MATERIAL_MAX_TEXTURES = _IRR_MATERIAL_MAX_TEXTURES_;
//! By default this is identical to MATERIAL_MAX_TEXTURES
/** Users can modify this value if they are certain they don't need all
available textures per material in their application. For example if you
never need more than 2 textures per material you can set this to 2.
We (mostly) avoid dynamic memory in SMaterial, so the extra memory
will still be allocated. But by lowering MATERIAL_MAX_TEXTURES_USED the
material comparisons and assignments can be faster. Also several other
places in the engine can be faster when reducing this value to the limit
you need.
NOTE: This should only be changed once and before any call to createDevice.
NOTE: Do not set it below 1 or above the value of _IRR_MATERIAL_MAX_TEXTURES_.
NOTE: Going below 4 is usually not worth it.
*/
IRRLICHT_API extern u32 MATERIAL_MAX_TEXTURES_USED;
//! Struct for holding parameters for a material renderer //! Struct for holding parameters for a material renderer
// Note for implementors: Serialization is in CNullDriver // Note for implementors: Serialization is in CNullDriver
class SMaterial class SMaterial
@ -323,7 +306,7 @@ namespace video
SMaterial(const SMaterial& other) SMaterial(const SMaterial& other)
{ {
// These pointers are checked during assignment // These pointers are checked during assignment
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].TextureMatrix = 0; TextureLayer[i].TextureMatrix = 0;
*this = other; *this = other;
} }
@ -565,23 +548,23 @@ namespace video
FrontfaceCulling = value; break; FrontfaceCulling = value; break;
case EMF_BILINEAR_FILTER: case EMF_BILINEAR_FILTER:
{ {
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].BilinearFilter = value; TextureLayer[i].BilinearFilter = value;
} }
break; break;
case EMF_TRILINEAR_FILTER: case EMF_TRILINEAR_FILTER:
{ {
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].TrilinearFilter = value; TextureLayer[i].TrilinearFilter = value;
} }
break; break;
case EMF_ANISOTROPIC_FILTER: case EMF_ANISOTROPIC_FILTER:
{ {
if (value) if (value)
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].AnisotropicFilter = 0xFF; TextureLayer[i].AnisotropicFilter = 0xFF;
else else
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
TextureLayer[i].AnisotropicFilter = 0; TextureLayer[i].AnisotropicFilter = 0;
} }
break; break;
@ -591,7 +574,7 @@ namespace video
NormalizeNormals = value; break; NormalizeNormals = value; break;
case EMF_TEXTURE_WRAP: case EMF_TEXTURE_WRAP:
{ {
for (u32 i=0; i<MATERIAL_MAX_TEXTURES_USED; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
{ {
TextureLayer[i].TextureWrapU = (E_TEXTURE_CLAMP)value; TextureLayer[i].TextureWrapU = (E_TEXTURE_CLAMP)value;
TextureLayer[i].TextureWrapV = (E_TEXTURE_CLAMP)value; TextureLayer[i].TextureWrapV = (E_TEXTURE_CLAMP)value;
@ -713,7 +696,7 @@ namespace video
PolygonOffsetSlopeScale != b.PolygonOffsetSlopeScale || PolygonOffsetSlopeScale != b.PolygonOffsetSlopeScale ||
UseMipMaps != b.UseMipMaps UseMipMaps != b.UseMipMaps
; ;
for (u32 i=0; (i<MATERIAL_MAX_TEXTURES_USED) && !different; ++i) for (u32 i=0; (i<MATERIAL_MAX_TEXTURES) && !different; ++i)
{ {
different |= (TextureLayer[i] != b.TextureLayer[i]); different |= (TextureLayer[i] != b.TextureLayer[i]);
} }

View File

@ -47,7 +47,6 @@ namespace video
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES)); Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES_USED));
Feature.ColorAttachment = 1; Feature.ColorAttachment = 1;
} }

View File

@ -82,7 +82,6 @@ namespace video
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES)); Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES_USED));
Feature.ColorAttachment = 1; Feature.ColorAttachment = 1;
#if defined(_IRR_OGLES1_USE_EXTPOINTER_) #if defined(_IRR_OGLES1_USE_EXTPOINTER_)

View File

@ -756,7 +756,6 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
else else
#endif #endif
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES)); Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES_USED));
#ifdef GL_ARB_occlusion_query #ifdef GL_ARB_occlusion_query
if (FeatureAvailable[IRR_ARB_occlusion_query]) if (FeatureAvailable[IRR_ARB_occlusion_query])

View File

@ -1097,7 +1097,6 @@ void CWebGL1Driver::initWebGLExtensions()
glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine);
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint);
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES)); Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES));
Feature.MaxTextureUnits = core::min_(Feature.MaxTextureUnits, static_cast<u8>(MATERIAL_MAX_TEXTURES_USED));
Feature.ColorAttachment = 1; Feature.ColorAttachment = 1;
} }

View File

@ -132,7 +132,6 @@ namespace core
namespace video namespace video
{ {
SMaterial IdentityMaterial; SMaterial IdentityMaterial;
u32 MATERIAL_MAX_TEXTURES_USED = MATERIAL_MAX_TEXTURES;
} }
} // end namespace irr } // end namespace irr