From 744b38dada917ac59f765c3e417aa6a0beefb53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 12 Jul 2025 21:54:07 +0200 Subject: [PATCH] GL: ensure the texture is actually created when using ARB_multi_bind. With ARB_DSA disabled, the test added in previous commit would assert already during bind(), and not later in label(). This was due to the state tracker being updated too early here. --- src/Magnum/GL/AbstractTexture.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 675cf5b4d..2dd69f534 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -347,9 +347,13 @@ void AbstractTexture::bind(Int textureUnit) { /* If already bound in given texture unit, nothing to do */ if(textureState.bindings[textureUnit].second() == _id) return; - /* Update state tracker, bind the texture to the unit */ - textureState.bindings[textureUnit] = {_target, _id}; + /* Bind the texture to the unit, *then* update the state tracker. The order + is important, as if bindImplementationMulti() is used, it calls into + createIfNotAlready() which then, if the state tracker would be already + updated, would see that the texture is bound already, and thus wouldn't + bind it at all, never actually creating it. */ textureState.bindImplementation(*this, textureUnit); + textureState.bindings[textureUnit] = {_target, _id}; } void AbstractTexture::bindImplementationDefault(AbstractTexture& self, GLint textureUnit) {