Browse Source

GL: port label() / setLabel() away from std::string.

All the tests were updated to explicitly check that non-null-terminated
strings get handled properly (the GL label APIs have an  explicit size,
so it *should*, but just in case). Also, because various subclasses
override the setter to return correct type for method chaining and the
override has to be deinlined to avoid relying on a StringView include,
the tests are now explicitly done for each leaf class, instead of the
subclass

The <string> being removed from the base class for all GL objects may
affect downstream projects which relied on it being included. In case of
Magnum, the breakages were already fixed in the previous commit.

Compile time improvement for the MagnumGL library alone is 0.2 second or
4% (6.1 seconds before, 5.9 after). Not bad, given that there's three
more files to compile and strings are still heavily used in other GL
debug output APIs and all shader stuff. For a build of just the GL
library and all tests, it goes down from 28.9 seconds to 28.1. Most
tests also still rely quite heavily on std::stringstream for debug
output testing, so the numbers still could go further.
pull/240/merge
Vladimír Vondruš 5 years ago
parent
commit
bc884428f8
  1. 35
      doc/changelog.dox
  2. 1
      src/Magnum/GL/AbstractFramebuffer.h
  3. 59
      src/Magnum/GL/AbstractObject.cpp
  4. 23
      src/Magnum/GL/AbstractObject.h
  5. 7
      src/Magnum/GL/AbstractQuery.cpp
  6. 22
      src/Magnum/GL/AbstractQuery.h
  7. 7
      src/Magnum/GL/AbstractShaderProgram.cpp
  8. 20
      src/Magnum/GL/AbstractShaderProgram.h
  9. 7
      src/Magnum/GL/AbstractTexture.cpp
  10. 22
      src/Magnum/GL/AbstractTexture.h
  11. 7
      src/Magnum/GL/Buffer.cpp
  12. 21
      src/Magnum/GL/Buffer.h
  13. 9
      src/Magnum/GL/BufferTexture.cpp
  14. 9
      src/Magnum/GL/BufferTexture.h
  15. 7
      src/Magnum/GL/CMakeLists.txt
  16. 11
      src/Magnum/GL/CubeMapTexture.cpp
  17. 9
      src/Magnum/GL/CubeMapTexture.h
  18. 7
      src/Magnum/GL/CubeMapTextureArray.cpp
  19. 9
      src/Magnum/GL/CubeMapTextureArray.h
  20. 7
      src/Magnum/GL/Framebuffer.cpp
  21. 21
      src/Magnum/GL/Framebuffer.h
  22. 4
      src/Magnum/GL/Implementation/DebugState.h
  23. 2
      src/Magnum/GL/Implementation/TextureState.cpp
  24. 7
      src/Magnum/GL/Mesh.cpp
  25. 21
      src/Magnum/GL/Mesh.h
  26. 20
      src/Magnum/GL/MultisampleTexture.cpp
  27. 11
      src/Magnum/GL/MultisampleTexture.h
  28. 43
      src/Magnum/GL/PipelineStatisticsQuery.cpp
  29. 11
      src/Magnum/GL/PipelineStatisticsQuery.h
  30. 11
      src/Magnum/GL/PrimitiveQuery.cpp
  31. 9
      src/Magnum/GL/PrimitiveQuery.h
  32. 9
      src/Magnum/GL/RectangleTexture.cpp
  33. 9
      src/Magnum/GL/RectangleTexture.h
  34. 8
      src/Magnum/GL/Renderbuffer.cpp
  35. 22
      src/Magnum/GL/Renderbuffer.h
  36. 43
      src/Magnum/GL/SampleQuery.cpp
  37. 11
      src/Magnum/GL/SampleQuery.h
  38. 7
      src/Magnum/GL/Shader.cpp
  39. 19
      src/Magnum/GL/Shader.h
  40. 6
      src/Magnum/GL/Test/AbstractObjectGLTest.cpp
  41. 52
      src/Magnum/GL/Test/AbstractQueryGLTest.cpp
  42. 13
      src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp
  43. 31
      src/Magnum/GL/Test/AbstractTextureGLTest.cpp
  44. 15
      src/Magnum/GL/Test/BufferGLTest.cpp
  45. 26
      src/Magnum/GL/Test/BufferTextureGLTest.cpp
  46. 26
      src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp
  47. 37
      src/Magnum/GL/Test/CubeMapTextureGLTest.cpp
  48. 14
      src/Magnum/GL/Test/FramebufferGLTest.cpp
  49. 14
      src/Magnum/GL/Test/MeshGLTest.cpp
  50. 48
      src/Magnum/GL/Test/MultisampleTextureGLTest.cpp
  51. 40
      src/Magnum/GL/Test/PipelineStatisticsQueryGLTest.cpp
  52. 56
      src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp
  53. 26
      src/Magnum/GL/Test/RectangleTextureGLTest.cpp
  54. 16
      src/Magnum/GL/Test/RenderbufferGLTest.cpp
  55. 57
      src/Magnum/GL/Test/SampleQueryGLTest.cpp
  56. 16
      src/Magnum/GL/Test/ShaderGLTest.cpp
  57. 64
      src/Magnum/GL/Test/TextureArrayGLTest.cpp
  58. 85
      src/Magnum/GL/Test/TextureGLTest.cpp
  59. 60
      src/Magnum/GL/Test/TimeQueryGLTest.cpp
  60. 18
      src/Magnum/GL/Test/TransformFeedbackGLTest.cpp
  61. 15
      src/Magnum/GL/Texture.cpp
  62. 9
      src/Magnum/GL/Texture.h
  63. 11
      src/Magnum/GL/TextureArray.cpp
  64. 9
      src/Magnum/GL/TextureArray.h
  65. 41
      src/Magnum/GL/TimeQuery.cpp
  66. 11
      src/Magnum/GL/TimeQuery.h
  67. 7
      src/Magnum/GL/TransformFeedback.cpp
  68. 21
      src/Magnum/GL/TransformFeedback.h

35
doc/changelog.dox

@ -892,20 +892,27 @@ See also:
@ref Corrade::Containers::ArrayView are now removed. This should have a
significant positive effect on compile times of code using the @ref GL,
@ref Audio, @ref Trade and @ref Text libraries
- As part of the ongoing STL header dependency cleanup,
@ref GL::Context::vendorString(),
@relativeref{GL::Context,rendererString()},
@relativeref{GL::Context,versionString()},
@relativeref{GL::Context,shadingLanguageVersionString()},
@relativeref{GL::Context,shadingLanguageVersionStrings()} and
@relativeref{GL::Context,extensionStrings()} now return
@relativeref{Corrade,Containers::StringView} or a
@relativeref{Corrade,Containers::Array} /
@relativeref{Corrade,Containers::ArrayView} of them, instead of a
@ref std::string and a @ref std::vector. For at least some backwards
compatibility the @ref Corrade/Containers/StringStl.h header is included to
provide implicit conversions to a @ref std::string, but in most cases
you'll be forced to change the code that uses those APIs.
- As part of the ongoing STL header dependency cleanup, the following
breaking changes related to @ref std::string and a @ref std::vector are
done:
- @ref GL::Context::vendorString(),
@relativeref{GL::Context,rendererString()},
@relativeref{GL::Context,versionString()},
@relativeref{GL::Context,shadingLanguageVersionString()},
@relativeref{GL::Context,shadingLanguageVersionStrings()} and
@relativeref{GL::Context,extensionStrings()} now return
@relativeref{Corrade,Containers::StringView} or a
@relativeref{Corrade,Containers::Array} /
@relativeref{Corrade,Containers::ArrayView} of them, instead of a
@ref std::string and a @ref std::vector.
- All @ref GL::Buffer::label() "label()" and
@ref GL::Buffer::setLabel() "setLabel()" APIs now work with a
@relativeref{Corrade,Containers::StringView} /
@relativeref{Corrade,Containers::String} instead of a @ref std::string
To handle most backwards compatibility, @ref Corrade/Containers/StringStl.h
is included in affected headers for implicit conversions from/to a
@ref std::string, but in some cases you may be forced to change the code
that uses those APIs.
- @ref GL::TextureFormat::SR8 and @ref GL::TextureFormat::SRG8 were present
on ES2 builds by mistake --- the @gl_extension{EXT,texture_sRGB_R8} and
@gl_extension{EXT,texture_sRGB_RG8} extensions require OpenGL ES 3.0 at

1
src/Magnum/GL/AbstractFramebuffer.h

@ -29,6 +29,7 @@
* @brief Class @ref Magnum::GL::AbstractFramebuffer, enum @ref Magnum::GL::FramebufferClear, @ref Magnum::GL::FramebufferBlit, @ref Magnum::GL::FramebufferBlitFilter, @ref Magnum::GL::FramebufferTarget, enum set @ref Magnum::GL::FramebufferClearMask
*/
#include <utility> /* std::swap() */
#include <Corrade/Containers/EnumSet.h>
#include "Magnum/GL/GL.h"

59
src/Magnum/GL/AbstractObject.cpp

