Browse Source

GL: put branch contents on a new line.

So line code coverage reports which branches weren't taken by tests.
Other libraries need similar treatment but there's too many cases to fix
so I'm doing it just here for now.
pull/680/head
Vladimír Vondruš 10 months ago
parent
commit
2d36cab303
  1. 12
      src/Magnum/GL/AbstractFramebuffer.cpp
  2. 3
      src/Magnum/GL/AbstractQuery.cpp
  3. 42
      src/Magnum/GL/AbstractShaderProgram.cpp
  4. 21
      src/Magnum/GL/AbstractTexture.cpp
  5. 21
      src/Magnum/GL/Buffer.cpp
  6. 3
      src/Magnum/GL/Context.cpp
  7. 3
      src/Magnum/GL/Framebuffer.cpp
  8. 12
      src/Magnum/GL/Implementation/driverSpecific.cpp
  9. 6
      src/Magnum/GL/Mesh.cpp
  10. 3
      src/Magnum/GL/MeshView.cpp
  11. 10
      src/Magnum/GL/Renderbuffer.cpp
  12. 3
      src/Magnum/GL/Shader.cpp
  13. 3
      src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp
  14. 9
      src/Magnum/GL/TransformFeedback.cpp

12
src/Magnum/GL/AbstractFramebuffer.cpp

