From 9213b7f16491a3cd644c56d98c8791b2e985ca1d Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 11 Oct 2025 19:38:38 +0200 Subject: [PATCH] Driver: Handle errors during texture creation (#16565) The OpenGL drivers do accept 'nullptr' textures, however the recent Mip-Mapping change did not respect that. Furthermore, errors during texture creation for the pipeline are now properly handled and shown as an error to the user. --- irr/src/COpenGLDriver.cpp | 3 ++- irr/src/OpenGL/Driver.cpp | 6 ++++-- src/client/render/pipeline.cpp | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/irr/src/COpenGLDriver.cpp b/irr/src/COpenGLDriver.cpp index 06348cb36c..ac0386b66f 100644 --- a/irr/src/COpenGLDriver.cpp +++ b/irr/src/COpenGLDriver.cpp @@ -2672,7 +2672,8 @@ bool COpenGLDriver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SCol // Update mip-map of the generated texture, if enabled. auto textures = CurrentRenderTarget->getTexture(); for (size_t i = 0; i < textures.size(); ++i) - textures[i]->regenerateMipMapLevels(); + if (textures[i]) + textures[i]->regenerateMipMapLevels(); } bool supportForFBO = (Feature.ColorAttachment > 0); diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp index 025eeb269e..1aaaf9ddc1 100644 --- a/irr/src/OpenGL/Driver.cpp +++ b/irr/src/OpenGL/Driver.cpp @@ -1704,8 +1704,10 @@ bool COpenGL3DriverBase::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, if (CurrentRenderTarget) { // Update mip-map of the generated texture, if enabled. auto textures = CurrentRenderTarget->getTexture(); - for (size_t i = 0; i < textures.size(); ++i) - textures[i]->regenerateMipMapLevels(); + for (size_t i = 0; i < textures.size(); ++i) { + if (textures[i]) + textures[i]->regenerateMipMapLevels(); + } } core::dimension2d destRenderTargetSize(0, 0); diff --git a/src/client/render/pipeline.cpp b/src/client/render/pipeline.cpp index 9812c4476c..cb791fef05 100644 --- a/src/client/render/pipeline.cpp +++ b/src/client/render/pipeline.cpp @@ -5,6 +5,7 @@ #include "pipeline.h" #include "client/client.h" #include "client/hud.h" +#include "gettext.h" #include "IRenderTarget.h" #include "SColor.h" @@ -85,7 +86,12 @@ void TextureBuffer::reset(PipelineContext &context) for (u32 i = 0; i < m_definitions.size(); i++) { video::ITexture **ptr = &m_textures[i]; - ensureTexture(ptr, m_definitions[i], context); + if (!ensureTexture(ptr, m_definitions[i], context)) { + throw ShaderException( + fmtgettext("Failed to create the texture \"%s\" for the rendering pipeline.", + m_definitions[i].name.c_str()) + + strgettext("\nCheck debug.txt for details.")); + } m_definitions[i].dirty = false; }