@ -27,6 +27,9 @@
#include <Corrade/Utility/Assert.h>
#include <Corrade/Containers/ArrayView.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
@ -123,77 +126,65 @@ Int AbstractObject::maxLabelLength() {
return value;
}
void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::ArrayView<const char>) {}
void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::StringView) {}
#ifndef MAGNUM_TARGET_GLES2
void AbstractObject::labelImplementationKhrDesktopES32(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) {
glObjectLabel(identifier, name, label.size(), label);
void AbstractObject::labelImplementationKhrDesktopES32(const GLenum identifier, const GLuint name, const Containers::StringView label) {
glObjectLabel(identifier, name, label.size(), label.data());
}
#endif
#ifdef MAGNUM_TARGET_GLES
void AbstractObject::labelImplementationKhrES(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) {
glObjectLabelKHR(identifier, name, label.size(), label);
void AbstractObject::labelImplementationKhrES(const GLenum identifier, const GLuint name, const Containers::StringView label) {
glObjectLabelKHR(identifier, name, label.size(), label.data());
}
#endif
void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) {
void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::StringView label) {
const GLenum type = extTypeFromKhrIdentifier(identifier);
glLabelObjectEXT(type, name, label.size(), label);
glLabelObjectEXT(type, name, label.size(), label.data());
}
std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; }
Containers::String AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; }
#ifndef MAGNUM_TARGET_GLES2
std::string AbstractObject::getLabelImplementationKhrDesktopES32(const GLenum identifier, const GLuint name) {
Containers::String AbstractObject::getLabelImplementationKhrDesktopES32(const GLenum identifier, const GLuint name) {
/* Get label size (w/o null terminator). Specifying 0 as size is not
allowed, thus we pass the maximum instead. */
GLsizei size = 0;
glGetObjectLabel(identifier, name, maxLabelLength(), &size, nullptr);
/* Make place also for the null terminator */
std::string label;
label.resize(size+1);
glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]);
/* Pop null terminator and return the string */
label.resize(size);
/* The storage already includes the null terminator */
Containers::String label{NoInit, std::size_t(size)};
glGetObjectLabel(identifier, name, size+1, nullptr, label.data());
return label;
}
#endif
#ifdef MAGNUM_TARGET_GLES
std::string AbstractObject::getLabelImplementationKhrES(const GLenum identifier, const GLuint name) {
Containers::String AbstractObject::getLabelImplementationKhrES(const GLenum identifier, const GLuint name) {
/* Get label size (w/o null terminator). Specifying 0 as size is not
allowed, thus we pass the maximum instead. */
GLsizei size = 0;
glGetObjectLabelKHR(identifier, name, maxLabelLength(), &size, nullptr);
/* Make place also for the null terminator */
std::string label;
label.resize(size+1);
glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]);
/* Pop null terminator and return the string */
label.resize(size);
/* The storage already includes the null terminator */
Containers::String label{NoInit, std::size_t(size)};
glGetObjectLabelKHR(identifier, name, size+1, nullptr, label.data());
return label;
}
#endif
std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) {
GLsizei size = 0;
Containers::String AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) {
const GLenum type = extTypeFromKhrIdentifier(identifier);
/* Get label size (w/o null terminator) */
const GLenum type = extTypeFromKhrIdentifier(identifier);
GLsizei size = 0;
glGetObjectLabelEXT(type, name, 0, &size, nullptr);
/* Make place also for the null terminator */
std::string label;
label.resize(size+1);
glGetObjectLabelEXT(type, name, size+1, nullptr, &label[0]);
/* Pop null terminator and return the string */
label.resize(size);
/* The storage already includes the null terminator */
Containers::String label{NoInit, std::size_t(size)};
glGetObjectLabelEXT(type, name, size+1, nullptr, label.data());
return label;
}
#endif

23
src/Magnum/GL/AbstractObject.h

@ -29,13 +29,18 @@
* @brief Class @ref Magnum::GL::AbstractObject
*/
#include <string>
#include <Corrade/Containers/EnumSet.h>
#include "Magnum/Magnum.h"
#include "Magnum/GL/OpenGL.h"
#include "Magnum/GL/visibility.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For the label stuff that used to be a std::string. Won't cover all cases but
should be sufficient. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
namespace Implementation { struct DebugState; }
@ -112,21 +117,21 @@ class MAGNUM_GL_EXPORT AbstractObject {
private:
#ifndef MAGNUM_TARGET_WEBGL
static MAGNUM_GL_LOCAL void labelImplementationNoOp(GLenum, GLuint, Containers::ArrayView<const char> label);
static MAGNUM_GL_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, Containers::ArrayView<const char> label);
static MAGNUM_GL_LOCAL void labelImplementationNoOp(GLenum, GLuint, Containers::StringView label);
static MAGNUM_GL_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, Containers::StringView label);
#ifndef MAGNUM_TARGET_GLES2
static MAGNUM_GL_LOCAL void labelImplementationKhrDesktopES32(GLenum identifier, GLuint name, Containers::ArrayView<const char> label);
static MAGNUM_GL_LOCAL void labelImplementationKhrDesktopES32(GLenum identifier, GLuint name, Containers::StringView label);
#endif
#ifdef MAGNUM_TARGET_GLES
static MAGNUM_GL_LOCAL void labelImplementationKhrES(GLenum identifier, GLuint name, Containers::ArrayView<const char> label);
static MAGNUM_GL_LOCAL void labelImplementationKhrES(GLenum identifier, GLuint name, Containers::StringView label);
#endif
static MAGNUM_GL_LOCAL std::string getLabelImplementationNoOp(GLenum, GLuint);
static MAGNUM_GL_LOCAL std::string getLabelImplementationExt(GLenum identifier, GLuint name);
static MAGNUM_GL_LOCAL Containers::String getLabelImplementationNoOp(GLenum, GLuint);
static MAGNUM_GL_LOCAL Containers::String getLabelImplementationExt(GLenum identifier, GLuint name);
#ifndef MAGNUM_TARGET_GLES2
static MAGNUM_GL_LOCAL std::string getLabelImplementationKhrDesktopES32(GLenum identifier, GLuint name);
static MAGNUM_GL_LOCAL Containers::String getLabelImplementationKhrDesktopES32(GLenum identifier, GLuint name);
#endif
#ifdef MAGNUM_TARGET_GLES
static MAGNUM_GL_LOCAL std::string getLabelImplementationKhrES(GLenum identifier, GLuint name);
static MAGNUM_GL_LOCAL Containers::String getLabelImplementationKhrES(GLenum identifier, GLuint name);
#endif
#endif
};

7
src/Magnum/GL/AbstractQuery.cpp