@ -105,7 +105,8 @@ Int AbstractFramebuffer::maxDualSourceDrawBuffers() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractFramebuffer::createIfNotAlready() { void AbstractFramebuffer::createIfNotAlready() {
if(_flags & ObjectFlag::Created) return; if(_flags & ObjectFlag::Created)
return;
/* glGen*() does not create the object, just reserves the name. Some /* glGen*() does not create the object, just reserves the name. Some
commands (such as glObjectLabel()) operate with IDs directly and they commands (such as glObjectLabel()) operate with IDs directly and they
@ -146,7 +147,8 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) {
void AbstractFramebuffer::bindImplementationSingle(AbstractFramebuffer& self, FramebufferTarget) { void AbstractFramebuffer::bindImplementationSingle(AbstractFramebuffer& self, FramebufferTarget) {
Implementation::FramebufferState& state = Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding);
if(state.readBinding == self._id) return; if(state.readBinding == self._id)
return;
state.readBinding = state.drawBinding = self._id; state.readBinding = state.drawBinding = self._id;
@ -163,10 +165,12 @@ void AbstractFramebuffer::bindImplementationDefault(AbstractFramebuffer& self, F
Implementation::FramebufferState& state = Context::current().state().framebuffer; Implementation::FramebufferState& state = Context::current().state().framebuffer;
if(target == FramebufferTarget::Read) { if(target == FramebufferTarget::Read) {
if(state.readBinding == self._id) return; if(state.readBinding == self._id)
return;
state.readBinding = self._id; state.readBinding = self._id;
} else if(target == FramebufferTarget::Draw) { } else if(target == FramebufferTarget::Draw) {
if(state.drawBinding == self._id) return; if(state.drawBinding == self._id)
return;
state.drawBinding = self._id; state.drawBinding = self._id;
} else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } else CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */

3
src/Magnum/GL/AbstractQuery.cpp

@ -46,7 +46,8 @@ AbstractQuery::AbstractQuery(GLenum target): _target{target}, _flags{ObjectFlag:
AbstractQuery::~AbstractQuery() { AbstractQuery::~AbstractQuery() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glDeleteQueries(1, &_id); glDeleteQueries(1, &_id);

42
src/Magnum/GL/AbstractShaderProgram.cpp

@ -307,7 +307,8 @@ AbstractShaderProgram::AbstractShaderProgram(AbstractShaderProgram&& other) noex
} }
AbstractShaderProgram::~AbstractShaderProgram() { AbstractShaderProgram::~AbstractShaderProgram() {
if(!_id) return; if(!_id)
return;
/* Remove current usage from the state */ /* Remove current usage from the state */
GLuint& current = Context::current().state().shaderProgram.current; GLuint& current = Context::current().state().shaderProgram.current;
@ -370,7 +371,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh) {
CORRADE_ASSERT(mesh._countSet, "GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?", *this); CORRADE_ASSERT(mesh._countSet, "GL::AbstractShaderProgram::draw(): Mesh::setCount() was never called, probably a mistake?", *this);
/* Nothing to draw, exit without touching any state */ /* Nothing to draw, exit without touching any state */
if(!mesh._count || !mesh._instanceCount) return *this; if(!mesh._count || !mesh._instanceCount)
return *this;
use(); use();
@ -386,7 +388,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(MeshView& mesh) {
CORRADE_ASSERT(mesh._countSet, "GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?", *this); CORRADE_ASSERT(mesh._countSet, "GL::AbstractShaderProgram::draw(): MeshView::setCount() was never called, probably a mistake?", *this);
/* Nothing to draw, exit without touching any state */ /* Nothing to draw, exit without touching any state */
if(!mesh._count || !mesh._instanceCount) return *this; if(!mesh._count || !mesh._instanceCount)
return *this;
use(); use();
@ -399,7 +402,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(MeshView& mesh) {
} }
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& indexOffsets) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& indexOffsets) {
if(!counts.size()) return *this; if(!counts.size())
return *this;
use(); use();
@ -409,7 +413,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers:
#ifndef CORRADE_TARGET_32BIT #ifndef CORRADE_TARGET_32BIT
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedLong>& indexOffsets) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedLong>& indexOffsets) {
if(!counts.size()) return *this; if(!counts.size())
return *this;
use(); use();
@ -425,7 +430,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers:
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& indexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& instanceOffsets) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& indexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& instanceOffsets) {
if(!counts.size()) return *this; if(!counts.size())
return *this;
use(); use();
@ -435,7 +441,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers:
#ifndef CORRADE_TARGET_32BIT #ifndef CORRADE_TARGET_32BIT
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedLong>& indexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& instanceOffsets) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedLong>& indexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& instanceOffsets) {
if(!counts.size()) return *this; if(!counts.size())
return *this;
use(); use();
@ -450,7 +457,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers:
#endif #endif
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& indexOffsets) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedInt>& indexOffsets) {
if(!counts.size()) return *this; if(!counts.size())
return *this;
use(); use();
@ -464,7 +472,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers:
#ifndef CORRADE_TARGET_32BIT #ifndef CORRADE_TARGET_32BIT
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedLong>& indexOffsets) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers::StridedArrayView1D<const UnsignedInt>& counts, const Containers::StridedArrayView1D<const UnsignedInt>& instanceCounts, const Containers::StridedArrayView1D<const UnsignedInt>& vertexOffsets, const Containers::StridedArrayView1D<const UnsignedLong>& indexOffsets) {
if(!counts.size()) return *this; if(!counts.size())
return *this;
use(); use();
@ -483,7 +492,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh, const Containers:
#endif #endif
AbstractShaderProgram& AbstractShaderProgram::draw(const Containers::Iterable<MeshView>& meshes) { AbstractShaderProgram& AbstractShaderProgram::draw(const Containers::Iterable<MeshView>& meshes) {
if(meshes.isEmpty()) return *this; if(meshes.isEmpty())
return *this;
use(); use();
@ -504,7 +514,8 @@ AbstractShaderProgram& AbstractShaderProgram::draw(const Containers::Iterable<Me
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
AbstractShaderProgram& AbstractShaderProgram::drawTransformFeedback(Mesh& mesh, TransformFeedback& xfb, UnsignedInt stream) { AbstractShaderProgram& AbstractShaderProgram::drawTransformFeedback(Mesh& mesh, TransformFeedback& xfb, UnsignedInt stream) {
/* Nothing to draw, exit without touching any state */ /* Nothing to draw, exit without touching any state */
if(!mesh._instanceCount) return *this; if(!mesh._instanceCount)
return *this;
use(); use();
mesh.drawInternal(xfb, stream, mesh._instanceCount); mesh.drawInternal(xfb, stream, mesh._instanceCount);
@ -513,7 +524,8 @@ AbstractShaderProgram& AbstractShaderProgram::drawTransformFeedback(Mesh& mesh,
AbstractShaderProgram& AbstractShaderProgram::drawTransformFeedback(MeshView& mesh, TransformFeedback& xfb, UnsignedInt stream) { AbstractShaderProgram& AbstractShaderProgram::drawTransformFeedback(MeshView& mesh, TransformFeedback& xfb, UnsignedInt stream) {
/* If nothing to draw, exit without touching any state */ /* If nothing to draw, exit without touching any state */
if(mesh._instanceCount) return *this; if(mesh._instanceCount)
return *this;
use(); use();
mesh._original->drawInternal(xfb, stream, mesh._instanceCount); mesh._original->drawInternal(xfb, stream, mesh._instanceCount);
@ -524,7 +536,8 @@ AbstractShaderProgram& AbstractShaderProgram::drawTransformFeedback(MeshView& me
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
AbstractShaderProgram& AbstractShaderProgram::dispatchCompute(const Vector3ui& workgroupCount) { AbstractShaderProgram& AbstractShaderProgram::dispatchCompute(const Vector3ui& workgroupCount) {
/* Nothing to dispatch, exit without touching any state */ /* Nothing to dispatch, exit without touching any state */
if(!workgroupCount.product()) return *this; if(!workgroupCount.product())
return *this;
use(); use();
glDispatchCompute(workgroupCount.x(), workgroupCount.y(), workgroupCount.z()); glDispatchCompute(workgroupCount.x(), workgroupCount.y(), workgroupCount.z());
@ -633,7 +646,8 @@ bool AbstractShaderProgram::checkLink(const Containers::Iterable<Shader>& shader
The checkCompile() API is called always, to print also compilation The checkCompile() API is called always, to print also compilation
warnings even in case everything still manages to link well. */ warnings even in case everything still manages to link well. */
for(Shader& shader: shaders) for(Shader& shader: shaders)
if(!shader.checkCompile()) return false; if(!shader.checkCompile())
return false;
GLint success, logLength; GLint success, logLength;
glGetProgramiv(_id, GL_LINK_STATUS, &success); glGetProgramiv(_id, GL_LINK_STATUS, &success);

21
src/Magnum/GL/AbstractTexture.cpp

@ -122,7 +122,8 @@ void AbstractTexture::unbind(const Int textureUnit) {
Implementation::TextureState& textureState = Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If given texture unit is already unbound, nothing to do */ /* If given texture unit is already unbound, nothing to do */
if(textureState.bindings[textureUnit].second() == 0) return; if(textureState.bindings[textureUnit].second() == 0)
return;
/* Unbind the texture, reset state tracker */ /* Unbind the texture, reset state tracker */
Context::current().state().texture.unbindImplementation(textureUnit); Context::current().state().texture.unbindImplementation(textureUnit);
@ -233,7 +234,8 @@ void AbstractTexture::createImplementationDSA(AbstractTexture& self) {
AbstractTexture::~AbstractTexture() { AbstractTexture::~AbstractTexture() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
/* Remove all bindings */ /* Remove all bindings */
for(auto& binding: Context::current().state().texture.bindings) { for(auto& binding: Context::current().state().texture.bindings) {
@ -254,7 +256,8 @@ AbstractTexture::~AbstractTexture() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractTexture::createIfNotAlready() { void AbstractTexture::createIfNotAlready() {
if(_flags & ObjectFlag::Created) return; if(_flags & ObjectFlag::Created)
return;
/* glGen*() does not create the object, just reserves the name. Some /* glGen*() does not create the object, just reserves the name. Some
commands (such as glBindTextures() or glObjectLabel()) operate with IDs commands (such as glBindTextures() or glObjectLabel()) operate with IDs
@ -293,7 +296,8 @@ void AbstractTexture::unbindImage(const Int imageUnit) {
Implementation::TextureState& textureState = Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If already unbound in given image unit, nothing to do */ /* If already unbound in given image unit, nothing to do */
if(textureState.imageBindings[imageUnit].id == 0) return; if(textureState.imageBindings[imageUnit].id == 0)
return;
/* Update state tracker, bind the texture to the unit */ /* Update state tracker, bind the texture to the unit */
textureState.imageBindings[imageUnit].id = 0; textureState.imageBindings[imageUnit].id = 0;
@ -343,7 +347,8 @@ void AbstractTexture::bindImageInternal(const Int imageUnit, const Int level, co
const Implementation::TextureState::ImageBinding state{_id, level, layered, layer, GLenum(access)}; const Implementation::TextureState::ImageBinding state{_id, level, layered, layer, GLenum(access)};
/* If already bound in given texture unit, nothing to do */ /* If already bound in given texture unit, nothing to do */
if(textureState.imageBindings[imageUnit] == state) return; if(textureState.imageBindings[imageUnit] == state)
return;
/* Update state tracker, bind the texture to the unit */ /* Update state tracker, bind the texture to the unit */
textureState.imageBindings[imageUnit] = state; textureState.imageBindings[imageUnit] = state;
@ -355,7 +360,8 @@ void AbstractTexture::bind(Int textureUnit) {
Implementation::TextureState& textureState = Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
/* If already bound in given texture unit, nothing to do */ /* If already bound in given texture unit, nothing to do */
if(textureState.bindings[textureUnit].second() == _id) return; if(textureState.bindings[textureUnit].second() == _id)
return;
/* Bind the texture to the unit, *then* update the state tracker. The order /* Bind the texture to the unit, *then* update the state tracker. The order
is important, as if bindImplementationMulti() is used, it calls into is important, as if bindImplementationMulti() is used, it calls into
@ -571,7 +577,8 @@ void AbstractTexture::bindInternal() {
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = internalTextureUnit)); glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = internalTextureUnit));
/* If already bound in given texture unit, nothing to do */ /* If already bound in given texture unit, nothing to do */
if(textureState.bindings[internalTextureUnit].second() == _id) return; if(textureState.bindings[internalTextureUnit].second() == _id)
return;
/* Update state tracker, bind the texture to the unit. Not directly calling /* Update state tracker, bind the texture to the unit. Not directly calling
glBindTexture() here because we may need to include various glBindTexture() here because we may need to include various

21
src/Magnum/GL/Buffer.cpp

@ -202,7 +202,8 @@ void Buffer::createImplementationDSA(Buffer& self) {
Buffer::~Buffer() { Buffer::~Buffer() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
GLuint* bindings = Context::current().state().buffer.bindings; GLuint* bindings = Context::current().state().buffer.bindings;
@ -232,7 +233,8 @@ void Buffer::setTargetHintImplementationSwiftShader(Buffer& self, const TargetHi
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void Buffer::createIfNotAlready() { void Buffer::createIfNotAlready() {
if(_flags & ObjectFlag::Created) return; if(_flags & ObjectFlag::Created)
return;
/* glGen*() does not create the object, just reserves the name. Some /* glGen*() does not create the object, just reserves the name. Some
commands (such as glInvalidateBufferData() or glObjectLabel()) operate commands (such as glInvalidateBufferData() or glObjectLabel()) operate
@ -280,7 +282,8 @@ void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) {
GLuint& bound = Context::current().state().buffer.bindings[Implementation::BufferState::indexForTarget(target)]; GLuint& bound = Context::current().state().buffer.bindings[Implementation::BufferState::indexForTarget(target)];
/* Already bound, nothing to do */ /* Already bound, nothing to do */
if(bound == id) return; if(bound == id)
return;
/* Bind the buffer otherwise, which will also finally create it */ /* Bind the buffer otherwise, which will also finally create it */
bound = id; bound = id;
@ -293,12 +296,14 @@ auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint {
GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)]; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)];
/* Shortcut - if already bound to hint, return */ /* Shortcut - if already bound to hint, return */
if(hintBinding == _id) return hint; if(hintBinding == _id)
return hint;
/* Return first target in which the buffer is bound */ /* Return first target in which the buffer is bound */
/** @todo wtf there is one more? */ /** @todo wtf there is one more? */
for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i)
if(bindings[i] == _id) return Implementation::BufferState::targetForIndex[i-1]; if(bindings[i] == _id)
return Implementation::BufferState::targetForIndex[i-1];
/* Sorry, this is ugly because GL is also ugly. Blame GL, not me. /* Sorry, this is ugly because GL is also ugly. Blame GL, not me.
@ -651,7 +656,8 @@ void Buffer::textureWorkaroundAppleBefore() {
pretty significant overhead. Skipping the whole thing if no buffer pretty significant overhead. Skipping the whole thing if no buffer
texture is known to be bound. */ texture is known to be bound. */
Implementation::TextureState& textureState = Context::current().state().texture; Implementation::TextureState& textureState = Context::current().state().texture;
if(textureState.bufferTextureBound.none()) return; if(textureState.bufferTextureBound.none())
return;
for(GLint textureUnit = 0; textureUnit != GLint(textureState.bindings.size()); ++textureUnit) { for(GLint textureUnit = 0; textureUnit != GLint(textureState.bindings.size()); ++textureUnit) {
/* Checking just /* Checking just
textureState.bindings[textureUnit].first != GL_TEXTURE_BUFFER textureState.bindings[textureUnit].first != GL_TEXTURE_BUFFER
@ -659,7 +665,8 @@ void Buffer::textureWorkaroundAppleBefore() {
the same texture unit. Magnum's state tracker ignores that (as it the same texture unit. Magnum's state tracker ignores that (as it
would mean having to maintain a state cache of 128 units times 12 would mean having to maintain a state cache of 128 units times 12
targets) and so this state is tracked separately. */ targets) and so this state is tracked separately. */
if(!textureState.bufferTextureBound[textureUnit]) continue; if(!textureState.bufferTextureBound[textureUnit])
continue;
/* Activate given texture unit if not already active, update state /* Activate given texture unit if not already active, update state
tracker */ tracker */

3
src/Magnum/GL/Context.cpp

@ -1220,7 +1220,8 @@ bool Context::isVersionSupported(Version version) const {
Version Context::supportedVersion(std::initializer_list<Version> versions) const { Version Context::supportedVersion(std::initializer_list<Version> versions) const {
for(auto version: versions) for(auto version: versions)
if(isVersionSupported(version)) return version; if(isVersionSupported(version))
return version;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
return Version::GL210; return Version::GL210;

3
src/Magnum/GL/Framebuffer.cpp

@ -125,7 +125,8 @@ void Framebuffer::createImplementationDSA(Framebuffer& self) {
Framebuffer::~Framebuffer() { Framebuffer::~Framebuffer() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
/* If bound, remove itself from state */ /* If bound, remove itself from state */
Context& context = Context::current(); Context& context = Context::current();

12
src/Magnum/GL/Implementation/driverSpecific.cpp

@ -518,14 +518,16 @@ constexpr Containers::StringView KnownWorkarounds[]{
bother with some binary search, which needs extra testing effort. */ bother with some binary search, which needs extra testing effort. */
Containers::StringView findWorkaround(Containers::StringView workaround) { Containers::StringView findWorkaround(Containers::StringView workaround) {
for(Containers::StringView i: KnownWorkarounds) for(Containers::StringView i: KnownWorkarounds)
if(workaround == i) return i; if(workaround == i)
return i;
return {}; return {};
} }
} }
auto Context::detectedDriver() -> DetectedDrivers { auto Context::detectedDriver() -> DetectedDrivers {
if(_detectedDrivers) return *_detectedDrivers; if(_detectedDrivers)
return *_detectedDrivers;
_detectedDrivers = DetectedDrivers{}; _detectedDrivers = DetectedDrivers{};
@ -681,7 +683,8 @@ bool Context::isDriverWorkaroundDisabled(const Containers::StringView workaround
compare just data pointers instead of the whole string as we store only compare just data pointers instead of the whole string as we store only
the views in the KnownWorkarounds list. */ the views in the KnownWorkarounds list. */
for(const auto& i: _driverWorkarounds) for(const auto& i: _driverWorkarounds)
if(i.first().data() == found.data()) return i.second(); if(i.first().data() == found.data())
return i.second();
arrayAppend(_driverWorkarounds, InPlaceInit, found, false); arrayAppend(_driverWorkarounds, InPlaceInit, found, false);
return false; return false;
} }
@ -717,7 +720,8 @@ void Context::setupDriverWorkarounds() {
#endif #endif
const Int firefoxVersion = EM_ASM_INT({ const Int firefoxVersion = EM_ASM_INT({
var match = navigator.userAgent.match(/Firefox\\\\/(\\\\d+)/); var match = navigator.userAgent.match(/Firefox\\\\/(\\\\d+)/);
if(match) return match[1]|0; /* coerce to an int (remember asm.js?) */ if(match)
return match[1]|0; /* coerce to an int (remember asm.js?) */
return 0; return 0;
}); });
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

6
src/Magnum/GL/Mesh.cpp

@ -205,7 +205,8 @@ struct Mesh::AttributeLayout {
GLint size() const { GLint size() const {
const GLint size = kindSize >> 2; const GLint size = kindSize >> 2;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!size) return GL_BGRA; if(!size)
return GL_BGRA;
#endif #endif
return size; return size;
} }
@ -394,7 +395,8 @@ Mesh::Mesh(const GLuint id, const MeshPrimitive primitive, const ObjectFlags fla
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
inline void Mesh::createIfNotAlready() { inline void Mesh::createIfNotAlready() {
/* If VAO extension is not available, the following is always true */ /* If VAO extension is not available, the following is always true */
if(_flags & ObjectFlag::Created) return; if(_flags & ObjectFlag::Created)
return;
/* glGen*() does not create the object, just reserves the name. Some /* glGen*() does not create the object, just reserves the name. Some
commands (such as glObjectLabel()) operate with IDs directly and they commands (such as glObjectLabel()) operate with IDs directly and they

3
src/Magnum/GL/MeshView.cpp

@ -130,7 +130,8 @@ void MeshView::multiDrawImplementationDefault(const Containers::Iterable<MeshVie
void MeshView::multiDrawImplementationFallback(const Containers::Iterable<MeshView>& meshes) { void MeshView::multiDrawImplementationFallback(const Containers::Iterable<MeshView>& meshes) {
for(MeshView& mesh: meshes) { for(MeshView& mesh: meshes) {
/* Nothing to draw in this mesh */ /* Nothing to draw in this mesh */
if(!mesh._count) continue; if(!mesh._count)
continue;
CORRADE_ASSERT(mesh._instanceCount == 1, "GL::AbstractShaderProgram::draw(): cannot multi-draw instanced meshes", ); CORRADE_ASSERT(mesh._instanceCount == 1, "GL::AbstractShaderProgram::draw(): cannot multi-draw instanced meshes", );

10
src/Magnum/GL/Renderbuffer.cpp

@ -90,7 +90,8 @@ void Renderbuffer::createImplementationDSA(Renderbuffer& self) {
Renderbuffer::~Renderbuffer() { Renderbuffer::~Renderbuffer() {
/* Moved out, nothing to do */ /* Moved out, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
/* If bound, remove itself from state */ /* If bound, remove itself from state */
GLuint& binding = Context::current().state().framebuffer.renderbufferBinding; GLuint& binding = Context::current().state().framebuffer.renderbufferBinding;
@ -101,7 +102,8 @@ Renderbuffer::~Renderbuffer() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
inline void Renderbuffer::createIfNotAlready() { inline void Renderbuffer::createIfNotAlready() {
if(_flags & ObjectFlag::Created) return; if(_flags & ObjectFlag::Created)
return;
/* glGen*() does not create the object, just reserves the name. Some /* glGen*() does not create the object, just reserves the name. Some
commands (such as glObjectLabel()) operate with IDs directly and they commands (such as glObjectLabel()) operate with IDs directly and they
@ -147,8 +149,8 @@ void Renderbuffer::setStorageMultisample(const Int samples, const RenderbufferFo
void Renderbuffer::bind() { void Renderbuffer::bind() {
GLuint& binding = Context::current().state().framebuffer.renderbufferBinding; GLuint& binding = Context::current().state().framebuffer.renderbufferBinding;
if(binding == _id)
if(binding == _id) return; return;
/* Binding the renderbuffer finally creates it */ /* Binding the renderbuffer finally creates it */
binding = _id; binding = _id;

3
src/Magnum/GL/Shader.cpp

@ -769,7 +769,8 @@ Shader::Shader(Shader&& other) noexcept: _type{other._type}, _id{other._id}, _fl
Shader::~Shader() { Shader::~Shader() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
glDeleteShader(_id); glDeleteShader(_id);
} }

3
src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp

@ -31,7 +31,8 @@
namespace Magnum { namespace GL { namespace Test { namespace Magnum { namespace GL { namespace Test {
GL::Context* currentContextInALibrary() { GL::Context* currentContextInALibrary() {
if(!GL::Context::hasCurrent()) return nullptr; if(!GL::Context::hasCurrent())
return nullptr;
return &GL::Context::current(); return &GL::Context::current();
} }

9
src/Magnum/GL/TransformFeedback.cpp

@ -132,7 +132,8 @@ void TransformFeedback::createImplementationDSA(TransformFeedback& self) {
TransformFeedback::~TransformFeedback() { TransformFeedback::~TransformFeedback() {
/* Moved out or not deleting on destruction, nothing to do */ /* Moved out or not deleting on destruction, nothing to do */
if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction))
return;
/* If bound, remove itself from state */ /* If bound, remove itself from state */
GLuint& binding = Context::current().state().transformFeedback.binding; GLuint& binding = Context::current().state().transformFeedback.binding;
@ -145,7 +146,8 @@ void TransformFeedback::bindInternal() {
GLuint& bound = Context::current().state().transformFeedback.binding; GLuint& bound = Context::current().state().transformFeedback.binding;
/* Already bound, nothing to do */ /* Already bound, nothing to do */
if(bound == _id) return; if(bound == _id)
return;
/* Bind the transform feedback otherwise, which will also finally create it */ /* Bind the transform feedback otherwise, which will also finally create it */
bound = _id; bound = _id;
@ -155,7 +157,8 @@ void TransformFeedback::bindInternal() {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
inline void TransformFeedback::createIfNotAlready() { inline void TransformFeedback::createIfNotAlready() {
if(_flags & ObjectFlag::Created) return; if(_flags & ObjectFlag::Created)
return;
/* glGen*() does not create the object, just reserves the name. Some /* glGen*() does not create the object, just reserves the name. Some
commands (such as glObjectLabel()) operate with IDs directly and they commands (such as glObjectLabel()) operate with IDs directly and they

Loading…
Cancel
Save