From 43a2af46ee8d1ba8b3a0428080e71c067873bfae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 15 Dec 2023 10:47:20 +0100 Subject: [PATCH] Fix error handling on texture creation failure --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- Common/Render/ManagedTexture.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index a509a3b1ac..2ec5347a55 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1298,7 +1298,7 @@ Texture *VKContext::CreateTexture(const TextureDesc &desc) { return tex; } else { ERROR_LOG(G3D, "Failed to create texture"); - delete tex; + tex->Release(); return nullptr; } } diff --git a/Common/Render/ManagedTexture.cpp b/Common/Render/ManagedTexture.cpp index 36a5031263..730fd29172 100644 --- a/Common/Render/ManagedTexture.cpp +++ b/Common/Render/ManagedTexture.cpp @@ -194,6 +194,10 @@ Draw::Texture *ManagedTexture::GetTexture() { } // Image load is done, texture creation is not. texture_ = CreateTextureFromTempImage(draw_, pendingImage_, generateMips_, filename_.c_str()); + if (!texture_) { + // Failed to create the texture for whatever reason, like dimensions. Don't retry next time. + state_ = LoadState::FAILED; + } pendingImage_.Free(); } return texture_;