Browse Source

GL: assume object is created if it's already bound somewhere.

The assertions triggered by the tests added in previous commit no longer
fire.
pull/680/head
Vladimír Vondruš 10 months ago
parent
commit
28f5d5a07c
  1. 12
      src/Magnum/GL/AbstractFramebuffer.cpp
  2. 12
      src/Magnum/GL/AbstractTexture.cpp
  3. 12
      src/Magnum/GL/Buffer.cpp
  4. 12
      src/Magnum/GL/Mesh.cpp
  5. 12
      src/Magnum/GL/Renderbuffer.cpp
  6. 12
      src/Magnum/GL/TransformFeedback.cpp

12
src/Magnum/GL/AbstractFramebuffer.cpp

@ -112,7 +112,17 @@ void AbstractFramebuffer::createIfNotAlready() {
require the object to be created. Binding the framebuffer finally require the object to be created. Binding the framebuffer finally
creates it. Also all EXT DSA functions implicitly create it. */ creates it. Also all EXT DSA functions implicitly create it. */
bindInternal(); bindInternal();
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
/* In some cases, such as when this function is called on a object created
using wrap(), ObjectFlag::Created might not be set but bindInternal()
above was a no-op as the object was already bound somewhere. In that
case assume that, since it's bound, it's already created, and we just
didn't know. See the wrapCreateIfNotAlready() test for a repro case.
Note that the branch is done this way instead of an unconditional |= to
make code coverage report that this codepath is indeed tested. */
if(!(_flags >= ObjectFlag::Created))
_flags |= ObjectFlag::Created;
} }
#endif #endif

12
src/Magnum/GL/AbstractTexture.cpp

@ -261,7 +261,17 @@ void AbstractTexture::createIfNotAlready() {
directly and they require the object to be created. Binding the texture directly and they require the object to be created. Binding the texture
to desired target finally creates it. */ to desired target finally creates it. */
bindInternal(); bindInternal();
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
/* In some cases, such as when this function is called on a object created
using wrap(), ObjectFlag::Created might not be set but bindInternal()
above was a no-op as the object was already bound somewhere. In that
case assume that, since it's bound, it's already created, and we just
didn't know. See the wrapCreateIfNotAlready() test for a repro case.
Note that the branch is done this way instead of an unconditional |= to
make code coverage report that this codepath is indeed tested. */
if(!(_flags >= ObjectFlag::Created))
_flags |= ObjectFlag::Created;
} }
#endif #endif

12
src/Magnum/GL/Buffer.cpp

@ -240,7 +240,17 @@ void Buffer::createIfNotAlready() {
buffer finally creates it. Also all EXT DSA functions implicitly create buffer finally creates it. Also all EXT DSA functions implicitly create
it. */ it. */
bindSomewhereInternal(_targetHint); bindSomewhereInternal(_targetHint);
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
/* In some cases, such as when this function is called on a object created
using wrap(), ObjectFlag::Created might not be set but bindInternal()
above was a no-op as the object was already bound somewhere. In that
case assume that, since it's bound, it's already created, and we just
didn't know. See the wrapCreateIfNotAlready() test for a repro case.
Note that the branch is done this way instead of an unconditional |= to
make code coverage report that this codepath is indeed tested. */
if(!(_flags >= ObjectFlag::Created))
_flags |= ObjectFlag::Created;
} }
#endif #endif

12
src/Magnum/GL/Mesh.cpp

@ -401,7 +401,17 @@ inline void Mesh::createIfNotAlready() {
require the object to be created. Binding the VAO finally creates it. require the object to be created. Binding the VAO finally creates it.
Also all EXT DSA functions implicitly create it. */ Also all EXT DSA functions implicitly create it. */
bindVAO(); bindVAO();
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
/* In some cases, such as when this function is called on a object created
using wrap(), ObjectFlag::Created might not be set but bindVAO() above
was a no-op as the object was already bound somewhere. In that case
assume that, since it's bound, it's already created, and we just didn't
know. See the wrapCreateIfNotAlready() test for a repro case.
Note that the branch is done this way instead of an unconditional |= to
make code coverage report that this codepath is indeed tested. */
if(!(_flags >= ObjectFlag::Created))
_flags |= ObjectFlag::Created;
} }
#endif #endif

12
src/Magnum/GL/Renderbuffer.cpp

@ -108,7 +108,17 @@ inline void Renderbuffer::createIfNotAlready() {
require the object to be created. Binding the renderbuffer finally require the object to be created. Binding the renderbuffer finally
creates it. Also all EXT DSA functions implicitly create it. */ creates it. Also all EXT DSA functions implicitly create it. */
bind(); bind();
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
/* In some cases, such as when this function is called on a object created
using wrap(), ObjectFlag::Created might not be set but bind() above was
a no-op as the object was already bound somewhere. In that case assume
that, since it's bound, it's already created, and we just didn't know.
See the wrapCreateIfNotAlready() test for a repro case.
Note that the branch is done this way instead of an unconditional |= to
make code coverage report that this codepath is indeed tested. */
if(!(_flags >= ObjectFlag::Created))
_flags |= ObjectFlag::Created;
} }
#endif #endif

12
src/Magnum/GL/TransformFeedback.cpp

@ -162,7 +162,17 @@ inline void TransformFeedback::createIfNotAlready() {
require the object to be created. Binding the transform feedback finally require the object to be created. Binding the transform feedback finally
creates it. Also all EXT DSA functions implicitly create it. */ creates it. Also all EXT DSA functions implicitly create it. */
bindInternal(); bindInternal();
CORRADE_INTERNAL_ASSERT(_flags & ObjectFlag::Created);
/* In some cases, such as when this function is called on a object created
using wrap(), ObjectFlag::Created might not be set but bindInternal()
above was a no-op as the object was already bound somewhere. In that
case assume that, since it's bound, it's already created, and we just
didn't know. See the wrapCreateIfNotAlready() test for a repro case.
Note that the branch is done this way instead of an unconditional |= to
make code coverage report that this codepath is indeed tested. */
if(!(_flags >= ObjectFlag::Created))
_flags |= ObjectFlag::Created;
} }
#endif #endif

Loading…
Cancel
Save