From 78692deca2a0f1248a09d536e14a172ce1ce58f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 3 Sep 2026 10:37:55 -0600 Subject: [PATCH] GLES: Set IS_3D when creating the 3D texture, not after uploading it The out-of-memory bail-out added in the previous commit returned before the status flag was set, leaving a GL_TEXTURE_3D object bound while ApplyTexture told the shader generator it was a 2D texture. The entry stays cached, so it would repeat every frame, not just the one that failed to allocate. --- GPU/GLES/TextureCacheGLES.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 9e137ac5d2..8cd71a4dec 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -233,6 +233,10 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) { } else { _dbg_assert_(draw_->GetDeviceCaps().texture3DSupported); entry->textureName = render_->CreateTexture(GL_TEXTURE_3D, tw, th, plan.depth, 1); + // Set this together with creating the texture - it has to match the target of the object we + // just created even if we bail out below, or the shader gets generated with a 2D sampler + // for a 3D texture. + entry->status |= TexStatus::IS_3D; } // Apply some additional compatibility checks. @@ -332,9 +336,6 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) { render_->TextureImage(entry->textureName, 0, plan.w * plan.scaleFactor, plan.h * plan.scaleFactor, plan.depth, dstFmt, data, GLRAllocType::ALIGNED); - // Signal that we support depth textures so use it as one. - entry->status |= TexStatus::IS_3D; - render_->FinalizeTexture(entry->textureName, 1, false); }