1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-04 01:05:48 +01:00

Irrlicht: expose MaxArrayTextureLayers

This commit is contained in:
sfan5
2025-10-08 16:56:26 +02:00
parent 0794912374
commit 3c60b348a6
7 changed files with 37 additions and 52 deletions

View File

@@ -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. */

View File

@@ -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.

View File

@@ -229,10 +229,7 @@ public:
virtual void makeColorKeyTexture(video::ITexture *texture,
core::position2d<s32> 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;

View File

@@ -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
{

View File

@@ -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<u32> &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;

View File

@@ -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[] = {

View File

@@ -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<s32> &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<u32> &size,
const io::path &name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override;