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.
This commit is contained in:
Henrik Rydgård committed 2026-09-04 10:41:31 -06:00
1 parent 89ebb8acc6
commit 78692deca2
1 file changed
+4 -3
+4 -3
View File
@@ -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);
}