From 3c60b348a62a70c2d491f1eefcc0ad683a94a2c6 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 8 Oct 2025 16:56:26 +0200 Subject: [PATCH] Irrlicht: expose MaxArrayTextureLayers --- irr/include/IVideoDriver.h | 22 ++++++++++++++++------ irr/src/CNullDriver.cpp | 17 ++++++----------- irr/src/CNullDriver.h | 10 ++-------- irr/src/COpenGLDriver.cpp | 12 +++++------- irr/src/COpenGLDriver.h | 8 +------- irr/src/OpenGL/Driver.cpp | 14 ++++++-------- irr/src/OpenGL/Driver.h | 6 +----- 7 files changed, 37 insertions(+), 52 deletions(-) diff --git a/irr/include/IVideoDriver.h b/irr/include/IVideoDriver.h index 2d58940c32..61342fbb97 100644 --- a/irr/include/IVideoDriver.h +++ b/irr/include/IVideoDriver.h @@ -62,6 +62,15 @@ struct SFrameStats { u32 HWBuffersActive = 0; }; +struct SDriverLimits { + //! Maximum amount of primitives that can be rendered in a single call + u32 MaxPrimitiveCount = 0; + //! Maximum width/height for a texture + u32 MaxTextureSize = 0; + //! Maximum number of images in an array texture + u32 MaxArrayTextureImages = 0; +}; + //! Interface to driver which is able to perform 2d and 3d graphics functions. /** This interface is one of the most important interfaces of the Irrlicht Engine: All rendering and texture manipulation is done with @@ -852,11 +861,8 @@ public: \param writer: Pointer to the external writer created. */ virtual void addExternalImageWriter(IImageWriter *writer) = 0; - //! Returns the maximum amount of primitives - /** (mostly vertices) which the device is able to render with - one drawVertexPrimitiveList call. - \return Maximum amount of primitives. */ - virtual u32 getMaximalPrimitiveCount() const = 0; + //! Returns some common driver limits. + virtual SDriverLimits getLimits() const = 0; //! Enables or disables a texture creation flag. /** These flags define how textures should be created. By @@ -1116,7 +1122,11 @@ public: virtual void setAllowZWriteOnTransparent(bool flag) = 0; //! Get the maximum texture size supported. - virtual core::dimension2du getMaxTextureSize() const = 0; + inline core::dimension2du getMaxTextureSize() const + { + auto l = getLimits(); + return {l.MaxTextureSize, l.MaxTextureSize}; + } //! Check if the driver supports creating textures with the given color format /** \return True if the format is available, false if not. */ diff --git a/irr/src/CNullDriver.cpp b/irr/src/CNullDriver.cpp index 1012e41cf0..bd11b236bf 100644 --- a/irr/src/CNullDriver.cpp +++ b/irr/src/CNullDriver.cpp @@ -837,18 +837,18 @@ void CNullDriver::makeColorKeyTexture(video::ITexture *texture, makeColorKeyTexture(texture, colorKey); } -//! Returns the maximum amount of primitives (mostly vertices) which -//! the device is able to render with one drawIndexedTriangleList -//! call. -u32 CNullDriver::getMaximalPrimitiveCount() const +SDriverLimits CNullDriver::getLimits() const { - return 0xFFFFFFFF; + SDriverLimits ret; + ret.MaxPrimitiveCount = 0xFFFFFFFF; + ret.MaxTextureSize = 0x10000; // maybe large enough + return ret; } //! checks triangle count and print warning if wrong bool CNullDriver::checkPrimitiveCount(u32 prmCount) const { - const u32 m = getMaximalPrimitiveCount(); + const u32 m = getLimits().MaxPrimitiveCount; if (prmCount > m) { char tmp[128]; @@ -1732,11 +1732,6 @@ void CNullDriver::enableMaterial2D(bool enable) OverrideMaterial2DEnabled = enable; } -core::dimension2du CNullDriver::getMaxTextureSize() const -{ - return core::dimension2du(0x10000, 0x10000); // maybe large enough -} - bool CNullDriver::needsTransparentRenderPass(const video::SMaterial &material) const { // TODO: I suspect it would be nice if the material had an enum for further control. diff --git a/irr/src/CNullDriver.h b/irr/src/CNullDriver.h index e5f4b5dea2..b31c2c13f9 100644 --- a/irr/src/CNullDriver.h +++ b/irr/src/CNullDriver.h @@ -229,10 +229,7 @@ public: virtual void makeColorKeyTexture(video::ITexture *texture, core::position2d colorKeyPixelPos) const override; - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - u32 getMaximalPrimitiveCount() const override; + SDriverLimits getLimits() const override; //! Enables or disables a texture creation flag. void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) override; @@ -280,7 +277,7 @@ public: //! Check if the driver supports creating textures with the given color format bool queryTextureFormat(ECOLOR_FORMAT format) const override { - return false; + return format == video::ECF_A8R8G8B8; } protected: @@ -529,9 +526,6 @@ public: AllowZWriteOnTransparent = flag; } - //! Returns the maximum texture size supported. - core::dimension2du getMaxTextureSize() const override; - //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass bool needsTransparentRenderPass(const video::SMaterial &material) const override; diff --git a/irr/src/COpenGLDriver.cpp b/irr/src/COpenGLDriver.cpp index 873586835a..045e65bbc4 100644 --- a/irr/src/COpenGLDriver.cpp +++ b/irr/src/COpenGLDriver.cpp @@ -2652,9 +2652,12 @@ ITexture *COpenGLDriver::addRenderTargetTextureCubemap(const u32 sideLen, const //! Returns the maximum amount of primitives (mostly vertices) which //! the device is able to render with one drawIndexedTriangleList //! call. -u32 COpenGLDriver::getMaximalPrimitiveCount() const +SDriverLimits COpenGLDriver::getLimits() const { - return 0x7fffffff; + SDriverLimits ret; + ret.MaxPrimitiveCount = 0x7fffffff; + ret.MaxTextureSize = MaxTextureSize; + return ret; } bool COpenGLDriver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) @@ -2863,11 +2866,6 @@ IImage *COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE return newImage; } -core::dimension2du COpenGLDriver::getMaxTextureSize() const -{ - return core::dimension2du(MaxTextureSize, MaxTextureSize); -} - //! Convert E_PRIMITIVE_TYPE to OpenGL equivalent GLenum COpenGLDriver::primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const { diff --git a/irr/src/COpenGLDriver.h b/irr/src/COpenGLDriver.h index d74c35250a..b7ee9f798e 100644 --- a/irr/src/COpenGLDriver.h +++ b/irr/src/COpenGLDriver.h @@ -241,10 +241,7 @@ public: //! IMaterialRendererServices) IVideoDriver *getVideoDriver() override; - //! Returns the maximum amount of primitives (mostly vertices) which - //! the device is able to render with one drawIndexedTriangleList - //! call. - u32 getMaximalPrimitiveCount() const override; + SDriverLimits getLimits() const override; virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override; @@ -274,9 +271,6 @@ public: //! Returns the graphics card vendor name. core::stringc getVendorInfo() override { return VendorName; } - //! Returns the maximum texture size supported. - core::dimension2du getMaxTextureSize() const override; - //! Removes a texture from the texture cache and deletes it, freeing lot of memory. void removeTexture(ITexture *texture) override; diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp index 1aaaf9ddc1..71470c573b 100644 --- a/irr/src/OpenGL/Driver.cpp +++ b/irr/src/OpenGL/Driver.cpp @@ -1688,10 +1688,13 @@ ITexture *COpenGL3DriverBase::addRenderTargetTextureCubemap(const u32 sideLen, c return renderTargetTexture; } -//! Returns the maximum amount of primitives -u32 COpenGL3DriverBase::getMaximalPrimitiveCount() const +SDriverLimits COpenGL3DriverBase::getLimits() const { - return Version.Spec == OpenGLSpec::ES ? 65535 : 0x7fffffff; + SDriverLimits ret; + ret.MaxPrimitiveCount = Version.Spec == OpenGLSpec::ES ? UINT16_MAX : INT32_MAX; + ret.MaxTextureSize = MaxTextureSize; + ret.MaxArrayTextureImages = MaxArrayTextureLayers; + return ret; } bool COpenGL3DriverBase::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor, f32 clearDepth, u8 clearStencil) @@ -1864,11 +1867,6 @@ void COpenGL3DriverBase::removeTexture(ITexture *texture) CNullDriver::removeTexture(texture); } -core::dimension2du COpenGL3DriverBase::getMaxTextureSize() const -{ - return core::dimension2du(MaxTextureSize, MaxTextureSize); -} - GLenum COpenGL3DriverBase::getGLBlend(E_BLEND_FACTOR factor) const { static GLenum const blendTable[] = { diff --git a/irr/src/OpenGL/Driver.h b/irr/src/OpenGL/Driver.h index 839c5f602b..c64d2a16c7 100644 --- a/irr/src/OpenGL/Driver.h +++ b/irr/src/OpenGL/Driver.h @@ -135,9 +135,6 @@ public: //! Returns the name of the video driver. const char *getName() const override; - //! Returns the maximum texture size supported. - core::dimension2du getMaxTextureSize() const override; - //! sets a viewport void setViewPort(const core::rect &area) override; @@ -202,8 +199,7 @@ public: //! Returns a pointer to the IVideoDriver interface. IVideoDriver *getVideoDriver() override; - //! Returns the maximum amount of primitives - u32 getMaximalPrimitiveCount() const override; + SDriverLimits getLimits() const override; virtual ITexture *addRenderTargetTexture(const core::dimension2d &size, const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override;