From bc884428f8c1d8f66ee0216c9a6a338eff31fca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Feb 2021 10:45:09 +0100 Subject: [PATCH] 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 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. --- doc/changelog.dox | 35 +++++--- src/Magnum/GL/AbstractFramebuffer.h | 1 + src/Magnum/GL/AbstractObject.cpp | 59 ++++++------- src/Magnum/GL/AbstractObject.h | 23 +++-- src/Magnum/GL/AbstractQuery.cpp | 7 +- src/Magnum/GL/AbstractQuery.h | 22 ++--- src/Magnum/GL/AbstractShaderProgram.cpp | 7 +- src/Magnum/GL/AbstractShaderProgram.h | 20 ++--- src/Magnum/GL/AbstractTexture.cpp | 7 +- src/Magnum/GL/AbstractTexture.h | 22 ++--- src/Magnum/GL/Buffer.cpp | 7 +- src/Magnum/GL/Buffer.h | 21 ++--- src/Magnum/GL/BufferTexture.cpp | 9 ++ src/Magnum/GL/BufferTexture.h | 9 +- src/Magnum/GL/CMakeLists.txt | 7 +- src/Magnum/GL/CubeMapTexture.cpp | 11 +++ src/Magnum/GL/CubeMapTexture.h | 9 +- src/Magnum/GL/CubeMapTextureArray.cpp | 7 ++ src/Magnum/GL/CubeMapTextureArray.h | 9 +- src/Magnum/GL/Framebuffer.cpp | 7 +- src/Magnum/GL/Framebuffer.h | 21 ++--- src/Magnum/GL/Implementation/DebugState.h | 4 +- src/Magnum/GL/Implementation/TextureState.cpp | 2 +- src/Magnum/GL/Mesh.cpp | 7 +- src/Magnum/GL/Mesh.h | 21 ++--- src/Magnum/GL/MultisampleTexture.cpp | 20 ++++- src/Magnum/GL/MultisampleTexture.h | 11 +-- src/Magnum/GL/PipelineStatisticsQuery.cpp | 43 ++++++++++ src/Magnum/GL/PipelineStatisticsQuery.h | 11 +-- src/Magnum/GL/PrimitiveQuery.cpp | 11 +++ src/Magnum/GL/PrimitiveQuery.h | 9 +- src/Magnum/GL/RectangleTexture.cpp | 9 ++ src/Magnum/GL/RectangleTexture.h | 9 +- src/Magnum/GL/Renderbuffer.cpp | 8 +- src/Magnum/GL/Renderbuffer.h | 22 ++--- src/Magnum/GL/SampleQuery.cpp | 43 ++++++++++ src/Magnum/GL/SampleQuery.h | 11 +-- src/Magnum/GL/Shader.cpp | 7 +- src/Magnum/GL/Shader.h | 19 ++--- src/Magnum/GL/Test/AbstractObjectGLTest.cpp | 6 +- src/Magnum/GL/Test/AbstractQueryGLTest.cpp | 52 +----------- .../GL/Test/AbstractShaderProgramGLTest.cpp | 13 ++- src/Magnum/GL/Test/AbstractTextureGLTest.cpp | 31 +------ src/Magnum/GL/Test/BufferGLTest.cpp | 15 +++- src/Magnum/GL/Test/BufferTextureGLTest.cpp | 26 ++++++ .../GL/Test/CubeMapTextureArrayGLTest.cpp | 26 ++++++ src/Magnum/GL/Test/CubeMapTextureGLTest.cpp | 37 ++++++++ src/Magnum/GL/Test/FramebufferGLTest.cpp | 14 ++- src/Magnum/GL/Test/MeshGLTest.cpp | 14 ++- .../GL/Test/MultisampleTextureGLTest.cpp | 48 +++++++++++ .../GL/Test/PipelineStatisticsQueryGLTest.cpp | 40 +++++++++ src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp | 56 ++++++++++++ src/Magnum/GL/Test/RectangleTextureGLTest.cpp | 26 ++++++ src/Magnum/GL/Test/RenderbufferGLTest.cpp | 16 +++- src/Magnum/GL/Test/SampleQueryGLTest.cpp | 57 +++++++++++++ src/Magnum/GL/Test/ShaderGLTest.cpp | 16 +++- src/Magnum/GL/Test/TextureArrayGLTest.cpp | 64 ++++++++++++++ src/Magnum/GL/Test/TextureGLTest.cpp | 85 +++++++++++++++++++ src/Magnum/GL/Test/TimeQueryGLTest.cpp | 60 ++++++++++++- .../GL/Test/TransformFeedbackGLTest.cpp | 18 +++- src/Magnum/GL/Texture.cpp | 15 ++++ src/Magnum/GL/Texture.h | 9 +- src/Magnum/GL/TextureArray.cpp | 11 +++ src/Magnum/GL/TextureArray.h | 9 +- src/Magnum/GL/TimeQuery.cpp | 41 +++++++++ src/Magnum/GL/TimeQuery.h | 11 +-- src/Magnum/GL/TransformFeedback.cpp | 7 +- src/Magnum/GL/TransformFeedback.h | 21 ++--- 68 files changed, 1046 insertions(+), 385 deletions(-) create mode 100644 src/Magnum/GL/PipelineStatisticsQuery.cpp create mode 100644 src/Magnum/GL/SampleQuery.cpp create mode 100644 src/Magnum/GL/TimeQuery.cpp diff --git a/doc/changelog.dox b/doc/changelog.dox index ff47cf039..f2335a65e 100644 --- a/doc/changelog.dox +++ b/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 diff --git a/src/Magnum/GL/AbstractFramebuffer.h b/src/Magnum/GL/AbstractFramebuffer.h index f6fa9cfb7..2aa742a15 100644 --- a/src/Magnum/GL/AbstractFramebuffer.h +++ b/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 /* std::swap() */ #include #include "Magnum/GL/GL.h" diff --git a/src/Magnum/GL/AbstractObject.cpp b/src/Magnum/GL/AbstractObject.cpp index 64b25908c..d6404ac5a 100644 --- a/src/Magnum/GL/AbstractObject.cpp +++ b/src/Magnum/GL/AbstractObject.cpp @@ -27,6 +27,9 @@ #include #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#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) {} +void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::StringView) {} #ifndef MAGNUM_TARGET_GLES2 -void AbstractObject::labelImplementationKhrDesktopES32(const GLenum identifier, const GLuint name, const Containers::ArrayView 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 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 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 diff --git a/src/Magnum/GL/AbstractObject.h b/src/Magnum/GL/AbstractObject.h index 2cfaf25d1..2cfaf08ce 100644 --- a/src/Magnum/GL/AbstractObject.h +++ b/src/Magnum/GL/AbstractObject.h @@ -29,13 +29,18 @@ * @brief Class @ref Magnum::GL::AbstractObject */ -#include #include #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 +#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 label); - static MAGNUM_GL_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, Containers::ArrayView 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 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 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 }; diff --git a/src/Magnum/GL/AbstractQuery.cpp b/src/Magnum/GL/AbstractQuery.cpp index e7579db26..b363b4983 100644 --- a/src/Magnum/GL/AbstractQuery.cpp +++ b/src/Magnum/GL/AbstractQuery.cpp @@ -25,6 +25,9 @@ #include "AbstractQuery.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif #include #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 label) { +AbstractQuery& AbstractQuery::setLabel(const Containers::StringView label) { #ifndef MAGNUM_TARGET_GLES2 Context::current().state().debug.labelImplementation(GL_QUERY, _id, label); #else diff --git a/src/Magnum/GL/AbstractQuery.h b/src/Magnum/GL/AbstractQuery.h index 743f5e9f5..e3fbd80c1 100644 --- a/src/Magnum/GL/AbstractQuery.h +++ b/src/Magnum/GL/AbstractQuery.h @@ -29,6 +29,7 @@ * @brief Class @ref Magnum::GL::AbstractQuery */ +#include /* std::swap() */ #include #include @@ -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 +#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 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 label); - #endif - void MAGNUM_GL_LOCAL createImplementationDefault(); #ifndef MAGNUM_TARGET_GLES void MAGNUM_GL_LOCAL createImplementationDSA(); diff --git a/src/Magnum/GL/AbstractShaderProgram.cpp b/src/Magnum/GL/AbstractShaderProgram.cpp index db6d06e4a..8750c260d 100644 --- a/src/Magnum/GL/AbstractShaderProgram.cpp +++ b/src/Magnum/GL/AbstractShaderProgram.cpp @@ -27,6 +27,9 @@ #include #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif #include #include @@ -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 label) { +AbstractShaderProgram& AbstractShaderProgram::setLabel(const Containers::StringView label) { #ifndef MAGNUM_TARGET_GLES2 Context::current().state().debug.labelImplementation(GL_PROGRAM, _id, label); #else diff --git a/src/Magnum/GL/AbstractShaderProgram.h b/src/Magnum/GL/AbstractShaderProgram.h index 2d1603a66..01b4429ab 100644 --- a/src/Magnum/GL/AbstractShaderProgram.h +++ b/src/Magnum/GL/AbstractShaderProgram.h @@ -41,6 +41,11 @@ #include #endif +#ifdef MAGNUM_BUILD_DEPRECATED +/* For label() / setLabel(), which used to be a std::string */ +#include +#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 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 label); - #endif - void bindAttributeLocationInternal(UnsignedInt location, Containers::ArrayView name); #ifndef MAGNUM_TARGET_GLES void bindFragmentDataLocationIndexedInternal(UnsignedInt location, UnsignedInt index, Containers::ArrayView name); diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index 8be37eacc..a06479b2f 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -27,6 +27,9 @@ #include #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 label) { +AbstractTexture& AbstractTexture::setLabel(const Containers::StringView label) { createIfNotAlready(); Context::current().state().debug.labelImplementation(GL_TEXTURE, _id, label); return *this; diff --git a/src/Magnum/GL/AbstractTexture.h b/src/Magnum/GL/AbstractTexture.h index 75b9755bd..bcb34b965 100644 --- a/src/Magnum/GL/AbstractTexture.h +++ b/src/Magnum/GL/AbstractTexture.h @@ -29,6 +29,7 @@ * @brief Class @ref Magnum::GL::AbstractTexture */ +#include /* std::swap() */ #include #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 +#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 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 label); - #endif - void MAGNUM_GL_LOCAL createIfNotAlready(); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp index 10f1afd02..b3b544cda 100644 --- a/src/Magnum/GL/Buffer.cpp +++ b/src/Magnum/GL/Buffer.cpp @@ -27,6 +27,9 @@ #include #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif #include #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 label) { +Buffer& Buffer::setLabel(const Containers::StringView label) { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES2 Context::current().state().debug.labelImplementation(GL_BUFFER, _id, label); diff --git a/src/Magnum/GL/Buffer.h b/src/Magnum/GL/Buffer.h index bb85569fc..076626f50 100644 --- a/src/Magnum/GL/Buffer.h +++ b/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 +#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 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 label); - #endif - #ifndef MAGNUM_TARGET_GLES void MAGNUM_GL_LOCAL storageImplementationDefault(Containers::ArrayView data, StorageFlags flags); void MAGNUM_GL_LOCAL storageImplementationDSA(Containers::ArrayView data, StorageFlags flags); diff --git a/src/Magnum/GL/BufferTexture.cpp b/src/Magnum/GL/BufferTexture.cpp index a08e3b91f..feeb983c6 100644 --- a/src/Magnum/GL/BufferTexture.cpp +++ b/src/Magnum/GL/BufferTexture.cpp @@ -25,6 +25,10 @@ #include "BufferTexture.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 diff --git a/src/Magnum/GL/BufferTexture.h b/src/Magnum/GL/BufferTexture.h index 3d6e4e918..716e3db68 100644 --- a/src/Magnum/GL/BufferTexture.h +++ b/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 BufferTexture& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + BufferTexture& setLabel(const Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/CMakeLists.txt b/src/Magnum/GL/CMakeLists.txt index 7c4bbb5bd..5b89d05e6 100644 --- a/src/Magnum/GL/CMakeLists.txt +++ b/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() diff --git a/src/Magnum/GL/CubeMapTexture.cpp b/src/Magnum/GL/CubeMapTexture.cpp index 86f5550db..d5db53505 100644 --- a/src/Magnum/GL/CubeMapTexture.cpp +++ b/src/Magnum/GL/CubeMapTexture.cpp @@ -25,6 +25,10 @@ #include "CubeMapTexture.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 + }} diff --git a/src/Magnum/GL/CubeMapTexture.h b/src/Magnum/GL/CubeMapTexture.h index e844fee65..da59ab408 100644 --- a/src/Magnum/GL/CubeMapTexture.h +++ b/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 CubeMapTexture& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + CubeMapTexture& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/CubeMapTextureArray.cpp b/src/Magnum/GL/CubeMapTextureArray.cpp index 451a08b34..17415414a 100644 --- a/src/Magnum/GL/CubeMapTextureArray.cpp +++ b/src/Magnum/GL/CubeMapTextureArray.cpp @@ -26,6 +26,8 @@ #include "CubeMapTextureArray.h" #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +#include + #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 diff --git a/src/Magnum/GL/CubeMapTextureArray.h b/src/Magnum/GL/CubeMapTextureArray.h index ff3b050b5..a5d60176f 100644 --- a/src/Magnum/GL/CubeMapTextureArray.h +++ b/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 CubeMapTextureArray& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + CubeMapTextureArray& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/Framebuffer.cpp b/src/Magnum/GL/Framebuffer.cpp index 477e94833..340d13961 100644 --- a/src/Magnum/GL/Framebuffer.cpp +++ b/src/Magnum/GL/Framebuffer.cpp @@ -26,6 +26,9 @@ #include "Framebuffer.h" #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 label) { +Framebuffer& Framebuffer::setLabel(const Containers::StringView label) { createIfNotAlready(); Context::current().state().debug.labelImplementation(GL_FRAMEBUFFER, _id, label); return *this; diff --git a/src/Magnum/GL/Framebuffer.h b/src/Magnum/GL/Framebuffer.h index 8d0c34673..42fb0713a 100644 --- a/src/Magnum/GL/Framebuffer.h +++ b/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 +#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 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 label); - #endif - void MAGNUM_GL_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, GLuint renderbufferId); #ifndef MAGNUM_TARGET_GLES void MAGNUM_GL_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, GLuint renderbufferId); diff --git a/src/Magnum/GL/Implementation/DebugState.h b/src/Magnum/GL/Implementation/DebugState.h index 159652425..912bd5e71 100644 --- a/src/Magnum/GL/Implementation/DebugState.h +++ b/src/Magnum/GL/Implementation/DebugState.h @@ -37,8 +37,8 @@ namespace Magnum { namespace GL { namespace Implementation { struct DebugState { explicit DebugState(Context& context, Containers::StaticArrayView extensions); - std::string(*getLabelImplementation)(GLenum, GLuint); - void(*labelImplementation)(GLenum, GLuint, Containers::ArrayView); + Containers::String(*getLabelImplementation)(GLenum, GLuint); + void(*labelImplementation)(GLenum, GLuint, Containers::StringView); void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugOutput::Severity, Containers::ArrayView); void(*controlImplementation)(GLenum, GLenum, GLenum, std::initializer_list, bool); diff --git a/src/Magnum/GL/Implementation/TextureState.cpp b/src/Magnum/GL/Implementation/TextureState.cpp index 9d031597e..077397a83 100644 --- a/src/Magnum/GL/Implementation/TextureState.cpp +++ b/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& i: imageBindings) - i = {State::DisengagedBinding, 0, false, 0, 0}; + i = std::make_tuple(State::DisengagedBinding, 0, false, 0, 0); #endif } diff --git a/src/Magnum/GL/Mesh.cpp b/src/Magnum/GL/Mesh.cpp index 10b238811..485aa28a5 100644 --- a/src/Magnum/GL/Mesh.cpp +++ b/src/Magnum/GL/Mesh.cpp @@ -27,6 +27,9 @@ #include #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif #include #include @@ -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 label) { +Mesh& Mesh::setLabel(const Containers::StringView label) { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES2 Context::current().state().debug.labelImplementation(GL_VERTEX_ARRAY, _id, label); diff --git a/src/Magnum/GL/Mesh.h b/src/Magnum/GL/Mesh.h index 49e0d60d4..d9f49126d 100644 --- a/src/Magnum/GL/Mesh.h +++ b/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 +#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 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 label); - #endif - /* Computing stride of interleaved vertex attributes */ template static GLsizei strideOfInterleaved(const Attribute& attribute, const U&... attributes) { return attribute.vectorStride()*Attribute::Vectors + strideOfInterleaved(attributes...); diff --git a/src/Magnum/GL/MultisampleTexture.cpp b/src/Magnum/GL/MultisampleTexture.cpp index 75d9e3ab8..92ff9d7a1 100644 --- a/src/Magnum/GL/MultisampleTexture.cpp +++ b/src/Magnum/GL/MultisampleTexture.cpp @@ -26,12 +26,18 @@ #include "MultisampleTexture.h" #ifndef MAGNUM_TARGET_GLES2 +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 MultisampleTexture& MultisampleTexture::setLabel(Containers::StringView label) { + AbstractTexture::setLabel(label); + return *this; +} + +template class MAGNUM_GL_EXPORT MultisampleTexture<2>; +template class MAGNUM_GL_EXPORT MultisampleTexture<3>; + +}} #endif diff --git a/src/Magnum/GL/MultisampleTexture.h b/src/Magnum/GL/MultisampleTexture.h index 8b9369652..710c212a3 100644 --- a/src/Magnum/GL/MultisampleTexture.h +++ b/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 class MultisampleTexture: public AbstractTexture { +template class MAGNUM_GL_EXPORT MultisampleTexture: public AbstractTexture { public: enum: UnsignedInt { Dimensions = dimensions /**< Texture dimension count */ @@ -302,14 +302,7 @@ template class MultisampleTexture: public AbstractTextur /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT - MultisampleTexture& setLabel(const std::string& label) { - AbstractTexture::setLabel(label); - return *this; - } - template MultisampleTexture& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + MultisampleTexture& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/PipelineStatisticsQuery.cpp b/src/Magnum/GL/PipelineStatisticsQuery.cpp new file mode 100644 index 000000000..3a750885e --- /dev/null +++ b/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š + + 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 +#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 diff --git a/src/Magnum/GL/PipelineStatisticsQuery.h b/src/Magnum/GL/PipelineStatisticsQuery.h index 1710dddba..e365f1acd 100644 --- a/src/Magnum/GL/PipelineStatisticsQuery.h +++ b/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 PipelineStatisticsQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } + PipelineStatisticsQuery& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/PrimitiveQuery.cpp b/src/Magnum/GL/PrimitiveQuery.cpp index f581bf04b..a5672f19a 100644 --- a/src/Magnum/GL/PrimitiveQuery.cpp +++ b/src/Magnum/GL/PrimitiveQuery.cpp @@ -25,6 +25,10 @@ #include "PrimitiveQuery.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 + }} diff --git a/src/Magnum/GL/PrimitiveQuery.h b/src/Magnum/GL/PrimitiveQuery.h index c39eacc67..90e6f055f 100644 --- a/src/Magnum/GL/PrimitiveQuery.h +++ b/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 PrimitiveQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } + PrimitiveQuery& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/RectangleTexture.cpp b/src/Magnum/GL/RectangleTexture.cpp index 02433b7c8..8fa827514 100644 --- a/src/Magnum/GL/RectangleTexture.cpp +++ b/src/Magnum/GL/RectangleTexture.cpp @@ -25,6 +25,10 @@ #include "RectangleTexture.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 diff --git a/src/Magnum/GL/RectangleTexture.h b/src/Magnum/GL/RectangleTexture.h index 63f47a1fa..1bc628dc7 100644 --- a/src/Magnum/GL/RectangleTexture.h +++ b/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 RectangleTexture& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + RectangleTexture& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/Renderbuffer.cpp b/src/Magnum/GL/Renderbuffer.cpp index f4b4bcdb2..033533821 100644 --- a/src/Magnum/GL/Renderbuffer.cpp +++ b/src/Magnum/GL/Renderbuffer.cpp @@ -25,6 +25,10 @@ #include "Renderbuffer.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#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 label) { +Renderbuffer& Renderbuffer::setLabel(const Containers::StringView label) { createIfNotAlready(); Context::current().state().debug.labelImplementation(GL_RENDERBUFFER, _id, label); return *this; diff --git a/src/Magnum/GL/Renderbuffer.h b/src/Magnum/GL/Renderbuffer.h index ed756e1c6..f4dd9c9ff 100644 --- a/src/Magnum/GL/Renderbuffer.h +++ b/src/Magnum/GL/Renderbuffer.h @@ -29,12 +29,19 @@ * @brief Class @ref Magnum::GL::Renderbuffer */ +#include /* std::swap() */ #include #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 +#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 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 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); diff --git a/src/Magnum/GL/SampleQuery.cpp b/src/Magnum/GL/SampleQuery.cpp new file mode 100644 index 000000000..1ef13eb96 --- /dev/null +++ b/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š + + 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 +#endif + +namespace Magnum { namespace GL { + +#ifndef MAGNUM_TARGET_WEBGL +SampleQuery& SampleQuery::setLabel(Containers::StringView label) { + AbstractQuery::setLabel(label); + return *this; +} +#endif + +}} +#endif diff --git a/src/Magnum/GL/SampleQuery.h b/src/Magnum/GL/SampleQuery.h index 167f5300c..484b90d9e 100644 --- a/src/Magnum/GL/SampleQuery.h +++ b/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 SampleQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } + SampleQuery& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/Shader.cpp b/src/Magnum/GL/Shader.cpp index 76207bc91..e1be76a3f 100644 --- a/src/Magnum/GL/Shader.cpp +++ b/src/Magnum/GL/Shader.cpp @@ -27,6 +27,9 @@ #include #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif #include #include #include @@ -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 label) { +Shader& Shader::setLabel(const Containers::StringView label) { #ifndef MAGNUM_TARGET_GLES2 Context::current().state().debug.labelImplementation(GL_SHADER, _id, label); #else diff --git a/src/Magnum/GL/Shader.h b/src/Magnum/GL/Shader.h index e41e5fa99..99984dc64 100644 --- a/src/Magnum/GL/Shader.h +++ b/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 +#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 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 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); diff --git a/src/Magnum/GL/Test/AbstractObjectGLTest.cpp b/src/Magnum/GL/Test/AbstractObjectGLTest.cpp index ef2691e5a..0dd2750dd 100644 --- a/src/Magnum/GL/Test/AbstractObjectGLTest.cpp +++ b/src/Magnum/GL/Test/AbstractObjectGLTest.cpp @@ -23,13 +23,15 @@ DEALINGS IN THE SOFTWARE. */ -#include - #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 +#endif + namespace Magnum { namespace GL { namespace Test { namespace { struct AbstractObjectGLTest: OpenGLTester { diff --git a/src/Magnum/GL/Test/AbstractQueryGLTest.cpp b/src/Magnum/GL/Test/AbstractQueryGLTest.cpp index f4dabbf36..27db52e44 100644 --- a/src/Magnum/GL/Test/AbstractQueryGLTest.cpp +++ b/src/Magnum/GL/Test/AbstractQueryGLTest.cpp @@ -23,8 +23,6 @@ DEALINGS IN THE SOFTWARE. */ -#include - #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()) - CORRADE_SKIP(Extensions::EXT::occlusion_query_boolean::string() << "is not supported."); - #endif - - /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current().isExtensionSupported() && - !Context::current().isExtensionSupported()) - 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()) - #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) diff --git a/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp b/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp index 1863330ee..78e258d85 100644 --- a/src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp +++ b/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 +#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 diff --git a/src/Magnum/GL/Test/AbstractTextureGLTest.cpp b/src/Magnum/GL/Test/AbstractTextureGLTest.cpp index cb233dcaf..7153c6deb 100644 --- a/src/Magnum/GL/Test/AbstractTextureGLTest.cpp +++ b/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() && - !Context::current().isExtensionSupported()) - 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) diff --git a/src/Magnum/GL/Test/BufferGLTest.cpp b/src/Magnum/GL/Test/BufferGLTest.cpp index ec369f46b..49fa30211 100644 --- a/src/Magnum/GL/Test/BufferGLTest.cpp +++ b/src/Magnum/GL/Test/BufferGLTest.cpp @@ -28,13 +28,16 @@ #include #include #include -#include #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 +#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 diff --git a/src/Magnum/GL/Test/BufferTextureGLTest.cpp b/src/Magnum/GL/Test/BufferTextureGLTest.cpp index a1cf89385..558f4faef 100644 --- a/src/Magnum/GL/Test/BufferTextureGLTest.cpp +++ b/src/Magnum/GL/Test/BufferTextureGLTest.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #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()) @@ -143,6 +150,25 @@ void BufferTextureGLTest::wrap() { glDeleteTextures(1, &id); } +void BufferTextureGLTest::label() { + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + 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()) diff --git a/src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp index 9836d781c..371524522 100644 --- a/src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/GL/Test/CubeMapTextureArrayGLTest.cpp @@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #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()) @@ -377,6 +384,25 @@ void CubeMapTextureArrayGLTest::wrap() { glDeleteTextures(1, &id); } +void CubeMapTextureArrayGLTest::label() { + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + 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()) diff --git a/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp b/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp index 8cf38740a..b0e0d9d80 100644 --- a/src/Magnum/GL/Test/CubeMapTextureGLTest.cpp +++ b/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 +#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 Containers::ArrayView 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() && + !Context::current().isExtensionSupported()) + 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); diff --git a/src/Magnum/GL/Test/FramebufferGLTest.cpp b/src/Magnum/GL/Test/FramebufferGLTest.cpp index 97ba1a0d8..aa62841d3 100644 --- a/src/Magnum/GL/Test/FramebufferGLTest.cpp +++ b/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 +#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()) @@ -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 diff --git a/src/Magnum/GL/Test/MeshGLTest.cpp b/src/Magnum/GL/Test/MeshGLTest.cpp index 8708363a4..c5e531b87 100644 --- a/src/Magnum/GL/Test/MeshGLTest.cpp +++ b/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 +#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 diff --git a/src/Magnum/GL/Test/MultisampleTextureGLTest.cpp b/src/Magnum/GL/Test/MultisampleTextureGLTest.cpp index 92c410b43..27a1b3474 100644 --- a/src/Magnum/GL/Test/MultisampleTextureGLTest.cpp +++ b/src/Magnum/GL/Test/MultisampleTextureGLTest.cpp @@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #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()) @@ -180,6 +189,45 @@ void MultisampleTextureGLTest::wrap2DArray() { glDeleteTextures(1, &id); } +void MultisampleTextureGLTest::label2D() { + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + 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() && + !Context::current().isExtensionSupported()) + 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()) diff --git a/src/Magnum/GL/Test/PipelineStatisticsQueryGLTest.cpp b/src/Magnum/GL/Test/PipelineStatisticsQueryGLTest.cpp index 74eaf1bff..8022b5139 100644 --- a/src/Magnum/GL/Test/PipelineStatisticsQueryGLTest.cpp +++ b/src/Magnum/GL/Test/PipelineStatisticsQueryGLTest.cpp @@ -23,6 +23,7 @@ DEALINGS IN THE SOFTWARE. */ +#include #include #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()) + CORRADE_SKIP(Extensions::ARB::pipeline_statistics_query::string() << "is not available"); + + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + CORRADE_SKIP("Required extension is not available"); + + PipelineStatisticsQuery query{PipelineStatisticsQuery::Target::ClippingInputPrimitives}; + + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + #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()) CORRADE_SKIP(Extensions::ARB::pipeline_statistics_query::string() << "is not available"); diff --git a/src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp b/src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp index 5b1d6ac0c..3599f1bfc 100644 --- a/src/Magnum/GL/Test/PrimitiveQueryGLTest.cpp +++ b/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 +#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()) + CORRADE_SKIP(Extensions::EXT::transform_feedback::string() << "is not supported."); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::EXT::geometry_shader::string() << "is not supported."); + #endif + + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + CORRADE_SKIP("Required extension is not available"); + + PrimitiveQuery query{PrimitiveQuery::Target::PrimitivesGenerated}; + + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + #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 diff --git a/src/Magnum/GL/Test/RectangleTextureGLTest.cpp b/src/Magnum/GL/Test/RectangleTextureGLTest.cpp index c887e01e1..96cf0e75d 100644 --- a/src/Magnum/GL/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/GL/Test/RectangleTextureGLTest.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #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()) 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() && + !Context::current().isExtensionSupported()) + 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()) CORRADE_SKIP(Extensions::ARB::texture_rectangle::string() << "is not supported."); diff --git a/src/Magnum/GL/Test/RenderbufferGLTest.cpp b/src/Magnum/GL/Test/RenderbufferGLTest.cpp index 5bc030117..fa4453212 100644 --- a/src/Magnum/GL/Test/RenderbufferGLTest.cpp +++ b/src/Magnum/GL/Test/RenderbufferGLTest.cpp @@ -23,8 +23,6 @@ DEALINGS IN THE SOFTWARE. */ -#include - #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 +#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()) @@ -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 diff --git a/src/Magnum/GL/Test/SampleQueryGLTest.cpp b/src/Magnum/GL/Test/SampleQueryGLTest.cpp index c69b73820..e5728613a 100644 --- a/src/Magnum/GL/Test/SampleQueryGLTest.cpp +++ b/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 +#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()) + CORRADE_SKIP(Extensions::EXT::occlusion_query_boolean::string() << "is not supported."); + #endif + + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + 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()) + #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; diff --git a/src/Magnum/GL/Test/ShaderGLTest.cpp b/src/Magnum/GL/Test/ShaderGLTest.cpp index aae6fad22..47a6c4658 100644 --- a/src/Magnum/GL/Test/ShaderGLTest.cpp +++ b/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 +#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 diff --git a/src/Magnum/GL/Test/TextureArrayGLTest.cpp b/src/Magnum/GL/Test/TextureArrayGLTest.cpp index 1b52a4ef7..9e0fa4983 100644 --- a/src/Magnum/GL/Test/TextureArrayGLTest.cpp +++ b/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 +#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()) @@ -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() && + !Context::current().isExtensionSupported()) + 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() && + !Context::current().isExtensionSupported()) + 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()) diff --git a/src/Magnum/GL/Test/TextureGLTest.cpp b/src/Magnum/GL/Test/TextureGLTest.cpp index 1a4a90e27..1a960d475 100644 --- a/src/Magnum/GL/Test/TextureGLTest.cpp +++ b/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 +#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() && + !Context::current().isExtensionSupported()) + 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() && + !Context::current().isExtensionSupported()) + 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() && + !Context::current().isExtensionSupported()) + 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; diff --git a/src/Magnum/GL/Test/TimeQueryGLTest.cpp b/src/Magnum/GL/Test/TimeQueryGLTest.cpp index 82462940d..2383313f8 100644 --- a/src/Magnum/GL/Test/TimeQueryGLTest.cpp +++ b/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 #include "Magnum/GL/Context.h" @@ -33,6 +32,10 @@ #include "Magnum/GL/RenderbufferFormat.h" #include "Magnum/GL/TimeQuery.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#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()) + CORRADE_SKIP(Extensions::ARB::timer_query::string() << "is not supported."); + #elif defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::EXT::disjoint_timer_query_webgl2::string() << "is not supported."); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::EXT::disjoint_timer_query::string() << "is not supported."); + #endif + + /* No-Op version is tested in AbstractObjectGLTest */ + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) + CORRADE_SKIP("Required extension is not available"); + + TimeQuery query{TimeQuery::Target::TimeElapsed}; + + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + #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()) diff --git a/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp b/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp index dc9c99905..7cccbfe16 100644 --- a/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp +++ b/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp @@ -25,7 +25,6 @@ #include #include -#include #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 +#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()) @@ -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 diff --git a/src/Magnum/GL/Texture.cpp b/src/Magnum/GL/Texture.cpp index 52926ee2b..813d25368 100644 --- a/src/Magnum/GL/Texture.cpp +++ b/src/Magnum/GL/Texture.cpp @@ -25,6 +25,10 @@ #include "Texture.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif + #include "Magnum/GL/Context.h" #include "Magnum/GL/Extensions.h" #include "Magnum/GL/Implementation/maxTextureSize.h" @@ -101,8 +105,19 @@ template CompressedBufferImage Texture Texture& Texture::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 diff --git a/src/Magnum/GL/Texture.h b/src/Magnum/GL/Texture.h index bfbf4113a..efe1f2ff7 100644 --- a/src/Magnum/GL/Texture.h +++ b/src/Magnum/GL/Texture.h @@ -1374,14 +1374,7 @@ template class Texture: public AbstractTexture { /* Overloads to remove WTF-factor from method chaining order */ #if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL) - Texture& setLabel(const std::string& label) { - AbstractTexture::setLabel(label); - return *this; - } - template Texture& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + Texture& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/TextureArray.cpp b/src/Magnum/GL/TextureArray.cpp index 0b1dfdb69..83d22992c 100644 --- a/src/Magnum/GL/TextureArray.cpp +++ b/src/Magnum/GL/TextureArray.cpp @@ -25,6 +25,10 @@ #include "TextureArray.h" +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif + #ifndef MAGNUM_TARGET_GLES2 #include "Magnum/GL/Context.h" #include "Magnum/GL/Extensions.h" @@ -95,6 +99,13 @@ template CompressedBufferImage TextureArra } #endif +#ifndef MAGNUM_TARGET_WEBGL +template TextureArray& TextureArray::setLabel(Containers::StringView label) { + AbstractTexture::setLabel(label); + return *this; +} +#endif + #ifndef MAGNUM_TARGET_GLES template class MAGNUM_GL_EXPORT TextureArray<1>; #endif diff --git a/src/Magnum/GL/TextureArray.h b/src/Magnum/GL/TextureArray.h index 3342c46aa..c4e3af507 100644 --- a/src/Magnum/GL/TextureArray.h +++ b/src/Magnum/GL/TextureArray.h @@ -938,14 +938,7 @@ template class TextureArray: public AbstractTexture { /* Overloads to remove WTF-factor from method chaining order */ #if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL) - TextureArray& setLabel(const std::string& label) { - AbstractTexture::setLabel(label); - return *this; - } - template TextureArray& setLabel(const char(&label)[size]) { - AbstractTexture::setLabel(label); - return *this; - } + TextureArray& setLabel(Containers::StringView label); #endif private: diff --git a/src/Magnum/GL/TimeQuery.cpp b/src/Magnum/GL/TimeQuery.cpp new file mode 100644 index 000000000..009263f7d --- /dev/null +++ b/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š + + 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 +#endif + +namespace Magnum { namespace GL { + +#ifndef MAGNUM_TARGET_WEBGL +TimeQuery& TimeQuery::setLabel(Containers::StringView label) { + AbstractQuery::setLabel(label); + return *this; +} +#endif + +}} diff --git a/src/Magnum/GL/TimeQuery.h b/src/Magnum/GL/TimeQuery.h index e4c0df5ff..8bfc1d48c 100644 --- a/src/Magnum/GL/TimeQuery.h +++ b/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 TimeQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } + TimeQuery& setLabel(Containers::StringView label); #endif /** diff --git a/src/Magnum/GL/TransformFeedback.cpp b/src/Magnum/GL/TransformFeedback.cpp index 747e57a32..181e360b0 100644 --- a/src/Magnum/GL/TransformFeedback.cpp +++ b/src/Magnum/GL/TransformFeedback.cpp @@ -27,6 +27,9 @@ #ifndef MAGNUM_TARGET_GLES2 #include +#ifndef MAGNUM_TARGET_WEBGL +#include +#endif #include #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 label) { +TransformFeedback& TransformFeedback::setLabel(const Containers::StringView label) { createIfNotAlready(); Context::current().state().debug.labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label); return *this; diff --git a/src/Magnum/GL/TransformFeedback.h b/src/Magnum/GL/TransformFeedback.h index 67059e342..6c397770b 100644 --- a/src/Magnum/GL/TransformFeedback.h +++ b/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 +#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 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 buffers); #endif - #ifndef MAGNUM_TARGET_WEBGL - TransformFeedback& setLabelInternal(Containers::ArrayView label); - #endif - GLuint _id; ObjectFlags _flags; };