@ -25,6 +25,9 @@
#include "AbstractQuery.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include <Corrade/Utility/Assert.h>
#include "Magnum/GL/Context.h"
@ -91,7 +94,7 @@ void AbstractQuery::createImplementationDSAExceptPipelineStats() {
#endif
#ifndef MAGNUM_TARGET_WEBGL
std::string AbstractQuery::label() const {
Containers::String AbstractQuery::label() const {
#ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug.getLabelImplementation(GL_QUERY, _id);
#else
@ -99,7 +102,7 @@ std::string AbstractQuery::label() const {
#endif
}
AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayView<const char> label) {
AbstractQuery& AbstractQuery::setLabel(const Containers::StringView label) {
#ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug.labelImplementation(GL_QUERY, _id, label);
#else

22
src/Magnum/GL/AbstractQuery.h

@ -29,6 +29,7 @@
* @brief Class @ref Magnum::GL::AbstractQuery
*/
#include <utility> /* std::swap() */
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Utility/Assert.h>
@ -37,6 +38,12 @@
#include "Magnum/configure.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
namespace Implementation { struct QueryState; }
@ -93,7 +100,7 @@ class MAGNUM_GL_EXPORT AbstractQuery: public AbstractObject {
* @def_gl{QUERY_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label() const;
Containers::String label() const;
/**
* @brief Set query label
@ -108,14 +115,7 @@ class MAGNUM_GL_EXPORT AbstractQuery: public AbstractObject {
* with @def_gl{QUERY_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
AbstractQuery& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> AbstractQuery& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
AbstractQuery& setLabel(Containers::StringView label);
#endif
/**
@ -183,10 +183,6 @@ class MAGNUM_GL_EXPORT AbstractQuery: public AbstractObject {
GLenum _target;
private:
#ifndef MAGNUM_TARGET_WEBGL
AbstractQuery& setLabelInternal(Containers::ArrayView<const char> label);
#endif
void MAGNUM_GL_LOCAL createImplementationDefault();
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL createImplementationDSA();

7
src/Magnum/GL/AbstractShaderProgram.cpp

@ -27,6 +27,9 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StridedArrayView.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/DebugStl.h>
@ -315,7 +318,7 @@ AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&&
}
#ifndef MAGNUM_TARGET_WEBGL
std::string AbstractShaderProgram::label() const {
Containers::String AbstractShaderProgram::label() const {
#ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug.getLabelImplementation(GL_PROGRAM, _id);
#else
@ -323,7 +326,7 @@ std::string AbstractShaderProgram::label() const {
#endif
}
AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayView<const char> label) {
AbstractShaderProgram& AbstractShaderProgram::setLabel(const Containers::StringView label) {
#ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug.labelImplementation(GL_PROGRAM, _id, label);
#else

20
src/Magnum/GL/AbstractShaderProgram.h

@ -41,6 +41,11 @@
#include <vector>
#endif
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
namespace Implementation { struct ShaderProgramState; }
@ -726,7 +731,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @def_gl{PROGRAM_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label() const;
Containers::String label() const;
/**
* @brief Set shader program label
@ -741,14 +746,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* with @def_gl{PROGRAM_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
AbstractShaderProgram& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> AbstractShaderProgram& setLabel(const char (&label)[size]) {
return setLabelInternal({label, size - 1});
}
AbstractShaderProgram& setLabel(Containers::StringView label);
#endif
/**
@ -1647,10 +1645,6 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
#endif
private:
#ifndef MAGNUM_TARGET_WEBGL
AbstractShaderProgram& setLabelInternal(Containers::ArrayView<const char> label);
#endif
void bindAttributeLocationInternal(UnsignedInt location, Containers::ArrayView<const char> name);
#ifndef MAGNUM_TARGET_GLES
void bindFragmentDataLocationIndexedInternal(UnsignedInt location, UnsignedInt index, Containers::ArrayView<const char> name);

7
src/Magnum/GL/AbstractTexture.cpp

@ -27,6 +27,9 @@
#include <tuple>
#include <Corrade/Containers/Array.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include "Magnum/Image.h"
#include "Magnum/ImageView.h"
@ -261,12 +264,12 @@ void AbstractTexture::createIfNotAlready() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string AbstractTexture::label() {
Containers::String AbstractTexture::label() {
createIfNotAlready();
return Context::current().state().debug.getLabelImplementation(GL_TEXTURE, _id);
}
AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayView<const char> label) {
AbstractTexture& AbstractTexture::setLabel(const Containers::StringView label) {
createIfNotAlready();
Context::current().state().debug.labelImplementation(GL_TEXTURE, _id, label);
return *this;

22
src/Magnum/GL/AbstractTexture.h

@ -29,6 +29,7 @@
* @brief Class @ref Magnum::GL::AbstractTexture
*/
#include <utility> /* std::swap() */
#include <Corrade/Containers/ArrayView.h>
#include "Magnum/DimensionTraits.h"
@ -36,6 +37,12 @@
#include "Magnum/GL/AbstractObject.h"
#include "Magnum/GL/GL.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
namespace Implementation {
@ -366,7 +373,7 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject {
* @def_gl{TEXTURE}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label();
Containers::String label();
/**
* @brief Set texture label
@ -381,14 +388,7 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject {
* @def_gl{TEXTURE}
* @requires_gles Debug output is not available in WebGL.
*/
AbstractTexture& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> AbstractTexture& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
AbstractTexture& setLabel(Containers::StringView label);
#endif
/**
@ -443,10 +443,6 @@ class MAGNUM_GL_EXPORT AbstractTexture: public AbstractObject {
explicit AbstractTexture(NoCreateT, GLenum target) noexcept: _target{target}, _id{0}, _flags{ObjectFlag::DeleteOnDestruction} {}
explicit AbstractTexture(GLuint id, GLenum target, ObjectFlags flags) noexcept: _target{target}, _id{id}, _flags{flags} {}
#ifndef MAGNUM_TARGET_WEBGL
AbstractTexture& setLabelInternal(Containers::ArrayView<const char> label);
#endif
void MAGNUM_GL_LOCAL createIfNotAlready();
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)

7
src/Magnum/GL/Buffer.cpp

@ -27,6 +27,9 @@
#include <tuple>
#include <Corrade/Containers/Array.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include <Corrade/Utility/Debug.h>
#include "Magnum/GL/Context.h"
@ -227,7 +230,7 @@ void Buffer::createIfNotAlready() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string Buffer::label() {
Containers::String Buffer::label() {
createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug.getLabelImplementation(GL_BUFFER, _id);
@ -236,7 +239,7 @@ std::string Buffer::label() {
#endif
}
Buffer& Buffer::setLabelInternal(const Containers::ArrayView<const char> label) {
Buffer& Buffer::setLabel(const Containers::StringView label) {
createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug.labelImplementation(GL_BUFFER, _id, label);

21
src/Magnum/GL/Buffer.h

@ -39,6 +39,12 @@
#include "Magnum/GL/AbstractObject.h"
#include "Magnum/GL/GL.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
/**
@ -949,7 +955,7 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
* @def_gl{BUFFER_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label();
Containers::String label();
/**
* @brief Set buffer label
@ -964,14 +970,7 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
* with @def_gl{BUFFER_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
Buffer& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Buffer& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
Buffer& setLabel(Containers::StringView label);
#endif
/** @brief Target hint */
@ -1348,10 +1347,6 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
void MAGNUM_GL_LOCAL createIfNotAlready();
#ifndef MAGNUM_TARGET_WEBGL
Buffer& setLabelInternal(Containers::ArrayView<const char> label);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL storageImplementationDefault(Containers::ArrayView<const void> data, StorageFlags flags);
void MAGNUM_GL_LOCAL storageImplementationDSA(Containers::ArrayView<const void> data, StorageFlags flags);

9
src/Magnum/GL/BufferTexture.cpp

@ -25,6 +25,10 @@
#include "BufferTexture.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#include "Magnum/GL/Buffer.h"
#include "Magnum/GL/BufferTextureFormat.h"
@ -134,5 +138,10 @@ BufferTexture& BufferTexture::resetBuffer() {
return *this;
}
BufferTexture& BufferTexture::setLabel(const Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
}}
#endif

9
src/Magnum/GL/BufferTexture.h

@ -246,14 +246,7 @@ class MAGNUM_GL_EXPORT BufferTexture: public AbstractTexture {
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
BufferTexture& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> BufferTexture& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
BufferTexture& setLabel(const Containers::StringView label);
#endif
private:

7
src/Magnum/GL/CMakeLists.txt

@ -36,6 +36,7 @@ set(MagnumGL_SRCS
Shader.cpp
Texture.cpp
TextureFormat.cpp
TimeQuery.cpp
Version.cpp
Implementation/BufferState.cpp
@ -108,7 +109,9 @@ set(MagnumGL_PRIVATE_HEADERS
# Desktop-only stuff
if(NOT TARGET_GLES)
list(APPEND MagnumGL_SRCS RectangleTexture.cpp)
list(APPEND MagnumGL_SRCS
PipelineStatisticsQuery.cpp
RectangleTexture.cpp)
list(APPEND MagnumGL_HEADERS
PipelineStatisticsQuery.h
RectangleTexture.h)
@ -166,6 +169,8 @@ endif()
# Desktop, OpenGL ES and WebGL 2.0 stuff that is not available in WebGL 1.0
if(NOT (TARGET_WEBGL AND TARGET_GLES2))
list(APPEND MagnumGL_SRCS
SampleQuery.cpp)
list(APPEND MagnumGL_HEADERS
SampleQuery.h)
endif()

11
src/Magnum/GL/CubeMapTexture.cpp

@ -25,6 +25,10 @@
#include "CubeMapTexture.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#include "Magnum/Image.h"
#include "Magnum/ImageView.h"
#ifndef MAGNUM_TARGET_GLES2
@ -727,4 +731,11 @@ void CubeMapTexture::compressedSubImageImplementationDSA(const CubeMapCoordinate
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
CubeMapTexture& CubeMapTexture::setLabel(Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
#endif
}}

9
src/Magnum/GL/CubeMapTexture.h

@ -1221,14 +1221,7 @@ class MAGNUM_GL_EXPORT CubeMapTexture: public AbstractTexture {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
CubeMapTexture& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> CubeMapTexture& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
CubeMapTexture& setLabel(Containers::StringView label);
#endif
private:

7
src/Magnum/GL/CubeMapTextureArray.cpp

@ -26,6 +26,8 @@
#include "CubeMapTextureArray.h"
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
#include <Corrade/Containers/StringView.h>
#include "Magnum/Image.h"
#include "Magnum/GL/BufferImage.h"
#include "Magnum/GL/Context.h"
@ -89,5 +91,10 @@ CompressedBufferImage3D CubeMapTextureArray::compressedSubImage(const Int level,
}
#endif
CubeMapTextureArray& CubeMapTextureArray::setLabel(Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
}}
#endif

9
src/Magnum/GL/CubeMapTextureArray.h

@ -893,14 +893,7 @@ class MAGNUM_GL_EXPORT CubeMapTextureArray: public AbstractTexture {
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
CubeMapTextureArray& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> CubeMapTextureArray& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
CubeMapTextureArray& setLabel(Containers::StringView label);
#endif
private:

7
src/Magnum/GL/Framebuffer.cpp

@ -26,6 +26,9 @@
#include "Framebuffer.h"
#include <Corrade/Containers/Array.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include "Magnum/Image.h"
#include "Magnum/GL/Context.h"
@ -142,12 +145,12 @@ Framebuffer::~Framebuffer() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string Framebuffer::label() {
Containers::String Framebuffer::label() {
createIfNotAlready();
return Context::current().state().debug.getLabelImplementation(GL_FRAMEBUFFER, _id);
}
Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayView<const char> label) {
Framebuffer& Framebuffer::setLabel(const Containers::StringView label) {
createIfNotAlready();
Context::current().state().debug.labelImplementation(GL_FRAMEBUFFER, _id, label);
return *this;

21
src/Magnum/GL/Framebuffer.h

@ -38,6 +38,12 @@
#undef Status
#endif
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
/**
@ -445,7 +451,7 @@ class MAGNUM_GL_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractO
* @def_gl{FRAMEBUFFER}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label();
Containers::String label();
/**
* @brief Set framebuffer label
@ -460,14 +466,7 @@ class MAGNUM_GL_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractO
* @def_gl{FRAMEBUFFER}
* @requires_gles Debug output is not available in WebGL.
*/
Framebuffer& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Framebuffer& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
Framebuffer& setLabel(Containers::StringView label);
#endif
/**
@ -903,10 +902,6 @@ class MAGNUM_GL_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractO
void MAGNUM_GL_LOCAL createImplementationDSA();
#endif
#ifndef MAGNUM_TARGET_WEBGL
Framebuffer& setLabelInternal(Containers::ArrayView<const char> label);
#endif
void MAGNUM_GL_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, GLuint renderbufferId);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, GLuint renderbufferId);

4
src/Magnum/GL/Implementation/DebugState.h

@ -37,8 +37,8 @@ namespace Magnum { namespace GL { namespace Implementation {
struct DebugState {
explicit DebugState(Context& context, Containers::StaticArrayView<Implementation::ExtensionCount, const char*> extensions);
std::string(*getLabelImplementation)(GLenum, GLuint);
void(*labelImplementation)(GLenum, GLuint, Containers::ArrayView<const char>);
Containers::String(*getLabelImplementation)(GLenum, GLuint);
void(*labelImplementation)(GLenum, GLuint, Containers::StringView);
void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugOutput::Severity, Containers::ArrayView<const char>);
void(*controlImplementation)(GLenum, GLenum, GLenum, std::initializer_list<UnsignedInt>, bool);

2
src/Magnum/GL/Implementation/TextureState.cpp

@ -552,7 +552,7 @@ void TextureState::reset() {
i = {{}, State::DisengagedBinding};
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
for(std::tuple<GLuint, GLint, GLboolean, GLint, GLenum>& i: imageBindings)
i = {State::DisengagedBinding, 0, false, 0, 0};
i = std::make_tuple(State::DisengagedBinding, 0, false, 0, 0);
#endif
}

7
src/Magnum/GL/Mesh.cpp

@ -27,6 +27,9 @@
#include <vector>
#include <Corrade/Containers/StridedArrayView.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/Debug.h>
@ -326,7 +329,7 @@ inline void Mesh::createIfNotAlready() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string Mesh::label() {
Containers::String Mesh::label() {
createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug.getLabelImplementation(GL_VERTEX_ARRAY, _id);
@ -335,7 +338,7 @@ std::string Mesh::label() {
#endif
}
Mesh& Mesh::setLabelInternal(const Containers::ArrayView<const char> label) {
Mesh& Mesh::setLabel(const Containers::StringView label) {
createIfNotAlready();
#ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug.labelImplementation(GL_VERTEX_ARRAY, _id, label);

21
src/Magnum/GL/Mesh.h

@ -38,6 +38,12 @@
#include "Magnum/GL/Buffer.h"
#include "Magnum/GL/GL.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
/**
@ -605,7 +611,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
* @def_gl{VERTEX_ARRAY_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label();
Containers::String label();
/**
* @brief Set mesh label
@ -620,14 +626,7 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
* with @def_gl{VERTEX_ARRAY_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
Mesh& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Mesh& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
Mesh& setLabel(Containers::StringView label);
#endif
/**
@ -1134,10 +1133,6 @@ class MAGNUM_GL_EXPORT Mesh: public AbstractObject {
void MAGNUM_GL_LOCAL createIfNotAlready();
#ifndef MAGNUM_TARGET_WEBGL
Mesh& setLabelInternal(Containers::ArrayView<const char> label);
#endif
/* Computing stride of interleaved vertex attributes */
template<UnsignedInt location, class T, class ...U> static GLsizei strideOfInterleaved(const Attribute<location, T>& attribute, const U&... attributes) {
return attribute.vectorStride()*Attribute<location, T>::Vectors + strideOfInterleaved(attributes...);

20
src/Magnum/GL/MultisampleTexture.cpp

@ -26,12 +26,18 @@
#include "MultisampleTexture.h"
#ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Implementation/maxTextureSize.h"
namespace Magnum { namespace GL { namespace Implementation {
namespace Magnum { namespace GL {
namespace Implementation {
template<> Vector2i MAGNUM_GL_EXPORT maxMultisampleTextureSize<2>() {
#ifndef MAGNUM_TARGET_GLES
@ -56,5 +62,15 @@ template<> Vector3i MAGNUM_GL_EXPORT maxMultisampleTextureSize<3>() {
return {Vector2i{Implementation::maxTextureSideSize()}, Implementation::max3DTextureDepth()};
}
}}}
}
template<UnsignedInt dimensions> MultisampleTexture<dimensions>& MultisampleTexture<dimensions>::setLabel(Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
template class MAGNUM_GL_EXPORT MultisampleTexture<2>;
template class MAGNUM_GL_EXPORT MultisampleTexture<3>;
}}
#endif

11
src/Magnum/GL/MultisampleTexture.h

@ -100,7 +100,7 @@ Note that multisample textures don't support compressed formats.
array textures.
@requires_gles Multisample textures are not available in WebGL.
*/
template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTexture {
template<UnsignedInt dimensions> class MAGNUM_GL_EXPORT MultisampleTexture: public AbstractTexture {
public:
enum: UnsignedInt {
Dimensions = dimensions /**< Texture dimension count */
@ -302,14 +302,7 @@ template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTextur
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
MultisampleTexture<dimensions>& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> MultisampleTexture<dimensions>& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
MultisampleTexture<dimensions>& setLabel(Containers::StringView label);
#endif
private:

43
src/Magnum/GL/PipelineStatisticsQuery.cpp

@ -0,0 +1,43 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "PipelineStatisticsQuery.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#ifndef MAGNUM_TARGET_GLES
namespace Magnum { namespace GL {
#ifndef MAGNUM_TARGET_WEBGL
PipelineStatisticsQuery& PipelineStatisticsQuery::setLabel(Containers::StringView label) {
AbstractQuery::setLabel(label);
return *this;
}
#endif
}}
#endif

11
src/Magnum/GL/PipelineStatisticsQuery.h

@ -48,7 +48,7 @@ performance measurements.
WebGL.
@see @ref PrimitiveQuery, @ref SampleQuery, @ref TimeQuery
*/
class PipelineStatisticsQuery: public AbstractQuery {
class MAGNUM_GL_EXPORT PipelineStatisticsQuery: public AbstractQuery {
public:
/**
* @brief Query target
@ -164,14 +164,7 @@ class PipelineStatisticsQuery: public AbstractQuery {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
PipelineStatisticsQuery& setLabel(const std::string& label) {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> PipelineStatisticsQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
PipelineStatisticsQuery& setLabel(Containers::StringView label);
#endif
private:

11
src/Magnum/GL/PrimitiveQuery.cpp

@ -25,6 +25,10 @@
#include "PrimitiveQuery.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
namespace Magnum { namespace GL {
void PrimitiveQuery::begin() {
@ -49,4 +53,11 @@ void PrimitiveQuery::end() {
#endif
}
#ifndef MAGNUM_TARGET_WEBGL
PrimitiveQuery& PrimitiveQuery::setLabel(Containers::StringView label) {
AbstractQuery::setLabel(label);
return *this;
}
#endif
}}

9
src/Magnum/GL/PrimitiveQuery.h

@ -202,14 +202,7 @@ class MAGNUM_GL_EXPORT PrimitiveQuery: public AbstractQuery {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
PrimitiveQuery& setLabel(const std::string& label) {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> PrimitiveQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
PrimitiveQuery& setLabel(Containers::StringView label);
#endif
private:

9
src/Magnum/GL/RectangleTexture.cpp

@ -25,6 +25,10 @@
#include "RectangleTexture.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#ifndef MAGNUM_TARGET_GLES
#include "Magnum/Image.h"
#include "Magnum/GL/BufferImage.h"
@ -88,5 +92,10 @@ CompressedBufferImage2D RectangleTexture::compressedSubImage(const Range2Di& ran
return std::move(image);
}
RectangleTexture& RectangleTexture::setLabel(Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
}}
#endif

9
src/Magnum/GL/RectangleTexture.h

@ -708,14 +708,7 @@ class MAGNUM_GL_EXPORT RectangleTexture: public AbstractTexture {
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
RectangleTexture& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> RectangleTexture& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
RectangleTexture& setLabel(Containers::StringView label);
#endif
private:

8
src/Magnum/GL/Renderbuffer.cpp

@ -25,6 +25,10 @@
#include "Renderbuffer.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
@ -106,12 +110,12 @@ inline void Renderbuffer::createIfNotAlready() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string Renderbuffer::label() {
Containers::String Renderbuffer::label() {
createIfNotAlready();
return Context::current().state().debug.getLabelImplementation(GL_RENDERBUFFER, _id);
}
Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayView<const char> label) {
Renderbuffer& Renderbuffer::setLabel(const Containers::StringView label) {
createIfNotAlready();
Context::current().state().debug.labelImplementation(GL_RENDERBUFFER, _id, label);
return *this;

22
src/Magnum/GL/Renderbuffer.h

@ -29,12 +29,19 @@
* @brief Class @ref Magnum::GL::Renderbuffer
*/
#include <utility> /* std::swap() */
#include <Corrade/Containers/ArrayView.h>
#include "Magnum/Tags.h"
#include "Magnum/GL/AbstractObject.h"
#include "Magnum/GL/GL.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
namespace Implementation { struct FramebufferState; }
@ -183,7 +190,7 @@ class MAGNUM_GL_EXPORT Renderbuffer: public AbstractObject {
* @def_gl{RENDERBUFFER}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label();
Containers::String label();
/**
* @brief Set renderbuffer label
@ -198,14 +205,7 @@ class MAGNUM_GL_EXPORT Renderbuffer: public AbstractObject {
* @def_gl{RENDERBUFFER}
* @requires_gles Debug output is not available in WebGL.
*/
Renderbuffer& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Renderbuffer& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
Renderbuffer& setLabel(Containers::StringView label);
#endif
/**
@ -255,10 +255,6 @@ class MAGNUM_GL_EXPORT Renderbuffer: public AbstractObject {
void MAGNUM_GL_LOCAL createIfNotAlready();
#ifndef MAGNUM_TARGET_WEBGL
Renderbuffer& setLabelInternal(Containers::ArrayView<const char> label);
#endif
void MAGNUM_GL_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_GL_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size);

43
src/Magnum/GL/SampleQuery.cpp

@ -0,0 +1,43 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "SampleQuery.h"
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
namespace Magnum { namespace GL {
#ifndef MAGNUM_TARGET_WEBGL
SampleQuery& SampleQuery::setLabel(Containers::StringView label) {
AbstractQuery::setLabel(label);
return *this;
}
#endif
}}
#endif

11
src/Magnum/GL/SampleQuery.h

@ -58,7 +58,7 @@ waiting for the result.
OpenGL ES 2.0.
@requires_webgl20 Queries are not available in WebGL 1.0.
*/
class SampleQuery: public AbstractQuery {
class MAGNUM_GL_EXPORT SampleQuery: public AbstractQuery {
public:
/**
* @brief Query target
@ -250,14 +250,7 @@ class SampleQuery: public AbstractQuery {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
SampleQuery& setLabel(const std::string& label) {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> SampleQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
SampleQuery& setLabel(Containers::StringView label);
#endif
private:

7
src/Magnum/GL/Shader.cpp

@ -27,6 +27,9 @@
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Reference.h>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/Debug.h>
#include <Corrade/Utility/DebugStl.h>
@ -679,7 +682,7 @@ Shader::~Shader() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string Shader::label() const {
Containers::String Shader::label() const {
#ifndef MAGNUM_TARGET_GLES2
return Context::current().state().debug.getLabelImplementation(GL_SHADER, _id);
#else
@ -687,7 +690,7 @@ std::string Shader::label() const {
#endif
}
Shader& Shader::setLabelInternal(const Containers::ArrayView<const char> label) {
Shader& Shader::setLabel(const Containers::StringView label) {
#ifndef MAGNUM_TARGET_GLES2
Context::current().state().debug.labelImplementation(GL_SHADER, _id, label);
#else

19
src/Magnum/GL/Shader.h

@ -37,6 +37,12 @@
#include "Magnum/GL/AbstractObject.h"
#include "Magnum/GL/GL.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
namespace Magnum { namespace GL {
namespace Implementation { struct ShaderState; }
@ -581,7 +587,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
* @def_gl{SHADER_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label() const;
Containers::String label() const;
/**
* @brief Set shader label
@ -596,14 +602,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
* with @def_gl{SHADER_OBJECT_EXT}
* @requires_gles Debug output is not available in WebGL.
*/
Shader& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
/** @overload */
template<std::size_t size> Shader& setLabel(const char(&label)[size]) {
return setLabelInternal({label, size - 1});
}
Shader& setLabel(Containers::StringView label);
#endif
/** @brief Shader type */
@ -645,8 +644,6 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
bool compile();
private:
Shader& setLabelInternal(Containers::ArrayView<const char> label);
void MAGNUM_GL_LOCAL addSourceImplementationDefault(std::string source);
#if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__)
void MAGNUM_GL_LOCAL addSourceImplementationEmscriptenPthread(std::string source);

6
src/Magnum/GL/Test/AbstractObjectGLTest.cpp

@ -23,13 +23,15 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Buffer.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/OpenGLTester.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct AbstractObjectGLTest: OpenGLTester {

52
src/Magnum/GL/Test/AbstractQueryGLTest.cpp

@ -23,8 +23,6 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/OpenGLTester.h"
@ -38,19 +36,14 @@ struct AbstractQueryGLTest: OpenGLTester {
void construct();
void constructMove();
#ifndef MAGNUM_TARGET_WEBGL
void label();
#endif
/* label() tested in subclasses because these all have to provide overloads
to return correct type for method chaining and these overloads have to
be deinlined to avoid including a StringView */
};
AbstractQueryGLTest::AbstractQueryGLTest() {
addTests({&AbstractQueryGLTest::construct,
&AbstractQueryGLTest::constructMove,
#ifndef MAGNUM_TARGET_WEBGL
&AbstractQueryGLTest::label
#endif
});
&AbstractQueryGLTest::constructMove});
}
void AbstractQueryGLTest::construct() {
@ -110,43 +103,6 @@ void AbstractQueryGLTest::constructMove() {
/* nothrow move constructibility tested in subclasses */
}
#ifndef MAGNUM_TARGET_WEBGL
void AbstractQueryGLTest::label() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::EXT::occlusion_query_boolean>())
CORRADE_SKIP(Extensions::EXT::occlusion_query_boolean::string() << "is not supported.");
#endif
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
#ifndef MAGNUM_TARGET_GLES
SampleQuery query{SampleQuery::Target::SamplesPassed};
#else
SampleQuery query{SampleQuery::Target::AnySamplesPassed};
#endif
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
#endif
{
query.begin(); query.end();
CORRADE_EXPECT_FAIL("Without ARB_direct_state_access, the object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
CORRADE_COMPARE(query.label(), "");
query.setLabel("MyQuery");
CORRADE_COMPARE(query.label(), "MyQuery");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
}}}}
CORRADE_TEST_MAIN(Magnum::GL::Test::AbstractQueryGLTest)

13
src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp

@ -46,6 +46,10 @@
#include "Magnum/Math/Vector4.h"
#include "Magnum/Math/Color.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct AbstractShaderProgramGLTest: OpenGLTester {
@ -129,6 +133,8 @@ AbstractShaderProgramGLTest::AbstractShaderProgramGLTest() {
});
}
using namespace Containers::Literals;
class DummyShader: public AbstractShaderProgram {
public:
explicit DummyShader() {}
@ -180,9 +186,12 @@ void AbstractShaderProgramGLTest::label() {
DummyShader shader;
CORRADE_COMPARE(shader.label(), "");
shader.setLabel("DummyShader");
CORRADE_COMPARE(shader.label(), "DummyShader");
/* Test the string size gets correctly used, instead of relying on null
termination */
shader.setLabel("DummyShader!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(shader.label(), "DummyShader");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif

31
src/Magnum/GL/Test/AbstractTextureGLTest.cpp

@ -43,6 +43,10 @@ struct AbstractTextureGLTest: OpenGLTester {
void construct();
void constructMove();
/* label() tested in subclasses because these all have to provide overloads
to return correct type for method chaining and these overloads have to
be deinlined to avoid including a StringView */
#ifndef MAGNUM_TARGET_GLES
void imageQueryViewNullptr();
void imageQueryViewBadSize();
@ -58,10 +62,6 @@ struct AbstractTextureGLTest: OpenGLTester {
void compressedSubImageQueryViewBadDataSize();
void compressedSubImageQueryViewBadFormat();
#endif
#ifndef MAGNUM_TARGET_WEBGL
void label();
#endif
};
AbstractTextureGLTest::AbstractTextureGLTest() {
@ -83,10 +83,6 @@ AbstractTextureGLTest::AbstractTextureGLTest() {
&AbstractTextureGLTest::compressedSubImageQueryViewBadDataSize,
&AbstractTextureGLTest::compressedSubImageQueryViewBadFormat,
#endif
#ifndef MAGNUM_TARGET_WEBGL
&AbstractTextureGLTest::label
#endif
});
}
@ -393,25 +389,6 @@ void AbstractTextureGLTest::compressedSubImageQueryViewBadFormat() {
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
void AbstractTextureGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
Texture2D texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
texture.setLabel("MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
}
#endif
}}}}
CORRADE_TEST_MAIN(Magnum::GL::Test::AbstractTextureGLTest)

15
src/Magnum/GL/Test/BufferGLTest.cpp

@ -28,13 +28,16 @@
#include <vector>
#include <Corrade/Containers/Array.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Buffer.h"
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/OpenGLTester.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct BufferGLTest: OpenGLTester {
@ -103,6 +106,10 @@ BufferGLTest::BufferGLTest() {
&BufferGLTest::invalidate});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void BufferGLTest::construct() {
{
Buffer buffer;
@ -194,14 +201,16 @@ void BufferGLTest::label() {
CORRADE_SKIP("Required extension is not available");
Buffer buffer;
CORRADE_COMPARE(buffer.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
buffer.setLabel("MyBuffer");
/* Test the string size gets correctly used, instead of relying on null
termination */
buffer.setLabel("MyBuffer!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(buffer.label(), "MyBuffer");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif

26
src/Magnum/GL/Test/BufferTextureGLTest.cpp

@ -24,6 +24,7 @@
*/
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/GL/Buffer.h"
@ -48,6 +49,8 @@ struct BufferTextureGLTest: OpenGLTester {
void constructMove();
void wrap();
void label();
void bind();
void bindImage();
@ -72,6 +75,8 @@ BufferTextureGLTest::BufferTextureGLTest() {
&BufferTextureGLTest::constructMove,
&BufferTextureGLTest::wrap,
&BufferTextureGLTest::label,
&BufferTextureGLTest::bind,
&BufferTextureGLTest::bindImage,
@ -92,6 +97,8 @@ BufferTextureGLTest::BufferTextureGLTest() {
});
}
using namespace Containers::Literals;
void BufferTextureGLTest::construct() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_buffer_object>())
@ -143,6 +150,25 @@ void BufferTextureGLTest::wrap() {
glDeleteTextures(1, &id);
}
void BufferTextureGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
BufferTexture texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void BufferTextureGLTest::bind() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_buffer_object>())

26
src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h"
@ -47,6 +48,8 @@ struct CubeMapTextureArrayGLTest: OpenGLTester {
void constructMove();
void wrap();
void label();
void bind();
void bindImage();
@ -269,6 +272,8 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() {
&CubeMapTextureArrayGLTest::constructMove,
&CubeMapTextureArrayGLTest::wrap,
&CubeMapTextureArrayGLTest::label,
&CubeMapTextureArrayGLTest::bind,
&CubeMapTextureArrayGLTest::bindImage,
@ -326,6 +331,8 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() {
&CubeMapTextureArrayGLTest::invalidateSubImage});
}
using namespace Containers::Literals;
void CubeMapTextureArrayGLTest::construct() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_cube_map_array>())
@ -377,6 +384,25 @@ void CubeMapTextureArrayGLTest::wrap() {
glDeleteTextures(1, &id);
}
void CubeMapTextureArrayGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
CubeMapTextureArray texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void CubeMapTextureArrayGLTest::bind() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_cube_map_array>())

37
src/Magnum/GL/Test/CubeMapTextureGLTest.cpp

@ -44,6 +44,10 @@
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct CubeMapTextureGLTest: OpenGLTester {
@ -53,6 +57,10 @@ struct CubeMapTextureGLTest: OpenGLTester {
void constructMove();
void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label();
#endif
void bind();
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
void bindImage();
@ -312,6 +320,10 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
&CubeMapTextureGLTest::constructMove,
&CubeMapTextureGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&CubeMapTextureGLTest::label,
#endif
&CubeMapTextureGLTest::bind,
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&CubeMapTextureGLTest::bindImage,
@ -437,6 +449,10 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() {
&CubeMapTextureGLTest::invalidateSubImage});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
template<std::size_t size, class T> Containers::ArrayView<const T> unsafeSuffix(const T(&data)[size], std::size_t offset) {
static_assert(sizeof(T) == 1, "");
return {data - offset, size + offset};
@ -477,6 +493,27 @@ void CubeMapTextureGLTest::wrap() {
glDeleteTextures(1, &id);
}
#ifndef MAGNUM_TARGET_WEBGL
void CubeMapTextureGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
CubeMapTexture texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
void CubeMapTextureGLTest::bind() {
CubeMapTexture texture;
texture.bind(15);

14
src/Magnum/GL/Test/FramebufferGLTest.cpp

@ -41,6 +41,10 @@
#include "Magnum/GL/TextureFormat.h"
#include "Magnum/Math/Color.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#ifndef MAGNUM_TARGET_GLES2
#include "Magnum/GL/BufferImage.h"
#include "Magnum/GL/TextureArray.h"
@ -323,6 +327,10 @@ FramebufferGLTest::FramebufferGLTest() {
#endif
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void FramebufferGLTest::construct() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::framebuffer_object>())
@ -405,14 +413,16 @@ void FramebufferGLTest::label() {
CORRADE_SKIP("Required extension is not supported");
Framebuffer framebuffer({{}, Vector2i(32)});
CORRADE_COMPARE(framebuffer.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
framebuffer.setLabel("MyFramebuffer");
/* Test the string size gets correctly used, instead of relying on null
termination */
framebuffer.setLabel("MyFramebuffer!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(framebuffer.label(), "MyFramebuffer");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif

14
src/Magnum/GL/Test/MeshGLTest.cpp

@ -49,6 +49,10 @@
#include "Magnum/Math/Matrix.h"
#include "Magnum/Math/Vector4.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
/* Tests also the MeshView class. */
@ -741,6 +745,10 @@ MeshGLTest::MeshGLTest() {
Renderer::setClearColor(0x000000_rgbf);
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void MeshGLTest::construct() {
{
const Mesh mesh;
@ -925,14 +933,16 @@ void MeshGLTest::label() {
CORRADE_SKIP("Required extension is not supported");
Mesh mesh;
CORRADE_COMPARE(mesh.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
mesh.setLabel("MyMesh");
/* Test the string size gets correctly used, instead of relying on null
termination */
mesh.setLabel("MyMesh!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(mesh.label(), "MyMesh");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif

48
src/Magnum/GL/Test/MultisampleTextureGLTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/GL/Context.h"
@ -46,6 +47,9 @@ struct MultisampleTextureGLTest: OpenGLTester {
void wrap2D();
void wrap2DArray();
void label2D();
void label2DArray();
void bind2D();
void bind2DArray();
@ -71,6 +75,9 @@ MultisampleTextureGLTest::MultisampleTextureGLTest() {
&MultisampleTextureGLTest::wrap2D,
&MultisampleTextureGLTest::wrap2DArray,
&MultisampleTextureGLTest::label2D,
&MultisampleTextureGLTest::label2DArray,
&MultisampleTextureGLTest::bind2D,
&MultisampleTextureGLTest::bind2DArray,
@ -87,6 +94,8 @@ MultisampleTextureGLTest::MultisampleTextureGLTest() {
&MultisampleTextureGLTest::invalidateSubImage2DArray});
}
using namespace Containers::Literals;
void MultisampleTextureGLTest::construct2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_multisample>())
@ -180,6 +189,45 @@ void MultisampleTextureGLTest::wrap2DArray() {
glDeleteTextures(1, &id);
}
void MultisampleTextureGLTest::label2D() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
MultisampleTexture2D texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void MultisampleTextureGLTest::label2DArray() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
MultisampleTexture2DArray texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void MultisampleTextureGLTest::bind2D() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_multisample>())

40
src/Magnum/GL/Test/PipelineStatisticsQueryGLTest.cpp

@ -23,6 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Numeric.h>
#include "Magnum/GL/AbstractShaderProgram.h"
@ -45,6 +46,8 @@ struct PipelineStatisticsQueryGLTest: OpenGLTester {
void constructMove();
void wrap();
void label();
void queryVerticesSubmitted();
};
@ -52,9 +55,13 @@ PipelineStatisticsQueryGLTest::PipelineStatisticsQueryGLTest() {
addTests({&PipelineStatisticsQueryGLTest::constructMove,
&PipelineStatisticsQueryGLTest::wrap,
&PipelineStatisticsQueryGLTest::label,
&PipelineStatisticsQueryGLTest::queryVerticesSubmitted});
}
using namespace Containers::Literals;
void PipelineStatisticsQueryGLTest::constructMove() {
/* Move constructor tested in AbstractQuery, here we just verify there
are no extra members that would need to be taken care of */
@ -82,6 +89,39 @@ void PipelineStatisticsQueryGLTest::wrap() {
glDeleteQueries(1, &id);
}
void PipelineStatisticsQueryGLTest::label() {
if(!Context::current().isExtensionSupported<Extensions::ARB::pipeline_statistics_query>())
CORRADE_SKIP(Extensions::ARB::pipeline_statistics_query::string() << "is not available");
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
PipelineStatisticsQuery query{PipelineStatisticsQuery::Target::ClippingInputPrimitives};
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
#endif
{
query.begin(); query.end();
CORRADE_EXPECT_FAIL("Without ARB_direct_state_access, the object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
CORRADE_COMPARE(query.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
query.setLabel("MyQuery!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(query.label(), "MyQuery");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void PipelineStatisticsQueryGLTest::queryVerticesSubmitted() {
if(!Context::current().isExtensionSupported<Extensions::ARB::pipeline_statistics_query>())
CORRADE_SKIP(Extensions::ARB::pipeline_statistics_query::string() << "is not available");

56
src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp

@ -41,6 +41,10 @@
#include "Magnum/GL/TransformFeedback.h"
#include "Magnum/Math/Vector2.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct PrimitiveQueryGLTest: OpenGLTester {
@ -49,6 +53,10 @@ struct PrimitiveQueryGLTest: OpenGLTester {
void constructMove();
void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label();
#endif
#ifndef MAGNUM_TARGET_WEBGL
void primitivesGenerated();
#endif
@ -65,6 +73,10 @@ PrimitiveQueryGLTest::PrimitiveQueryGLTest() {
addTests({&PrimitiveQueryGLTest::constructMove,
&PrimitiveQueryGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&PrimitiveQueryGLTest::label,
#endif
#ifndef MAGNUM_TARGET_WEBGL
&PrimitiveQueryGLTest::primitivesGenerated,
#endif
@ -78,6 +90,10 @@ PrimitiveQueryGLTest::PrimitiveQueryGLTest() {
});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void PrimitiveQueryGLTest::constructMove() {
/* Move constructor tested in AbstractQuery. Compared to other *Query
classes, PrimitiveQuery contains an additional layer ID, which is
@ -113,6 +129,46 @@ void PrimitiveQueryGLTest::wrap() {
glDeleteQueries(1, &id);
}
#ifndef MAGNUM_TARGET_WEBGL
void PrimitiveQueryGLTest::label() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::EXT::transform_feedback>())
CORRADE_SKIP(Extensions::EXT::transform_feedback::string() << "is not supported.");
#else
if(!Context::current().isExtensionSupported<Extensions::EXT::geometry_shader>())
CORRADE_SKIP(Extensions::EXT::geometry_shader::string() << "is not supported.");
#endif
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
PrimitiveQuery query{PrimitiveQuery::Target::PrimitivesGenerated};
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
#endif
{
query.begin(); query.end();
CORRADE_EXPECT_FAIL("Without ARB_direct_state_access, the object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
CORRADE_COMPARE(query.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
query.setLabel("MyQuery!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(query.label(), "MyQuery");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
void PrimitiveQueryGLTest::primitivesGenerated() {
#ifndef MAGNUM_TARGET_GLES

26
src/Magnum/GL/Test/RectangleTextureGLTest.cpp

@ -24,6 +24,7 @@
*/
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Compare/Container.h>
#include "Magnum/Image.h"
@ -48,6 +49,8 @@ struct RectangleTextureGLTest: OpenGLTester {
void constructMove();
void wrap();
void label();
void bind();
void bindImage();
@ -119,6 +122,8 @@ RectangleTextureGLTest::RectangleTextureGLTest() {
&RectangleTextureGLTest::constructMove,
&RectangleTextureGLTest::wrap,
&RectangleTextureGLTest::label,
&RectangleTextureGLTest::bind,
&RectangleTextureGLTest::bindImage,
@ -155,6 +160,8 @@ RectangleTextureGLTest::RectangleTextureGLTest() {
&RectangleTextureGLTest::invalidateSubImage});
}
using namespace Containers::Literals;
void RectangleTextureGLTest::construct() {
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::ARB::texture_rectangle::string() << "is not supported.");
@ -196,6 +203,25 @@ void RectangleTextureGLTest::wrap() {
glDeleteTextures(1, &id);
}
void RectangleTextureGLTest::label() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
RectangleTexture texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void RectangleTextureGLTest::bind() {
if(!Context::current().isExtensionSupported<Extensions::ARB::texture_rectangle>())
CORRADE_SKIP(Extensions::ARB::texture_rectangle::string() << "is not supported.");

16
src/Magnum/GL/Test/RenderbufferGLTest.cpp

@ -23,8 +23,6 @@
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/OpenGLTester.h"
@ -32,6 +30,10 @@
#include "Magnum/GL/RenderbufferFormat.h"
#include "Magnum/Math/Vector2.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct RenderbufferGLTest: OpenGLTester {
@ -68,6 +70,10 @@ RenderbufferGLTest::RenderbufferGLTest() {
});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void RenderbufferGLTest::construct() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::framebuffer_object>())
@ -145,14 +151,16 @@ void RenderbufferGLTest::label() {
CORRADE_SKIP("Required extension is not available");
Renderbuffer renderbuffer;
CORRADE_COMPARE(renderbuffer.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
renderbuffer.setLabel("MyRenderbuffer");
/* Test the string size gets correctly used, instead of relying on null
termination */
renderbuffer.setLabel("MyRenderbuffer!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(renderbuffer.label(), "MyRenderbuffer");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif

57
src/Magnum/GL/Test/SampleQueryGLTest.cpp

@ -39,6 +39,10 @@
#include "Magnum/GL/SampleQuery.h"
#include "Magnum/GL/Shader.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct SampleQueryGLTest: OpenGLTester {
@ -47,6 +51,10 @@ struct SampleQueryGLTest: OpenGLTester {
void constructMove();
void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label();
#endif
void querySamplesPassed();
#ifndef MAGNUM_TARGET_GLES
void conditionalRender();
@ -57,6 +65,10 @@ SampleQueryGLTest::SampleQueryGLTest() {
addTests({&SampleQueryGLTest::constructMove,
&SampleQueryGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&SampleQueryGLTest::label,
#endif
&SampleQueryGLTest::querySamplesPassed,
#ifndef MAGNUM_TARGET_GLES
&SampleQueryGLTest::conditionalRender
@ -64,6 +76,10 @@ SampleQueryGLTest::SampleQueryGLTest() {
});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void SampleQueryGLTest::constructMove() {
/* Move constructor tested in AbstractQuery, here we just verify there
are no extra members that would need to be taken care of */
@ -101,6 +117,47 @@ void SampleQueryGLTest::wrap() {
#endif
}
#ifndef MAGNUM_TARGET_WEBGL
void SampleQueryGLTest::label() {
#ifdef MAGNUM_TARGET_GLES2
if(!Context::current().isExtensionSupported<Extensions::EXT::occlusion_query_boolean>())
CORRADE_SKIP(Extensions::EXT::occlusion_query_boolean::string() << "is not supported.");
#endif
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
#ifndef MAGNUM_TARGET_GLES
SampleQuery query{SampleQuery::Target::SamplesPassed};
#else
SampleQuery query{SampleQuery::Target::AnySamplesPassed};
#endif
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
#endif
{
query.begin(); query.end();
CORRADE_EXPECT_FAIL("Without ARB_direct_state_access, the object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
CORRADE_COMPARE(query.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
query.setLabel("MyQuery!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(query.label(), "MyQuery");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
struct MyShader: public AbstractShaderProgram {
typedef Attribute<0, Vector2> Position;

16
src/Magnum/GL/Test/ShaderGLTest.cpp

@ -31,6 +31,10 @@
#include "Magnum/GL/Shader.h"
#include "Magnum/GL/OpenGLTester.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include "configure.h"
namespace Magnum { namespace GL { namespace Test { namespace {
@ -71,6 +75,10 @@ ShaderGLTest::ShaderGLTest() {
&ShaderGLTest::compileNoVersion});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void ShaderGLTest::construct() {
{
#ifndef MAGNUM_TARGET_GLES
@ -155,10 +163,14 @@ void ShaderGLTest::label() {
Shader shader(Version::GLES200, Shader::Type::Vertex);
#endif
CORRADE_COMPARE(shader.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
shader.setLabel("MyShader");
CORRADE_COMPARE(shader.label(), "MyShader");
/* Test the string size gets correctly used, instead of relying on null
termination */
shader.setLabel("MyShader!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(shader.label(), "MyShader");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif

64
src/Magnum/GL/Test/TextureArrayGLTest.cpp

@ -37,6 +37,10 @@
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#ifndef MAGNUM_TARGET_WEBGL
#include "Magnum/GL/ImageFormat.h"
#endif
@ -58,6 +62,13 @@ struct TextureArrayGLTest: OpenGLTester {
#endif
void wrap2D();
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES
void label1D();
#endif
void label2D();
#endif
#ifndef MAGNUM_TARGET_GLES
void bind1D();
#endif
@ -282,6 +293,13 @@ TextureArrayGLTest::TextureArrayGLTest() {
#endif
&TextureArrayGLTest::wrap2D,
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::label1D,
#endif
&TextureArrayGLTest::label2D,
#endif
#ifndef MAGNUM_TARGET_GLES
&TextureArrayGLTest::bind1D,
#endif
@ -406,6 +424,10 @@ TextureArrayGLTest::TextureArrayGLTest() {
});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
#ifndef MAGNUM_TARGET_GLES
void TextureArrayGLTest::construct1D() {
if(!Context::current().isExtensionSupported<Extensions::EXT::texture_array>())
@ -484,6 +506,48 @@ void TextureArrayGLTest::wrap2D() {
glDeleteTextures(1, &id);
}
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES
void TextureArrayGLTest::label1D() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
Texture1DArray texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
void TextureArrayGLTest::label2D() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
Texture2DArray texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#ifndef MAGNUM_TARGET_GLES
void TextureArrayGLTest::bind1D() {
if(!Context::current().isExtensionSupported<Extensions::EXT::texture_array>())

85
src/Magnum/GL/Test/TextureGLTest.cpp

@ -42,6 +42,10 @@
#include "Magnum/Math/Color.h"
#include "Magnum/Math/Range.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct TextureGLTest: OpenGLTester {
@ -65,6 +69,14 @@ struct TextureGLTest: OpenGLTester {
void wrap3D();
#endif
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES
void label1D();
#endif
void label2D();
void label3D();
#endif
#ifndef MAGNUM_TARGET_GLES
void bind1D();
#endif
@ -445,6 +457,14 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::wrap3D,
#endif
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::label1D,
#endif
&TextureGLTest::label2D,
&TextureGLTest::label3D,
#endif
#ifndef MAGNUM_TARGET_GLES
&TextureGLTest::bind1D,
#endif
@ -652,6 +672,10 @@ TextureGLTest::TextureGLTest() {
&TextureGLTest::srgbAlphaStorage});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
#ifndef MAGNUM_TARGET_GLES
void TextureGLTest::construct1D() {
{
@ -757,6 +781,67 @@ void TextureGLTest::wrap3D() {
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
#ifndef MAGNUM_TARGET_GLES
void TextureGLTest::label1D() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
Texture1D texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
void TextureGLTest::label2D() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
Texture2D texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
void TextureGLTest::label3D() {
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
Texture3D texture;
CORRADE_COMPARE(texture.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
texture.setLabel("MyTexture!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(texture.label(), "MyTexture");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
#ifndef MAGNUM_TARGET_GLES
void TextureGLTest::bind1D() {
Texture1D texture;

60
src/Magnum/GL/Test/TimeQueryGLTest.cpp

@ -22,7 +22,6 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/TestSuite/Compare/Numeric.h>
#include "Magnum/GL/Context.h"
@ -33,6 +32,10 @@
#include "Magnum/GL/RenderbufferFormat.h"
#include "Magnum/GL/TimeQuery.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct TimeQueryGLTest: OpenGLTester {
@ -41,6 +44,10 @@ struct TimeQueryGLTest: OpenGLTester {
void constructMove();
void wrap();
#ifndef MAGNUM_TARGET_WEBGL
void label();
#endif
void queryTime();
void queryTimestamp();
};
@ -49,10 +56,18 @@ TimeQueryGLTest::TimeQueryGLTest() {
addTests({&TimeQueryGLTest::constructMove,
&TimeQueryGLTest::wrap,
#ifndef MAGNUM_TARGET_WEBGL
&TimeQueryGLTest::label,
#endif
&TimeQueryGLTest::queryTime,
&TimeQueryGLTest::queryTimestamp});
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void TimeQueryGLTest::constructMove() {
/* Move constructor tested in AbstractQuery, here we just verify there
are no extra members that would need to be taken care of */
@ -96,6 +111,49 @@ void TimeQueryGLTest::wrap() {
#endif
}
#ifndef MAGNUM_TARGET_WEBGL
void TimeQueryGLTest::label() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::timer_query>())
CORRADE_SKIP(Extensions::ARB::timer_query::string() << "is not supported.");
#elif defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
if(!Context::current().isExtensionSupported<Extensions::EXT::disjoint_timer_query_webgl2>())
CORRADE_SKIP(Extensions::EXT::disjoint_timer_query_webgl2::string() << "is not supported.");
#else
if(!Context::current().isExtensionSupported<Extensions::EXT::disjoint_timer_query>())
CORRADE_SKIP(Extensions::EXT::disjoint_timer_query::string() << "is not supported.");
#endif
/* No-Op version is tested in AbstractObjectGLTest */
if(!Context::current().isExtensionSupported<Extensions::KHR::debug>() &&
!Context::current().isExtensionSupported<Extensions::EXT::debug_label>())
CORRADE_SKIP("Required extension is not available");
TimeQuery query{TimeQuery::Target::TimeElapsed};
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::direct_state_access>())
#endif
{
query.begin(); query.end();
CORRADE_EXPECT_FAIL("Without ARB_direct_state_access, the object must be used at least once before setting/querying label.");
CORRADE_VERIFY(false);
}
CORRADE_COMPARE(query.label(), "");
MAGNUM_VERIFY_NO_GL_ERROR();
/* Test the string size gets correctly used, instead of relying on null
termination */
query.setLabel("MyQuery!"_s.except(1));
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(query.label(), "MyQuery");
MAGNUM_VERIFY_NO_GL_ERROR();
}
#endif
void TimeQueryGLTest::queryTime() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::timer_query>())

18
src/Magnum/GL/Test/TransformFeedbackGLTest.cpp

@ -25,7 +25,6 @@
#include <tuple>
#include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/DebugStl.h>
#include "Magnum/Image.h"
#include "Magnum/GL/AbstractShaderProgram.h"
@ -44,6 +43,10 @@
#include "Magnum/GL/TransformFeedback.h"
#include "Magnum/Math/Vector2.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
namespace Magnum { namespace GL { namespace Test { namespace {
struct TransformFeedbackGLTest: OpenGLTester {
@ -111,6 +114,10 @@ TransformFeedbackGLTest::TransformFeedbackGLTest() {
#endif
}
#ifndef MAGNUM_TARGET_WEBGL
using namespace Containers::Literals;
#endif
void TransformFeedbackGLTest::construct() {
#ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::ARB::transform_feedback2>())
@ -189,7 +196,6 @@ void TransformFeedbackGLTest::label() {
CORRADE_SKIP("Required extension is not available");
TransformFeedback feedback;
CORRADE_COMPARE(feedback.label(), "");
{
#ifdef MAGNUM_TARGET_GLES
@ -200,7 +206,9 @@ void TransformFeedbackGLTest::label() {
MAGNUM_VERIFY_NO_GL_ERROR();
}
feedback.setLabel("MyXfb");
/* Test the string size gets correctly used, instead of relying on null
termination */
feedback.setLabel("MyXfb!"_s.except(1));
{
#ifdef MAGNUM_TARGET_GLES
CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::NVidia &&
@ -210,7 +218,9 @@ void TransformFeedbackGLTest::label() {
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE(feedback.label(), "MyXfb");
MAGNUM_VERIFY_NO_GL_ERROR(); /* Check for errors again to flush the error state */
/* Here it's *essential* to check for errors again to flush the error
state in case of the XFAIL */
MAGNUM_VERIFY_NO_GL_ERROR();
}
}
#endif

15
src/Magnum/GL/Texture.cpp

@ -25,6 +25,10 @@
#include "Texture.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
#include "Magnum/GL/Implementation/maxTextureSize.h"
@ -101,8 +105,19 @@ template<UnsignedInt dimensions> CompressedBufferImage<dimensions> Texture<dimen
compressedSubImage(level, range, image, usage);
return std::move(image);
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
template<UnsignedInt dimensions> Texture<dimensions>& Texture<dimensions>::setLabel(Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
#endif
#ifndef MAGNUM_TARGET_GLES
template class MAGNUM_GL_EXPORT Texture<1>;
#endif
#if !defined(MAGNUM_TARGET_GLES) || !defined(MAGNUM_TARGET_WEBGL)
template class MAGNUM_GL_EXPORT Texture<2>;
template class MAGNUM_GL_EXPORT Texture<3>;
#endif

9
src/Magnum/GL/Texture.h

@ -1374,14 +1374,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
Texture<dimensions>& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> Texture<dimensions>& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
Texture<dimensions>& setLabel(Containers::StringView label);
#endif
private:

11
src/Magnum/GL/TextureArray.cpp

@ -25,6 +25,10 @@
#include "TextureArray.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
#ifndef MAGNUM_TARGET_GLES2
#include "Magnum/GL/Context.h"
#include "Magnum/GL/Extensions.h"
@ -95,6 +99,13 @@ template<UnsignedInt dimensions> CompressedBufferImage<dimensions+1> TextureArra
}
#endif
#ifndef MAGNUM_TARGET_WEBGL
template<UnsignedInt dimensions> TextureArray<dimensions>& TextureArray<dimensions>::setLabel(Containers::StringView label) {
AbstractTexture::setLabel(label);
return *this;
}
#endif
#ifndef MAGNUM_TARGET_GLES
template class MAGNUM_GL_EXPORT TextureArray<1>;
#endif

9
src/Magnum/GL/TextureArray.h

@ -938,14 +938,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
TextureArray<dimensions>& setLabel(const std::string& label) {
AbstractTexture::setLabel(label);
return *this;
}
template<std::size_t size> TextureArray<dimensions>& setLabel(const char(&label)[size]) {
AbstractTexture::setLabel<size>(label);
return *this;
}
TextureArray<dimensions>& setLabel(Containers::StringView label);
#endif
private:

41
src/Magnum/GL/TimeQuery.cpp

@ -0,0 +1,41 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "TimeQuery.h"
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/StringView.h>
#endif
namespace Magnum { namespace GL {
#ifndef MAGNUM_TARGET_WEBGL
TimeQuery& TimeQuery::setLabel(Containers::StringView label) {
AbstractQuery::setLabel(label);
return *this;
}
#endif
}}

11
src/Magnum/GL/TimeQuery.h

@ -55,7 +55,7 @@ times are reported in nanoseconds.
@todo timestamp with glGet + example usage
@todo @gl_extension{EXT,disjoint_timer_query} --- GL_GPU_DISJOINT_EXT support? where?
*/
class TimeQuery: public AbstractQuery {
class MAGNUM_GL_EXPORT TimeQuery: public AbstractQuery {
public:
/**
* @brief Query target
@ -142,14 +142,7 @@ class TimeQuery: public AbstractQuery {
/* Overloads to remove WTF-factor from method chaining order */
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
TimeQuery& setLabel(const std::string& label) {
AbstractQuery::setLabel(label);
return *this;
}
template<std::size_t size> TimeQuery& setLabel(const char(&label)[size]) {
AbstractQuery::setLabel<size>(label);
return *this;
}
TimeQuery& setLabel(Containers::StringView label);
#endif
/**

7
src/Magnum/GL/TransformFeedback.cpp

@ -27,6 +27,9 @@
#ifndef MAGNUM_TARGET_GLES2
#include <tuple>
#ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h>
#endif
#include <Corrade/Utility/Assert.h>
#include "Magnum/GL/AbstractShaderProgram.h"
@ -160,12 +163,12 @@ inline void TransformFeedback::createIfNotAlready() {
}
#ifndef MAGNUM_TARGET_WEBGL
std::string TransformFeedback::label() {
Containers::String TransformFeedback::label() {
createIfNotAlready();
return Context::current().state().debug.getLabelImplementation(GL_TRANSFORM_FEEDBACK, _id);
}
TransformFeedback& TransformFeedback::setLabelInternal(const Containers::ArrayView<const char> label) {
TransformFeedback& TransformFeedback::setLabel(const Containers::StringView label) {
createIfNotAlready();
Context::current().state().debug.labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label);
return *this;

21
src/Magnum/GL/TransformFeedback.h

@ -38,6 +38,12 @@
#include "Magnum/GL/AbstractObject.h"
#include "Magnum/GL/GL.h"
#ifdef MAGNUM_BUILD_DEPRECATED
/* For label() / setLabel(), which used to be a std::string. Not ideal for the
return type, but at least something. */
#include <Corrade/Containers/StringStl.h>
#endif
#ifndef MAGNUM_TARGET_GLES2
namespace Magnum { namespace GL {
@ -257,7 +263,7 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject {
* with @def_gl{TRANSFORM_FEEDBACK}
* @requires_gles Debug output is not available in WebGL.
*/
std::string label();
Containers::String label();
/**
* @brief Set transform feedback label
@ -272,16 +278,9 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject {
* @def_gl{TRANSFORM_FEEDBACK}
* @requires_gles Debug output is not available in WebGL.
*/
TransformFeedback& setLabel(const std::string& label) {
return setLabelInternal({label.data(), label.size()});
}
TransformFeedback& setLabel(Containers::StringView label);
#endif
/** @overload */
template<std::size_t size> TransformFeedback& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
}
/**
* @brief Attach range of buffer
* @return Reference to self (for method chaining)
@ -437,10 +436,6 @@ class MAGNUM_GL_EXPORT TransformFeedback: public AbstractObject {
void MAGNUM_GL_LOCAL attachImplementationDSA(GLuint firstIndex, std::initializer_list<Buffer*> buffers);
#endif
#ifndef MAGNUM_TARGET_WEBGL
TransformFeedback& setLabelInternal(Containers::ArrayView<const char> label);
#endif
GLuint _id;
ObjectFlags _flags;
};

Loading…
Cancel
Save