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
creates it. Also all EXT DSA functions implicitly create it. */
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

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
to desired target finally creates it. */
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

12
src/Magnum/GL/Buffer.cpp

@ -240,7 +240,17 @@ void Buffer::createIfNotAlready() {
buffer finally creates it. Also all EXT DSA functions implicitly create
it. */
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

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.
Also all EXT DSA functions implicitly create it. */
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

12
src/Magnum/GL/Renderbuffer.cpp

@ -108,7 +108,17 @@ inline void Renderbuffer::createIfNotAlready() {
require the object to be created. Binding the renderbuffer finally
creates it. Also all EXT DSA functions implicitly create it. */
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

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
creates it. Also all EXT DSA functions implicitly create it. */
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

Loading…
Cancel
Save