1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-12 16:15:20 +02:00

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.
This commit is contained in:
SmallJoker
2025-10-11 19:38:38 +02:00
committed by GitHub
parent f205f6f539
commit 9213b7f164
3 changed files with 13 additions and 4 deletions

View File

@@ -2672,7 +2672,8 @@ bool COpenGLDriver::setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SCol
// Update mip-map of the generated texture, if enabled. // Update mip-map of the generated texture, if enabled.
auto textures = CurrentRenderTarget->getTexture(); auto textures = CurrentRenderTarget->getTexture();
for (size_t i = 0; i < textures.size(); ++i) for (size_t i = 0; i < textures.size(); ++i)
textures[i]->regenerateMipMapLevels(); if (textures[i])
textures[i]->regenerateMipMapLevels();
} }
bool supportForFBO = (Feature.ColorAttachment > 0); bool supportForFBO = (Feature.ColorAttachment > 0);

View File

@@ -1704,8 +1704,10 @@ bool COpenGL3DriverBase::setRenderTargetEx(IRenderTarget *target, u16 clearFlag,
if (CurrentRenderTarget) { if (CurrentRenderTarget) {
// Update mip-map of the generated texture, if enabled. // Update mip-map of the generated texture, if enabled.
auto textures = CurrentRenderTarget->getTexture(); auto textures = CurrentRenderTarget->getTexture();
for (size_t i = 0; i < textures.size(); ++i) for (size_t i = 0; i < textures.size(); ++i) {
textures[i]->regenerateMipMapLevels(); if (textures[i])
textures[i]->regenerateMipMapLevels();
}
} }
core::dimension2d<u32> destRenderTargetSize(0, 0); core::dimension2d<u32> destRenderTargetSize(0, 0);

View File

@@ -5,6 +5,7 @@
#include "pipeline.h" #include "pipeline.h"
#include "client/client.h" #include "client/client.h"
#include "client/hud.h" #include "client/hud.h"
#include "gettext.h"
#include "IRenderTarget.h" #include "IRenderTarget.h"
#include "SColor.h" #include "SColor.h"
@@ -85,7 +86,12 @@ void TextureBuffer::reset(PipelineContext &context)
for (u32 i = 0; i < m_definitions.size(); i++) { for (u32 i = 0; i < m_definitions.size(); i++) {
video::ITexture **ptr = &m_textures[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; m_definitions[i].dirty = false;
} }