From ac015f926d625d1fc89dad65146fcf3af035443e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 17:10:29 +0200 Subject: [PATCH 01/72] Hide Buffer::bind() and Buffer::unbind() from public API. There should be no need to use these directly (and in some cases it might be harmful). The bind()/unbind() names will be used for glBindBufferBase()/glBindBufferRange() later. --- src/Magnum/AbstractFramebuffer.cpp | 2 +- src/Magnum/AbstractTexture.cpp | 26 ++++++++++++------------- src/Magnum/Buffer.cpp | 22 ++++++++++----------- src/Magnum/Buffer.h | 31 +++++++++--------------------- src/Magnum/Mesh.cpp | 10 +++++----- 5 files changed, 39 insertions(+), 52 deletions(-) diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index f205c4f2d..2bf1f5b97 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -222,7 +222,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf if(image.size() != size) image.setData(image.format(), image.type(), size, nullptr, usage); - image.buffer().bind(Buffer::Target::PixelPack); + image.buffer().bindInternal(Buffer::Target::PixelPack); (Context::current()->state().framebuffer->readImplementation)(offset, size, image.format(), image.type(), image.dataSize(size), nullptr); } #endif diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index fa22cba23..9d78a49ff 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1156,7 +1156,7 @@ template void AbstractTexture::image(GLenum target, GLin if(image.size() != size) image.setData(image.format(), image.type(), size, nullptr, usage); - image.buffer().bind(Buffer::Target::PixelPack); + image.buffer().bindInternal(Buffer::Target::PixelPack); (this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr); } @@ -1224,78 +1224,78 @@ void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& text #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) { - Buffer::unbind(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); } void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) { - image.buffer().bind(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) { - Buffer::unbind(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { - image.buffer().bind(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference2D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbind(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::Target::PixelUnpack); #endif (texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { - image.buffer().bind(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, const ImageReference2D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbind(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::Target::PixelUnpack); #endif (texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) { - image.buffer().bind(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbind(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::Target::PixelUnpack); #endif (texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { - image.buffer().bind(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, const ImageReference3D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbind(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::Target::PixelUnpack); #endif (texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) { - image.buffer().bind(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::Target::PixelUnpack); (texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index e6c704ba5..83bc6fa4f 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -161,7 +161,7 @@ Buffer& Buffer::setLabelInternal(const Containers::ArrayReference la return *this; } -void Buffer::bind(Target target, GLuint id) { +void Buffer::bindInternal(Target target, GLuint id) { GLuint& bound = Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; /* Already bound, nothing to do */ @@ -172,7 +172,7 @@ void Buffer::bind(Target target, GLuint id) { glBindBuffer(GLenum(target), id); } -Buffer::Target Buffer::bindInternal(Target hint) { +Buffer::Target Buffer::bindSomewhereInternal(Target hint) { GLuint* bindings = Context::current()->state().buffer->bindings; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)]; @@ -269,7 +269,7 @@ void Buffer::subDataInternal(GLintptr offset, GLsizeiptr size, GLvoid* data) { #ifndef MAGNUM_TARGET_GLES2 void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - glCopyBufferSubData(GLenum(read.bindInternal(Target::CopyRead)), GLenum(write.bindInternal(Target::CopyWrite)), readOffset, writeOffset, size); + glCopyBufferSubData(GLenum(read.bindSomewhereInternal(Target::CopyRead)), GLenum(write.bindSomewhereInternal(Target::CopyWrite)), readOffset, writeOffset, size); } #ifndef MAGNUM_TARGET_GLES @@ -280,7 +280,7 @@ void Buffer::copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOff #endif void Buffer::getParameterImplementationDefault(const GLenum value, GLint* const data) { - glGetBufferParameteriv(GLenum(bindInternal(_targetHint)), value, data); + glGetBufferParameteriv(GLenum(bindSomewhereInternal(_targetHint)), value, data); } #ifndef MAGNUM_TARGET_GLES @@ -291,7 +291,7 @@ void Buffer::getParameterImplementationDSA(const GLenum value, GLint* const data #ifndef MAGNUM_TARGET_GLES void Buffer::getSubDataImplementationDefault(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { - glGetBufferSubData(GLenum(bindInternal(_targetHint)), offset, size, data); + glGetBufferSubData(GLenum(bindSomewhereInternal(_targetHint)), offset, size, data); } void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { @@ -300,7 +300,7 @@ void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr #endif void Buffer::dataImplementationDefault(GLsizeiptr size, const GLvoid* data, BufferUsage usage) { - glBufferData(GLenum(bindInternal(_targetHint)), size, data, GLenum(usage)); + glBufferData(GLenum(bindSomewhereInternal(_targetHint)), size, data, GLenum(usage)); } #ifndef MAGNUM_TARGET_GLES @@ -310,7 +310,7 @@ void Buffer::dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUs #endif void Buffer::subDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data) { - glBufferSubData(GLenum(bindInternal(_targetHint)), offset, size, data); + glBufferSubData(GLenum(bindSomewhereInternal(_targetHint)), offset, size, data); } #ifndef MAGNUM_TARGET_GLES @@ -337,7 +337,7 @@ void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length) void* Buffer::mapImplementationDefault(MapAccess access) { #ifndef MAGNUM_TARGET_GLES - return glMapBuffer(GLenum(bindInternal(_targetHint)), GLenum(access)); + return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) return glMapBufferOES(GLenum(bindInternal(_targetHint)), GLenum(access)); #else @@ -354,7 +354,7 @@ void* Buffer::mapImplementationDSA(MapAccess access) { void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) { #ifndef MAGNUM_TARGET_GLES2 - return glMapBufferRange(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access)); + return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) return glMapBufferRangeEXT(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access)); #else @@ -373,7 +373,7 @@ void* Buffer::mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapF void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) { #ifndef MAGNUM_TARGET_GLES2 - glFlushMappedBufferRange(GLenum(bindInternal(_targetHint)), offset, length); + glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glFlushMappedBufferRangeEXT(GLenum(bindInternal(_targetHint)), offset, length); #else @@ -391,7 +391,7 @@ void Buffer::flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr lengt bool Buffer::unmapImplementationDefault() { #ifndef MAGNUM_TARGET_GLES2 - return glUnmapBuffer(GLenum(bindInternal(_targetHint))); + return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint))); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) return glUnmapBufferOES(GLenum(bindInternal(_targetHint))); #else diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 8f867aae8..31dc9ecec 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -504,14 +504,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { static Int maxUniformBindings(); #endif - /** - * @brief Unbind any buffer from given target - * @param target %Target - * - * @see @fn_gl{BindBuffer} - */ - static void unbind(Target target) { bind(target, 0); } - #ifndef MAGNUM_TARGET_GLES2 /** * @brief Copy one buffer to another @@ -622,18 +614,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { return *this; } - /** - * @brief Bind buffer - * @param target %Target - * - * @see @fn_gl{BindBuffer} - * @todo Allow binding to Target::ElementArray only if VAO is bound - * to avoid potential issues? - * @todo Don't allow user to bind buffers? - * @bug Binding to ElementArray if any VAO is active will corrupt the mesh - */ - void bind(Target target) { bind(target, _id); } - /** * @brief %Buffer size * @@ -868,11 +848,18 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { void unmapSub(); #endif + #ifdef DOXYGEN_GENERATING_OUTPUT + private: + #endif + /* There should be no need to use these from user code */ + static void unbindInternal(Target target) { bindInternal(target, 0); } + void bindInternal(Target target) { bindInternal(target, _id); } + private: Buffer& setLabelInternal(Containers::ArrayReference label); - static void bind(Target hint, GLuint id); - Target MAGNUM_LOCAL bindInternal(Target hint); + static void bindInternal(Target hint, GLuint id); + Target MAGNUM_LOCAL bindSomewhereInternal(Target hint); #ifndef MAGNUM_TARGET_GLES2 static void MAGNUM_LOCAL copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index 5028a0e45..b7b654da7 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -355,7 +355,7 @@ void Mesh::attributePointerImplementationDSA(const Attribute& attribute) { void Mesh::vertexAttribPointer(const Attribute& attribute) { glEnableVertexAttribArray(attribute.location); - attribute.buffer->bind(Buffer::Target::Array); + attribute.buffer->bindInternal(Buffer::Target::Array); glVertexAttribPointer(attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, reinterpret_cast(attribute.offset)); if(attribute.divisor) { #ifndef MAGNUM_TARGET_GLES2 @@ -390,7 +390,7 @@ void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute) void Mesh::vertexAttribPointer(const IntegerAttribute& attribute) { glEnableVertexAttribArray(attribute.location); - attribute.buffer->bind(Buffer::Target::Array); + attribute.buffer->bindInternal(Buffer::Target::Array); glVertexAttribIPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); if(attribute.divisor) glVertexAttribDivisor(attribute.location, attribute.divisor); } @@ -418,7 +418,7 @@ void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) { void Mesh::vertexAttribPointer(const LongAttribute& attribute) { glEnableVertexAttribArray(attribute.location); - attribute.buffer->bind(Buffer::Target::Array); + attribute.buffer->bindInternal(Buffer::Target::Array); glVertexAttribLPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); if(attribute.divisor) glVertexAttribDivisor(attribute.location, attribute.divisor); } @@ -465,7 +465,7 @@ void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { /** @todo Do this cleaner way */ Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::Target::ElementArray)] = 0; - buffer.bind(Buffer::Target::ElementArray); + buffer.bindInternal(Buffer::Target::ElementArray); } void Mesh::bindImplementationDefault() { @@ -484,7 +484,7 @@ void Mesh::bindImplementationDefault() { #endif /* Bind index buffer, if the mesh is indexed */ - if(_indexBuffer) _indexBuffer->bind(Buffer::Target::ElementArray); + if(_indexBuffer) _indexBuffer->bindInternal(Buffer::Target::ElementArray); } void Mesh::bindImplementationVAO() { From a6ec3fcbf8d10c93eb1ec72d7958ea39fc40e5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 17:15:19 +0200 Subject: [PATCH 02/72] Mention usage of flextGL. --- CONTRIBUTORS.md => CREDITS.md | 7 +++++++ README.md | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) rename CONTRIBUTORS.md => CREDITS.md (70%) diff --git a/CONTRIBUTORS.md b/CREDITS.md similarity index 70% rename from CONTRIBUTORS.md rename to CREDITS.md index 5de717cf0..ce9d3beed 100644 --- a/CONTRIBUTORS.md +++ b/CREDITS.md @@ -1,3 +1,10 @@ +Third-party components +---------------------- + +* **flextGL** extension loader generator -- https://github.com/ginkgo/flextGL, + Copyright © 2011 Thomas Weber, licensed under + [MIT license](https://raw.githubusercontent.com/ginkgo/flextGL/master/COPYING) + Contributors to Magnum library ------------------------------ diff --git a/README.md b/README.md index e561f3a32..984c6265c 100644 --- a/README.md +++ b/README.md @@ -172,11 +172,10 @@ idea? Feel free to visit my website or contact me at: * E-mail -- mosra@centrum.cz * Jabber -- mosra@jabbim.cz -CONTRIBUTORS -============ +CREDITS +======= -See [CONTRIBUTORS.md](CONTRIBUTORS.md) file for details. Big thanks to everyone -involved! +See [CREDITS.md](CREDITS.md) file for details. Big thanks to everyone involved! LICENSE ======= From 561a3cc9653a05adb40a07a4963edba593285207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 19:58:55 +0200 Subject: [PATCH 03/72] Fix compilation on ES. --- src/Magnum/Buffer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 83bc6fa4f..e5f072b7a 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -339,7 +339,7 @@ void* Buffer::mapImplementationDefault(MapAccess access) { #ifndef MAGNUM_TARGET_GLES return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - return glMapBufferOES(GLenum(bindInternal(_targetHint)), GLenum(access)); + return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); #else static_cast(access); CORRADE_ASSERT_UNREACHABLE(); @@ -356,7 +356,7 @@ void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, #ifndef MAGNUM_TARGET_GLES2 return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - return glMapBufferRangeEXT(GLenum(bindInternal(_targetHint)), offset, length, GLenum(access)); + return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); #else static_cast(offset); static_cast(length); @@ -375,7 +375,7 @@ void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr l #ifndef MAGNUM_TARGET_GLES2 glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glFlushMappedBufferRangeEXT(GLenum(bindInternal(_targetHint)), offset, length); + glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length); #else static_cast(offset); static_cast(length); @@ -393,7 +393,7 @@ bool Buffer::unmapImplementationDefault() { #ifndef MAGNUM_TARGET_GLES2 return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint))); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - return glUnmapBufferOES(GLenum(bindInternal(_targetHint))); + return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint))); #else CORRADE_ASSERT_UNREACHABLE(); #endif From c2b01cf6de7348a9608875980b0c455e7ceb4c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 17:58:39 +0200 Subject: [PATCH 04/72] Doc++ --- src/Magnum/Buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 31dc9ecec..abf1817e0 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -213,7 +213,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { /** * @brief %Buffer target * - * @see @ref bind(Target), @ref unbind(Target) + * @see @ref Buffer(), @ref setTargetHint() */ enum class Target: GLenum { /** Used for storing vertex attributes. */ From 009f2e29b626a92cd45c821f46912c0f4f83f42d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 01:36:37 +0200 Subject: [PATCH 05/72] Updated GL headers for OpenGL 4.5. --- src/MagnumExternal/OpenGL/GL/extensions.txt | 4 +- src/MagnumExternal/OpenGL/GL/flextGL.cpp | 108 ++++++++ src/MagnumExternal/OpenGL/GL/flextGL.h | 257 ++++++++++++++++++ .../OpenGL/GL/flextGLPlatform.cpp | 108 ++++++++ 4 files changed, 475 insertions(+), 2 deletions(-) diff --git a/src/MagnumExternal/OpenGL/GL/extensions.txt b/src/MagnumExternal/OpenGL/GL/extensions.txt index 5fbd0749d..1410f6530 100644 --- a/src/MagnumExternal/OpenGL/GL/extensions.txt +++ b/src/MagnumExternal/OpenGL/GL/extensions.txt @@ -1,7 +1,7 @@ # The following output is taken from `magnum-info` with removed `GL_` prefixes. -# Only vendor extensions are needed, everything else is pulled in with GL 4.4. +# Only vendor extensions are needed, everything else is pulled in with GL 4.5. -version 4.4 core +version 4.5 core extension AMD_vertex_shader_layer optional extension AMD_shader_trinary_minmax optional diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.cpp b/src/MagnumExternal/OpenGL/GL/flextGL.cpp index 7f45fa612..327438d99 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGL.cpp @@ -516,6 +516,114 @@ FLEXTGL_EXPORT void(APIENTRY *flextglBindSamplers)(GLuint, GLsizei, const GLuint FLEXTGL_EXPORT void(APIENTRY *flextglBindImageTextures)(GLuint, GLsizei, const GLuint *) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglBindVertexBuffers)(GLuint, GLsizei, const GLuint *, const GLintptr *, const GLsizei *) = nullptr; +/* GL_VERSION_4_5 */ +FLEXTGL_EXPORT void(APIENTRY *flextglClipControl)(GLenum, GLenum) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateTransformFeedbacks)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTransformFeedbackBufferBase)(GLuint, GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTransformFeedbackBufferRange)(GLuint, GLuint, GLuint, GLintptr, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTransformFeedbackiv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTransformFeedbacki_v)(GLuint, GLenum, GLuint, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTransformFeedbacki64_v)(GLuint, GLenum, GLuint, GLint64 *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateBuffers)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedBufferStorage)(GLuint, GLsizei, const void *, GLbitfield) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedBufferData)(GLuint, GLsizei, const void *, GLenum) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedBufferSubData)(GLuint, GLintptr, GLsizei, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCopyNamedBufferSubData)(GLuint, GLuint, GLintptr, GLintptr, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferData)(GLuint, GLenum, GLenum, GLenum, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferSubData)(GLuint, GLenum, GLintptr, GLsizei, GLenum, GLenum, const void *) = nullptr; +FLEXTGL_EXPORT void *(APIENTRY *flextglMapNamedBuffer)(GLuint, GLenum) = nullptr; +FLEXTGL_EXPORT void *(APIENTRY *flextglMapNamedBufferRange)(GLuint, GLintptr, GLsizei, GLbitfield) = nullptr; +FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapNamedBuffer)(GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglFlushMappedNamedBufferRange)(GLuint, GLintptr, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferParameteriv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferParameteri64v)(GLuint, GLenum, GLint64 *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferPointerv)(GLuint, GLenum, void **) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferSubData)(GLuint, GLintptr, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateFramebuffers)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferRenderbuffer)(GLuint, GLenum, GLenum, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferParameteri)(GLuint, GLenum, GLint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferTexture)(GLuint, GLenum, GLuint, GLint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferTextureLayer)(GLuint, GLenum, GLuint, GLint, GLint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferDrawBuffer)(GLuint, GLenum) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferDrawBuffers)(GLuint, GLsizei, const GLenum *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferReadBuffer)(GLuint, GLenum) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglInvalidateNamedFramebufferData)(GLuint, GLsizei, const GLenum *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglInvalidateNamedFramebufferSubData)(GLuint, GLsizei, const GLenum *, GLint, GLint, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferiv)(GLuint, GLenum, GLint, const GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferuiv)(GLuint, GLenum, GLint, const GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfv)(GLuint, GLenum, GLint, const GLfloat *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfi)(GLuint, GLenum, const GLfloat, GLint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglBlitNamedFramebuffer)(GLuint, GLuint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = nullptr; +FLEXTGL_EXPORT GLenum(APIENTRY *flextglCheckNamedFramebufferStatus)(GLuint, GLenum) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedFramebufferParameteriv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedFramebufferAttachmentParameteriv)(GLuint, GLenum, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateRenderbuffers)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedRenderbufferStorage)(GLuint, GLenum, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglNamedRenderbufferStorageMultisample)(GLuint, GLsizei, GLenum, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedRenderbufferParameteriv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateTextures)(GLenum, GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureBuffer)(GLuint, GLenum, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureBufferRange)(GLuint, GLenum, GLuint, GLintptr, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage1D)(GLuint, GLsizei, GLenum, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage2D)(GLuint, GLsizei, GLenum, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage3D)(GLuint, GLsizei, GLenum, GLsizei, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage2DMultisample)(GLuint, GLsizei, GLenum, GLsizei, GLsizei, GLboolean) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage3DMultisample)(GLuint, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, GLboolean) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureSubImage1D)(GLuint, GLint, GLint, GLsizei, GLenum, GLenum, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureSubImage2D)(GLuint, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureSubImage3D)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCompressedTextureSubImage1D)(GLuint, GLint, GLint, GLsizei, GLenum, GLsizei, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCompressedTextureSubImage2D)(GLuint, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCompressedTextureSubImage3D)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCopyTextureSubImage1D)(GLuint, GLint, GLint, GLint, GLint, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCopyTextureSubImage2D)(GLuint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCopyTextureSubImage3D)(GLuint, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterf)(GLuint, GLenum, GLfloat) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterfv)(GLuint, GLenum, const GLfloat *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameteri)(GLuint, GLenum, GLint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterIiv)(GLuint, GLenum, const GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterIuiv)(GLuint, GLenum, const GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameteriv)(GLuint, GLenum, const GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGenerateTextureMipmap)(GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglBindTextureUnit)(GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureImage)(GLuint, GLint, GLenum, GLenum, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetCompressedTextureImage)(GLuint, GLint, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureLevelParameterfv)(GLuint, GLint, GLenum, GLfloat *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureLevelParameteriv)(GLuint, GLint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameterfv)(GLuint, GLenum, GLfloat *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameterIiv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameterIuiv)(GLuint, GLenum, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameteriv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateVertexArrays)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglDisableVertexArrayAttrib)(GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglEnableVertexArrayAttrib)(GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayElementBuffer)(GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayVertexBuffer)(GLuint, GLuint, GLuint, GLintptr, GLsizei) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayVertexBuffers)(GLuint, GLuint, GLsizei, const GLuint *, const GLintptr *, const GLsizei *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribBinding)(GLuint, GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribFormat)(GLuint, GLuint, GLint, GLenum, GLboolean, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribIFormat)(GLuint, GLuint, GLint, GLenum, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribLFormat)(GLuint, GLuint, GLint, GLenum, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayBindingDivisor)(GLuint, GLuint, GLuint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetVertexArrayiv)(GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetVertexArrayIndexediv)(GLuint, GLuint, GLenum, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetVertexArrayIndexed64iv)(GLuint, GLuint, GLenum, GLint64 *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateSamplers)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateProgramPipelines)(GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglCreateQueries)(GLenum, GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglMemoryBarrierByRegion)(GLbitfield) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureSubImage)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetCompressedTextureSubImage)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT GLenum(APIENTRY *flextglGetGraphicsResetStatus)(void) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetnCompressedTexImage)(GLenum, GLint, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetnTexImage)(GLenum, GLint, GLenum, GLenum, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformdv)(GLuint, GLint, GLsizei, GLdouble *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformfv)(GLuint, GLint, GLsizei, GLfloat *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformiv)(GLuint, GLint, GLsizei, GLint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformuiv)(GLuint, GLint, GLsizei, GLuint *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglReadnPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLsizei, void *) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglTextureBarrier)(void) = nullptr; + /* GL_ARB_robustness */ FLEXTGL_EXPORT GLenum(APIENTRY *flextglGetGraphicsResetStatusARB)(void) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglGetnTexImageARB)(GLenum, GLint, GLenum, GLenum, GLsizei, void *) = nullptr; diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.h b/src/MagnumExternal/OpenGL/GL/flextGL.h index 927f8322c..a6752e6d8 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.h +++ b/src/MagnumExternal/OpenGL/GL/flextGL.h @@ -1483,6 +1483,48 @@ typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum #define GL_STENCIL_INDEX8 0x8D48 #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +/* GL_VERSION_4_5 */ + +#define GL_CONTEXT_LOST 0x0507 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_TEXTURE_BINDING 0x82EB +#define GL_NO_ERROR 0 +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_LOST 0x0507 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_NONE 0 +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC + /* GL_ARB_robustness */ #define GL_NO_ERROR 0 @@ -2611,6 +2653,221 @@ GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglBindImageTextures)(GLuint, GLsizei, c GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglBindVertexBuffers)(GLuint, GLsizei, const GLuint *, const GLintptr *, const GLsizei *); #define glBindVertexBuffers flextglBindVertexBuffers +/* GL_VERSION_4_5 */ + +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClipControl)(GLenum, GLenum); +#define glClipControl flextglClipControl +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateTransformFeedbacks)(GLsizei, GLuint *); +#define glCreateTransformFeedbacks flextglCreateTransformFeedbacks +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTransformFeedbackBufferBase)(GLuint, GLuint, GLuint); +#define glTransformFeedbackBufferBase flextglTransformFeedbackBufferBase +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTransformFeedbackBufferRange)(GLuint, GLuint, GLuint, GLintptr, GLsizei); +#define glTransformFeedbackBufferRange flextglTransformFeedbackBufferRange +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTransformFeedbackiv)(GLuint, GLenum, GLint *); +#define glGetTransformFeedbackiv flextglGetTransformFeedbackiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTransformFeedbacki_v)(GLuint, GLenum, GLuint, GLint *); +#define glGetTransformFeedbacki_v flextglGetTransformFeedbacki_v +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTransformFeedbacki64_v)(GLuint, GLenum, GLuint, GLint64 *); +#define glGetTransformFeedbacki64_v flextglGetTransformFeedbacki64_v +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateBuffers)(GLsizei, GLuint *); +#define glCreateBuffers flextglCreateBuffers +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedBufferStorage)(GLuint, GLsizei, const void *, GLbitfield); +#define glNamedBufferStorage flextglNamedBufferStorage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedBufferData)(GLuint, GLsizei, const void *, GLenum); +#define glNamedBufferData flextglNamedBufferData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedBufferSubData)(GLuint, GLintptr, GLsizei, const void *); +#define glNamedBufferSubData flextglNamedBufferSubData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCopyNamedBufferSubData)(GLuint, GLuint, GLintptr, GLintptr, GLsizei); +#define glCopyNamedBufferSubData flextglCopyNamedBufferSubData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferData)(GLuint, GLenum, GLenum, GLenum, const void *); +#define glClearNamedBufferData flextglClearNamedBufferData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferSubData)(GLuint, GLenum, GLintptr, GLsizei, GLenum, GLenum, const void *); +#define glClearNamedBufferSubData flextglClearNamedBufferSubData +GLAPI FLEXTGL_EXPORT void *(APIENTRY *flextglMapNamedBuffer)(GLuint, GLenum); +#define glMapNamedBuffer flextglMapNamedBuffer +GLAPI FLEXTGL_EXPORT void *(APIENTRY *flextglMapNamedBufferRange)(GLuint, GLintptr, GLsizei, GLbitfield); +#define glMapNamedBufferRange flextglMapNamedBufferRange +GLAPI FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapNamedBuffer)(GLuint); +#define glUnmapNamedBuffer flextglUnmapNamedBuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglFlushMappedNamedBufferRange)(GLuint, GLintptr, GLsizei); +#define glFlushMappedNamedBufferRange flextglFlushMappedNamedBufferRange +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferParameteriv)(GLuint, GLenum, GLint *); +#define glGetNamedBufferParameteriv flextglGetNamedBufferParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferParameteri64v)(GLuint, GLenum, GLint64 *); +#define glGetNamedBufferParameteri64v flextglGetNamedBufferParameteri64v +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferPointerv)(GLuint, GLenum, void **); +#define glGetNamedBufferPointerv flextglGetNamedBufferPointerv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedBufferSubData)(GLuint, GLintptr, GLsizei, void *); +#define glGetNamedBufferSubData flextglGetNamedBufferSubData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateFramebuffers)(GLsizei, GLuint *); +#define glCreateFramebuffers flextglCreateFramebuffers +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferRenderbuffer)(GLuint, GLenum, GLenum, GLuint); +#define glNamedFramebufferRenderbuffer flextglNamedFramebufferRenderbuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferParameteri)(GLuint, GLenum, GLint); +#define glNamedFramebufferParameteri flextglNamedFramebufferParameteri +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferTexture)(GLuint, GLenum, GLuint, GLint); +#define glNamedFramebufferTexture flextglNamedFramebufferTexture +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferTextureLayer)(GLuint, GLenum, GLuint, GLint, GLint); +#define glNamedFramebufferTextureLayer flextglNamedFramebufferTextureLayer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferDrawBuffer)(GLuint, GLenum); +#define glNamedFramebufferDrawBuffer flextglNamedFramebufferDrawBuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferDrawBuffers)(GLuint, GLsizei, const GLenum *); +#define glNamedFramebufferDrawBuffers flextglNamedFramebufferDrawBuffers +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedFramebufferReadBuffer)(GLuint, GLenum); +#define glNamedFramebufferReadBuffer flextglNamedFramebufferReadBuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglInvalidateNamedFramebufferData)(GLuint, GLsizei, const GLenum *); +#define glInvalidateNamedFramebufferData flextglInvalidateNamedFramebufferData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglInvalidateNamedFramebufferSubData)(GLuint, GLsizei, const GLenum *, GLint, GLint, GLsizei, GLsizei); +#define glInvalidateNamedFramebufferSubData flextglInvalidateNamedFramebufferSubData +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferiv)(GLuint, GLenum, GLint, const GLint *); +#define glClearNamedFramebufferiv flextglClearNamedFramebufferiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferuiv)(GLuint, GLenum, GLint, const GLuint *); +#define glClearNamedFramebufferuiv flextglClearNamedFramebufferuiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfv)(GLuint, GLenum, GLint, const GLfloat *); +#define glClearNamedFramebufferfv flextglClearNamedFramebufferfv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfi)(GLuint, GLenum, const GLfloat, GLint); +#define glClearNamedFramebufferfi flextglClearNamedFramebufferfi +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglBlitNamedFramebuffer)(GLuint, GLuint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +#define glBlitNamedFramebuffer flextglBlitNamedFramebuffer +GLAPI FLEXTGL_EXPORT GLenum(APIENTRY *flextglCheckNamedFramebufferStatus)(GLuint, GLenum); +#define glCheckNamedFramebufferStatus flextglCheckNamedFramebufferStatus +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedFramebufferParameteriv)(GLuint, GLenum, GLint *); +#define glGetNamedFramebufferParameteriv flextglGetNamedFramebufferParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedFramebufferAttachmentParameteriv)(GLuint, GLenum, GLenum, GLint *); +#define glGetNamedFramebufferAttachmentParameteriv flextglGetNamedFramebufferAttachmentParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateRenderbuffers)(GLsizei, GLuint *); +#define glCreateRenderbuffers flextglCreateRenderbuffers +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedRenderbufferStorage)(GLuint, GLenum, GLsizei, GLsizei); +#define glNamedRenderbufferStorage flextglNamedRenderbufferStorage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglNamedRenderbufferStorageMultisample)(GLuint, GLsizei, GLenum, GLsizei, GLsizei); +#define glNamedRenderbufferStorageMultisample flextglNamedRenderbufferStorageMultisample +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetNamedRenderbufferParameteriv)(GLuint, GLenum, GLint *); +#define glGetNamedRenderbufferParameteriv flextglGetNamedRenderbufferParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateTextures)(GLenum, GLsizei, GLuint *); +#define glCreateTextures flextglCreateTextures +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureBuffer)(GLuint, GLenum, GLuint); +#define glTextureBuffer flextglTextureBuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureBufferRange)(GLuint, GLenum, GLuint, GLintptr, GLsizei); +#define glTextureBufferRange flextglTextureBufferRange +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage1D)(GLuint, GLsizei, GLenum, GLsizei); +#define glTextureStorage1D flextglTextureStorage1D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage2D)(GLuint, GLsizei, GLenum, GLsizei, GLsizei); +#define glTextureStorage2D flextglTextureStorage2D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage3D)(GLuint, GLsizei, GLenum, GLsizei, GLsizei, GLsizei); +#define glTextureStorage3D flextglTextureStorage3D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage2DMultisample)(GLuint, GLsizei, GLenum, GLsizei, GLsizei, GLboolean); +#define glTextureStorage2DMultisample flextglTextureStorage2DMultisample +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureStorage3DMultisample)(GLuint, GLsizei, GLenum, GLsizei, GLsizei, GLsizei, GLboolean); +#define glTextureStorage3DMultisample flextglTextureStorage3DMultisample +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureSubImage1D)(GLuint, GLint, GLint, GLsizei, GLenum, GLenum, const void *); +#define glTextureSubImage1D flextglTextureSubImage1D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureSubImage2D)(GLuint, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *); +#define glTextureSubImage2D flextglTextureSubImage2D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureSubImage3D)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void *); +#define glTextureSubImage3D flextglTextureSubImage3D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCompressedTextureSubImage1D)(GLuint, GLint, GLint, GLsizei, GLenum, GLsizei, const void *); +#define glCompressedTextureSubImage1D flextglCompressedTextureSubImage1D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCompressedTextureSubImage2D)(GLuint, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *); +#define glCompressedTextureSubImage2D flextglCompressedTextureSubImage2D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCompressedTextureSubImage3D)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *); +#define glCompressedTextureSubImage3D flextglCompressedTextureSubImage3D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCopyTextureSubImage1D)(GLuint, GLint, GLint, GLint, GLint, GLsizei); +#define glCopyTextureSubImage1D flextglCopyTextureSubImage1D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCopyTextureSubImage2D)(GLuint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#define glCopyTextureSubImage2D flextglCopyTextureSubImage2D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCopyTextureSubImage3D)(GLuint, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#define glCopyTextureSubImage3D flextglCopyTextureSubImage3D +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterf)(GLuint, GLenum, GLfloat); +#define glTextureParameterf flextglTextureParameterf +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterfv)(GLuint, GLenum, const GLfloat *); +#define glTextureParameterfv flextglTextureParameterfv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameteri)(GLuint, GLenum, GLint); +#define glTextureParameteri flextglTextureParameteri +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterIiv)(GLuint, GLenum, const GLint *); +#define glTextureParameterIiv flextglTextureParameterIiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameterIuiv)(GLuint, GLenum, const GLuint *); +#define glTextureParameterIuiv flextglTextureParameterIuiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureParameteriv)(GLuint, GLenum, const GLint *); +#define glTextureParameteriv flextglTextureParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGenerateTextureMipmap)(GLuint); +#define glGenerateTextureMipmap flextglGenerateTextureMipmap +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglBindTextureUnit)(GLuint, GLuint); +#define glBindTextureUnit flextglBindTextureUnit +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureImage)(GLuint, GLint, GLenum, GLenum, GLsizei, void *); +#define glGetTextureImage flextglGetTextureImage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetCompressedTextureImage)(GLuint, GLint, GLsizei, void *); +#define glGetCompressedTextureImage flextglGetCompressedTextureImage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureLevelParameterfv)(GLuint, GLint, GLenum, GLfloat *); +#define glGetTextureLevelParameterfv flextglGetTextureLevelParameterfv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureLevelParameteriv)(GLuint, GLint, GLenum, GLint *); +#define glGetTextureLevelParameteriv flextglGetTextureLevelParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameterfv)(GLuint, GLenum, GLfloat *); +#define glGetTextureParameterfv flextglGetTextureParameterfv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameterIiv)(GLuint, GLenum, GLint *); +#define glGetTextureParameterIiv flextglGetTextureParameterIiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameterIuiv)(GLuint, GLenum, GLuint *); +#define glGetTextureParameterIuiv flextglGetTextureParameterIuiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureParameteriv)(GLuint, GLenum, GLint *); +#define glGetTextureParameteriv flextglGetTextureParameteriv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateVertexArrays)(GLsizei, GLuint *); +#define glCreateVertexArrays flextglCreateVertexArrays +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglDisableVertexArrayAttrib)(GLuint, GLuint); +#define glDisableVertexArrayAttrib flextglDisableVertexArrayAttrib +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglEnableVertexArrayAttrib)(GLuint, GLuint); +#define glEnableVertexArrayAttrib flextglEnableVertexArrayAttrib +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayElementBuffer)(GLuint, GLuint); +#define glVertexArrayElementBuffer flextglVertexArrayElementBuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayVertexBuffer)(GLuint, GLuint, GLuint, GLintptr, GLsizei); +#define glVertexArrayVertexBuffer flextglVertexArrayVertexBuffer +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayVertexBuffers)(GLuint, GLuint, GLsizei, const GLuint *, const GLintptr *, const GLsizei *); +#define glVertexArrayVertexBuffers flextglVertexArrayVertexBuffers +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribBinding)(GLuint, GLuint, GLuint); +#define glVertexArrayAttribBinding flextglVertexArrayAttribBinding +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribFormat)(GLuint, GLuint, GLint, GLenum, GLboolean, GLuint); +#define glVertexArrayAttribFormat flextglVertexArrayAttribFormat +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribIFormat)(GLuint, GLuint, GLint, GLenum, GLuint); +#define glVertexArrayAttribIFormat flextglVertexArrayAttribIFormat +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayAttribLFormat)(GLuint, GLuint, GLint, GLenum, GLuint); +#define glVertexArrayAttribLFormat flextglVertexArrayAttribLFormat +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglVertexArrayBindingDivisor)(GLuint, GLuint, GLuint); +#define glVertexArrayBindingDivisor flextglVertexArrayBindingDivisor +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetVertexArrayiv)(GLuint, GLenum, GLint *); +#define glGetVertexArrayiv flextglGetVertexArrayiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetVertexArrayIndexediv)(GLuint, GLuint, GLenum, GLint *); +#define glGetVertexArrayIndexediv flextglGetVertexArrayIndexediv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetVertexArrayIndexed64iv)(GLuint, GLuint, GLenum, GLint64 *); +#define glGetVertexArrayIndexed64iv flextglGetVertexArrayIndexed64iv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateSamplers)(GLsizei, GLuint *); +#define glCreateSamplers flextglCreateSamplers +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateProgramPipelines)(GLsizei, GLuint *); +#define glCreateProgramPipelines flextglCreateProgramPipelines +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglCreateQueries)(GLenum, GLsizei, GLuint *); +#define glCreateQueries flextglCreateQueries +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglMemoryBarrierByRegion)(GLbitfield); +#define glMemoryBarrierByRegion flextglMemoryBarrierByRegion +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetTextureSubImage)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLsizei, void *); +#define glGetTextureSubImage flextglGetTextureSubImage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetCompressedTextureSubImage)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, void *); +#define glGetCompressedTextureSubImage flextglGetCompressedTextureSubImage +GLAPI FLEXTGL_EXPORT GLenum(APIENTRY *flextglGetGraphicsResetStatus)(void); +#define glGetGraphicsResetStatus flextglGetGraphicsResetStatus +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetnCompressedTexImage)(GLenum, GLint, GLsizei, void *); +#define glGetnCompressedTexImage flextglGetnCompressedTexImage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetnTexImage)(GLenum, GLint, GLenum, GLenum, GLsizei, void *); +#define glGetnTexImage flextglGetnTexImage +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformdv)(GLuint, GLint, GLsizei, GLdouble *); +#define glGetnUniformdv flextglGetnUniformdv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformfv)(GLuint, GLint, GLsizei, GLfloat *); +#define glGetnUniformfv flextglGetnUniformfv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformiv)(GLuint, GLint, GLsizei, GLint *); +#define glGetnUniformiv flextglGetnUniformiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetnUniformuiv)(GLuint, GLint, GLsizei, GLuint *); +#define glGetnUniformuiv flextglGetnUniformuiv +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglReadnPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLsizei, void *); +#define glReadnPixels flextglReadnPixels +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglTextureBarrier)(void); +#define glTextureBarrier flextglTextureBarrier + /* GL_AMD_vertex_shader_layer */ diff --git a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp index b666b8db8..c27911197 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp @@ -520,6 +520,114 @@ void flextGLInit() { flextglBindImageTextures = reinterpret_cast(loader.load("glBindImageTextures")); flextglBindVertexBuffers = reinterpret_cast(loader.load("glBindVertexBuffers")); + /* GL_VERSION_4_5 */ + flextglClipControl = reinterpret_cast(loader.load("glClipControl")); + flextglCreateTransformFeedbacks = reinterpret_cast(loader.load("glCreateTransformFeedbacks")); + flextglTransformFeedbackBufferBase = reinterpret_cast(loader.load("glTransformFeedbackBufferBase")); + flextglTransformFeedbackBufferRange = reinterpret_cast(loader.load("glTransformFeedbackBufferRange")); + flextglGetTransformFeedbackiv = reinterpret_cast(loader.load("glGetTransformFeedbackiv")); + flextglGetTransformFeedbacki_v = reinterpret_cast(loader.load("glGetTransformFeedbacki_v")); + flextglGetTransformFeedbacki64_v = reinterpret_cast(loader.load("glGetTransformFeedbacki64_v")); + flextglCreateBuffers = reinterpret_cast(loader.load("glCreateBuffers")); + flextglNamedBufferStorage = reinterpret_cast(loader.load("glNamedBufferStorage")); + flextglNamedBufferData = reinterpret_cast(loader.load("glNamedBufferData")); + flextglNamedBufferSubData = reinterpret_cast(loader.load("glNamedBufferSubData")); + flextglCopyNamedBufferSubData = reinterpret_cast(loader.load("glCopyNamedBufferSubData")); + flextglClearNamedBufferData = reinterpret_cast(loader.load("glClearNamedBufferData")); + flextglClearNamedBufferSubData = reinterpret_cast(loader.load("glClearNamedBufferSubData")); + flextglMapNamedBuffer = reinterpret_cast(loader.load("glMapNamedBuffer")); + flextglMapNamedBufferRange = reinterpret_cast(loader.load("glMapNamedBufferRange")); + flextglUnmapNamedBuffer = reinterpret_cast(loader.load("glUnmapNamedBuffer")); + flextglFlushMappedNamedBufferRange = reinterpret_cast(loader.load("glFlushMappedNamedBufferRange")); + flextglGetNamedBufferParameteriv = reinterpret_cast(loader.load("glGetNamedBufferParameteriv")); + flextglGetNamedBufferParameteri64v = reinterpret_cast(loader.load("glGetNamedBufferParameteri64v")); + flextglGetNamedBufferPointerv = reinterpret_cast(loader.load("glGetNamedBufferPointerv")); + flextglGetNamedBufferSubData = reinterpret_cast(loader.load("glGetNamedBufferSubData")); + flextglCreateFramebuffers = reinterpret_cast(loader.load("glCreateFramebuffers")); + flextglNamedFramebufferRenderbuffer = reinterpret_cast(loader.load("glNamedFramebufferRenderbuffer")); + flextglNamedFramebufferParameteri = reinterpret_cast(loader.load("glNamedFramebufferParameteri")); + flextglNamedFramebufferTexture = reinterpret_cast(loader.load("glNamedFramebufferTexture")); + flextglNamedFramebufferTextureLayer = reinterpret_cast(loader.load("glNamedFramebufferTextureLayer")); + flextglNamedFramebufferDrawBuffer = reinterpret_cast(loader.load("glNamedFramebufferDrawBuffer")); + flextglNamedFramebufferDrawBuffers = reinterpret_cast(loader.load("glNamedFramebufferDrawBuffers")); + flextglNamedFramebufferReadBuffer = reinterpret_cast(loader.load("glNamedFramebufferReadBuffer")); + flextglInvalidateNamedFramebufferData = reinterpret_cast(loader.load("glInvalidateNamedFramebufferData")); + flextglInvalidateNamedFramebufferSubData = reinterpret_cast(loader.load("glInvalidateNamedFramebufferSubData")); + flextglClearNamedFramebufferiv = reinterpret_cast(loader.load("glClearNamedFramebufferiv")); + flextglClearNamedFramebufferuiv = reinterpret_cast(loader.load("glClearNamedFramebufferuiv")); + flextglClearNamedFramebufferfv = reinterpret_cast(loader.load("glClearNamedFramebufferfv")); + flextglClearNamedFramebufferfi = reinterpret_cast(loader.load("glClearNamedFramebufferfi")); + flextglBlitNamedFramebuffer = reinterpret_cast(loader.load("glBlitNamedFramebuffer")); + flextglCheckNamedFramebufferStatus = reinterpret_cast(loader.load("glCheckNamedFramebufferStatus")); + flextglGetNamedFramebufferParameteriv = reinterpret_cast(loader.load("glGetNamedFramebufferParameteriv")); + flextglGetNamedFramebufferAttachmentParameteriv = reinterpret_cast(loader.load("glGetNamedFramebufferAttachmentParameteriv")); + flextglCreateRenderbuffers = reinterpret_cast(loader.load("glCreateRenderbuffers")); + flextglNamedRenderbufferStorage = reinterpret_cast(loader.load("glNamedRenderbufferStorage")); + flextglNamedRenderbufferStorageMultisample = reinterpret_cast(loader.load("glNamedRenderbufferStorageMultisample")); + flextglGetNamedRenderbufferParameteriv = reinterpret_cast(loader.load("glGetNamedRenderbufferParameteriv")); + flextglCreateTextures = reinterpret_cast(loader.load("glCreateTextures")); + flextglTextureBuffer = reinterpret_cast(loader.load("glTextureBuffer")); + flextglTextureBufferRange = reinterpret_cast(loader.load("glTextureBufferRange")); + flextglTextureStorage1D = reinterpret_cast(loader.load("glTextureStorage1D")); + flextglTextureStorage2D = reinterpret_cast(loader.load("glTextureStorage2D")); + flextglTextureStorage3D = reinterpret_cast(loader.load("glTextureStorage3D")); + flextglTextureStorage2DMultisample = reinterpret_cast(loader.load("glTextureStorage2DMultisample")); + flextglTextureStorage3DMultisample = reinterpret_cast(loader.load("glTextureStorage3DMultisample")); + flextglTextureSubImage1D = reinterpret_cast(loader.load("glTextureSubImage1D")); + flextglTextureSubImage2D = reinterpret_cast(loader.load("glTextureSubImage2D")); + flextglTextureSubImage3D = reinterpret_cast(loader.load("glTextureSubImage3D")); + flextglCompressedTextureSubImage1D = reinterpret_cast(loader.load("glCompressedTextureSubImage1D")); + flextglCompressedTextureSubImage2D = reinterpret_cast(loader.load("glCompressedTextureSubImage2D")); + flextglCompressedTextureSubImage3D = reinterpret_cast(loader.load("glCompressedTextureSubImage3D")); + flextglCopyTextureSubImage1D = reinterpret_cast(loader.load("glCopyTextureSubImage1D")); + flextglCopyTextureSubImage2D = reinterpret_cast(loader.load("glCopyTextureSubImage2D")); + flextglCopyTextureSubImage3D = reinterpret_cast(loader.load("glCopyTextureSubImage3D")); + flextglTextureParameterf = reinterpret_cast(loader.load("glTextureParameterf")); + flextglTextureParameterfv = reinterpret_cast(loader.load("glTextureParameterfv")); + flextglTextureParameteri = reinterpret_cast(loader.load("glTextureParameteri")); + flextglTextureParameterIiv = reinterpret_cast(loader.load("glTextureParameterIiv")); + flextglTextureParameterIuiv = reinterpret_cast(loader.load("glTextureParameterIuiv")); + flextglTextureParameteriv = reinterpret_cast(loader.load("glTextureParameteriv")); + flextglGenerateTextureMipmap = reinterpret_cast(loader.load("glGenerateTextureMipmap")); + flextglBindTextureUnit = reinterpret_cast(loader.load("glBindTextureUnit")); + flextglGetTextureImage = reinterpret_cast(loader.load("glGetTextureImage")); + flextglGetCompressedTextureImage = reinterpret_cast(loader.load("glGetCompressedTextureImage")); + flextglGetTextureLevelParameterfv = reinterpret_cast(loader.load("glGetTextureLevelParameterfv")); + flextglGetTextureLevelParameteriv = reinterpret_cast(loader.load("glGetTextureLevelParameteriv")); + flextglGetTextureParameterfv = reinterpret_cast(loader.load("glGetTextureParameterfv")); + flextglGetTextureParameterIiv = reinterpret_cast(loader.load("glGetTextureParameterIiv")); + flextglGetTextureParameterIuiv = reinterpret_cast(loader.load("glGetTextureParameterIuiv")); + flextglGetTextureParameteriv = reinterpret_cast(loader.load("glGetTextureParameteriv")); + flextglCreateVertexArrays = reinterpret_cast(loader.load("glCreateVertexArrays")); + flextglDisableVertexArrayAttrib = reinterpret_cast(loader.load("glDisableVertexArrayAttrib")); + flextglEnableVertexArrayAttrib = reinterpret_cast(loader.load("glEnableVertexArrayAttrib")); + flextglVertexArrayElementBuffer = reinterpret_cast(loader.load("glVertexArrayElementBuffer")); + flextglVertexArrayVertexBuffer = reinterpret_cast(loader.load("glVertexArrayVertexBuffer")); + flextglVertexArrayVertexBuffers = reinterpret_cast(loader.load("glVertexArrayVertexBuffers")); + flextglVertexArrayAttribBinding = reinterpret_cast(loader.load("glVertexArrayAttribBinding")); + flextglVertexArrayAttribFormat = reinterpret_cast(loader.load("glVertexArrayAttribFormat")); + flextglVertexArrayAttribIFormat = reinterpret_cast(loader.load("glVertexArrayAttribIFormat")); + flextglVertexArrayAttribLFormat = reinterpret_cast(loader.load("glVertexArrayAttribLFormat")); + flextglVertexArrayBindingDivisor = reinterpret_cast(loader.load("glVertexArrayBindingDivisor")); + flextglGetVertexArrayiv = reinterpret_cast(loader.load("glGetVertexArrayiv")); + flextglGetVertexArrayIndexediv = reinterpret_cast(loader.load("glGetVertexArrayIndexediv")); + flextglGetVertexArrayIndexed64iv = reinterpret_cast(loader.load("glGetVertexArrayIndexed64iv")); + flextglCreateSamplers = reinterpret_cast(loader.load("glCreateSamplers")); + flextglCreateProgramPipelines = reinterpret_cast(loader.load("glCreateProgramPipelines")); + flextglCreateQueries = reinterpret_cast(loader.load("glCreateQueries")); + flextglMemoryBarrierByRegion = reinterpret_cast(loader.load("glMemoryBarrierByRegion")); + flextglGetTextureSubImage = reinterpret_cast(loader.load("glGetTextureSubImage")); + flextglGetCompressedTextureSubImage = reinterpret_cast(loader.load("glGetCompressedTextureSubImage")); + flextglGetGraphicsResetStatus = reinterpret_cast(loader.load("glGetGraphicsResetStatus")); + flextglGetnCompressedTexImage = reinterpret_cast(loader.load("glGetnCompressedTexImage")); + flextglGetnTexImage = reinterpret_cast(loader.load("glGetnTexImage")); + flextglGetnUniformdv = reinterpret_cast(loader.load("glGetnUniformdv")); + flextglGetnUniformfv = reinterpret_cast(loader.load("glGetnUniformfv")); + flextglGetnUniformiv = reinterpret_cast(loader.load("glGetnUniformiv")); + flextglGetnUniformuiv = reinterpret_cast(loader.load("glGetnUniformuiv")); + flextglReadnPixels = reinterpret_cast(loader.load("glReadnPixels")); + flextglTextureBarrier = reinterpret_cast(loader.load("glTextureBarrier")); + /* GL_AMD_vertex_shader_layer */ /* GL_AMD_shader_trinary_minmax */ From 7b5d9a63f103155ab246fed3fac8eeb04db720c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 01:39:43 +0200 Subject: [PATCH 06/72] Initial support for OpenGL 4.5. --- Doxyfile | 1 + README.md | 2 +- doc/mainpage.dox | 2 +- doc/opengl-mapping.dox | 131 +++++++++++++++++++++------------------- doc/opengl-support.dox | 16 +++++ doc/opengl.dox | 2 + src/Magnum/Context.cpp | 15 +++++ src/Magnum/Extensions.h | 13 ++++ src/Magnum/Shader.cpp | 1 + src/Magnum/Version.cpp | 1 + src/Magnum/Version.h | 14 ++++- 11 files changed, 133 insertions(+), 65 deletions(-) diff --git a/Doxyfile b/Doxyfile index bbf610f7c..3cf913f0b 100644 --- a/Doxyfile +++ b/Doxyfile @@ -258,6 +258,7 @@ ALIASES = \ "requires_gl42=@xrefitem requires-gl42 \"Requires OpenGL 4.2\" \"Functionality requiring OpenGL 4.2\"" \ "requires_gl43=@xrefitem requires-gl43 \"Requires OpenGL 4.3\" \"Functionality requiring OpenGL 4.3\"" \ "requires_gl44=@xrefitem requires-gl44 \"Requires OpenGL 4.4\" \"Functionality requiring OpenGL 4.4\"" \ + "requires_gl45=@xrefitem requires-gl45 \"Requires OpenGL 4.5\" \"Functionality requiring OpenGL 4.5\"" \ "requires_extension=@xrefitem requires-extension \"Requires OpenGL extension\" \"Functionality requiring specific OpenGL extension\"" \ "extension{2}=\1_\2" \ "extension2{2}=\1_\2" \ diff --git a/README.md b/README.md index 984c6265c..5afb0eb6d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ SUPPORTED PLATFORMS Graphics APIs: -* **OpenGL** 2.1 through 4.4, core profile functionality and modern +* **OpenGL** 2.1 through 4.5, core profile functionality and modern extensions * **OpenGL ES** 2.0, 3.0, 3.1 and extensions to match desktop OpenGL functionality diff --git a/doc/mainpage.dox b/doc/mainpage.dox index 41f8e69f8..47140d8ed 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -67,7 +67,7 @@ recent C++11 features and to abstract away platform-specific issues. Graphics APIs: -- **OpenGL** 2.1 through 4.4, core profile functionality and modern +- **OpenGL** 2.1 through 4.5, core profile functionality and modern extensions - **OpenGL ES** 2.0, 3.0, 3.1 and extensions to match desktop OpenGL functionality diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 06608e7f0..e05a92e9f 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -57,37 +57,38 @@ OpenGL function | Matching API @fn_gl{BindProgramPipeline} | | @fn_gl{BindRenderbuffer} | not needed, handled internally in @ref Renderbuffer @fn_gl{BindSampler}, \n @fn_gl{BindSamplers} | | -@fn_gl{BindTexture}, \n @fn_gl{BindTextures}, \n @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} | @ref AbstractTexture::bind() +@fn_gl{BindTexture}, \n @fn_gl{BindTextureUnit}, \n @fn_gl{BindTextures}, \n @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} | @ref AbstractTexture::bind() @fn_gl{BindTransformFeedback} | | @fn_gl{BindVertexArray} | not needed, handled internally in @ref Mesh -@fn_gl{BindVertexBuffer}, \n @fn_gl{BindVertexBuffers} | | +@fn_gl{BindVertexBuffer}, \n `glVertexArrayVertexBuffer()`, \n @fn_gl_extension{VertexArrayBindVertexBuffer,EXT,direct_state_access} \n @fn_gl{BindVertexBuffers}, \n `glVertexArrayVertexBuffers()` | | @fn_gl{BlendColor} | @ref Renderer::setBlendColor() @fn_gl{BlendEquation}, \n @fn_gl{BlendEquationSeparate} | @ref Renderer::setBlendEquation() @fn_gl{BlendFunc}, \n @fn_gl{BlendFuncSeparate} | @ref Renderer::setBlendFunction() -@fn_gl{BlitFramebuffer} | @ref AbstractFramebuffer::blit() -@fn_gl{BufferData}, \n @fn_gl_extension{NamedBufferData,EXT,direct_state_access} | @ref Buffer::setData() -@fn_gl{BufferStorage} | | -@fn_gl{BufferSubData}, \n @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access} | @ref Buffer::setSubData() -@fn_gl{CheckFramebufferStatus}, \n @fn_gl_extension{CheckNamedFramebufferStatus,EXT,direct_state_access} | @ref DefaultFramebuffer::checkStatus(), \n @ref Framebuffer::checkStatus() +@fn_gl{BlitFramebuffer}, \n `glBlitNamedFramebuffer()` | @ref AbstractFramebuffer::blit() +@fn_gl{BufferData}, \n `glNamedBufferData()`, \n @fn_gl_extension{NamedBufferData,EXT,direct_state_access} | @ref Buffer::setData() +@fn_gl{BufferStorage}, \n `glNamedBufferStorage()`, \n @fn_gl_extension{NamedBufferStorage,EXT,direct_state_access} | | +@fn_gl{BufferSubData}, \n `glNamedBufferSubData()`, \n @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access} | @ref Buffer::setSubData() +@fn_gl{CheckFramebufferStatus}, \n `glCheckNamedFramebufferStatus()`, \n @fn_gl_extension{CheckNamedFramebufferStatus,EXT,direct_state_access} | @ref DefaultFramebuffer::checkStatus(), \n @ref Framebuffer::checkStatus() @fn_gl{ClampColor} | | @fn_gl{Clear} | @ref AbstractFramebuffer::clear() -@fn_gl{ClearBuffer} | | -@fn_gl{ClearBufferData} | | -@fn_gl{ClearBufferSubData} | | +@fn_gl{ClearBuffer}, \n `glClearNamedFramebuffer()` | | +@fn_gl{ClearBufferData}, \n `glClearNamedBufferData()`, \n @fn_gl_extension{ClearNamedBufferData,EXT,direct_state_access} | | +@fn_gl{ClearBufferSubData}, \n `glClearNamedBufferSubData()`, \n @fn_gl_extension{ClearNamedBufferSubData,EXT,direct_state_access} | | @fn_gl{ClearColor} | @ref Renderer::setClearColor() @fn_gl{ClearDepth} | @ref Renderer::setClearDepth() @fn_gl{ClearStencil} | @ref Renderer::setClearStencil() @fn_gl{ClearTexImage} | | @fn_gl{ClearTexSubImage} | | @fn_gl{ClientWaitSync} | | +@fn_gl{ClipControl} | | @fn_gl{ColorMask} | @ref Renderer::setColorMask() @fn_gl{CompileShader} | @ref Shader::compile() -@fn_gl{CompressedTexImage1D}, \n @fn_gl{CompressedTexImage2D}, \n @fn_gl{CompressedTexImage3D} | | -@fn_gl{CompressedTexSubImage1D}, \n @fn_gl{CompressedTexSubImage2D}, \n @fn_gl{CompressedTexSubImage3D} | | -@fn_gl{CopyBufferSubData}, \n @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access} | @ref Buffer::copy() +@fn_gl{CompressedTexImage1D}, \n @fn_gl_extension{CompressedTextureImage1D,EXT,direct_state_access}, \n @fn_gl{CompressedTexImage2D}, \n @fn_gl_extension{CompressedTextureImage2D,EXT,direct_state_access}, \n @fn_gl{CompressedTexImage3D}, \n @fn_gl_extension{CompressedTextureImage3D,EXT,direct_state_access} | | +@fn_gl{CompressedTexSubImage1D}, \n `glCompressedTextureSubImage1D()`, \n @fn_gl_extension{CompressedTextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{CompressedTexSubImage2D}, \n `glCompressedTextureSubImage2D()`, \n @fn_gl_extension{CompressedTextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{CompressedTexSubImage3D}, \n `glCompressedTextureSubImage3D()`, \n @fn_gl_extension{CompressedTextureSubImage3D,EXT,direct_state_access} | | +@fn_gl{CopyBufferSubData}, \n `glCopyNamedBufferSubData()`, \n @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access} | @ref Buffer::copy() @fn_gl{CopyImageSubData} | | -@fn_gl{CopyTexImage1D}, \n @fn_gl{CopyTexImage2D} | | -@fn_gl{CopyTexSubImage1D}, \n @fn_gl{CopyTexSubImage2D}, \n @fn_gl{CopyTexSubImage3D} | | +@fn_gl{CopyTexImage1D}, \n @fn_gl_extension{CopyTextureImage1D,EXT,direct_state_access}, \n @fn_gl{CopyTexImage2D}, \n @fn_gl_extension{CopyTextureImage2D,EXT,direct_state_access} | | +@fn_gl{CopyTexSubImage1D}, \n `glCopyTextureSubImage1D()`, \n @fn_gl_extension{CopyTextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{CopyTexSubImage2D}, \n `glCopyTextureSubImage2D()`, \n @fn_gl_extension{CopyTextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{CopyTexSubImage3D}, \n `glCopyTextureSubImage3D()`, \n @fn_gl_extension{CopyTextureSubImage3D,EXT,direct_state_access} | | @fn_gl{CreateProgram}, @fn_gl{DeleteProgram} | @ref AbstractShaderProgram constructor and destructor @fn_gl{CreateShader}, @fn_gl{DeleteShader} | @ref Shader constructor and destructor @fn_gl{CreateShaderProgram} | | @@ -105,46 +106,47 @@ OpenGL function | Matching API @fn_gl{DispatchComputeIndirect} | | @fn_gl{DrawArrays}, \n @fn_gl{DrawArraysInstanced}, \n @fn_gl{DrawArraysInstancedBaseInstance}, \n @fn_gl{DrawElements}, \n @fn_gl{DrawRangeElements}, \n @fn_gl{DrawElementsBaseVertex}, \n @fn_gl{DrawRangeElementsBaseVertex}, \n @fn_gl{DrawElementsInstanced}, \n @fn_gl{DrawElementsInstancedBaseInstance}, \n @fn_gl{DrawElementsInstancedBaseVertex}, \n @fn_gl{DrawElementsInstancedBaseVertexBaseInstance} | @ref Mesh::draw(), \n @ref MeshView::draw() @fn_gl{DrawArraysIndirect}, \n @fn_gl{DrawElementsIndirect}, \n @fn_gl{MultiDrawArraysIndirect}, \n @fn_gl{MultiDrawElementsIndirect} | | -@fn_gl{DrawBuffer}, \n @fn_gl_extension{FramebufferDrawBuffers,EXT,direct_state_access}, \n @fn_gl{DrawBuffers}, \n @fn_gl_extension{FramebufferDrawBuffers,EXT,direct_state_access} | @ref DefaultFramebuffer::mapForDraw(), \n @ref Framebuffer::mapForDraw() +@fn_gl{DrawBuffer}, \n `glNamedFramebufferDrawBuffer()`, \n @fn_gl_extension{FramebufferDrawBuffer,EXT,direct_state_access}, \n @fn_gl{DrawBuffers}, \n `glNamedFramebufferDrawBuffers()`, \n @fn_gl_extension{FramebufferDrawBuffers,EXT,direct_state_access} | @ref DefaultFramebuffer::mapForDraw(), \n @ref Framebuffer::mapForDraw() @fn_gl{DrawTransformFeedback}, \n @fn_gl{DrawTransformFeedbackInstanced}, \n @fn_gl{DrawTransformFeedbackStream}, \n @fn_gl{DrawTransformFeedbackStreamInstanced} | | @fn_gl{Enable}, `glDisable()` | @ref Renderer::setFeature() -@fn_gl{EnableVertexAttribArray}, \n @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access} \n @fn_gl2{DisableVertexAttribArray,EnableVertexAttribArray}, \n @fn_gl_extension{DisableVertexArrayAttrib,EXT,direct_state_access} | @ref Mesh::addVertexBuffer() +@fn_gl{EnableVertexAttribArray}, \n `glEnableVertexArrayAttrib()`, \n @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access} \n `glDisableVertexAttribArray()`, \n `glDisableVertexArrayAttrib()`, \n `glDisableVertexArrayAttribEXT()` | @ref Mesh::addVertexBuffer() @fn_gl{FenceSync}, @fn_gl{DeleteSync} | | @fn_gl{Finish} | @ref Renderer::finish() @fn_gl{Flush} | @ref Renderer::flush() -@fn_gl{FlushMappedBufferRange}, \n @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access} | @ref Buffer::flushMappedRange() -@fn_gl2{FramebufferParameter,FramebufferParameteri} | | -@fn_gl{FramebufferRenderbuffer}, \n @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} | @ref Framebuffer::attachRenderbuffer() -@fn_gl{FramebufferTexture} | not used, the functions below are used instead for compatibility reasons +@fn_gl{FlushMappedBufferRange}, \n `glFlushMappedNamedBufferRange()`, \n @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access} | @ref Buffer::flushMappedRange() +@fn_gl2{FramebufferParameter,FramebufferParameteri}, \n `glNamedFramebufferParameter()`, \n @fn_gl_extension{NamedFramebufferParameter,EXT,direct_state_access} | | +@fn_gl{FramebufferRenderbuffer}, \n `glNamedFramebufferRenderbuffer()`, \n @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} | @ref Framebuffer::attachRenderbuffer() +@fn_gl{FramebufferTexture}, \n `glNamedFramebufferTexture()`, \n @fn_gl_extension{NamedFramebufferTexture,EXT,direct_state_access} | not used, the functions below are used instead for compatibility reasons @fn_gl2{FramebufferTexture1D,FramebufferTexture}, \n @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access}, \n `glFramebufferTexture2D()`, \n `glNamedFramebufferTexture2DEXT()` | @ref Framebuffer::attachTexture() @fn_gl2{FramebufferTexture3D,FramebufferTexture} | not used, @fn_gl{FramebufferTextureLayer} has more complete features -@fn_gl{FramebufferTextureLayer}, \n @fn_gl_extension{NamedFramebufferTextureLayer,EXT,direct_state_access} | @ref Framebuffer::attachTextureLayer() +@fn_gl{FramebufferTextureLayer}, \n `glNamedFramebufferTextureLayer()`, \n @fn_gl_extension{NamedFramebufferTextureLayer,EXT,direct_state_access} | @ref Framebuffer::attachTextureLayer() @fn_gl{FrontFace} | @ref Renderer::setFrontFace() -@fn_gl{GenBuffers}, @fn_gl{DeleteBuffers} | @ref Buffer constructor and destructor -@fn_gl{GenFramebuffers}, @fn_gl{DeleteFramebuffers} | @ref Framebuffer constructor and destructor -@fn_gl{GenProgramPipelines}, @fn_gl{DeleteProgramPipelines} | | -@fn_gl{GenQueries}, @fn_gl{DeleteQueries} | @ref AbstractQuery constructor and destructor -@fn_gl{GenRenderbuffers}, @fn_gl{DeleteRenderbuffers} | @ref Renderbuffer constructor and destructor -@fn_gl{GenSamplers}, @fn_gl{DeleteSamplers} | | -@fn_gl{GenTextures}, @fn_gl{DeleteTextures} | @ref AbstractTexture constructor and destructor -@fn_gl{GenTransformFeedbacks}, @fn_gl{DeleteTransformFeedbacks} | | -@fn_gl{GenVertexArrays}, @fn_gl{DeleteVertexArrays} | @ref Mesh constructor and destructor -@fn_gl{GenerateMipmap}, \n @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access} | @ref Texture::generateMipmap(), \n @ref TextureArray::generateMipmap(), \n @ref CubeMapTexture::generateMipmap(), \n @ref CubeMapTextureArray::generateMipmap() +@fn_gl{GenBuffers}, \n @fn_gl{CreateBuffers}, \n @fn_gl{DeleteBuffers} | @ref Buffer constructor and destructor +@fn_gl{GenFramebuffers}, \n @fn_gl{CreateFramebuffers}, \n @fn_gl{DeleteFramebuffers} | @ref Framebuffer constructor and destructor +@fn_gl{GenProgramPipelines}, \n @fn_gl{CreateProgramPipelines}, \n @fn_gl{DeleteProgramPipelines} | | +@fn_gl{GenQueries}, \n @fn_gl{CreateQueries}, \n @fn_gl{DeleteQueries} | @ref AbstractQuery constructor and destructor +@fn_gl{GenRenderbuffers}, \n @fn_gl{CreateRenderbuffers}, \n @fn_gl{DeleteRenderbuffers} | @ref Renderbuffer constructor and destructor +@fn_gl{GenSamplers}, \n @fn_gl{CreateSamplers}, \n @fn_gl{DeleteSamplers} | | +@fn_gl{GenTextures}, \n @fn_gl{CreateTextures}, \n @fn_gl{DeleteTextures} | @ref AbstractTexture constructor and destructor +@fn_gl{GenTransformFeedbacks}, \n @fn_gl{CreateTransformFeedbacks}, \n @fn_gl{DeleteTransformFeedbacks} | | +@fn_gl{GenVertexArrays}, \n @fn_gl{CreateVertexArrays}, \n @fn_gl{DeleteVertexArrays} | @ref Mesh constructor and destructor +@fn_gl{GenerateMipmap}, \n `glGenerateTextureMipmap()`, \n @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access} | @ref Texture::generateMipmap(), \n @ref TextureArray::generateMipmap(), \n @ref CubeMapTexture::generateMipmap(), \n @ref CubeMapTextureArray::generateMipmap() @fn_gl{Get} | see @ref opengl-mapping-state "table below" @fn_gl2{GetActiveAtomicCounterBuffer,GetActiveAtomicCounterBufferiv} | not queryable @fn_gl{GetActiveAttrib}, \n @fn_gl{GetActiveSubroutineName}, \n @fn_gl{GetActiveSubroutineUniform}, \n @fn_gl{GetActiveSubroutineUniformName}, \n @fn_gl{GetActiveUniform}, \n @fn_gl{GetActiveUniformBlock}, \n @fn_gl{GetActiveUniformBlockName}, \n @fn_gl{GetActiveUniformName}, \n @fn_gl{GetActiveUniforms} | not queryable @fn_gl{GetAttachedShaders} | not queryable, @ref AbstractShaderProgram::attachShader() setter only @fn_gl{GetAttribLocation} | not queryable, @ref AbstractShaderProgram::bindAttributeLocation() setter only -@fn_gl{GetBufferParameter}, \n @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access} | @ref Buffer::size() -@fn_gl2{GetBufferPointer,GetBufferPointerv} | not queryable, @ref Buffer::map() setter only -@fn_gl{GetBufferSubData}, \n @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access} | @ref Buffer::data(), \n @ref Buffer::subData() -@fn_gl{GetCompressedTexImage} | | +@fn_gl{GetBufferParameter}, \n `glGetNamedBufferParameter()`, \n @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access} | @ref Buffer::size() +@fn_gl2{GetBufferPointer,GetBufferPointerv}, \n `glGetNamedBufferPointer()`, \n @fn_gl_extension{GetNamedBufferPointer,EXT,direct_state_access} | not queryable, @ref Buffer::map() setter only +@fn_gl{GetBufferSubData}, \n `glGetNamedBufferSubData()`, \n @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access} | @ref Buffer::data(), \n @ref Buffer::subData() +@fn_gl{GetCompressedTexImage}, \n `glGetnCompressedTexImage()`, \n @fn_gl_extension{GetnCompressedTexImage,ARB,robustness}, \n `glGetCompressedTextureImage()`, \n @fn_gl_extension{GetCompressedTextureImage,EXT,direct_state_access} | | +@fn_gl{GetCompressedTextureSubImage} | | @fn_gl{GetDebugMessageLog} | | @fn_gl{GetError} | @ref Renderer::error() @fn_gl{GetFragDataIndex}, @fn_gl{GetFragDataLocation} | not queryable, @ref AbstractShaderProgram::bindFragmentDataLocation() and \n @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() setters only -@fn_gl{GetFramebufferAttachmentParameter} | not queryable, @ref Framebuffer setters only -@fn_gl{GetFramebufferParameter} | not queryable, @ref DefaultFramebuffer and \n @ref Framebuffer setters only -@fn_gl_extension{GetGraphicsResetStatus,ARB,robustness} | @ref Renderer::graphicsResetStatus() +@fn_gl{GetFramebufferAttachmentParameter}, \n `glGetNamedFramebufferAttachmentParameter()`, \n @fn_gl_extension{GetNamedFramebufferAttachmentParameter,EXT,direct_state_access} | not queryable, @ref Framebuffer setters only +@fn_gl{GetFramebufferParameter}, \n `glGetNamedFramebufferParameter()`, \n @fn_gl_extension{GetNamedFramebufferParameter,EXT,direct_state_access} | not queryable, @ref DefaultFramebuffer and \n @ref Framebuffer setters only +@fn_gl{GetGraphicsResetStatus}, \n @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness} | @ref Renderer::graphicsResetStatus() @fn_gl{GetInternalformat} | | @fn_gl{GetMultisample} | | @fn_gl{GetObjectLabel}, \n @fn_gl{GetObjectPtrLabel} | @ref AbstractShaderProgram::label(), \n @ref AbstractQuery::label(), \n @ref AbstractTexture::label(), \n @ref Buffer::label(), \n @ref Framebuffer::label(), \n @ref Mesh::label(), \n @ref Renderbuffer::label(), \n @ref Shader::label() @@ -162,7 +164,7 @@ OpenGL function | Matching API @fn_gl{GetQueryIndexed} | | @fn_gl{GetQueryObject} | @ref AbstractQuery::result() @fn_gl2{GetQuery,GetQueryiv} | | -@fn_gl{GetRenderbufferParameter} | not queryable, @ref Renderbuffer::setStorage() and \n @ref Renderbuffer::setStorageMultisample() setter only +@fn_gl{GetRenderbufferParameter}, \n `glGetNamedRenderbufferParameter()`, \n @fn_gl_extension{GetNamedRenderbufferParameter,EXT,direct_state_access} | not queryable, @ref Renderbuffer::setStorage() and \n @ref Renderbuffer::setStorageMultisample() setter only @fn_gl{GetSamplerParameter} | | @fn_gl{GetShader}, \n @fn_gl{GetShaderInfoLog} | @ref Shader::compile() @fn_gl{GetShaderPrecisionFormat} | | @@ -171,20 +173,22 @@ OpenGL function | Matching API @fn_gl{GetSubroutineIndex} | | @fn_gl{GetSubroutineUniformLocation} | | @fn_gl{GetSync} | | -@fn_gl{GetTexImage}, \n @fn_gl_extension{GetTextureImage,EXT,direct_state_access}, \n @fn_gl_extension{GetnTexImage,ARB,robustness} | @ref Texture::image(), \n @ref TextureArray::image(), \n @ref CubeMapTexture::image(), \n @ref CubeMapTextureArray::image(), \n @ref RectangleTexture::image() -@fn_gl{GetTexLevelParameter}, \n @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} | @ref Texture::imageSize(), \n @ref TextureArray::imageSize(), \n @ref CubeMapTexture::imageSize(), \n @ref CubeMapTextureArray::imageSize(), \n @ref RectangleTexture::imageSize() -@fn_gl{GetTexParameter} | | +@fn_gl{GetTexImage}, \n `glGetnTexImage()`, \n @fn_gl_extension{GetnTexImage,ARB,robustness}, \n `glGetTextureImage()`, \n @fn_gl_extension{GetTextureImage,EXT,direct_state_access} | @ref Texture::image(), \n @ref TextureArray::image(), \n @ref CubeMapTexture::image(), \n @ref CubeMapTextureArray::image(), \n @ref RectangleTexture::image() +@fn_gl{GetTexLevelParameter}, \n `glGetTextureLevelParameter()`, \n @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} | @ref Texture::imageSize(), \n @ref TextureArray::imageSize(), \n @ref CubeMapTexture::imageSize(), \n @ref CubeMapTextureArray::imageSize(), \n @ref RectangleTexture::imageSize() +@fn_gl{GetTexParameter}, \n `glGetTextureParameter()`, \n @fn_gl_extension{GetTextureParameter,EXT,direct_state_access} | | +@fn_gl{GetTextureSubImage} | | +@fn_gl{GetTransformFeedback} | | @fn_gl{GetTransformFeedbackVarying} | | -@fn_gl{GetUniform} | not queryable, @ref AbstractShaderProgram::setUniform() setter only +@fn_gl{GetUniform}, \n `glGetnUniform()`, \n @fn_gl_extension{GetnUniform,ARB,robustness} | not queryable, @ref AbstractShaderProgram::setUniform() setter only @fn_gl{GetUniformBlockIndex} | | @fn_gl{GetUniformIndices} | | @fn_gl{GetUniformLocation} | @ref AbstractShaderProgram::uniformLocation() @fn_gl{GetUniformSubroutine} | | -@fn_gl{GetVertexAttrib} | not queryable, @ref Mesh::addVertexBuffer() setter only +@fn_gl{GetVertexAttrib}, \n @fn_gl{GetVertexArray}, \n @fn_gl_extension{GetVertexArray,EXT,direct_state_access} | not queryable, @ref Mesh::addVertexBuffer() setter only @fn_gl{InvalidateBufferData} | @ref Buffer::invalidateData() @fn_gl{InvalidateBufferSubData} | @ref Buffer::invalidateSubData() -@fn_gl{InvalidateFramebuffer}, \n @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate() -@fn_gl{InvalidateSubFramebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate() +@fn_gl{InvalidateFramebuffer}, \n `glInvalidateNamedFramebufferData()`, \n @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate() +@fn_gl{InvalidateSubFramebuffer}, \n `glInvalidateNamedFramebufferSubData()` | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate() @fn_gl{InvalidateTexImage} | @ref Texture::invalidateImage(), \n @ref TextureArray::invalidateImage(), \n @ref CubeMapTexture::invalidateImage(), \n @ref CubeMapTextureArray::invalidateImage(), \n @ref RectangleTexture::invalidateImage(), \n @ref MultisampleTexture::invalidateImage() @fn_gl{InvalidateTexSubImage} | @ref Texture::invalidateSubImage(), \n @ref TextureArray::invalidateSubImage(), \n @ref CubeMapTexture::invalidateSubImage(), \n @ref CubeMapTextureArray::invalidateSubImage(), \n @ref RectangleTexture::invalidateSubImage(), \n @ref MultisampleTexture::invalidateSubImage() @fn_gl{IsBuffer}, \n @fn_gl{IsFramebuffer}, \n @fn_gl{IsProgram}, \n @fn_gl{IsProgramPipeline}, \n @fn_gl{IsQuery}, \n @fn_gl{IsRenderbuffer}, \n @fn_gl{IsSampler}, \n @fn_gl{IsShader}, \n @fn_gl{IsSync}, \n @fn_gl{IsTexture}, \n @fn_gl{IsTransformFeedback}, \n @fn_gl{IsVertexArray} | not needed, objects are strongly typed @@ -192,9 +196,9 @@ OpenGL function | Matching API @fn_gl{LineWidth} | @ref Renderer::setLineWidth() @fn_gl{LinkProgram} | @ref AbstractShaderProgram::link() @fn_gl{LogicOp} | @ref Renderer::setLogicOperation() -@fn_gl{MapBuffer}, `glUnmapBuffer()`, \n @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access}, \n @fn_gl{MapBufferRange}, \n @fn_gl_extension{MapNamedBufferRange,EXT,direct_state_access} | @ref Buffer::map(), @ref Buffer::unmap() +@fn_gl{MapBuffer}, \n `glMapNamedBuffer()`, \n @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, \n @fn_gl{MapBufferRange}, \n `glMapNamedBufferRange()`, \n @fn_gl_extension{MapNamedBufferRange,EXT,direct_state_access}, \n @fn_gl{UnmapBuffer}, \n `glUnmapNamedBuffer()`, \n @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access} | @ref Buffer::map(), @ref Buffer::unmap() @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}, @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub} | @ref Buffer::mapSub(), @ref Buffer::unmapSub() -@fn_gl{MemoryBarrier} | | +@fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | | @fn_gl{MinSampleShading} | | @fn_gl{MultiDrawArrays}, \n @fn_gl{MultiDrawElements}, \n @fn_gl{MultiDrawElementsBaseVertex} | @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list>) @fn_gl{ObjectLabel}, \n @fn_gl{ObjectPtrLabel}, \n @fn_gl_extension2{LabelObject,EXT,debug_label} | @ref AbstractShaderProgram::setLabel(), \n @ref AbstractQuery::setLabel(), \n @ref AbstractTexture::setLabel(), \n @ref Buffer::setLabel(), \n @ref Framebuffer::setLabel(), \n @ref Mesh::setLabel(), \n @ref Renderbuffer::setLabel(), \n @ref Shader::setLabel() @@ -211,11 +215,11 @@ OpenGL function | Matching API @fn_gl{ProvokingVertex} | @ref Renderer::setProvokingVertex() @fn_gl{PushDebugGroup}, @fn_gl{PopDebugGroup} | | @fn_gl{QueryCounter} | @ref TimeQuery::timestamp() -@fn_gl{ReadBuffer}, \n @fn_gl_extension{FramebufferReadBuffer,EXT,direct_state_access} | @ref DefaultFramebuffer::mapForRead(), \n @ref Framebuffer::mapForRead() -@fn_gl{ReadPixels}, \n @fn_gl_extension{ReadnPixels,ARB,robustness} | @ref DefaultFramebuffer::read(), \n @ref Framebuffer::read() +@fn_gl{ReadBuffer}, \n `glNamedFramebufferReadBuffer()`, \n @fn_gl_extension{FramebufferReadBuffer,EXT,direct_state_access} | @ref DefaultFramebuffer::mapForRead(), \n @ref Framebuffer::mapForRead() +@fn_gl{ReadPixels}, \n `glReadnPixels()`, \n @fn_gl_extension{ReadnPixels,ARB,robustness} | @ref DefaultFramebuffer::read(), \n @ref Framebuffer::read() @fn_gl{ReleaseShaderCompiler} | | -@fn_gl{RenderbufferStorage}, \n @fn_gl_extension{NamedRenderbufferStorage,EXT,direct_state_access} | @ref Renderbuffer::setStorage() -@fn_gl{RenderbufferStorageMultisample}, \n @fn_gl_extension{NamedRenderbufferStorageMultisample,EXT,direct_state_access} | @ref Renderbuffer::setStorageMultisample() +@fn_gl{RenderbufferStorage}, \n `glNamedRenderbufferStorage()`, \n @fn_gl_extension{NamedRenderbufferStorage,EXT,direct_state_access} | @ref Renderbuffer::setStorage() +@fn_gl{RenderbufferStorageMultisample}, \n `glNamedRenderbufferStorageMultisample()`, \n @fn_gl_extension{NamedRenderbufferStorageMultisample,EXT,direct_state_access} | @ref Renderbuffer::setStorageMultisample() @fn_gl{SampleCoverage} | | @fn_gl{SampleMaski} | | @fn_gl{SamplerParameter} | | @@ -228,14 +232,16 @@ OpenGL function | Matching API @fn_gl{StencilFunc}, \n @fn_gl{StencilFuncSeparate} | @ref Renderer::setStencilFunction() @fn_gl{StencilMask}, \n @fn_gl{StencilMaskSeparate} | @ref Renderer::setStencilMask() @fn_gl{StencilOp}, \n @fn_gl{StencilOpSeparate} | @ref Renderer::setStencilOperation() -@fn_gl{TexBuffer}, \n @fn_gl_extension{TextureBuffer,EXT,direct_state_access}, \n @fn_gl{TexBufferRange}, \n @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} | @ref BufferTexture::setBuffer() +@fn_gl{TexBuffer}, \n `glTextureBuffer()`, \n @fn_gl_extension{TextureBuffer,EXT,direct_state_access}, \n @fn_gl{TexBufferRange}, \n `glTextureBufferRange()`, \n @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} | @ref BufferTexture::setBuffer() @fn_gl{TexImage1D}, \n @fn_gl_extension{TextureImage1D,EXT,direct_state_access} \n @fn_gl{TexImage2D}, \n @fn_gl_extension{TextureImage2D,EXT,direct_state_access}, \n @fn_gl{TexImage3D}, \n @fn_gl_extension{TextureImage3D,EXT,direct_state_access} | @ref Texture::setImage(), \n @ref TextureArray::setImage(), \n @ref CubeMapTexture::setImage(), \n @ref CubeMapTextureArray::setImage(), \n @ref RectangleTexture::setImage() @fn_gl{TexImage2DMultisample}, \n @fn_gl{TexImage3DMultisample} | @ref MultisampleTexture::setStorage() -@fn_gl{TexParameter}, \n @fn_gl_extension{TextureParameter,EXT,direct_state_access} | @ref Texture::setBaseLevel() "*Texture::setBaseLevel()", \n @ref Texture::setMaxLevel() "*Texture::setMaxLevel()", \n @ref Texture::setMinificationFilter() "*Texture::setMinificationFilter()", \n @ref Texture::setMagnificationFilter() "*Texture::setMagnificationFilter()", \n @ref Texture::setMinLod() "*Texture::setMinLod()", \n @ref Texture::setMaxLod() "*Texture::setMaxLod()", \n @ref Texture::setLodBias() "*Texture::setLodBias()", \n @ref Texture::setWrapping() "*Texture::setWrapping()", \n @ref Texture::setBorderColor() "*Texture::setBorderColor()", \n @ref Texture::setMaxAnisotropy() "*Texture::setMaxAnisotropy()", \n @ref Texture::setSRGBDecode() "*Texture::setSRGBDecode()", \n @ref Texture::setSwizzle() "*Texture::setSwizzle()", \n @ref Texture::setCompareMode() "*Texture::setCompareMode()", \n @ref Texture::setCompareFunction() "*Texture::setCompareFunction()", \n @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" -@fn_gl{TexStorage1D}, \n @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}, \n @fn_gl{TexStorage2D}, \n @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, \n @fn_gl{TexStorage3D}, \n @fn_gl_extension{TextureStorage3D,EXT,direct_state_access} | @ref Texture::setStorage(), \n @ref TextureArray::setStorage(), \n @ref CubeMapTexture::setStorage(), \n @ref CubeMapTextureArray::setStorage(), \n @ref RectangleTexture::setStorage() -@fn_gl{TexStorage2DMultisample}, \n @fn_gl_extension{TextureStorage2DMultisample,EXT,direct_state_access}, \n @fn_gl{TexStorage3DMultisample}, \n @fn_gl_extension{TextureStorage3DMultisample,EXT,direct_state_access} | @ref MultisampleTexture::setStorage() -@fn_gl{TexSubImage1D}, \n @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{TexSubImage2D}, \n @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{TexSubImage3D}, \n @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} | @ref Texture::setSubImage(), \n @ref TextureArray::setSubImage(), \n @ref CubeMapTexture::setSubImage(), \n @ref CubeMapTextureArray::setSubImage(), \n @ref RectangleTexture::setSubImage() +@fn_gl{TexParameter}, \n `glTextureParameter()`, \n @fn_gl_extension{TextureParameter,EXT,direct_state_access} | @ref Texture::setBaseLevel() "*Texture::setBaseLevel()", \n @ref Texture::setMaxLevel() "*Texture::setMaxLevel()", \n @ref Texture::setMinificationFilter() "*Texture::setMinificationFilter()", \n @ref Texture::setMagnificationFilter() "*Texture::setMagnificationFilter()", \n @ref Texture::setMinLod() "*Texture::setMinLod()", \n @ref Texture::setMaxLod() "*Texture::setMaxLod()", \n @ref Texture::setLodBias() "*Texture::setLodBias()", \n @ref Texture::setWrapping() "*Texture::setWrapping()", \n @ref Texture::setBorderColor() "*Texture::setBorderColor()", \n @ref Texture::setMaxAnisotropy() "*Texture::setMaxAnisotropy()", \n @ref Texture::setSRGBDecode() "*Texture::setSRGBDecode()", \n @ref Texture::setSwizzle() "*Texture::setSwizzle()", \n @ref Texture::setCompareMode() "*Texture::setCompareMode()", \n @ref Texture::setCompareFunction() "*Texture::setCompareFunction()", \n @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()" +@fn_gl{TexStorage1D}, \n `glTextureStorage1D()`, \n @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}, \n @fn_gl{TexStorage2D}, \n `glTextureStorage2D()`, \n @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, \n @fn_gl{TexStorage3D}, \n `glTextureStorage3D()`, \n @fn_gl_extension{TextureStorage3D,EXT,direct_state_access} | @ref Texture::setStorage(), \n @ref TextureArray::setStorage(), \n @ref CubeMapTexture::setStorage(), \n @ref CubeMapTextureArray::setStorage(), \n @ref RectangleTexture::setStorage() +@fn_gl{TexStorage2DMultisample}, \n `glTextureStorage2DMultisample()`, \n @fn_gl_extension{TextureStorage2DMultisample,EXT,direct_state_access}, \n @fn_gl{TexStorage3DMultisample}, \n `glTextureStorage3DMultisample()`, \n @fn_gl_extension{TextureStorage3DMultisample,EXT,direct_state_access} | @ref MultisampleTexture::setStorage() +@fn_gl{TexSubImage1D}, \n `glTextureSubImage1D()`, \n @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{TexSubImage2D}, \n `glTextureSubImage2D()`, \n @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{TexSubImage3D}, \n `glTextureSubImage3D()`, \n @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} | @ref Texture::setSubImage(), \n @ref TextureArray::setSubImage(), \n @ref CubeMapTexture::setSubImage(), \n @ref CubeMapTextureArray::setSubImage(), \n @ref RectangleTexture::setSubImage() +@fn_gl{TextureBarrier} | | @fn_gl{TextureView} | | +@fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | | @fn_gl{TransformFeedbackVaryings} | | @fn_gl{Uniform}, \n @fn_gl{ProgramUniform}, \n @fn_gl_extension{ProgramUniform,EXT,direct_state_access} | @ref AbstractShaderProgram::setUniform() @fn_gl{UniformBlockBinding} | | @@ -244,12 +250,13 @@ OpenGL function | Matching API @fn_gl{UseProgramStages} | | @fn_gl{ValidateProgram} | @ref AbstractShaderProgram::validate() @fn_gl{ValidateProgramPipeline} | | +@fn_gl{VertexArrayElementBuffer} | | @fn_gl{VertexAttrib} | not supported (@ref opengl-unsupported "details") -@fn_gl{VertexAttribBinding} | | +@fn_gl{VertexAttribBinding}, \n `glVertexArrayAttribBinding()`, \n @fn_gl_extension{VertexArrayVertexAttribBinding,EXT,direct_state_access} | | @fn_gl{VertexAttribDivisor}, \n @fn_gl_extension{VertexArrayVertexAttribDivisor,EXT,direct_state_access} | @ref Mesh::addVertexBufferInstanced() -@fn_gl{VertexAttribFormat} | | +@fn_gl{VertexAttribFormat}, \n `glVertexArrayAttribFormat()`, \n @fn_gl_extension{VertexArrayVertexAttribFormat,EXT,direct_state_access} | | @fn_gl{VertexAttribPointer}, \n @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} | @ref Mesh::addVertexBuffer() -@fn_gl{VertexBindingDivisor} | | +@fn_gl{VertexBindingDivisor}, \n `glVertexArrayBindingDivisor()`, \n @fn_gl_extension{VertexArrayVertexBindingDivisor,EXT,direct_state_access} | | @fn_gl{Viewport} | @ref DefaultFramebuffer::setViewport(), \n @ref Framebuffer::setViewport() @fn_gl{ViewportArray} | | @fn_gl{ViewportIndexed} | | @@ -309,6 +316,8 @@ OpenGL function | Matching API @def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugMessage::maxMessageLength() @def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | | @def_gl{MAX_CLIP_DISTANCES} | | +@def_gl{MAX_CULL_DISTANCES} | | +@def_gl{MAX_COMBINED_CLIP_AND_CULL_DISTANCES} | | @def_gl{MAX_COLOR_TEXTURE_SAMPLES}, \n @def_gl{MAX_DEPTH_TEXTURE_SAMPLES}, \n @def_gl{MAX_INTEGER_SAMPLES} | @ref AbstractTexture::maxColorSamples(), \n @ref AbstractTexture::maxDepthSamples(), \n @ref AbstractTexture::maxIntegerSamples() @def_gl{MAX_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDrawBuffers() @def_gl{MAX_DUAL_SOURCE_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDualSourceDrawBuffers() diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index c1984a2d0..3d0cf6f60 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -207,6 +207,22 @@ following: @extension{ARB,texture_stencil8} | done @extension{ARB,vertex_type_10f_11f_11f_rev} | done +@subsection opengl-support-45 OpenGL 4.5 + +%Extension | Status +-------------------------------------------- | ------ +@extension{ARB,ES3_1_compatibility} | | +@extension{ARB,clip_control} | | +@extension{ARB,conditional_render_inverted} | | +@extension{ARB,cull_distance} | | +@extension{ARB,derivative_control} | done (shading language only) +@extension{ARB,direct_state_access} | | +@extension{ARB,get_texture_sub_image} | | +@extension{ARB,shader_texture_image_samples} | done (shading language only) +@extension{ARB,texture_barrier} | | +@extension{KHR,context_flush_control} (also in ES) | | +@extension{KHR,robustness} (also in ES) | | + @subsection opengl-support-extensions OpenGL extensions @todo @extension{ARB,sparse_texture}, @extension{ARB,bindless_texture} + their vendor equivalents diff --git a/doc/opengl.dox b/doc/opengl.dox index 582ad9213..4338b6abf 100644 --- a/doc/opengl.dox +++ b/doc/opengl.dox @@ -55,6 +55,7 @@ is supported on older Intel GPUs even if they are capable of OpenGL 2.1 only). - @subpage requires-gl42 - @subpage requires-gl43 - @subpage requires-gl44 +- @subpage requires-gl45 - @subpage requires-extension - @subpage requires-gl - @subpage requires-gles20 @@ -74,6 +75,7 @@ is supported on older Intel GPUs even if they are capable of OpenGL 2.1 only). @page requires-gl42 Functionality requiring OpenGL 4.2 @page requires-gl43 Functionality requiring OpenGL 4.3 @page requires-gl44 Functionality requiring OpenGL 4.4 +@page requires-gl45 Functionality requiring OpenGL 4.5 @page requires-extension Functionality requiring specific OpenGL extension diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 23c9e5dab..2a798abef 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -189,6 +189,18 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,ARB,texture_mirror_clamp_to_edge), _extension(GL,ARB,texture_stencil8), _extension(GL,ARB,vertex_type_10f_11f_11f_rev)}; + static const std::vector extensions450{ + _extension(GL,ARB,ES3_1_compatibility), + _extension(GL,ARB,clip_control), + _extension(GL,ARB,conditional_render_inverted), + _extension(GL,ARB,cull_distance), + _extension(GL,ARB,derivative_control), + _extension(GL,ARB,direct_state_access), + _extension(GL,ARB,get_texture_sub_image), + _extension(GL,ARB,shader_texture_image_samples), + _extension(GL,ARB,texture_barrier), + _extension(GL,KHR,context_flush_control), + _extension(GL,KHR,robustness)}; #undef _extension #else static const std::vector extensions{ @@ -207,6 +219,8 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,multisampled_render_to_texture), _extension(GL,EXT,robustness), _extension(GL,KHR,debug), + _extension(GL,KHR,context_flush_control), + _extension(GL,KHR,robustness), _extension(GL,NV,read_buffer_front), _extension(GL,NV,read_depth), _extension(GL,NV,read_stencil), @@ -278,6 +292,7 @@ const std::vector& Extension::extensions(Version version) { /* case Version::GLES300: */ case Version::GL430: return extensions430; case Version::GL440: return extensions440; + case Version::GL450: return extensions450; #else case Version::GLES200: return empty; case Version::GLES300: diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 55f02dfcc..a59ff7855 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -169,6 +169,15 @@ namespace GL { _extension(GL,ARB,texture_mirror_clamp_to_edge, GL210, GL440) // #149 _extension(GL,ARB,texture_stencil8, GL210, GL440) // #150 _extension(GL,ARB,vertex_type_10f_11f_11f_rev, GL300, GL440) // #151 + _extension(GL,ARB,ES3_1_compatibility, GL440, GL450) // #159 + _extension(GL,ARB,clip_control, GL210, GL450) // #160 + _extension(GL,ARB,conditional_render_inverted, GL300, GL450) // #161 + _extension(GL,ARB,cull_distance, GL300, GL450) // #162 + _extension(GL,ARB,derivative_control, GL400, GL450) // #163 + _extension(GL,ARB,direct_state_access, GL210, GL450) // #164 + _extension(GL,ARB,get_texture_sub_image, GL210, GL450) // #165 + _extension(GL,ARB,shader_texture_image_samples, GL430, GL450) // #166 + _extension(GL,ARB,texture_barrier, GL210, GL450) // #167 } namespace ATI { _extension(GL,ATI,texture_mirror_once, GL210, None) // #221 } namespace EXT { @@ -197,6 +206,8 @@ namespace GL { /* INTEL_map_texture not supported */ // #429 } namespace KHR { _extension(GL,KHR,debug, GL210, GL430) // #119 + _extension(GL,KHR,context_flush_control, GL210, GL450) // #168 + _extension(GL,KHR,robustness, GL320, GL450) // #170 } namespace NV { _extension(GL,NV,half_float, GL210, GL300) // #283 _extension(GL,NV,primitive_restart, GL210, GL310) // #285 @@ -271,6 +282,8 @@ namespace GL { #endif } namespace KHR { _extension(GL,KHR,debug, GLES200, None) // #118 + _extension(GL,KHR,robustness, GLES200, None) // #170 + _extension(GL,KHR,context_flush_control, GLES200, None) // #191 } namespace NV { #ifdef MAGNUM_TARGET_GLES2 _extension(GL,NV,draw_buffers, GLES200, GLES300) // #91 diff --git a/src/Magnum/Shader.cpp b/src/Magnum/Shader.cpp index c646296d7..80d58f8ee 100644 --- a/src/Magnum/Shader.cpp +++ b/src/Magnum/Shader.cpp @@ -625,6 +625,7 @@ Shader::Shader(const Version version, const Type type): _type(type), _id(0) { case Version::GL420: _sources.push_back("#version 420\n"); return; case Version::GL430: _sources.push_back("#version 430\n"); return; case Version::GL440: _sources.push_back("#version 440\n"); return; + case Version::GL450: _sources.push_back("#version 450\n"); return; #else case Version::GLES200: _sources.push_back("#version 100\n"); return; case Version::GLES300: _sources.push_back("#version 300 es\n"); return; diff --git a/src/Magnum/Version.cpp b/src/Magnum/Version.cpp index 2ba4c3535..b51b09c6e 100644 --- a/src/Magnum/Version.cpp +++ b/src/Magnum/Version.cpp @@ -45,6 +45,7 @@ Debug operator<<(Debug debug, Version value) { _c(GL420, "OpenGL 4.2") _c(GL430, "OpenGL 4.3") _c(GL440, "OpenGL 4.4") + _c(GL450, "OpenGL 4.5") #else _c(GLES200, "OpenGL ES 2.0") _c(GLES300, "OpenGL ES 3.0") diff --git a/src/Magnum/Version.h b/src/Magnum/Version.h index 24a5efc01..2196d5d1b 100644 --- a/src/Magnum/Version.h +++ b/src/Magnum/Version.h @@ -54,6 +54,7 @@ enum class Version: Int { GL420 = 420, /**< @brief OpenGL 4.2, GLSL 4.20 */ GL430 = 430, /**< @brief OpenGL 4.3, GLSL 4.30 */ GL440 = 440, /**< @brief OpenGL 4.4, GLSL 4.40 */ + GL450 = 450, /**< @brief OpenGL 4.5, GLSL 4.50 */ #endif /** @@ -82,8 +83,17 @@ enum class Version: Int { GLES300 = 300, #endif - #ifdef MAGNUM_TARGET_GLES - GLES310 = 310 /**< @brief OpenGL ES 3.1, GLSL ES 3.10 */ + /** + * @brief OpenGL ES 3.1, GLSL ES 3.10 + * + * All the functionality is present in OpenGL 4.5 (extension + * @extension{ARB,ES3_1_compatibility}), so on desktop OpenGL this is the + * equivalent to @ref Version::GL450. + */ + #ifndef MAGNUM_TARGET_GLES + GLES310 = 450 + #else + GLES310 = 310 #endif }; From 0c37555079a7facc7fe056704d1780549a3bd9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 21:21:01 +0200 Subject: [PATCH 07/72] Removed APPLE_flush_buffer_range from extension list. Not mentioned anywhere, doesn't add anything to ARB_map_buffer_range. --- doc/opengl-support.dox | 2 -- src/Magnum/Context.cpp | 1 - src/Magnum/Extensions.h | 1 - 3 files changed, 4 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 3d0cf6f60..9e2fc5ad5 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -48,14 +48,12 @@ following: @subsection opengl-support-30 OpenGL 3.0 @todo Replace @extension{APPLE,vertex_array_object} with ARB version (we use only ARB functions without APPLE fallback) -@todo @extension{APPLE,flush_buffer_range} doesn't add anything to @extension{ARB,map_buffer_range} (remove it and leave only ARB one) @todo @extension{EXT,texture_array} overlaps with @extension{ARB,framebuffer_object} @todo Add @extension{ARB,depth_buffer_float} and implement the missing @fn_gl{DepthRange} function, but keep (and implement) @extension{NV,depth_buffer_float} for non-linear depth buffer @todo @extension{ARB,half_float_pixel}, @extension{ARB,half_float_vertex}? %Extension | Status -------------------------------------------- | ------ -@extension{APPLE,flush_buffer_range} | done (GL 3.0 subset) @extension{APPLE,vertex_array_object} | done (GL 3.0 subset) @extension{ARB,map_buffer_range} | done @extension{ARB,color_buffer_float} | | diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 2a798abef..79a60887c 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -72,7 +72,6 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,debug_marker), _extension(GL,GREMEDY,string_marker)}; static const std::vector extensions300{ - _extension(GL,APPLE,flush_buffer_range), _extension(GL,APPLE,vertex_array_object), _extension(GL,ARB,map_buffer_range), _extension(GL,ARB,color_buffer_float), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index a59ff7855..cd18c6842 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -74,7 +74,6 @@ namespace GL { _extension(GL,AMD,vertex_shader_layer, GL210, None) // #417 _extension(GL,AMD,shader_trinary_minmax, GL210, None) // #428 } namespace APPLE { - _extension(GL,APPLE,flush_buffer_range, GL210, GL300) // #321 _extension(GL,APPLE,vertex_array_object, GL210, GL300) // #273 } namespace ARB { _extension(GL,ARB,texture_rectangle, GL210, GL310) // #38 From f246b41ad9934638d3d0b0e652c5f2c92895cf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 13 Aug 2014 21:55:05 +0200 Subject: [PATCH 08/72] Replaced APPLE_vertex_array_object with ARB_vertex_array_object. We use the core functions without APPLE fallback. --- doc/opengl-support.dox | 3 +- doc/opengl.dox | 2 +- src/Magnum/Context.cpp | 2 +- src/Magnum/Extensions.h | 3 +- src/Magnum/Implementation/MeshState.cpp | 4 +-- src/Magnum/Mesh.h | 45 +++++++++++++++++-------- src/Magnum/MeshView.h | 8 +++-- src/Magnum/Test/ContextGLTest.cpp | 6 ++-- src/Magnum/Test/MeshGLTest.cpp | 6 ++-- 9 files changed, 49 insertions(+), 30 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 9e2fc5ad5..93ec8687c 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -47,20 +47,19 @@ following: @subsection opengl-support-30 OpenGL 3.0 -@todo Replace @extension{APPLE,vertex_array_object} with ARB version (we use only ARB functions without APPLE fallback) @todo @extension{EXT,texture_array} overlaps with @extension{ARB,framebuffer_object} @todo Add @extension{ARB,depth_buffer_float} and implement the missing @fn_gl{DepthRange} function, but keep (and implement) @extension{NV,depth_buffer_float} for non-linear depth buffer @todo @extension{ARB,half_float_pixel}, @extension{ARB,half_float_vertex}? %Extension | Status -------------------------------------------- | ------ -@extension{APPLE,vertex_array_object} | done (GL 3.0 subset) @extension{ARB,map_buffer_range} | done @extension{ARB,color_buffer_float} | | @extension{ARB,half_float_pixel} | done @extension{ARB,texture_float} | done @extension{ARB,depth_buffer_float} | done @extension{ARB,texture_rg} | done +@extension{ARB,vertex_array_object} | done @extension{ARB,framebuffer_object} | done @extension{EXT,gpu_shader4} | done @extension{EXT,packed_float} | done diff --git a/doc/opengl.dox b/doc/opengl.dox index 4338b6abf..babe2c6c6 100644 --- a/doc/opengl.dox +++ b/doc/opengl.dox @@ -43,7 +43,7 @@ The engine requires at least OpenGL 2.1 or OpenGL ES 2.0, but some specific functionality has greater requirements. Following are lists of features requiring specific OpenGL version. In most cases it is also specified which extension is required, so if given hardware supports required extension, it -doesn't need to have required OpenGL version too (e.g. `APPLE_vertex_array_object` +doesn't need to have required OpenGL version too (e.g. `ARB_vertex_array_object` is supported on older Intel GPUs even if they are capable of OpenGL 2.1 only). - @subpage requires-gl30 diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 79a60887c..81d8d783e 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -72,13 +72,13 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,debug_marker), _extension(GL,GREMEDY,string_marker)}; static const std::vector extensions300{ - _extension(GL,APPLE,vertex_array_object), _extension(GL,ARB,map_buffer_range), _extension(GL,ARB,color_buffer_float), _extension(GL,ARB,half_float_pixel), _extension(GL,ARB,texture_float), _extension(GL,ARB,depth_buffer_float), _extension(GL,ARB,texture_rg), + _extension(GL,ARB,vertex_array_object), _extension(GL,ARB,framebuffer_object), _extension(GL,EXT,gpu_shader4), _extension(GL,EXT,packed_float), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index cd18c6842..9032773cf 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -73,8 +73,6 @@ namespace GL { namespace AMD { _extension(GL,AMD,vertex_shader_layer, GL210, None) // #417 _extension(GL,AMD,shader_trinary_minmax, GL210, None) // #428 - } namespace APPLE { - _extension(GL,APPLE,vertex_array_object, GL210, GL300) // #273 } namespace ARB { _extension(GL,ARB,texture_rectangle, GL210, GL310) // #38 _extension(GL,ARB,color_buffer_float, GL210, GL300) // #39 @@ -88,6 +86,7 @@ namespace GL { _extension(GL,ARB,map_buffer_range, GL210, GL300) // #50 _extension(GL,ARB,texture_buffer_object, GL210, GL310) // #51 _extension(GL,ARB,texture_rg, GL210, GL300) // #53 + _extension(GL,ARB,vertex_array_object, GL210, GL300) // #54 _extension(GL,ARB,uniform_buffer_object, GL210, GL310) // #57 _extension(GL,ARB,copy_buffer, /*?*/ GL210, GL310) // #59 _extension(GL,ARB,depth_clamp, /*?*/ GL210, GL320) // #61 diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index eed3a9763..308099769 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -39,7 +39,7 @@ MeshState::MeshState(Context& context, std::vector& extensions): cu #endif { #ifndef MAGNUM_TARGET_GLES - if(context.isExtensionSupported()) + if(context.isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(context.isExtensionSupported()) #else @@ -48,7 +48,7 @@ MeshState::MeshState(Context& context, std::vector& extensions): cu #endif { #ifndef MAGNUM_TARGET_GLES - extensions.push_back(Extensions::GL::APPLE::vertex_array_object::string()); + extensions.push_back(Extensions::GL::ARB::vertex_array_object::string()); #elif defined(MAGNUM_TARGET_GLES2) extensions.push_back(Extensions::GL::OES::vertex_array_object::string()); #endif diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index 4e3cdf063..eb5bba758 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -316,7 +316,7 @@ layout, see @ref addVertexBuffer() documentation for details. @anchor Mesh-performance-optimization ## Performance optimizations -If @extension{APPLE,vertex_array_object} (part of OpenGL 3.0), OpenGL ES 3.0 or +If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL ES 3.0 or @es_extension{OES,vertex_array_object} on OpenGL ES 2.0 is supported, VAOs are used instead of binding the buffers and specifying vertex attribute pointers in each @ref draw() call. The engine tracks currently bound VAO and currently @@ -409,9 +409,10 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @brief Constructor * @param primitive Primitive type * - * Creates mesh with no vertex buffers and zero vertex count. + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, vertex array object is created. * @see @ref setPrimitive(), @ref setCount(), @fn_gl{GenVertexArrays} - * (if @extension{APPLE,vertex_array_object} is available) */ explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles); @@ -424,8 +425,10 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { /** * @brief Destructor * - * @see @fn_gl{DeleteVertexArrays} (if - * @extension{APPLE,vertex_array_object} is available) + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, vertex array object is deleted. + * @see @fn_gl{DeleteVertexArrays} */ ~Mesh(); @@ -438,8 +441,9 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { /** * @brief OpenGL mesh ID * - * If @extension{APPLE,vertex_array_object} (part of OpenGL 3.0) is not - * available, returns `0`. + * If neither @extension{ARB,vertex_array_object} (part of OpenGL 3.0) + * nor OpenGL ES 3.0 nor @es_extension{OES,vertex_array_object} in + * OpenGL ES 2.0 is available, returns `0`. */ GLuint id() const { return _id; } @@ -662,6 +666,10 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * .addVertexBuffer(buffer, 76 + 24*vertexCount, Shaders::Phong::Normal()); * @endcode * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the vertex array object is used to hold the parameters. + * * @attention The buffer passed as parameter is not managed by the * mesh, you must ensure it will exist for whole lifetime of the * mesh and delete it afterwards. @@ -678,7 +686,6 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @fn_gl{VertexAttribPointer} or * @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} - * if @extension{APPLE,vertex_array_object} is available */ template inline Mesh& addVertexBuffer(Buffer& buffer, GLintptr offset, const T&... attributes) { addVertexBufferInternal(buffer, offset, strideOfInterleaved(attributes...), 0, attributes...); @@ -693,6 +700,11 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * number of instances that will pass until new data are fetched from * the buffer. Setting it to `0` is equivalent to calling * @ref addVertexBuffer(). + * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the vertex array object is used to hold the parameters. + * * @see @ref maxVertexAttributes(), @ref setPrimitive(), * @ref setCount(), @ref setInstanceCount(), @ref setBaseInstance(), * @fn_gl{BindVertexArray}, @fn_gl{EnableVertexAttribArray}, @@ -701,7 +713,6 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, * @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access}, * @fn_gl_extension{VertexArrayVertexAttribDivisor,EXT,direct_state_access} - * if @extension{APPLE,vertex_array_object} is available * @requires_gl33 %Extension @extension{ARB,instanced_arrays} * @requires_gles30 %Extension @es_extension{ANGLE,instanced_arrays}, * @es_extension{EXT,instanced_arrays} or @@ -728,10 +739,14 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * On OpenGL ES 2.0 this function behaves always as * @ref setIndexBuffer(Buffer&, GLintptr, IndexType), as this * functionality is not available there. + * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the vertex array object is used to hold the parameters. + * * @see @ref maxElementsIndices(), @ref maxElementsVertices(), * @ref setCount(), @ref isIndexed(), @fn_gl{BindVertexArray}, - * @fn_gl{BindBuffer} (if @extension{APPLE,vertex_array_object} is - * available) + * @fn_gl{BindBuffer} */ Mesh& setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end); @@ -758,14 +773,16 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * set up. If vertex/index count or instance count is `0`, no draw * commands are issued. See also * @ref AbstractShaderProgram-rendering-workflow "AbstractShaderProgram documentation" - * for more information. + * for more information. If @extension{ARB,vertex_array_object} (part + * of OpenGL 3.0), OpenGL ES 3.0 or @es_extension{OES,vertex_array_object} + * in OpenGL ES 2.0 is available, the associated vertex array object is + * bound instead of setting up the mesh from scratch. * @see @ref setCount(), @ref setInstanceCount(), * @ref MeshView::draw(AbstractShaderProgram&), * @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list>), * @fn_gl{UseProgram}, @fn_gl{EnableVertexAttribArray}, * @fn_gl{BindBuffer}, @fn_gl{VertexAttribPointer}, - * @fn_gl{DisableVertexAttribArray} or @fn_gl{BindVertexArray} (if - * @extension{APPLE,vertex_array_object} is available), + * @fn_gl{DisableVertexAttribArray} or @fn_gl{BindVertexArray}, * @fn_gl{DrawArrays}/@fn_gl{DrawArraysInstanced}/ * @fn_gl{DrawArraysInstancedBaseInstance} or @fn_gl{DrawElements}/ * @fn_gl{DrawRangeElements}/@fn_gl{DrawElementsBaseVertex}/ diff --git a/src/Magnum/MeshView.h b/src/Magnum/MeshView.h index fc9fcd01c..8f6c9bb68 100644 --- a/src/Magnum/MeshView.h +++ b/src/Magnum/MeshView.h @@ -66,13 +66,17 @@ class MAGNUM_EXPORT MeshView { * In OpenGL ES, if @es_extension2{EXT,multi_draw_arrays,multi_draw_arrays} * is not present, the functionality is emulated using sequence of * @ref draw(AbstractShaderProgram&) calls. + * + * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL + * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is + * available, the associated vertex array object is bound instead of + * setting up the mesh from scratch. * @attention All meshes must be views of the same original mesh and * must not be instanced. * @see @ref draw(AbstractShaderProgram&), @fn_gl{UseProgram}, * @fn_gl{EnableVertexAttribArray}, @fn_gl{BindBuffer}, * @fn_gl{VertexAttribPointer}, @fn_gl{DisableVertexAttribArray} - * or @fn_gl{BindVertexArray} (if @extension{APPLE,vertex_array_object} - * is available), @fn_gl{MultiDrawArrays} or + * or @fn_gl{BindVertexArray}, @fn_gl{MultiDrawArrays} or * @fn_gl{MultiDrawElements}/@fn_gl{MultiDrawElementsBaseVertex} */ static void draw(AbstractShaderProgram& shader, std::initializer_list> meshes); diff --git a/src/Magnum/Test/ContextGLTest.cpp b/src/Magnum/Test/ContextGLTest.cpp index e6de8bcfe..198ea4fd2 100644 --- a/src/Magnum/Test/ContextGLTest.cpp +++ b/src/Magnum/Test/ContextGLTest.cpp @@ -91,14 +91,14 @@ void ContextGLTest::isExtensionSupported() { void ContextGLTest::isExtensionDisabled() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::APPLE::vertex_array_object::string() + std::string(" extension should be supported, can't test")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::vertex_array_object::string() + std::string(" extension should be supported, can't test")); if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::explicit_attrib_location::string() + std::string(" extension should be supported, can't test")); /* This is not disabled anywhere */ - CORRADE_VERIFY(!Context::current()->isExtensionDisabled()); + CORRADE_VERIFY(!Context::current()->isExtensionDisabled()); /* This is disabled in GL < 3.2 to work around GLSL compiler bugs */ CORRADE_VERIFY(Context::current()->isExtensionDisabled(Version::GL310)); diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 83e0c3f6c..0431d282d 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -233,7 +233,7 @@ void MeshGLTest::construct() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current()->isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(Context::current()->isExtensionSupported()) #endif @@ -257,7 +257,7 @@ void MeshGLTest::constructMove() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current()->isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(Context::current()->isExtensionSupported()) #endif @@ -277,7 +277,7 @@ void MeshGLTest::constructMove() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current()->isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) if(Context::current()->isExtensionSupported()) #endif From 2a5db55117a64ade35895bf627c49a9075494b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Aug 2014 12:33:32 +0200 Subject: [PATCH 09/72] Text: unified and updated pre-rendered glyph set. --- src/Magnum/Text/DistanceFieldGlyphCache.h | 2 +- src/Magnum/Text/GlyphCache.h | 2 +- src/Magnum/Text/fontconverter.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.h b/src/Magnum/Text/DistanceFieldGlyphCache.h index 0bbd24639..260b8ff9c 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.h +++ b/src/Magnum/Text/DistanceFieldGlyphCache.h @@ -49,7 +49,7 @@ Text::AbstractFont* font; Text::GlyphCache* cache = new Text::DistanceFieldGlyphCache(Vector2i(2048), Vector2i(384)); font->createGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789 "); + "0123456789?!:;,. "); @endcode @see @ref TextureTools::distanceField() diff --git a/src/Magnum/Text/GlyphCache.h b/src/Magnum/Text/GlyphCache.h index 5a327d9d3..59802b1b4 100644 --- a/src/Magnum/Text/GlyphCache.h +++ b/src/Magnum/Text/GlyphCache.h @@ -52,7 +52,7 @@ Text::AbstractFont* font; Text::GlyphCache* cache = new GlyphCache(Vector2i(512)); font->createGlyphCache(cache, "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789 "); + "0123456789?!:;,. "); @endcode See @ref Renderer for information about text rendering. diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index ab890dcb7..88a76db64 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -64,7 +64,7 @@ Arguments: - `--plugin-dir DIR` -- base plugin dir (defaults to plugin directory in %Magnum install location) - `--characters CHARACTERS` -- characters to include in the output (default: - `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!:,. `) + `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!:;,. `) - `--font-size N` -- input font size (default: `128`) - `--atlas-size "X Y"` -- glyph atlas size (default: `"2048 2048"`) - `--output-size "X Y"` -- output atlas size. If set to zero size, distance @@ -107,7 +107,7 @@ FontConverter::FontConverter(const Arguments& arguments): Platform::WindowlessAp .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelpKey("plugin-dir", "DIR").setHelp("plugin-dir", "base plugin dir") .addOption("characters", "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789?!:,. ").setHelp("characters", "characters to include in the output") + "0123456789?!:;,. ").setHelp("characters", "characters to include in the output") .addOption("font-size", "128").setHelpKey("font-size", "N").setHelp("font-size", "input font size") .addOption("atlas-size", "2048 2048").setHelpKey("atlas-size", "\"X Y\"").setHelp("atlas-size", "glyph atlas size") .addOption("output-size", "256 256").setHelpKey("output-size", "\"X Y\"").setHelp("output-size", "output atlas size. If set to zero size, distance field computation will not be used.") From 8903941462e22349cf321f95b7dde8dad6b3dc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Aug 2014 12:35:09 +0200 Subject: [PATCH 10/72] Text: updated and fixed Renderer docs. Thanks again, @wivlaro. --- src/Magnum/Text/Renderer.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Magnum/Text/Renderer.h b/src/Magnum/Text/Renderer.h index 94127c4e6..18a567922 100644 --- a/src/Magnum/Text/Renderer.h +++ b/src/Magnum/Text/Renderer.h @@ -176,20 +176,22 @@ methods, returning result either as data arrays or as fully configured mesh. The text can be then drawn as usual by configuring the shader and drawing the mesh: @code -Text::AbstractFont* font; +// Font instance, received from plugin manager +std::unique_ptr font; + +// Configured glyph cache Text::GlyphCache cache; -Shaders::VectorShader2D shader; +Shaders::Vector2D shader; Buffer vertexBuffer, indexBuffer; Mesh mesh; -// Render the text -Range2D rectangle; -std::tie(mesh, rectangle) = Text::Renderer2D::render(*font, cache, 0.15f, - "Hello World!", vertexBuffer, indexBuffer, BufferUsage::StaticDraw); +// Render the text, centered +std::tie(mesh, std::ignore) = Text::Renderer2D::render(*font, cache, 0.15f, + "Hello World!", vertexBuffer, indexBuffer, BufferUsage::StaticDraw, Text::Alignment::LineCenter); -// Draw white text centered on the screen -shader.setTransformationProjectionMatrix(projection*Matrix3::translation(-rectangle.width()/2.0f)) +// Draw the text on the screen +shader.setTransformationProjectionMatrix(projection) .setColor(Color3(1.0f)) .setVectorTexture(glyphCache->texture()); mesh.draw(shader); @@ -202,19 +204,19 @@ While this method is sufficient for one-shot rendering of static texts, for mutable texts (e.g. FPS counters, chat messages) there is another approach that doesn't recreate everything on each text change: @code -Text::AbstractFont* font; +std::unique_ptr font; Text::GlyphCache cache; -Shaders::VectorShader2D shader; +Shaders::Vector2D shader; // Initialize renderer and reserve memory for enough glyphs Text::Renderer2D renderer(*font, cache, 0.15f); -renderer.reserve(32, BufferUsage::DynamicDraw, BufferUsage::StaticDraw); +renderer.reserve(32, BufferUsage::DynamicDraw, BufferUsage::StaticDraw, Text::Alignment::LineCenter); // Update the text occasionally renderer.render("Hello World Countdown: 10"); -// Draw the text centered on the screen -shader.setTransformationProjectionMatrix(projection*Matrix3::translation(-renderer.rectangle().width()/2.0f)) +// Draw the text on the screen +shader.setTransformationProjectionMatrix(projection) .setColor(Color3(1.0f)) .setVectorTexture(glyphCache->texture()); renderer.mesh().draw(shader); From 6f688ab9473f48bf3cce90693b889aa769ec3af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Aug 2014 15:49:03 +0200 Subject: [PATCH 11/72] "Fix" flaky TimeQueryGLTest. Some operations are too fast so the time reported might as well be 0. --- src/Magnum/Test/TimeQueryGLTest.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index 233a98b8a..a92a62db0 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -56,7 +56,7 @@ void TimeQueryGLTest::queryTime() { const auto result1 = q1.result(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(result1 > 0); + CORRADE_VERIFY(result1 >= 0); TimeQuery q2; q2.begin(TimeQuery::Target::TimeElapsed); @@ -66,7 +66,7 @@ void TimeQueryGLTest::queryTime() { const auto result2 = q2.result(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(result2 > result1); + CORRADE_VERIFY(result2 >= result1); } void TimeQueryGLTest::queryTimestamp() { @@ -91,9 +91,9 @@ void TimeQueryGLTest::queryTimestamp() { const auto result2 = q2.result(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(result > 0); - CORRADE_VERIFY(result2 > result1); - CORRADE_VERIFY(result2-result1 > result); + CORRADE_VERIFY(result >= 0); + CORRADE_VERIFY(result2 >= result1); + CORRADE_VERIFY(result2-result1 >= result); } }} From 7f238d0bc49d0c39ee7a0178af17c999232809c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 16 Aug 2014 16:01:24 +0200 Subject: [PATCH 12/72] Updated related projects in README. --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 5afb0eb6d..299e652d7 100644 --- a/README.md +++ b/README.md @@ -147,17 +147,20 @@ RELATED PROJECTS The engine itself is kept as small as possible with only little dependencies. Additional functionality, often depending on external libraries, is provided in -separate repositories. Integration with various external math and physics -libraries can be found at https://github.com/mosra/magnum-integration. Various -importer plugins for image, audio and 3D model formats are maintained in -separate repository, which can be found at https://github.com/mosra/magnum-plugins. - -There are also examples of engine usage, varying from simple *Hello World*-like -example to more advanced applications, such as viewer for complex 3D models. -Example repository is at https://github.com/mosra/magnum-examples. - -Repository with bootstrap projects for many use cases, helping you get up and -running in no time is located at https://github.com/mosra/magnum-bootstrap. +separate repositories. + +* **Magnum Bootstrap** -- bootstrap projects for many use cases, helping you + get up and running in no time: https://github.com/mosra/magnum-bootstrap +* **Magnum Plugins** -- various importer plugins for image, font, audio and + 3D model formats is at https://github.com/mosra/magnum-plugins +* **Magnum Integration** -- integration with various external math and + physics, get it at https://github.com/mosra/magnum-integration +* **Magnum Examples** -- examples of engine usage, varying from simple + *Hello World*-like example to more advanced applications, such as viewer + for complex 3D models. See it at https://github.com/mosra/magnum-examples +* **libRocket integration** -- integrates Magnum as rendering backend into + [libRocket](https://github.com/libRocket/libRocket) GUI library: + https://github.com/miguelmartin75/Magnum-libRocket CONTACT ======= From 63bca6c65a34c264a6134ee1a5002994ef3c3002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 11:20:44 +0200 Subject: [PATCH 13/72] More README updates. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 299e652d7..c4874e268 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,9 @@ INSTALLATION ============ You can either use packaging scripts, which are stored in `package/` -subdirectory, or compile and install everything manually. Note that Doxygen -documentation (see above or build your own using instructions below) contains -more comprehensive guide for building, packaging and crosscompiling. +subdirectory, or compile and install everything manually. Note that +[Magnum documentation](http://mosra.cz/blog/magnum-doc/) contains more +comprehensive guide for building, packaging and crosscompiling. Minimal dependencies -------------------- From fec3bdadd7cdba31912b553ab70386aa2b57dc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 11:21:09 +0200 Subject: [PATCH 14/72] doc: mention usage of CMAKE_INSTALL_RPATH and CMAKE_PREFIX_PATH. --- doc/building.dox | 20 ++++++++++++++------ doc/cmake.dox | 5 +++++ doc/getting-started.dox | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/building.dox b/doc/building.dox index 423d52eb9..22471272f 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -78,6 +78,15 @@ can be built and installed using these four commands: See @ref building-features "below" for additional configuration options. +If you have the dependencies installed in non-standard location (other than +`/usr`, e.g. `/home/xyz/projects`), set `CMAKE_PREFIX_PATH` to that directory +to help CMake find them. You can enter more different dirs if you separate them +with semicolons. + +Also, if you plan to install the library to non-standard location, you might +want to set `CMAKE_INSTALL_RPATH` to `lib/` subdir of given prefix (e.g. +`/home/xyz/projects/lib`), so the dynamic libraries can be found at runtime. + @subsection building-windows Building on Windows On Windows you can use either MinGW or MSVC 2013 compiler. It's then up to you @@ -86,12 +95,11 @@ line. Note that for most convenient usage it's best use some dedicated directory (e.g. `C:/Sys`) for installing dependencies instead of putting each dependency to its own directory in `C:/Program Files`. Then add its `bin/` subdir (e.g. `C:/Sys/bin`) to PATH so all the DLLs are found when running the -executables. If you are using MinGW, the `C:/MinGW` directory is in most cases +executables. If you are using MinGW, the `C:/MinGW` directory is in most cases already prepared for exactly this. -When running CMake, set `CMAKE_INSTALL_PREFIX` parameter to that directory so -CMake knows where to look for installed libraries and where to install new -ones. +Then, when running CMake, set `CMAKE_PREFIX_PATH` and `CMAKE_INSTALL_PREFIX` +value to that directory (e.g. `-DCMAKE_INSTALL_PREFIX=C:/Sys`). @subsubsection building-windows-msvc Using Visual Studio @@ -116,8 +124,8 @@ On Windows you can also use QtCreator (just QtCreator, you don't need the full Qt SDK). Configure it to use CMake and either MSVC compiler or MinGW and and then just open project's root `CMakeLists.txt` file within it. QtCreator then asks you where to create build directory, allows you to specify initial CMake -parameters (e.g. `CMAKE_FIND_ROOT_PATH` and `CMAKE_INSTALL_PREFIX`) and then -you can just press *Configure* and everything is ready to be built. +parameters (e.g. `CMAKE_PREFIX_PATH` and `CMAKE_INSTALL_PREFIX`) and then you +can just press *Configure* and everything is ready to be built. After the initial import you might want to reconfigure some CMake variables, see @ref building-features "below" for more information. diff --git a/doc/cmake.dox b/doc/cmake.dox index 46ba9862a..9a7199bc4 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -41,6 +41,11 @@ Note that the module files are updated as the library evolves, you are encouraged to update your copies from time to time to avoid strange building issues. +If you installed the library or its dependencies to non-standard location +(other than `/usr`, e.g. `/home/xyz/projects`), set `CMAKE_PREFIX_PATH` to that +directory to help CMake find it. You can enter more different dirs if you +separate them with semicolons. + Basic usage is: find_package(Magnum REQUIRED) diff --git a/doc/getting-started.dox b/doc/getting-started.dox index e8d0ff721..21421ec26 100644 --- a/doc/getting-started.dox +++ b/doc/getting-started.dox @@ -164,14 +164,14 @@ straightforward way to create the project file is via the command-line: mkdir build cd build - cmake -DCMAKE_FIND_ROOT_PATH="C:/Sys" .. + cmake -DCMAKE_PREFIX_PATH="C:/Sys" .. You can also use CMake GUI. Then open the `MyApplication.sln` project file generated by CMake in the build directory. With QtCreator just open project's root `CMakeLists.txt` file. It then asks you where to create build directory, allows you to specify initial CMake parameters -(e.g. `CMAKE_FIND_ROOT_PATH`) and then you can just press *Configure* and +(e.g. `CMAKE_PREFIX_PATH`) and then you can just press *Configure* and everything is ready to be built. If CMake isn't able to find the dependencies on Windows, you might want to look From 3eff64ab62b3ac69803453253f87f2cc9cc609eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 11:29:18 +0200 Subject: [PATCH 15/72] Platform: doc++. --- src/Magnum/Platform/AndroidApplication.h | 4 +++- src/Magnum/Platform/GlutApplication.h | 4 +++- src/Magnum/Platform/NaClApplication.h | 4 +++- src/Magnum/Platform/Sdl2Application.h | 4 +++- src/Magnum/Platform/WindowlessCglApplication.h | 6 ++++-- src/Magnum/Platform/WindowlessGlxApplication.h | 6 ++++-- src/Magnum/Platform/WindowlessWglApplication.h | 6 ++++-- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Magnum/Platform/AndroidApplication.h b/src/Magnum/Platform/AndroidApplication.h index 0660734cf..1cb730249 100644 --- a/src/Magnum/Platform/AndroidApplication.h +++ b/src/Magnum/Platform/AndroidApplication.h @@ -98,6 +98,8 @@ properly set **absolute** path to `toolchains/modules/` directory containing -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" cmake --build . +See @ref cmake for more information. + The compiled binaries will be put into `lib/armeabi-v7a` and `lib/x86`. You can then build the APK package simply by running `ant`. The resulting APK package can be then installed directly on the device or emulator using `adb install`. @@ -114,7 +116,7 @@ Request `%AndroidApplication` component, add `${MAGNUM_ANDROIDAPPLICATION_INCLUDE_DIRS}` to include path and link to `${MAGNUM_ANDROIDAPPLICATION_LIBRARIES}`. If no other application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. See +`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see @ref building and @ref cmake for more information. Note that unlike on other platforms you need to create *shared library* instead of executable. The resulting binary then needs to be copied to `lib/armeabi-v7a` and `lib/x86`, diff --git a/src/Magnum/Platform/GlutApplication.h b/src/Magnum/Platform/GlutApplication.h index 1bab6db64..be6a91ba0 100644 --- a/src/Magnum/Platform/GlutApplication.h +++ b/src/Magnum/Platform/GlutApplication.h @@ -70,13 +70,15 @@ with these four commands: cmake --build . ./src/MyApplication # or ./src/Debug/MyApplication +See @ref cmake for more information. + ## General usage In CMake you need to request `%GlutApplication` component, add `${MAGNUM_GLUTAPPLICATION_INCLUDE_DIRS}` to include path and link to `${MAGNUM_GLUTAPPLICATION_LIBRARIES}`. If no other application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. See +`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw diff --git a/src/Magnum/Platform/NaClApplication.h b/src/Magnum/Platform/NaClApplication.h index fd554540f..092e84251 100644 --- a/src/Magnum/Platform/NaClApplication.h +++ b/src/Magnum/Platform/NaClApplication.h @@ -109,6 +109,8 @@ location of your webserver to have the files installed in proper location (e.g. cmake --build . cmake --build . --target install +See @ref cmake for more information. + You can then open `MyApplication` through your webserver in Chrome (e.g. `http://localhost/nacl/MyApplication.html`). @@ -120,7 +122,7 @@ ES). Request `%NaClApplication` component, add `${MAGNUM_NACLAPPLICATION_INCLUDE_DIRS}` to include path and link to `${MAGNUM_NACLAPPLICATION_LIBRARIES}`. If no other application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. See +`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index 52b43cfe6..f963ed86a 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -76,6 +76,8 @@ with these four commands: cmake --build . ./src/MyApplication # or ./src/Debug/MyApplication +See @ref cmake for more information. + ## Bootstrap application for Emscripten Fully contained base application using @ref Sdl2Application for both desktop @@ -115,7 +117,7 @@ In case of Emscripten you need also `FindOpenGLES2.cmake`. Request `%Sdl2Application` component, add `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` to include path and link to `${MAGNUM_SDL2APPLICATION_LIBRARIES}`. If no other application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` -and `${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. See +and `${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw on the diff --git a/src/Magnum/Platform/WindowlessCglApplication.h b/src/Magnum/Platform/WindowlessCglApplication.h index 225ed3a53..0f751b16c 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.h +++ b/src/Magnum/Platform/WindowlessCglApplication.h @@ -63,6 +63,8 @@ application with these four commands: cmake --build . ./src/MyApplication # or ./src/Debug/MyApplication +See @ref cmake for more information. + ## General usage In CMake you need to request `%WindowlessCglApplication` component, add @@ -70,8 +72,8 @@ In CMake you need to request `%WindowlessCglApplication` component, add `${MAGNUM_WINDOWLESSCGLAPPLICATION_LIBRARIES}`. If no other windowless application is requested, you can also use generic `${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. See -@ref building and @ref cmake for more information. +`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. Again, +see @ref building and @ref cmake for more information. Place your code into @ref exec(). The subclass can be then used directly in `main()` -- see convenience macro @ref MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN(). diff --git a/src/Magnum/Platform/WindowlessGlxApplication.h b/src/Magnum/Platform/WindowlessGlxApplication.h index 90eb770fb..49098fe94 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.h +++ b/src/Magnum/Platform/WindowlessGlxApplication.h @@ -69,6 +69,8 @@ application with these four commands: cmake --build . ./src/MyApplication # or ./src/Debug/MyApplication +See @ref cmake for more information. + ## General usage In CMake you need to request `%WindowlessGlxApplication` component, add @@ -76,8 +78,8 @@ In CMake you need to request `%WindowlessGlxApplication` component, add `${MAGNUM_WINDOWLESSGLXAPPLICATION_LIBRARIES}`. If no other windowless application is requested, you can also use generic `${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. See -@ref building and @ref cmake for more information. +`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. Again, +see @ref building and @ref cmake for more information. Place your code into @ref exec(). The subclass can be then used directly in `main()` -- see convenience macro @ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(). diff --git a/src/Magnum/Platform/WindowlessWglApplication.h b/src/Magnum/Platform/WindowlessWglApplication.h index a21cf341d..3f1ecb623 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.h +++ b/src/Magnum/Platform/WindowlessWglApplication.h @@ -64,6 +64,8 @@ application with these four commands: cmake --build . ./src/MyApplication # or ./src/Debug/MyApplication +See @ref cmake for more information. + ## General usage In CMake you need to request `%WindowlessWglApplication` component, add @@ -71,8 +73,8 @@ In CMake you need to request `%WindowlessWglApplication` component, add `${MAGNUM_WINDOWLESSWGLAPPLICATION_LIBRARIES}`. If no other windowless application is requested, you can also use generic `${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. See -@ref building and @ref cmake for more information. +`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. Again, +see @ref building and @ref cmake for more information. Place your code into @ref exec(). The subclass can be then used in main function using @ref MAGNUM_WINDOWLESSWGLAPPLICATION_MAIN() macro. See From 4f30c667a36dca36bf4ffb056922fcf0db7fb905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 12:00:18 +0200 Subject: [PATCH 16/72] Minor cleanup. --- src/Magnum/Query.cpp | 28 ++++++++++++++-------------- src/Magnum/Query.h | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Magnum/Query.cpp b/src/Magnum/Query.cpp index 3e01d4b8e..1a74b584e 100644 --- a/src/Magnum/Query.cpp +++ b/src/Magnum/Query.cpp @@ -33,7 +33,7 @@ namespace Magnum { -AbstractQuery::AbstractQuery(): target() { +AbstractQuery::AbstractQuery(): _target{} { #ifndef MAGNUM_TARGET_GLES2 glGenQueries(1, &_id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) @@ -74,7 +74,7 @@ AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayReference< } bool AbstractQuery::resultAvailable() { - CORRADE_ASSERT(!target, "AbstractQuery::resultAvailable(): the query is currently running", false); + CORRADE_ASSERT(!_target, "AbstractQuery::resultAvailable(): the query is currently running", false); GLuint result; #ifndef MAGNUM_TARGET_GLES2 @@ -89,7 +89,7 @@ bool AbstractQuery::resultAvailable() { #ifndef DOXYGEN_GENERATING_OUTPUT template<> UnsignedInt AbstractQuery::result() { - CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {}); + CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); UnsignedInt result; #ifndef MAGNUM_TARGET_GLES2 @@ -105,7 +105,7 @@ template<> UnsignedInt AbstractQuery::result() { template<> bool AbstractQuery::result() { return result() != 0; } template<> Int AbstractQuery::result() { - CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {}); + CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); Int result; #ifndef MAGNUM_TARGET_GLES @@ -120,7 +120,7 @@ template<> Int AbstractQuery::result() { #ifndef MAGNUM_TARGET_WEBGL template<> UnsignedLong AbstractQuery::result() { - CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {}); + CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); UnsignedLong result; #ifndef MAGNUM_TARGET_GLES @@ -134,7 +134,7 @@ template<> UnsignedLong AbstractQuery::result() { } template<> Long AbstractQuery::result() { - CORRADE_ASSERT(!target, "AbstractQuery::result(): the query is currently running", {}); + CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); Long result; #ifndef MAGNUM_TARGET_GLES @@ -149,13 +149,13 @@ template<> Long AbstractQuery::result() { #endif #endif -void AbstractQuery::begin(GLenum target) { - CORRADE_ASSERT(!this->target, "AbstractQuery::begin(): the query is already running", ); +void AbstractQuery::begin(const GLenum target) { + CORRADE_ASSERT(!_target, "AbstractQuery::begin(): the query is already running", ); #ifndef MAGNUM_TARGET_GLES2 - glBeginQuery(this->target = target, id()); + glBeginQuery(_target = target, id()); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glBeginQueryEXT(this->target = target, id()); + glBeginQueryEXT(_target = target, id()); #else static_cast(target); CORRADE_ASSERT_UNREACHABLE(); @@ -163,16 +163,16 @@ void AbstractQuery::begin(GLenum target) { } void AbstractQuery::end() { - CORRADE_ASSERT(target, "AbstractQuery::end(): the query is not running", ); + CORRADE_ASSERT(_target, "AbstractQuery::end(): the query is not running", ); #ifndef MAGNUM_TARGET_GLES2 - glEndQuery(target); + glEndQuery(_target); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glEndQueryEXT(target); + glEndQueryEXT(_target); #else CORRADE_ASSERT_UNREACHABLE(); #endif - target = {}; + _target = {}; } } diff --git a/src/Magnum/Query.h b/src/Magnum/Query.h index 50b917fdc..2e2f265fb 100644 --- a/src/Magnum/Query.h +++ b/src/Magnum/Query.h @@ -154,7 +154,7 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { AbstractQuery& setLabelInternal(Containers::ArrayReference label); GLuint _id; - GLenum target; + GLenum _target; }; @@ -474,13 +474,13 @@ class TimeQuery: public AbstractQuery { #endif }; -inline AbstractQuery::AbstractQuery(AbstractQuery&& other) noexcept: _id(other._id), target(other.target) { +inline AbstractQuery::AbstractQuery(AbstractQuery&& other) noexcept: _id(other._id), _target(other._target) { other._id = 0; } inline AbstractQuery& AbstractQuery::operator=(AbstractQuery&& other) noexcept { std::swap(_id, other._id); - std::swap(target, other.target); + std::swap(_target, other._target); return *this; } From 7caeb928d2a92c7d37a9616cc3c24e90d0987efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 12:36:33 +0200 Subject: [PATCH 17/72] Obvious check is obvious. Thanks, compiler. --- src/Magnum/Test/TimeQueryGLTest.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index a92a62db0..680f95544 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -56,7 +56,6 @@ void TimeQueryGLTest::queryTime() { const auto result1 = q1.result(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(result1 >= 0); TimeQuery q2; q2.begin(TimeQuery::Target::TimeElapsed); @@ -91,7 +90,6 @@ void TimeQueryGLTest::queryTimestamp() { const auto result2 = q2.result(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_VERIFY(result >= 0); CORRADE_VERIFY(result2 >= result1); CORRADE_VERIFY(result2-result1 >= result); } From d2e28e5f9981854f1a7435b734a2e6e146b4e643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 12:58:07 +0200 Subject: [PATCH 18/72] Split Query.h into per-class header. The old Query.h header is still working, but marked as deprecated and will be removed in some future release. --- src/Magnum/{Query.cpp => AbstractQuery.cpp} | 2 +- src/Magnum/AbstractQuery.h | 182 ++++++++ src/Magnum/CMakeLists.txt | 10 +- src/Magnum/PrimitiveQuery.h | 110 +++++ src/Magnum/Query.h | 460 +------------------- src/Magnum/SampleQuery.h | 191 ++++++++ src/Magnum/Test/AbstractQueryGLTest.cpp | 2 +- src/Magnum/Test/PrimitiveQueryGLTest.cpp | 2 +- src/Magnum/Test/SampleQueryGLTest.cpp | 2 +- src/Magnum/Test/TimeQueryGLTest.cpp | 2 +- src/Magnum/TimeQuery.h | 121 +++++ 11 files changed, 623 insertions(+), 461 deletions(-) rename src/Magnum/{Query.cpp => AbstractQuery.cpp} (99%) create mode 100644 src/Magnum/AbstractQuery.h create mode 100644 src/Magnum/PrimitiveQuery.h create mode 100644 src/Magnum/SampleQuery.h create mode 100644 src/Magnum/TimeQuery.h diff --git a/src/Magnum/Query.cpp b/src/Magnum/AbstractQuery.cpp similarity index 99% rename from src/Magnum/Query.cpp rename to src/Magnum/AbstractQuery.cpp index 1a74b584e..2de393661 100644 --- a/src/Magnum/Query.cpp +++ b/src/Magnum/AbstractQuery.cpp @@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE. */ -#include "Query.h" +#include "AbstractQuery.h" #include diff --git a/src/Magnum/AbstractQuery.h b/src/Magnum/AbstractQuery.h new file mode 100644 index 000000000..0dcd628d4 --- /dev/null +++ b/src/Magnum/AbstractQuery.h @@ -0,0 +1,182 @@ +#ifndef Magnum_AbstractQuery_h +#define Magnum_AbstractQuery_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + 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. +*/ + +/** @file + * @brief Class @ref Magnum::AbstractQuery + */ + +#include +#include + +#include "Magnum/AbstractObject.h" +#include "Magnum/configure.h" + +namespace Magnum { + +/** +@brief Base class for queries + +See @ref PrimitiveQuery, @ref SampleQuery and @ref TimeQuery documentation for +more information. +@todo `QUERY_COUNTER_BITS` (not sure since when this is supported) +*/ +class MAGNUM_EXPORT AbstractQuery: public AbstractObject { + public: + /** @brief Copying is not allowed */ + AbstractQuery(const AbstractQuery&) = delete; + + /** @brief Move constructor */ + AbstractQuery(AbstractQuery&& other) noexcept; + + /** @brief Copying is not allowed */ + AbstractQuery& operator=(const AbstractQuery&) = delete; + + /** @brief Move assignment */ + AbstractQuery& operator=(AbstractQuery&& other) noexcept; + + /** @brief OpenGL query ID */ + GLuint id() const { return _id; } + + /** + * @brief %Query label + * + * The result is *not* cached, repeated queries will result in repeated + * OpenGL calls. If OpenGL 4.3 is not supported and neither + * @extension{KHR,debug} nor @extension2{EXT,debug_label} desktop or ES + * extension is available, this function returns empty string. + * @see @fn_gl{GetObjectLabel} with @def_gl{QUERY} or + * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with + * @def_gl{QUERY_OBJECT_EXT} + */ + std::string label() const; + + /** + * @brief Set query label + * @return Reference to self (for method chaining) + * + * Default is empty string. If OpenGL 4.3 is not supported and neither + * @extension{KHR,debug} nor @extension2{EXT,debug_label} desktop or ES + * extension is available, this function does nothing. + * @see @ref maxLabelLength(), @fn_gl{ObjectLabel} with + * @def_gl{QUERY} or @fn_gl_extension2{LabelObject,EXT,debug_label} + * with @def_gl{QUERY_OBJECT_EXT} + */ + AbstractQuery& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractQuery& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } + + /** + * @brief Whether the result is available + * + * @see @fn_gl{GetQueryObject} with @def_gl{QUERY_RESULT_AVAILABLE} + */ + bool resultAvailable(); + + /** + * @brief Result + * @tparam T Result type. Can be either `bool`, @ref UnsignedInt, + * @ref Int, @ref UnsignedLong or @ref Long. + * + * Note that this function is blocking until the result is available. + * See resultAvailable(). + * @attention @ref Magnum::UnsignedLong "UnsignedLong" and @ref Magnum::Long "Long" + * result type is not available in @ref MAGNUM_TARGET_WEBGL "WebGL". + * @see @fn_gl{GetQueryObject} with @def_gl{QUERY_RESULT} + * @requires_gl33 %Extension @extension{ARB,timer_query} for result + * type @ref Magnum::UnsignedInt "UnsignedInt" and @ref Magnum::Long + * "Long" + * @requires_es_extension %Extension @es_extension{EXT,disjoint_timer_query} + * for result types @ref Magnum::Int "Int", @ref Magnum::UnsignedLong "UnsignedLong" + * @ref Magnum::Long "Long". + */ + template T result(); + + /** + * @brief End query + * + * The result can be then retrieved by calling @ref result(). + * @see @fn_gl{EndQuery} + */ + void end(); + + protected: + /** + * @brief Constructor + * + * Generates one OpenGL query. + * @see @fn_gl{GenQueries} + */ + explicit AbstractQuery(); + + /** + * @brief Destructor + * + * Deletes assigned OpenGL query. + * @see @fn_gl{DeleteQueries} + */ + ~AbstractQuery(); + + #ifdef DOXYGEN_GENERATING_OUTPUT + private: + #endif + void begin(GLenum target); + + private: + AbstractQuery& setLabelInternal(Containers::ArrayReference label); + + GLuint _id; + GLenum _target; +}; + +#ifndef DOXYGEN_GENERATING_OUTPUT +template<> bool MAGNUM_EXPORT AbstractQuery::result(); +template<> UnsignedInt MAGNUM_EXPORT AbstractQuery::result(); +template<> Int MAGNUM_EXPORT AbstractQuery::result(); +#ifndef MAGNUM_TARGET_WEBGL +template<> UnsignedLong MAGNUM_EXPORT AbstractQuery::result(); +template<> Long MAGNUM_EXPORT AbstractQuery::result(); +#endif +#endif + +inline AbstractQuery::AbstractQuery(AbstractQuery&& other) noexcept: _id(other._id), _target(other._target) { + other._id = 0; +} + +inline AbstractQuery& AbstractQuery::operator=(AbstractQuery&& other) noexcept { + std::swap(_id, other._id); + std::swap(_target, other._target); + return *this; +} + +} + +#endif diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index d6db799e4..b560ce451 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -31,6 +31,7 @@ set(Magnum_SRCS AbstractFramebuffer.cpp AbstractImage.cpp AbstractObject.cpp + AbstractQuery.cpp AbstractTexture.cpp AbstractShaderProgram.cpp Buffer.cpp @@ -44,7 +45,6 @@ set(Magnum_SRCS Mesh.cpp MeshView.cpp OpenGL.cpp - Query.cpp Renderbuffer.cpp Renderer.cpp Resource.cpp @@ -83,6 +83,7 @@ set(Magnum_HEADERS AbstractFramebuffer.h AbstractImage.h AbstractObject.h + AbstractQuery.h AbstractResourceLoader.h AbstractShaderProgram.h AbstractTexture.h @@ -103,17 +104,18 @@ set(Magnum_HEADERS Mesh.h MeshView.h OpenGL.h - Query.h Renderbuffer.h RenderbufferFormat.h Renderer.h Resource.h ResourceManager.h + SampleQuery.h Sampler.h Shader.h Texture.h TextureFormat.h Timeline.h + TimeQuery.h Types.h Version.h @@ -135,7 +137,8 @@ set(Magnum_PRIVATE_HEADERS # Deprecated headers if(BUILD_DEPRECATED) set(Magnum_HEADERS ${Magnum_HEADERS} - DebugMarker.h) + DebugMarker.h + Query.h) endif() # Desktop-only stuff @@ -155,6 +158,7 @@ if(NOT TARGET_GLES2) set(Magnum_HEADERS ${Magnum_HEADERS} BufferImage.h MultisampleTexture.h + PrimitiveQuery.h TextureArray.h) set(Magnum_SRCS ${Magnum_SRCS} BufferImage.cpp diff --git a/src/Magnum/PrimitiveQuery.h b/src/Magnum/PrimitiveQuery.h new file mode 100644 index 000000000..d196e95ca --- /dev/null +++ b/src/Magnum/PrimitiveQuery.h @@ -0,0 +1,110 @@ +#ifndef Magnum_PrimitiveQuery_h +#define Magnum_PrimitiveQuery_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + 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. +*/ + +#ifndef MAGNUM_TARGET_GLES2 +/** @file + * @brief Class @ref Magnum::PrimitiveQuery + */ +#endif + +#include "Magnum/AbstractQuery.h" + +#ifndef MAGNUM_TARGET_GLES2 +namespace Magnum { + +/** +@brief Query for primitives + +Queries count of generated primitives from vertex shader, geometry shader or +transform feedback. Example usage: +@code +PrimitiveQuery q; + +q.begin(PrimitiveQuery::Target::PrimitivesGenerated); +// rendering... +q.end(); + +if(!q.resultAvailable()) { + // do some work until to give OpenGL some time... +} + +// ...or block until the result is available +UnsignedInt primitiveCount = q.result(); +@endcode +@requires_gl30 %Extension @extension{EXT,transform_feedback} +@requires_gles30 Only sample queries are available on OpenGL ES 2.0. + +@see @ref SampleQuery, @ref TimeQuery +@todo glBeginQueryIndexed +*/ +class PrimitiveQuery: public AbstractQuery { + public: + /** @brief Query target */ + enum class Target: GLenum { + #ifndef MAGNUM_TARGET_GLES + /** + * Count of primitives generated from vertex shader or geometry + * shader. + * @requires_gl Only transform feedback query is available in + * OpenGL ES. + */ + PrimitivesGenerated = GL_PRIMITIVES_GENERATED, + #endif + + /** Count of primitives written to transform feedback buffer. */ + TransformFeedbackPrimitivesWritten = GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN + }; + + explicit PrimitiveQuery() {} + + /** + * @brief Begin query + * + * Begins counting of given @p target until @ref end() is called. + * @see @fn_gl{BeginQuery} + */ + void begin(Target target) { + AbstractQuery::begin(GLenum(target)); + } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT + PrimitiveQuery& setLabel(const std::string& label) { + AbstractQuery::setLabel(label); + return *this; + } + template PrimitiveQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } + #endif +}; + +} +#endif + +#endif diff --git a/src/Magnum/Query.h b/src/Magnum/Query.h index 2e2f265fb..5bde8162e 100644 --- a/src/Magnum/Query.h +++ b/src/Magnum/Query.h @@ -27,463 +27,17 @@ /** @file * @brief Class @ref Magnum::AbstractQuery, @ref Magnum::PrimitiveQuery, @ref Magnum::SampleQuery, @ref Magnum::TimeQuery + * @deprecated Use @ref Magnum/PrimitiveQuery.h, @ref Magnum/SampleQuery.h or @ref Magnum/TimeQuery.h instead. */ -#include -#include - -#include "Magnum/AbstractObject.h" #include "Magnum/configure.h" -namespace Magnum { - -/** -@brief Base class for queries - -See @ref PrimitiveQuery, @ref SampleQuery and @ref TimeQuery documentation for -more information. -@todo `QUERY_COUNTER_BITS` (not sure since when this is supported) -*/ -class MAGNUM_EXPORT AbstractQuery: public AbstractObject { - public: - /** @brief Copying is not allowed */ - AbstractQuery(const AbstractQuery&) = delete; - - /** @brief Move constructor */ - AbstractQuery(AbstractQuery&& other) noexcept; - - /** @brief Copying is not allowed */ - AbstractQuery& operator=(const AbstractQuery&) = delete; - - /** @brief Move assignment */ - AbstractQuery& operator=(AbstractQuery&& other) noexcept; - - /** @brief OpenGL query ID */ - GLuint id() const { return _id; } - - /** - * @brief %Query label - * - * The result is *not* cached, repeated queries will result in repeated - * OpenGL calls. If OpenGL 4.3 is not supported and neither - * @extension{KHR,debug} nor @extension2{EXT,debug_label} desktop or ES - * extension is available, this function returns empty string. - * @see @fn_gl{GetObjectLabel} with @def_gl{QUERY} or - * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with - * @def_gl{QUERY_OBJECT_EXT} - */ - std::string label() const; - - /** - * @brief Set query label - * @return Reference to self (for method chaining) - * - * Default is empty string. If OpenGL 4.3 is not supported and neither - * @extension{KHR,debug} nor @extension2{EXT,debug_label} desktop or ES - * extension is available, this function does nothing. - * @see @ref maxLabelLength(), @fn_gl{ObjectLabel} with - * @def_gl{QUERY} or @fn_gl_extension2{LabelObject,EXT,debug_label} - * with @def_gl{QUERY_OBJECT_EXT} - */ - AbstractQuery& setLabel(const std::string& label) { - return setLabelInternal({label.data(), label.size()}); - } - - /** @overload */ - template AbstractQuery& setLabel(const char(&label)[size]) { - return setLabelInternal(label); - } - - /** - * @brief Whether the result is available - * - * @see @fn_gl{GetQueryObject} with @def_gl{QUERY_RESULT_AVAILABLE} - */ - bool resultAvailable(); - - /** - * @brief Result - * @tparam T Result type. Can be either `bool`, @ref UnsignedInt, - * @ref Int, @ref UnsignedLong or @ref Long. - * - * Note that this function is blocking until the result is available. - * See resultAvailable(). - * @attention @ref Magnum::UnsignedLong "UnsignedLong" and @ref Magnum::Long "Long" - * result type is not available in @ref MAGNUM_TARGET_WEBGL "WebGL". - * @see @fn_gl{GetQueryObject} with @def_gl{QUERY_RESULT} - * @requires_gl33 %Extension @extension{ARB,timer_query} for result - * type @ref Magnum::UnsignedInt "UnsignedInt" and @ref Magnum::Long - * "Long" - * @requires_es_extension %Extension @es_extension{EXT,disjoint_timer_query} - * for result types @ref Magnum::Int "Int", @ref Magnum::UnsignedLong "UnsignedLong" - * @ref Magnum::Long "Long". - */ - template T result(); - - /** - * @brief End query - * - * The result can be then retrieved by calling @ref result(). - * @see @fn_gl{EndQuery} - */ - void end(); - - protected: - /** - * @brief Constructor - * - * Generates one OpenGL query. - * @see @fn_gl{GenQueries} - */ - explicit AbstractQuery(); - - /** - * @brief Destructor - * - * Deletes assigned OpenGL query. - * @see @fn_gl{DeleteQueries} - */ - ~AbstractQuery(); - - #ifdef DOXYGEN_GENERATING_OUTPUT - private: - #endif - void begin(GLenum target); - - private: - AbstractQuery& setLabelInternal(Containers::ArrayReference label); - - GLuint _id; - GLenum _target; -}; - - -#ifndef DOXYGEN_GENERATING_OUTPUT -template<> bool MAGNUM_EXPORT AbstractQuery::result(); -template<> UnsignedInt MAGNUM_EXPORT AbstractQuery::result(); -template<> Int MAGNUM_EXPORT AbstractQuery::result(); -#ifndef MAGNUM_TARGET_WEBGL -template<> UnsignedLong MAGNUM_EXPORT AbstractQuery::result(); -template<> Long MAGNUM_EXPORT AbstractQuery::result(); -#endif -#endif - -#ifndef MAGNUM_TARGET_GLES2 -/** -@brief Query for primitives - -Queries count of generated primitives from vertex shader, geometry shader or -transform feedback. Example usage: -@code -PrimitiveQuery q; - -q.begin(PrimitiveQuery::Target::PrimitivesGenerated); -// rendering... -q.end(); - -if(!q.resultAvailable()) { - // do some work until to give OpenGL some time... -} - -// ...or block until the result is available -UnsignedInt primitiveCount = q.result(); -@endcode -@requires_gl30 %Extension @extension{EXT,transform_feedback} -@requires_gles30 Only sample queries are available on OpenGL ES 2.0. - -@see @ref SampleQuery, @ref TimeQuery -@todo glBeginQueryIndexed -*/ -class PrimitiveQuery: public AbstractQuery { - public: - /** @brief Query target */ - enum class Target: GLenum { - #ifndef MAGNUM_TARGET_GLES - /** - * Count of primitives generated from vertex shader or geometry - * shader. - * @requires_gl Only transform feedback query is available in - * OpenGL ES. - */ - PrimitivesGenerated = GL_PRIMITIVES_GENERATED, - #endif - - /** Count of primitives written to transform feedback buffer. */ - TransformFeedbackPrimitivesWritten = GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN - }; - - explicit PrimitiveQuery() {} - - /** - * @brief Begin query - * - * Begins counting of given @p target until @ref end() is called. - * @see @fn_gl{BeginQuery} - */ - void begin(Target target) { - AbstractQuery::begin(GLenum(target)); - } - - /* Overloads to remove WTF-factor from method chaining order */ - #ifndef DOXYGEN_GENERATING_OUTPUT - PrimitiveQuery& setLabel(const std::string& label) { - AbstractQuery::setLabel(label); - return *this; - } - template PrimitiveQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } - #endif -}; +#ifdef MAGNUM_BUILD_DEPRECATED +#include "Magnum/PrimitiveQuery.h" +#include "Magnum/SampleQuery.h" +#include "Magnum/TimeQuery.h" +#else +#error use Magnum/PrimitiveQuery.h, Magnum/SampleQuery.h or Magnum/TimeQuery.h instead. #endif -/** -@brief Query for samples - -Queries count of samples passed from fragment shader or boolean value -indicating whether any samples passed. Can be used for example for conditional -rendering: -@code -SampleQuery q; - -q.begin(SampleQuery::Target::AnySamplesPassed); -// render simplified object to test whether it is visible at all... -q.end(); - -// render full version of the object only if it is visible -if(q.result()) { - // ... -} -@endcode -This approach has some drawbacks, as the rendering is blocked until result is -available for the CPU to decide. This can be improved by using conditional -rendering on GPU itself. The drawing commands will be sent to the GPU and -processed or discarded later, so CPU can continue executing the code without -waiting for the result. -@code -SampleQuery q; - -q.begin(SampleQuery::Target::AnySamplesPassed); -// render simplified object to test whether it is visible at all... -q.end(); - -q.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); -// render full version of the object only if the query returns nonzero result -q.endConditionalRender(); -@endcode - -@see @ref PrimitiveQuery, @ref TimeQuery -@requires_gles30 %Extension @es_extension{EXT,occlusion_query_boolean} in - OpenGL ES 2.0 -*/ -class SampleQuery: public AbstractQuery { - public: - /** @brief Query target */ - enum class Target: GLenum { - #ifndef MAGNUM_TARGET_GLES - /** - * Count of samples passed from fragment shader - * @requires_gl Only boolean query is available in OpenGL ES. - */ - SamplesPassed = GL_SAMPLES_PASSED, - #endif - - /** - * Whether any samples passed from fragment shader - * @requires_gl33 %Extension @extension{ARB,occlusion_query2} - */ - #ifndef MAGNUM_TARGET_GLES2 - AnySamplesPassed = GL_ANY_SAMPLES_PASSED, - #else - AnySamplesPassed = GL_ANY_SAMPLES_PASSED_EXT, - #endif - - /** - * Whether any samples passed from fragment shader (conservative) - * - * An implementation may choose a less precise version of the - * test at the expense of some false positives. - * @requires_gl43 %Extension @extension{ARB,ES3_compatibility} - */ - #ifndef MAGNUM_TARGET_GLES2 - AnySamplesPassedConservative = GL_ANY_SAMPLES_PASSED_CONSERVATIVE - #else - AnySamplesPassedConservative = GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT - #endif - }; - - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Conditional render mode - * - * @requires_gl30 %Extension @extension{NV,conditional_render} - * @requires_gl Conditional rendering is not available in OpenGL ES. - */ - enum class ConditionalRenderMode: GLenum { - /** - * If query result is not yet available, waits for it and - * then begins conditional rendering based on result value. - */ - Wait = GL_QUERY_WAIT, - - /** - * If query result is not yet available, OpenGL may begin - * rendering like if the result value was nonzero. - */ - NoWait = GL_QUERY_NO_WAIT, - - /** - * The same as Wait, but regions untouched by the sample query may - * not be rendered at all. - */ - ByRegionWait = GL_QUERY_BY_REGION_WAIT, - - /** - * The same as NoWait, but regions untouched by the sample query - * may not be rendered at all. - */ - ByRegionNoWait = GL_QUERY_BY_REGION_NO_WAIT - }; - #endif - - explicit SampleQuery() {} - - /** @copydoc PrimitiveQuery::begin() */ - void begin(Target target) { - AbstractQuery::begin(GLenum(target)); - } - - #ifndef MAGNUM_TARGET_GLES - /** - * @brief Begin conditional rendering based on result value - * - * @see @fn_gl{BeginConditionalRender} - * @requires_gl30 %Extension @extension{NV,conditional_render} - * @requires_gl Conditional rendering is not available in OpenGL ES. - */ - void beginConditionalRender(ConditionalRenderMode mode) { - glBeginConditionalRender(id(), GLenum(mode)); - } - - /** - * @brief End conditional render - * - * @see @fn_gl{EndConditionalRender} - * @requires_gl30 %Extension @extension{NV,conditional_render} - * @requires_gl Conditional rendering is not available in OpenGL ES. - */ - void endConditionalRender() { - glEndConditionalRender(); - } - #endif - - /* Overloads to remove WTF-factor from method chaining order */ - #ifndef DOXYGEN_GENERATING_OUTPUT - SampleQuery& setLabel(const std::string& label) { - AbstractQuery::setLabel(label); - return *this; - } - template SampleQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } - #endif -}; - -/** -@brief Query for elapsed time - -Queries timestamp after all previous OpenGL calls have been processed. It can -query either duration of sequence of commands or absolute timestamp. Example -usage of both methods: -@code -TimeQuery q1, q2; -q1.begin(TimeQuery::Target::TimeElapsed); -// rendering... -q1.end(); -q2.begin(TimeQuery::Target::TimeElapsed); -// another rendering... -q2.end(); -UnsignedInt timeElapsed1 = q1.result(); -UnsignedInt timeElapsed2 = q2.result(); -@endcode -@code -TimeQuery q1, q2, q3; -q1.timestamp(); -// rendering... -q2.timestamp(); -// another rendering... -q3.timestamp(); -UnsignedInt tmp = q2.result(); -UnsignedInt timeElapsed1 = tmp-q1.result(); -UnsignedInt timeElapsed2 = q3.result()-tmp; -@endcode -Using the latter results in fewer OpenGL calls when doing more measures. -@requires_gl33 %Extension @extension{ARB,timer_query} -@requires_es_extension %Extension @es_extension{EXT,disjoint_timer_query} - -@see @ref PrimitiveQuery, @ref SampleQuery -@todo timestamp with glGet + example usage -@todo @es_extension{EXT,disjoint_timer_query} -- GL_GPU_DISJOINT_EXT support? where? -*/ -class TimeQuery: public AbstractQuery { - public: - /** @brief Query target */ - enum class Target: GLenum { - /** Elapsed time */ - #ifndef MAGNUM_TARGET_GLES - TimeElapsed = GL_TIME_ELAPSED - #else - TimeElapsed = GL_TIME_ELAPSED_EXT - #endif - }; - - explicit TimeQuery() {} - - /** - * @brief Query timestamp - * - * @see @fn_gl{QueryCounter} with @def_gl{TIMESTAMP} - */ - void timestamp() { - #ifndef MAGNUM_TARGET_GLES - glQueryCounter(id(), GL_TIMESTAMP); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glQueryCounterEXT(id(), GL_TIMESTAMP_EXT); - #else - CORRADE_ASSERT_UNREACHABLE(); - #endif - } - - /** @copydoc PrimitiveQuery::begin() */ - void begin(Target target) { - AbstractQuery::begin(GLenum(target)); - } - - /* Overloads to remove WTF-factor from method chaining order */ - #ifndef DOXYGEN_GENERATING_OUTPUT - TimeQuery& setLabel(const std::string& label) { - AbstractQuery::setLabel(label); - return *this; - } - template TimeQuery& setLabel(const char(&label)[size]) { - AbstractQuery::setLabel(label); - return *this; - } - #endif -}; - -inline AbstractQuery::AbstractQuery(AbstractQuery&& other) noexcept: _id(other._id), _target(other._target) { - other._id = 0; -} - -inline AbstractQuery& AbstractQuery::operator=(AbstractQuery&& other) noexcept { - std::swap(_id, other._id); - std::swap(_target, other._target); - return *this; -} - -} - #endif diff --git a/src/Magnum/SampleQuery.h b/src/Magnum/SampleQuery.h new file mode 100644 index 000000000..0d8459ed7 --- /dev/null +++ b/src/Magnum/SampleQuery.h @@ -0,0 +1,191 @@ +#ifndef Magnum_SampleQuery_h +#define Magnum_SampleQuery_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + 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. +*/ + +/** @file + * @brief Class @ref Magnum::SampleQuery + */ + +#include "Magnum/AbstractQuery.h" + +namespace Magnum { + +/** +@brief Query for samples + +Queries count of samples passed from fragment shader or boolean value +indicating whether any samples passed. Can be used for example for conditional +rendering: +@code +SampleQuery q; + +q.begin(SampleQuery::Target::AnySamplesPassed); +// render simplified object to test whether it is visible at all... +q.end(); + +// render full version of the object only if it is visible +if(q.result()) { + // ... +} +@endcode +This approach has some drawbacks, as the rendering is blocked until result is +available for the CPU to decide. This can be improved by using conditional +rendering on GPU itself. The drawing commands will be sent to the GPU and +processed or discarded later, so CPU can continue executing the code without +waiting for the result. +@code +SampleQuery q; + +q.begin(SampleQuery::Target::AnySamplesPassed); +// render simplified object to test whether it is visible at all... +q.end(); + +q.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); +// render full version of the object only if the query returns nonzero result +q.endConditionalRender(); +@endcode + +@see @ref PrimitiveQuery, @ref TimeQuery +@requires_gles30 %Extension @es_extension{EXT,occlusion_query_boolean} in + OpenGL ES 2.0 +*/ +class SampleQuery: public AbstractQuery { + public: + /** @brief Query target */ + enum class Target: GLenum { + #ifndef MAGNUM_TARGET_GLES + /** + * Count of samples passed from fragment shader + * @requires_gl Only boolean query is available in OpenGL ES. + */ + SamplesPassed = GL_SAMPLES_PASSED, + #endif + + /** + * Whether any samples passed from fragment shader + * @requires_gl33 %Extension @extension{ARB,occlusion_query2} + */ + #ifndef MAGNUM_TARGET_GLES2 + AnySamplesPassed = GL_ANY_SAMPLES_PASSED, + #else + AnySamplesPassed = GL_ANY_SAMPLES_PASSED_EXT, + #endif + + /** + * Whether any samples passed from fragment shader (conservative) + * + * An implementation may choose a less precise version of the + * test at the expense of some false positives. + * @requires_gl43 %Extension @extension{ARB,ES3_compatibility} + */ + #ifndef MAGNUM_TARGET_GLES2 + AnySamplesPassedConservative = GL_ANY_SAMPLES_PASSED_CONSERVATIVE + #else + AnySamplesPassedConservative = GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT + #endif + }; + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Conditional render mode + * + * @requires_gl30 %Extension @extension{NV,conditional_render} + * @requires_gl Conditional rendering is not available in OpenGL ES. + */ + enum class ConditionalRenderMode: GLenum { + /** + * If query result is not yet available, waits for it and + * then begins conditional rendering based on result value. + */ + Wait = GL_QUERY_WAIT, + + /** + * If query result is not yet available, OpenGL may begin + * rendering like if the result value was nonzero. + */ + NoWait = GL_QUERY_NO_WAIT, + + /** + * The same as Wait, but regions untouched by the sample query may + * not be rendered at all. + */ + ByRegionWait = GL_QUERY_BY_REGION_WAIT, + + /** + * The same as NoWait, but regions untouched by the sample query + * may not be rendered at all. + */ + ByRegionNoWait = GL_QUERY_BY_REGION_NO_WAIT + }; + #endif + + explicit SampleQuery() {} + + /** @copydoc PrimitiveQuery::begin() */ + void begin(Target target) { + AbstractQuery::begin(GLenum(target)); + } + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Begin conditional rendering based on result value + * + * @see @fn_gl{BeginConditionalRender} + * @requires_gl30 %Extension @extension{NV,conditional_render} + * @requires_gl Conditional rendering is not available in OpenGL ES. + */ + void beginConditionalRender(ConditionalRenderMode mode) { + glBeginConditionalRender(id(), GLenum(mode)); + } + + /** + * @brief End conditional render + * + * @see @fn_gl{EndConditionalRender} + * @requires_gl30 %Extension @extension{NV,conditional_render} + * @requires_gl Conditional rendering is not available in OpenGL ES. + */ + void endConditionalRender() { + glEndConditionalRender(); + } + #endif + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT + SampleQuery& setLabel(const std::string& label) { + AbstractQuery::setLabel(label); + return *this; + } + template SampleQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } + #endif +}; + +} + +#endif diff --git a/src/Magnum/Test/AbstractQueryGLTest.cpp b/src/Magnum/Test/AbstractQueryGLTest.cpp index 0706be23c..256fc236e 100644 --- a/src/Magnum/Test/AbstractQueryGLTest.cpp +++ b/src/Magnum/Test/AbstractQueryGLTest.cpp @@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE. */ -#include "Magnum/Query.h" +#include "Magnum/SampleQuery.h" #include "Magnum/Test/AbstractOpenGLTester.h" namespace Magnum { namespace Test { diff --git a/src/Magnum/Test/PrimitiveQueryGLTest.cpp b/src/Magnum/Test/PrimitiveQueryGLTest.cpp index c85a70f05..dcb2574a1 100644 --- a/src/Magnum/Test/PrimitiveQueryGLTest.cpp +++ b/src/Magnum/Test/PrimitiveQueryGLTest.cpp @@ -30,7 +30,7 @@ #include "Magnum/Buffer.h" #include "Magnum/Framebuffer.h" #include "Magnum/Mesh.h" -#include "Magnum/Query.h" +#include "Magnum/PrimitiveQuery.h" #include "Magnum/Renderbuffer.h" #include "Magnum/RenderbufferFormat.h" #include "Magnum/Shader.h" diff --git a/src/Magnum/Test/SampleQueryGLTest.cpp b/src/Magnum/Test/SampleQueryGLTest.cpp index e3f305f2b..9d71a36bd 100644 --- a/src/Magnum/Test/SampleQueryGLTest.cpp +++ b/src/Magnum/Test/SampleQueryGLTest.cpp @@ -30,9 +30,9 @@ #include "Magnum/Buffer.h" #include "Magnum/Framebuffer.h" #include "Magnum/Mesh.h" -#include "Magnum/Query.h" #include "Magnum/Renderbuffer.h" #include "Magnum/RenderbufferFormat.h" +#include "Magnum/SampleQuery.h" #include "Magnum/Shader.h" #include "Magnum/Test/AbstractOpenGLTester.h" diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index 680f95544..c1741bd1f 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -23,7 +23,7 @@ DEALINGS IN THE SOFTWARE. */ -#include "Magnum/Query.h" +#include "Magnum/TimeQuery.h" #include "Magnum/Test/AbstractOpenGLTester.h" namespace Magnum { namespace Test { diff --git a/src/Magnum/TimeQuery.h b/src/Magnum/TimeQuery.h new file mode 100644 index 000000000..23a005b21 --- /dev/null +++ b/src/Magnum/TimeQuery.h @@ -0,0 +1,121 @@ +#ifndef Magnum_TimeQuery_h +#define Magnum_TimeQuery_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + 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. +*/ + +/** @file + * @brief Class @ref Magnum::TimeQuery + */ + +#include "Magnum/AbstractQuery.h" + +namespace Magnum { + +/** +@brief Query for elapsed time + +Queries timestamp after all previous OpenGL calls have been processed. It can +query either duration of sequence of commands or absolute timestamp. Example +usage of both methods: +@code +TimeQuery q1, q2; +q1.begin(TimeQuery::Target::TimeElapsed); +// rendering... +q1.end(); +q2.begin(TimeQuery::Target::TimeElapsed); +// another rendering... +q2.end(); +UnsignedInt timeElapsed1 = q1.result(); +UnsignedInt timeElapsed2 = q2.result(); +@endcode +@code +TimeQuery q1, q2, q3; +q1.timestamp(); +// rendering... +q2.timestamp(); +// another rendering... +q3.timestamp(); +UnsignedInt tmp = q2.result(); +UnsignedInt timeElapsed1 = tmp-q1.result(); +UnsignedInt timeElapsed2 = q3.result()-tmp; +@endcode +Using the latter results in fewer OpenGL calls when doing more measures. +@requires_gl33 %Extension @extension{ARB,timer_query} +@requires_es_extension %Extension @es_extension{EXT,disjoint_timer_query} + +@see @ref PrimitiveQuery, @ref SampleQuery +@todo timestamp with glGet + example usage +@todo @es_extension{EXT,disjoint_timer_query} -- GL_GPU_DISJOINT_EXT support? where? +*/ +class TimeQuery: public AbstractQuery { + public: + /** @brief Query target */ + enum class Target: GLenum { + /** Elapsed time */ + #ifndef MAGNUM_TARGET_GLES + TimeElapsed = GL_TIME_ELAPSED + #else + TimeElapsed = GL_TIME_ELAPSED_EXT + #endif + }; + + explicit TimeQuery() {} + + /** + * @brief Query timestamp + * + * @see @fn_gl{QueryCounter} with @def_gl{TIMESTAMP} + */ + void timestamp() { + #ifndef MAGNUM_TARGET_GLES + glQueryCounter(id(), GL_TIMESTAMP); + #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + glQueryCounterEXT(id(), GL_TIMESTAMP_EXT); + #else + CORRADE_ASSERT_UNREACHABLE(); + #endif + } + + /** @copydoc PrimitiveQuery::begin() */ + void begin(Target target) { + AbstractQuery::begin(GLenum(target)); + } + + /* Overloads to remove WTF-factor from method chaining order */ + #ifndef DOXYGEN_GENERATING_OUTPUT + TimeQuery& setLabel(const std::string& label) { + AbstractQuery::setLabel(label); + return *this; + } + template TimeQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } + #endif +}; + +} + +#endif From 80cab864b2d04cc77d99310f787b9e0877260fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 13:33:47 +0200 Subject: [PATCH 19/72] Doc++ --- src/Magnum/Math/Geometry/Rectangle.h | 2 +- src/Magnum/SampleQuery.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Math/Geometry/Rectangle.h b/src/Magnum/Math/Geometry/Rectangle.h index a4154272f..0f0c99f67 100644 --- a/src/Magnum/Math/Geometry/Rectangle.h +++ b/src/Magnum/Math/Geometry/Rectangle.h @@ -27,7 +27,7 @@ /** @file * @brief Class @ref Magnum::Math::Geometry::Rectangle - * @deprecated Use @ref Math/Range.h instead. + * @deprecated Use @ref Magnum/Math/Range.h instead. */ #include "Magnum/Math/Range.h" diff --git a/src/Magnum/SampleQuery.h b/src/Magnum/SampleQuery.h index 0d8459ed7..a97609894 100644 --- a/src/Magnum/SampleQuery.h +++ b/src/Magnum/SampleQuery.h @@ -129,14 +129,14 @@ class SampleQuery: public AbstractQuery { NoWait = GL_QUERY_NO_WAIT, /** - * The same as Wait, but regions untouched by the sample query may - * not be rendered at all. + * The same as @ref ConditionalRenderMode::Wait, but regions + * untouched by the sample query may not be rendered at all. */ ByRegionWait = GL_QUERY_BY_REGION_WAIT, /** - * The same as NoWait, but regions untouched by the sample query - * may not be rendered at all. + * The same as @ref ConditionalRenderMode::NoWait, but regions + * untouched by the sample query may not be rendered at all. */ ByRegionNoWait = GL_QUERY_BY_REGION_NO_WAIT }; From c08b1263e113966d5f7c107683e16f6d9fabc17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 14:22:23 +0200 Subject: [PATCH 20/72] Support for ARB_conditional_render_inverted (GL 4.5). That was easy. --- doc/opengl-support.dox | 2 +- src/Magnum/SampleQuery.h | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 93ec8687c..fb75af729 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -210,7 +210,7 @@ following: -------------------------------------------- | ------ @extension{ARB,ES3_1_compatibility} | | @extension{ARB,clip_control} | | -@extension{ARB,conditional_render_inverted} | | +@extension{ARB,conditional_render_inverted} | done @extension{ARB,cull_distance} | | @extension{ARB,derivative_control} | done (shading language only) @extension{ARB,direct_state_access} | | diff --git a/src/Magnum/SampleQuery.h b/src/Magnum/SampleQuery.h index a97609894..9fee36ccf 100644 --- a/src/Magnum/SampleQuery.h +++ b/src/Magnum/SampleQuery.h @@ -117,28 +117,58 @@ class SampleQuery: public AbstractQuery { */ enum class ConditionalRenderMode: GLenum { /** - * If query result is not yet available, waits for it and - * then begins conditional rendering based on result value. + * If query result is not yet available, waits for it and then + * begins rendering only if result is nonzero. */ Wait = GL_QUERY_WAIT, /** - * If query result is not yet available, OpenGL may begin - * rendering like if the result value was nonzero. + * If query result is not yet available, waits for it and then + * begins rendering only if result is zero. + * @requires_gl45 %Extension @extension{ARB,conditional_render_inverted} + */ + WaitInverted = GL_QUERY_WAIT_INVERTED, + + /** + * If query result is not yet available, begins rendering like if + * the result was nonzero. */ NoWait = GL_QUERY_NO_WAIT, + /** + * If query result is not yet available, begins rendering like if + * the result was zero. + * @requires_gl45 %Extension @extension{ARB,conditional_render_inverted} + */ + NoWaitInverted = GL_QUERY_NO_WAIT_INVERTED, + /** * The same as @ref ConditionalRenderMode::Wait, but regions * untouched by the sample query may not be rendered at all. */ ByRegionWait = GL_QUERY_BY_REGION_WAIT, + /** + * The same as @ref ConditionalRenderMode::WaitInverted, but + * regions untouched by the sample query may not be rendered at + * all. + * @requires_gl45 %Extension @extension{ARB,conditional_render_inverted} + */ + ByRegionWaitInverted = GL_QUERY_BY_REGION_WAIT_INVERTED, + /** * The same as @ref ConditionalRenderMode::NoWait, but regions * untouched by the sample query may not be rendered at all. */ - ByRegionNoWait = GL_QUERY_BY_REGION_NO_WAIT + ByRegionNoWait = GL_QUERY_BY_REGION_NO_WAIT, + + /** + * The same as @ref ConditionalRenderMode::NoWaitInverted, but + * regions untouched by the sample query may not be rendered at + * all. + * @requires_gl45 %Extension @extension{ARB,conditional_render_inverted} + */ + ByRegionNoWaitInverted = GL_QUERY_BY_REGION_NO_WAIT_INVERTED }; #endif From 424207269539cce21241b7e5f4ab13a62d7e3f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 14:53:45 +0200 Subject: [PATCH 21/72] Ensure that texture object is properly created before using it. As glGen*() only reserves object name without creating it, it must be ensured that the object is created before calling functions which expect already created object (such as glObjectLabel() or glBindTextures()). Allows me to remove quite a lot hacks in the tests. --- src/Magnum/AbstractTexture.cpp | 52 +++++++++++++++++-- src/Magnum/AbstractTexture.h | 8 ++- src/Magnum/Test/AbstractTextureGLTest.cpp | 11 ++-- src/Magnum/Test/BufferTextureGLTest.cpp | 13 ----- src/Magnum/Test/CubeMapTextureArrayGLTest.cpp | 9 ---- src/Magnum/Test/CubeMapTextureGLTest.cpp | 9 ---- src/Magnum/Test/MultisampleTextureGLTest.cpp | 16 ------ src/Magnum/Test/RectangleTextureGLTest.cpp | 9 ---- src/Magnum/Test/TextureArrayGLTest.cpp | 16 ------ src/Magnum/Test/TextureGLTest.cpp | 25 --------- 10 files changed, 57 insertions(+), 111 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 9d78a49ff..d5f1e7256 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -172,8 +172,9 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, std: /* Create array of IDs and also update bindings in state tracker */ Containers::Array ids{textures.size()}; Int i{}; - for(const AbstractTexture* const texture: textures) { - textureState->bindings[firstTextureUnit + i].second = ids[i] = texture ? texture->id() : 0; + for(AbstractTexture* const texture: textures) { + if(texture) texture->createIfNotAlready(); + textureState->bindings[firstTextureUnit + i].second = ids[i] = texture ? texture->_id : 0; ++i; } @@ -181,7 +182,7 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, std: } #endif -AbstractTexture::AbstractTexture(GLenum target): _target(target) { +AbstractTexture::AbstractTexture(GLenum target): _target{target}, _created{false} { glGenTextures(1, &_id); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -197,11 +198,25 @@ AbstractTexture::~AbstractTexture() { glDeleteTextures(1, &_id); } -std::string AbstractTexture::label() const { +inline void AbstractTexture::createIfNotAlready() { + if(_created) return; + + /* glGen*() does not create the object, just reserves the name. Some + commands (such as glBindTextures() or glObjectLabel()) operate with IDs + directly and they require the object to be created. Binding the texture + to desired target finally creates it. Also all EXT DSA functions + implicitly create it. */ + bindInternal(); + CORRADE_INTERNAL_ASSERT(_created); +} + +std::string AbstractTexture::label() { + createIfNotAlready(); return Context::current()->state().debug->getLabelImplementation(GL_TEXTURE, _id); } AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayReference label) { + createIfNotAlready(); Context::current()->state().debug->labelImplementation(GL_TEXTURE, _id, label); return *this; } @@ -224,15 +239,19 @@ void AbstractTexture::bindImplementationDefault(GLint textureUnit) { if(textureState->currentTextureUnit != textureUnit) glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit)); + /* Binding the texture finally creates it */ + _created = true; glBindTexture(_target, _id); } #ifndef MAGNUM_TARGET_GLES void AbstractTexture::bindImplementationMulti(GLint textureUnit) { + createIfNotAlready(); glBindTextures(textureUnit, 1, &_id); } void AbstractTexture::bindImplementationDSA(GLint textureUnit) { + _created = true; glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, _id); } #endif @@ -359,6 +378,7 @@ void AbstractTexture::mipmapImplementationDefault() { #ifndef MAGNUM_TARGET_GLES void AbstractTexture::mipmapImplementationDSA() { + _created = true; glGenerateTextureMipmapEXT(_id, _target); } #endif @@ -383,6 +403,9 @@ void AbstractTexture::bindInternal() { /* Bind the texture to internal unit if not already, update state tracker */ if(textureState->bindings[internalTextureUnit].second == _id) return; textureState->bindings[internalTextureUnit] = {_target, _id}; + + /* Binding the texture finally creates it */ + _created = true; glBindTexture(_target, _id); } @@ -764,6 +787,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint val #ifndef MAGNUM_TARGET_GLES void AbstractTexture::parameterImplementationDSA(GLenum parameter, GLint value) { + _created = true; glTextureParameteriEXT(_id, _target, parameter, value); } #endif @@ -775,6 +799,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLfloat v #ifndef MAGNUM_TARGET_GLES void AbstractTexture::parameterImplementationDSA(GLenum parameter, GLfloat value) { + _created = true; glTextureParameterfEXT(_id, _target, parameter, value); } #endif @@ -787,6 +812,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLi #ifndef MAGNUM_TARGET_GLES void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLint* values) { + _created = true; glTextureParameterivEXT(_id, _target, parameter, values); } #endif @@ -799,6 +825,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLf #ifndef MAGNUM_TARGET_GLES void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLfloat* values) { + _created = true; glTextureParameterfvEXT(_id, _target, parameter, values); } #endif @@ -810,6 +837,7 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL } void AbstractTexture::parameterIImplementationDSA(GLenum parameter, const GLuint* values) { + _created = true; glTextureParameterIuivEXT(_id, _target, parameter, values); } @@ -819,6 +847,7 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL } void AbstractTexture::parameterIImplementationDSA(GLenum parameter, const GLint* values) { + _created = true; glTextureParameterIivEXT(_id, _target, parameter, values); } #endif @@ -837,6 +866,7 @@ void AbstractTexture::getLevelParameterImplementationDefault(GLenum target, GLin #ifndef MAGNUM_TARGET_GLES void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values) { + _created = true; glGetTextureLevelParameterivEXT(_id, target, level, parameter, values); } #endif @@ -860,6 +890,7 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels } void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { + _created = true; glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]); } #endif @@ -920,6 +951,7 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels #ifndef MAGNUM_TARGET_GLES void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { + _created = true; glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y()); } #endif @@ -974,6 +1006,7 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels #ifndef MAGNUM_TARGET_GLES void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { + _created = true; glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); } #endif @@ -994,6 +1027,7 @@ void AbstractTexture::storageMultisampleImplementationDefault(const GLenum targe #ifndef MAGNUM_TARGET_GLES void AbstractTexture::storageMultisampleImplementationDSA(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { + _created = true; glTextureStorage2DMultisampleEXT(_id, target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); } @@ -1008,6 +1042,7 @@ void AbstractTexture::storageMultisampleImplementationDefault(const GLenum targe } void AbstractTexture::storageMultisampleImplementationDSA(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { + _created = true; glTextureStorage3DMultisampleEXT(_id, target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } #endif @@ -1019,6 +1054,7 @@ void AbstractTexture::getImageImplementationDefault(const GLenum target, const G } void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) { + _created = true; glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data); } @@ -1035,6 +1071,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex } void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { + _created = true; glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data); } #endif @@ -1046,6 +1083,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex #ifndef MAGNUM_TARGET_GLES void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { + _created = true; glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data); } #endif @@ -1070,6 +1108,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex #ifndef MAGNUM_TARGET_GLES void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { + _created = true; glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data); } #endif @@ -1081,6 +1120,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, } void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { + _created = true; glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], GLenum(format), GLenum(type), data); } #endif @@ -1092,6 +1132,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, #ifndef MAGNUM_TARGET_GLES void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { + _created = true; glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } #endif @@ -1116,6 +1157,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, #ifndef MAGNUM_TARGET_GLES void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { + _created = true; glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); } #endif @@ -1124,6 +1166,7 @@ void AbstractTexture::invalidateImageImplementationNoOp(GLint) {} #ifndef MAGNUM_TARGET_GLES void AbstractTexture::invalidateImageImplementationARB(GLint level) { + createIfNotAlready(); glInvalidateTexImage(_id, level); } #endif @@ -1132,6 +1175,7 @@ void AbstractTexture::invalidateSubImageImplementationNoOp(GLint, const Vector3i #ifndef MAGNUM_TARGET_GLES void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vector3i& offset, const Vector3i& size) { + createIfNotAlready(); glInvalidateTexSubImage(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z()); } #endif diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index edc1f0816..2cdf30902 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -247,7 +247,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with * @def_gl{TEXTURE} */ - std::string label() const; + std::string label(); /** * @brief Set texture label @@ -360,6 +360,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { static void MAGNUM_LOCAL bindImplementationMulti(GLint firstTextureUnit, std::initializer_list textures); #endif + void MAGNUM_LOCAL createIfNotAlready(); + void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL bindImplementationMulti(GLint textureUnit); @@ -484,6 +486,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { ColorType MAGNUM_LOCAL imageTypeForInternalFormat(TextureFormat internalFormat); GLuint _id; + bool _created; /* see createIfNotAlready() for details */ }; #ifndef DOXYGEN_GENERATING_OUTPUT @@ -587,13 +590,14 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { }; #endif -inline AbstractTexture::AbstractTexture(AbstractTexture&& other) noexcept: _target(other._target), _id(other._id) { +inline AbstractTexture::AbstractTexture(AbstractTexture&& other) noexcept: _target{other._target}, _id{other._id}, _created{other._created} { other._id = 0; } inline AbstractTexture& AbstractTexture::operator=(AbstractTexture&& other) noexcept { std::swap(_target, other._target); std::swap(_id, other._id); + std::swap(_created, other._created); return *this; } diff --git a/src/Magnum/Test/AbstractTextureGLTest.cpp b/src/Magnum/Test/AbstractTextureGLTest.cpp index e5e6f39fe..9fd259e07 100644 --- a/src/Magnum/Test/AbstractTextureGLTest.cpp +++ b/src/Magnum/Test/AbstractTextureGLTest.cpp @@ -93,20 +93,15 @@ void AbstractTextureGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); - { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); - CORRADE_VERIFY(false); - } Texture2D texture; - texture.setMinificationFilter(Sampler::Filter::Linear); CORRADE_COMPARE(texture.label(), ""); + MAGNUM_VERIFY_NO_ERROR(); texture.setLabel("MyTexture"); - CORRADE_COMPARE(texture.label(), "MyTexture"); - MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(texture.label(), "MyTexture"); } }} diff --git a/src/Magnum/Test/BufferTextureGLTest.cpp b/src/Magnum/Test/BufferTextureGLTest.cpp index 0789b2aaa..b67180ea9 100644 --- a/src/Magnum/Test/BufferTextureGLTest.cpp +++ b/src/Magnum/Test/BufferTextureGLTest.cpp @@ -67,19 +67,6 @@ void BufferTextureGLTest::bind() { CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); BufferTexture texture; - - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it"); - Buffer buffer; - constexpr UnsignedByte data[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f - }; - buffer.setData(data, BufferUsage::StaticDraw); - texture.setBuffer(BufferTextureFormat::R8UI, buffer); - CORRADE_VERIFY(false); - } - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index 253c56ae2..908ae7cc9 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -103,15 +103,6 @@ void CubeMapTextureArrayGLTest::bind() { CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); CubeMapTextureArray texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 5a7a23805..d93507960 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -128,15 +128,6 @@ void CubeMapTextureGLTest::construct() { void CubeMapTextureGLTest::bind() { CubeMapTexture texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/MultisampleTextureGLTest.cpp b/src/Magnum/Test/MultisampleTextureGLTest.cpp index e38fc50c3..0ccde3e5e 100644 --- a/src/Magnum/Test/MultisampleTextureGLTest.cpp +++ b/src/Magnum/Test/MultisampleTextureGLTest.cpp @@ -135,15 +135,6 @@ void MultisampleTextureGLTest::bind2D() { #endif MultisampleTexture2D texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setStorage(4, TextureFormat::RGBA8, {16, 16}); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); @@ -163,13 +154,6 @@ void MultisampleTextureGLTest::bind2DArray() { CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); MultisampleTexture2DArray texture; - - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setStorage(4, TextureFormat::RGBA8, {16, 16, 5}); - CORRADE_VERIFY(false); - } - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index 8bc4a3994..0bc52e25a 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -101,15 +101,6 @@ void RectangleTextureGLTest::bind() { CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setWrapping(Sampler::Wrapping::ClampToEdge); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index 3c0dec591..775bfcc91 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -233,13 +233,6 @@ void TextureArrayGLTest::bind1D() { CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; - - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); @@ -261,15 +254,6 @@ void TextureArrayGLTest::bind2D() { #endif Texture2DArray texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index 04a786e11..7fe72cfb5 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -292,13 +292,6 @@ void TextureGLTest::construct3D() { #ifndef MAGNUM_TARGET_GLES void TextureGLTest::bind1D() { Texture1D texture; - - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); @@ -315,15 +308,6 @@ void TextureGLTest::bind1D() { void TextureGLTest::bind2D() { Texture2D texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); @@ -344,15 +328,6 @@ void TextureGLTest::bind3D() { #endif Texture3D texture; - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) { - CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it."); - texture.setBaseLevel(0); - CORRADE_VERIFY(false); - } - #endif - texture.bind(15); MAGNUM_VERIFY_NO_ERROR(); From 8f58d9dd8287b3f28a94b71d3a2ff7ba652bb4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 15:38:32 +0200 Subject: [PATCH 22/72] Ensure that buffer object is properly created before using it. --- src/Magnum/Buffer.cpp | 39 ++++++++++++++++++++++++++++---- src/Magnum/Buffer.h | 18 +++++++++------ src/Magnum/Test/BufferGLTest.cpp | 11 +++------ 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index e5f072b7a..627b92f70 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -122,10 +122,11 @@ void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const } #endif -Buffer::Buffer(Buffer::Target targetHint): _targetHint(targetHint) +Buffer::Buffer(const Target targetHint): _targetHint{targetHint}, #ifdef CORRADE_TARGET_NACL - , _mappedBuffer(nullptr) + _mappedBuffer{nullptr}, #endif + _created{false} { glGenBuffers(1, &_id); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); @@ -144,7 +145,20 @@ Buffer::~Buffer() { glDeleteBuffers(1, &_id); } -std::string Buffer::label() const { +inline void Buffer::createIfNotAlready() { + if(_created) return; + + /* glGen*() does not create the object, just reserves the name. Some + commands (such as glInvalidateBufferData() or glObjectLabel()) operate + with IDs directly and they require the object to be created. Binding the + buffer finally creates it. Also all EXT DSA functions implicitly create + it. */ + bindSomewhereInternal(_targetHint); + CORRADE_INTERNAL_ASSERT(_created); +} + +std::string Buffer::label() { + createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES return Context::current()->state().debug->getLabelImplementation(GL_BUFFER, _id); #else @@ -153,6 +167,7 @@ std::string Buffer::label() const { } Buffer& Buffer::setLabelInternal(const Containers::ArrayReference label) { + createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_BUFFER, _id, label); #else @@ -161,14 +176,16 @@ Buffer& Buffer::setLabelInternal(const Containers::ArrayReference la return *this; } -void Buffer::bindInternal(Target target, GLuint id) { +void Buffer::bindInternal(const Target target, Buffer* const buffer) { + const GLuint id = buffer ? buffer->_id : 0; GLuint& bound = Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; /* Already bound, nothing to do */ if(bound == id) return; - /* Bind the buffer otherwise */ + /* Bind the buffer otherwise, which will also finally create it */ bound = id; + buffer->_created = true; glBindBuffer(GLenum(target), id); } @@ -186,6 +203,7 @@ Buffer::Target Buffer::bindSomewhereInternal(Target hint) { /* Bind the buffer to hint target otherwise */ hintBinding = _id; + _created = true; glBindBuffer(GLenum(hint), _id); return hint; } @@ -274,6 +292,7 @@ void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr rea #ifndef MAGNUM_TARGET_GLES void Buffer::copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { + read._created = write._created = true; glNamedCopyBufferSubDataEXT(read._id, write._id, readOffset, writeOffset, size); } #endif @@ -285,6 +304,7 @@ void Buffer::getParameterImplementationDefault(const GLenum value, GLint* const #ifndef MAGNUM_TARGET_GLES void Buffer::getParameterImplementationDSA(const GLenum value, GLint* const data) { + _created = true; glGetNamedBufferParameterivEXT(_id, value, data); } #endif @@ -295,6 +315,7 @@ void Buffer::getSubDataImplementationDefault(const GLintptr offset, const GLsize } void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { + _created = true; glGetNamedBufferSubDataEXT(_id, offset, size, data); } #endif @@ -305,6 +326,7 @@ void Buffer::dataImplementationDefault(GLsizeiptr size, const GLvoid* data, Buff #ifndef MAGNUM_TARGET_GLES void Buffer::dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUsage usage) { + _created = true; glNamedBufferDataEXT(_id, size, data, GLenum(usage)); } #endif @@ -315,6 +337,7 @@ void Buffer::subDataImplementationDefault(GLintptr offset, GLsizeiptr size, cons #ifndef MAGNUM_TARGET_GLES void Buffer::subDataImplementationDSA(GLintptr offset, GLsizeiptr size, const GLvoid* data) { + _created = true; glNamedBufferSubDataEXT(_id, offset, size, data); } #endif @@ -323,6 +346,7 @@ void Buffer::invalidateImplementationNoOp() {} #ifndef MAGNUM_TARGET_GLES void Buffer::invalidateImplementationARB() { + createIfNotAlready(); glInvalidateBufferData(_id); } #endif @@ -331,6 +355,7 @@ void Buffer::invalidateSubImplementationNoOp(GLintptr, GLsizeiptr) {} #ifndef MAGNUM_TARGET_GLES void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length) { + createIfNotAlready(); glInvalidateBufferSubData(_id, offset, length); } #endif @@ -348,6 +373,7 @@ void* Buffer::mapImplementationDefault(MapAccess access) { #ifndef MAGNUM_TARGET_GLES void* Buffer::mapImplementationDSA(MapAccess access) { + _created = true; return glMapNamedBufferEXT(_id, GLenum(access)); } #endif @@ -367,6 +393,7 @@ void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, #ifndef MAGNUM_TARGET_GLES void* Buffer::mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapFlags access) { + _created = true; return glMapNamedBufferRangeEXT(_id, offset, length, GLenum(access)); } #endif @@ -385,6 +412,7 @@ void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr l #ifndef MAGNUM_TARGET_GLES void Buffer::flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr length) { + _created = true; glFlushMappedNamedBufferRangeEXT(_id, offset, length); } #endif @@ -401,6 +429,7 @@ bool Buffer::unmapImplementationDefault() { #ifndef MAGNUM_TARGET_GLES bool Buffer::unmapImplementationDSA() { + _created = true; return glUnmapNamedBufferEXT(_id); } #endif diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index abf1817e0..d627700d7 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -569,7 +569,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with * @def_gl{BUFFER_OBJECT_EXT} */ - std::string label() const; + std::string label(); /** * @brief Set buffer label @@ -852,13 +852,11 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { private: #endif /* There should be no need to use these from user code */ - static void unbindInternal(Target target) { bindInternal(target, 0); } - void bindInternal(Target target) { bindInternal(target, _id); } + static void unbindInternal(Target target) { bindInternal(target, nullptr); } + void bindInternal(Target target) { bindInternal(target, this); } private: - Buffer& setLabelInternal(Containers::ArrayReference label); - - static void bindInternal(Target hint, GLuint id); + static void bindInternal(Target hint, Buffer* buffer); Target MAGNUM_LOCAL bindSomewhereInternal(Target hint); #ifndef MAGNUM_TARGET_GLES2 @@ -868,6 +866,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif #endif + void MAGNUM_LOCAL createIfNotAlready(); + + Buffer& setLabelInternal(Containers::ArrayReference label); + #ifndef MAGNUM_TARGET_GLES void subDataInternal(GLintptr offset, GLsizeiptr size, GLvoid* data); #endif @@ -927,6 +929,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #ifdef CORRADE_TARGET_NACL void* _mappedBuffer; #endif + bool _created; /* see createIfNotAlready() for details */ }; CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags) @@ -934,13 +937,14 @@ CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags) /** @debugoperatorclassenum{Magnum::Buffer,Magnum::Buffer::Target} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::Target value); -inline Buffer::Buffer(Buffer&& other) noexcept: _id(other._id), _targetHint(other._targetHint) { +inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, _created{other._created} { other._id = 0; } inline Buffer& Buffer::operator=(Buffer&& other) noexcept { std::swap(_id, other._id); std::swap(_targetHint, other._targetHint); + std::swap(_created, other._created); return *this; } diff --git a/src/Magnum/Test/BufferGLTest.cpp b/src/Magnum/Test/BufferGLTest.cpp index 4358835bd..ab36e04d7 100644 --- a/src/Magnum/Test/BufferGLTest.cpp +++ b/src/Magnum/Test/BufferGLTest.cpp @@ -118,20 +118,15 @@ void BufferGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); - { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); - CORRADE_VERIFY(false); - } Buffer buffer; - buffer.setData({nullptr, 3}, BufferUsage::StaticDraw); CORRADE_COMPARE(buffer.label(), ""); + MAGNUM_VERIFY_NO_ERROR(); buffer.setLabel("MyBuffer"); - CORRADE_COMPARE(buffer.label(), "MyBuffer"); - MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(buffer.label(), "MyBuffer"); } void BufferGLTest::data() { From 0d4b66789b844c4d4199794caa7667e6a1c82557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 15:58:43 +0200 Subject: [PATCH 23/72] Ensure that the framebuffer object is properly created before using it. --- src/Magnum/AbstractFramebuffer.cpp | 19 +++++++++++++++++++ src/Magnum/AbstractFramebuffer.h | 3 +++ src/Magnum/DefaultFramebuffer.cpp | 5 ++++- src/Magnum/Framebuffer.cpp | 9 ++++++++- src/Magnum/Framebuffer.h | 4 +++- src/Magnum/Test/FramebufferGLTest.cpp | 12 ------------ 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index 2bf1f5b97..03b5ab92c 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -82,6 +82,17 @@ Int AbstractFramebuffer::maxDualSourceDrawBuffers() { } #endif +void AbstractFramebuffer::createIfNotAlready() { + if(_created) return; + + /* glGen*() does not create the object, just reserves the name. Some + commands (such as glObjectLabel()) operate with IDs directly and they + require the object to be created. Binding the framebuffer finally + creates it. Also all EXT DSA functions implicitly create it. */ + bindInternal(); + CORRADE_INTERNAL_ASSERT(_created); +} + void AbstractFramebuffer::bind(FramebufferTarget target) { bindInternal(target); setViewportInternal(); @@ -102,6 +113,8 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) { state->readBinding = state->drawBinding = _id; } else CORRADE_ASSERT_UNREACHABLE(); + /* Binding the framebuffer finally creates it */ + _created = true; glBindFramebuffer(GLenum(target), _id); } @@ -119,6 +132,8 @@ FramebufferTarget AbstractFramebuffer::bindInternal() { /* Or bind it, if not already */ state->readBinding = _id; + /* Binding the framebuffer finally creates it */ + _created = true; #ifndef MAGNUM_TARGET_GLES2 glBindFramebuffer(GLenum(FramebufferTarget::Read), _id); return FramebufferTarget::Read; @@ -256,6 +271,7 @@ GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTa #ifndef MAGNUM_TARGET_GLES GLenum AbstractFramebuffer::checkStatusImplementationDSA(const FramebufferTarget target) { + _created = true; return glCheckNamedFramebufferStatusEXT(_id, GLenum(target)); } #endif @@ -280,6 +296,7 @@ void AbstractFramebuffer::drawBuffersImplementationDefault(GLsizei count, const #ifndef MAGNUM_TARGET_GLES void AbstractFramebuffer::drawBuffersImplementationDSA(GLsizei count, const GLenum* buffers) { + _created = true; glFramebufferDrawBuffersEXT(_id, count, buffers); } #endif @@ -305,6 +322,7 @@ void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) { #ifndef MAGNUM_TARGET_GLES void AbstractFramebuffer::drawBufferImplementationDSA(GLenum buffer) { + _created = true; glFramebufferDrawBufferEXT(_id, buffer); } #endif @@ -328,6 +346,7 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) { #ifndef MAGNUM_TARGET_GLES void AbstractFramebuffer::readBufferImplementationDSA(GLenum buffer) { + _created = true; glFramebufferReadBufferEXT(_id, buffer); } #endif diff --git a/src/Magnum/AbstractFramebuffer.h b/src/Magnum/AbstractFramebuffer.h index c3c11c26e..dea83a065 100644 --- a/src/Magnum/AbstractFramebuffer.h +++ b/src/Magnum/AbstractFramebuffer.h @@ -329,11 +329,14 @@ class MAGNUM_EXPORT AbstractFramebuffer { explicit AbstractFramebuffer() = default; ~AbstractFramebuffer() = default; + void MAGNUM_LOCAL createIfNotAlready(); + void MAGNUM_LOCAL bindInternal(FramebufferTarget target); FramebufferTarget MAGNUM_LOCAL bindInternal(); void MAGNUM_LOCAL setViewportInternal(); GLuint _id; + bool _created; /* see createIfNotAlready() for details */ Range2Di _viewport; private: diff --git a/src/Magnum/DefaultFramebuffer.cpp b/src/Magnum/DefaultFramebuffer.cpp index 9c9f4991b..034f37cc7 100644 --- a/src/Magnum/DefaultFramebuffer.cpp +++ b/src/Magnum/DefaultFramebuffer.cpp @@ -36,7 +36,10 @@ namespace Magnum { DefaultFramebuffer defaultFramebuffer; -DefaultFramebuffer::DefaultFramebuffer() { _id = 0; } +DefaultFramebuffer::DefaultFramebuffer() { + _id = 0; + _created = true; +} DefaultFramebuffer::Status DefaultFramebuffer::checkStatus(const FramebufferTarget target) { return Status((this->*Context::current()->state().framebuffer->checkStatusImplementation)(target)); diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index fefb79bfa..a1357979f 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -81,6 +81,7 @@ Int Framebuffer::maxColorAttachments() { Framebuffer::Framebuffer(const Range2Di& viewport) { _viewport = viewport; + _created = false; glGenFramebuffers(1, &_id); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); @@ -108,11 +109,13 @@ Framebuffer::~Framebuffer() { glDeleteFramebuffers(1, &_id); } -std::string Framebuffer::label() const { +std::string Framebuffer::label() { + createIfNotAlready(); return Context::current()->state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id); } Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayReference label) { + createIfNotAlready(); Context::current()->state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); return *this; } @@ -255,6 +258,7 @@ void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, #ifndef MAGNUM_TARGET_GLES void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer) { + _created = true; glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id()); } @@ -263,6 +267,7 @@ void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, GL } void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { + _created = true; glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); } #endif @@ -273,6 +278,7 @@ void Framebuffer::texture2DImplementationDefault(BufferAttachment attachment, GL #ifndef MAGNUM_TARGET_GLES void Framebuffer::texture2DImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint mipLevel) { + _created = true; glNamedFramebufferTexture2DEXT(_id, GLenum(attachment), textureTarget, textureId, mipLevel); } #endif @@ -293,6 +299,7 @@ void Framebuffer::textureLayerImplementationDefault(BufferAttachment attachment, #ifndef MAGNUM_TARGET_GLES void Framebuffer::textureLayerImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { + _created = true; glNamedFramebufferTextureLayerEXT(_id, GLenum(attachment), textureId, mipLevel, layer); } #endif diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index e5d7b76da..c264aa0bf 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -341,7 +341,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with * @def_gl{FRAMEBUFFER} */ - std::string label() const; + std::string label(); /** * @brief Set framebuffer label @@ -664,6 +664,7 @@ Debug MAGNUM_EXPORT operator<<(Debug debug, Framebuffer::Status value); inline Framebuffer::Framebuffer(Framebuffer&& other) noexcept { _id = other._id; _viewport = other._viewport; + _created = other._created; other._id = 0; other._viewport = {}; } @@ -671,6 +672,7 @@ inline Framebuffer::Framebuffer(Framebuffer&& other) noexcept { inline Framebuffer& Framebuffer::operator=(Framebuffer&& other) noexcept { std::swap(_id, other._id); std::swap(_viewport, other._viewport); + std::swap(_created, other._created); return *this; } diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index e4c897ae1..93970d89f 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -215,19 +215,7 @@ void FramebufferGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); - { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); - CORRADE_VERIFY(false); - } - Renderbuffer renderbuffer; - #ifndef MAGNUM_TARGET_GLES2 - renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128}); - #else - renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128}); - #endif Framebuffer framebuffer({{}, Vector2i(32)}); - framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment(Framebuffer::BufferAttachment::Depth), renderbuffer); CORRADE_COMPARE(framebuffer.label(), ""); MAGNUM_VERIFY_NO_ERROR(); From dc10402c1c72643a9d6aa6f604e5f60f7e8f3118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 16:15:19 +0200 Subject: [PATCH 24/72] Ensure that the mesh object is properly created before using it. --- src/Magnum/Mesh.cpp | 50 +++++++++++++++++++++++++--------- src/Magnum/Mesh.h | 7 +++-- src/Magnum/Test/MeshGLTest.cpp | 12 ++------ 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index b7b654da7..0a2794e63 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -72,7 +72,7 @@ std::size_t Mesh::indexSize(IndexType type) { CORRADE_ASSERT_UNREACHABLE(); } -Mesh::Mesh(MeshPrimitive primitive): _primitive(primitive), _count(0), _baseVertex(0), _instanceCount{1}, +Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _count{0}, _baseVertex{0}, _instanceCount{1}, #ifndef MAGNUM_TARGET_GLES _baseInstance{0}, #endif @@ -95,7 +95,7 @@ Mesh::~Mesh() { (this->*Context::current()->state().mesh->destroyImplementation)(); } -Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _count(other._count), _baseVertex{other._baseVertex}, _instanceCount{other._instanceCount}, +Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _created{other._created}, _primitive(other._primitive), _count(other._count), _baseVertex{other._baseVertex}, _instanceCount{other._instanceCount}, #ifndef MAGNUM_TARGET_GLES _baseInstance{other._baseInstance}, #endif @@ -115,6 +115,7 @@ Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), Mesh& Mesh::operator=(Mesh&& other) noexcept { std::swap(_id, other._id); + std::swap(_created, other._created); std::swap(_primitive, other._primitive); std::swap(_count, other._count); std::swap(_baseVertex, other._baseVertex); @@ -140,7 +141,20 @@ Mesh& Mesh::operator=(Mesh&& other) noexcept { return *this; } -std::string Mesh::label() const { +inline void Mesh::createIfNotAlready() { + /* If VAO extension is not available, _created is always true */ + if(_created) return; + + /* glGen*() does not create the object, just reserves the name. Some + commands (such as glObjectLabel()) operate with IDs directly and they + require the object to be created. Binding the VAO finally creates it. + Also all EXT DSA functions implicitly create it. */ + bindVAO(); + CORRADE_INTERNAL_ASSERT(_created); +} + +std::string Mesh::label() { + createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES return Context::current()->state().debug->getLabelImplementation(GL_VERTEX_ARRAY, _id); #else @@ -149,6 +163,7 @@ std::string Mesh::label() const { } Mesh& Mesh::setLabelInternal(const Containers::ArrayReference label) { + createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label); #else @@ -284,22 +299,28 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i (this->*state.unbindImplementation)(); } -void Mesh::bindVAO(GLuint vao) { +void Mesh::bindVAO() { GLuint& current = Context::current()->state().mesh->currentVAO; - if(current != vao) { + if(current != _id) { + /* Binding the VAO finally creates it */ + _created = true; #ifndef MAGNUM_TARGET_GLES2 - glBindVertexArray(current = vao); + glBindVertexArray(current = _id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glBindVertexArrayOES(current = vao); + glBindVertexArrayOES(current = _id); #else CORRADE_ASSERT_UNREACHABLE(); #endif } } -void Mesh::createImplementationDefault() { _id = 0; } +void Mesh::createImplementationDefault() { + _id = 0; + _created = true; +} void Mesh::createImplementationVAO() { + _created = false; #ifndef MAGNUM_TARGET_GLES2 glGenVertexArrays(1, &_id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) @@ -341,12 +362,13 @@ void Mesh::attributePointerImplementationVAO(const Attribute& attribute) { "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), ); #endif - bindVAO(_id); + bindVAO(); vertexAttribPointer(attribute); } #ifndef MAGNUM_TARGET_GLES void Mesh::attributePointerImplementationDSA(const Attribute& attribute) { + _created = true; glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, attribute.offset); if(attribute.divisor) glVertexArrayVertexAttribDivisorEXT(_id, attribute.location, attribute.divisor); @@ -376,12 +398,13 @@ void Mesh::attributePointerImplementationDefault(const IntegerAttribute& attribu } void Mesh::attributePointerImplementationVAO(const IntegerAttribute& attribute) { - bindVAO(_id); + bindVAO(); vertexAttribPointer(attribute); } #ifndef MAGNUM_TARGET_GLES void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute) { + _created = true; glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribIOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.stride, attribute.offset); if(attribute.divisor) glVertexArrayVertexAttribDivisorEXT(_id, attribute.location, attribute.divisor); @@ -406,11 +429,12 @@ void Mesh::attributePointerImplementationDefault(const LongAttribute& attribute) } void Mesh::attributePointerImplementationVAO(const LongAttribute& attribute) { - bindVAO(_id); + bindVAO(); vertexAttribPointer(attribute); } void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) { + _created = true; glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribLOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.stride, attribute.offset); if(attribute.divisor) glVertexArrayVertexAttribDivisorEXT(_id, attribute.location, attribute.divisor); @@ -459,7 +483,7 @@ void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint void Mesh::bindIndexBufferImplementationDefault(Buffer&) {} void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { - bindVAO(_id); + bindVAO(); /* Reset ElementArray binding to force explicit glBindBuffer call later */ /** @todo Do this cleaner way */ @@ -488,7 +512,7 @@ void Mesh::bindImplementationDefault() { } void Mesh::bindImplementationVAO() { - bindVAO(_id); + bindVAO(); } void Mesh::unbindImplementationDefault() { diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index eb5bba758..b79df2367 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -458,7 +458,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with * @def_gl{VERTEX_ARRAY_OBJECT_EXT} */ - std::string label() const; + std::string label(); /** * @brief Set mesh label @@ -860,6 +860,8 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { #endif #endif + void MAGNUM_LOCAL createIfNotAlready(); + Mesh& setLabelInternal(Containers::ArrayReference label); /* Computing stride of interleaved vertex attributes */ @@ -927,7 +929,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { #endif #endif - static void MAGNUM_LOCAL bindVAO(GLuint vao); + void MAGNUM_LOCAL bindVAO(); #ifndef MAGNUM_TARGET_GLES void drawInternal(Int count, Int baseVertex, Int instanceCount, UnsignedInt baseInstance, GLintptr indexOffset, Int indexStart, Int indexEnd); @@ -995,6 +997,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { #endif GLuint _id; + bool _created; /* see createIfNotAlready() for details */ MeshPrimitive _primitive; Int _count, _baseVertex, _instanceCount; #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 0431d282d..603b3501a 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -295,21 +295,15 @@ void MeshGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); - { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); - CORRADE_VERIFY(false); - } - Buffer buffer{Buffer::Target::ElementArray}; Mesh mesh; - mesh.setIndexBuffer(buffer, 0, Mesh::IndexType::UnsignedShort); CORRADE_COMPARE(mesh.label(), ""); + MAGNUM_VERIFY_NO_ERROR(); mesh.setLabel("MyMesh"); - CORRADE_COMPARE(mesh.label(), "MyMesh"); - MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(mesh.label(), "MyMesh"); } namespace { From 385549d0b8cece0135ac51bb26b811d78a6935cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 16:28:12 +0200 Subject: [PATCH 25/72] Ensure that the renderbuffer object is properly created before using it. --- src/Magnum/Renderbuffer.cpp | 21 +++++++++++++++++++-- src/Magnum/Renderbuffer.h | 8 ++++++-- src/Magnum/Test/RenderbufferGLTest.cpp | 20 +++----------------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/Magnum/Renderbuffer.cpp b/src/Magnum/Renderbuffer.cpp index ef5a978cb..5f0292c12 100644 --- a/src/Magnum/Renderbuffer.cpp +++ b/src/Magnum/Renderbuffer.cpp @@ -64,7 +64,7 @@ Int Renderbuffer::maxSamples() { return value; } -Renderbuffer::Renderbuffer() { glGenRenderbuffers(1, &_id); } +Renderbuffer::Renderbuffer(): _created{false} { glGenRenderbuffers(1, &_id); } Renderbuffer::~Renderbuffer() { /* Moved out, nothing to do */ @@ -77,11 +77,24 @@ Renderbuffer::~Renderbuffer() { glDeleteRenderbuffers(1, &_id); } -std::string Renderbuffer::label() const { +inline void Renderbuffer::createIfNotAlready() { + if(_created) return; + + /* glGen*() does not create the object, just reserves the name. Some + commands (such as glObjectLabel()) operate with IDs directly and they + require the object to be created. Binding the renderbuffer finally + creates it. Also all EXT DSA functions implicitly create it. */ + bind(); + CORRADE_INTERNAL_ASSERT(_created); +} + +std::string Renderbuffer::label() { + createIfNotAlready(); return Context::current()->state().debug->getLabelImplementation(GL_RENDERBUFFER, _id); } Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayReference label) { + createIfNotAlready(); Context::current()->state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); return *this; } @@ -99,7 +112,9 @@ void Renderbuffer::bind() { if(binding == _id) return; + /* Binding the renderbuffer finally creates it */ binding = _id; + _created = true; glBindRenderbuffer(GL_RENDERBUFFER, _id); } @@ -110,6 +125,7 @@ void Renderbuffer::storageImplementationDefault(RenderbufferFormat internalForma #ifndef MAGNUM_TARGET_GLES void Renderbuffer::storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size) { + _created = true; glNamedRenderbufferStorageEXT(_id, GLenum(internalFormat), size.x(), size.y()); } #endif @@ -147,6 +163,7 @@ void Renderbuffer::storageMultisampleImplementationNV(const GLsizei samples, con #ifndef MAGNUM_TARGET_GLES void Renderbuffer::storageMultisampleImplementationDSA(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size) { + _created = true; glNamedRenderbufferStorageMultisampleEXT(_id, samples, GLenum(internalFormat), size.x(), size.y()); } #endif diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index 3173e3d6d..6764ace61 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -124,7 +124,7 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { * @fn_gl_extension2{GetObjectLabel,EXT,debug_label} with * @def_gl{RENDERBUFFER} */ - std::string label() const; + std::string label(); /** * @brief Set renderbuffer label @@ -178,6 +178,8 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size); private: + void MAGNUM_LOCAL createIfNotAlready(); + Renderbuffer& setLabelInternal(Containers::ArrayReference label); void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); @@ -198,14 +200,16 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { void MAGNUM_LOCAL bind(); GLuint _id; + bool _created; /* see createIfNotAlready() for details */ }; -inline Renderbuffer::Renderbuffer(Renderbuffer&& other) noexcept: _id(other._id) { +inline Renderbuffer::Renderbuffer(Renderbuffer&& other) noexcept: _id{other._id}, _created{other._created} { other._id = 0; } inline Renderbuffer& Renderbuffer::operator=(Renderbuffer&& other) noexcept { std::swap(_id, other._id); + std::swap(_created, other._created); return *this; } diff --git a/src/Magnum/Test/RenderbufferGLTest.cpp b/src/Magnum/Test/RenderbufferGLTest.cpp index a19a0a23f..eab8cc786 100644 --- a/src/Magnum/Test/RenderbufferGLTest.cpp +++ b/src/Magnum/Test/RenderbufferGLTest.cpp @@ -111,29 +111,15 @@ void RenderbufferGLTest::label() { CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif - /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) - CORRADE_SKIP("Required extension is not available"); - - { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); - CORRADE_VERIFY(false); - } Renderbuffer renderbuffer; - #ifndef MAGNUM_TARGET_GLES2 - renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128}); - #else - renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128}); - #endif CORRADE_COMPARE(renderbuffer.label(), ""); + MAGNUM_VERIFY_NO_ERROR(); renderbuffer.setLabel("MyRenderbuffer"); - CORRADE_COMPARE(renderbuffer.label(), "MyRenderbuffer"); - MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(renderbuffer.label(), "MyRenderbuffer"); } void RenderbufferGLTest::setStorage() { From a3aa26bbe49f254c91876a1fb63a3ccf57c09aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 15:01:03 +0200 Subject: [PATCH 26/72] Proper state tracking also in texture-multi-bind. --- src/Magnum/AbstractTexture.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index d5f1e7256..f4e31d568 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -172,13 +172,21 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, std: /* Create array of IDs and also update bindings in state tracker */ Containers::Array ids{textures.size()}; Int i{}; + bool different = false; for(AbstractTexture* const texture: textures) { if(texture) texture->createIfNotAlready(); - textureState->bindings[firstTextureUnit + i].second = ids[i] = texture ? texture->_id : 0; + + const GLuint id = ids[i] = texture ? texture->_id : 0; + if(textureState->bindings[firstTextureUnit + i].second != id) { + different = true; + textureState->bindings[firstTextureUnit + i].second = id; + } + ++i; } - glBindTextures(firstTextureUnit, ids.size(), ids); + /* Avoid doing the binding if there is nothing different */ + if(different) glBindTextures(firstTextureUnit, ids.size(), ids); } #endif From bdfa72e0e9ab26723b791a3375e17e741a5e11fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 16:19:12 +0200 Subject: [PATCH 27/72] Fix Buffer move construction/assignment on NaCl. --- src/Magnum/Buffer.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index d627700d7..f3697b092 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -937,13 +937,24 @@ CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags) /** @debugoperatorclassenum{Magnum::Buffer,Magnum::Buffer::Target} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::Target value); -inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, _created{other._created} { +inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, + #ifdef CORRADE_TARGET_NACL + _mappedBuffer{other._mappedBuffer}, + #endif + _created{other._created} +{ other._id = 0; + #ifdef CORRADE_TARGET_NACL + other._mappedBuffer = nullptr; + #endif } inline Buffer& Buffer::operator=(Buffer&& other) noexcept { std::swap(_id, other._id); std::swap(_targetHint, other._targetHint); + #ifdef CORRADE_TARGET_NACL + std::swap(_mappedBuffer, other._mappedBuffer); + #endif std::swap(_created, other._created); return *this; } From 1f6ae8f359976e5b2f1b9649342434a00a6ccbe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 16:33:28 +0200 Subject: [PATCH 28/72] Text: fix performance warning in test. --- src/Magnum/Text/Test/RendererGLTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Text/Test/RendererGLTest.cpp b/src/Magnum/Text/Test/RendererGLTest.cpp index 391637539..561ca0d50 100644 --- a/src/Magnum/Text/Test/RendererGLTest.cpp +++ b/src/Magnum/Text/Test/RendererGLTest.cpp @@ -272,7 +272,7 @@ void RendererGLTest::mutableText() { CORRADE_COMPARE(renderer.rectangle(), Range2D()); /* Reserve some capacity */ - renderer.reserve(4, BufferUsage::StaticDraw, BufferUsage::StaticDraw); + renderer.reserve(4, BufferUsage::DynamicDraw, BufferUsage::DynamicDraw); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(renderer.capacity(), 4); /** @todo How to verify this on ES? */ From af88f166fae10c03f483b3b0f5df3b527a24569f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 16:55:07 +0200 Subject: [PATCH 29/72] Added Renderer::Feature::RasterizerDiscard. --- src/Magnum/Renderer.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Magnum/Renderer.h b/src/Magnum/Renderer.h index bbaddfd24..90d0cdf26 100644 --- a/src/Magnum/Renderer.h +++ b/src/Magnum/Renderer.h @@ -194,6 +194,16 @@ class MAGNUM_EXPORT Renderer { ProgramPointSize = GL_PROGRAM_POINT_SIZE, #endif + #ifndef MAGNUM_TARGET_GLES2 + /** + * Discard primitives before rasterization. + * @requires_gl30 %Extension @extension{EXT,transform_feedback} + * @requires_gles30 Transform feedback is not available in OpenGL + * ES 2.0. + */ + RasterizerDiscard = GL_RASTERIZER_DISCARD, + #endif + /** * Scissor test * @see @ref setScissor() From 3d0b573efbe3646f83e335cf05ae5ec56419af76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Aug 2014 17:26:43 +0200 Subject: [PATCH 30/72] Doc++, minor cleanup. --- doc/opengl-mapping.dox | 7 +++---- src/Magnum/AbstractQuery.cpp | 4 ++-- src/Magnum/AbstractShaderProgram.h | 9 ++++++--- src/Magnum/AbstractTexture.h | 3 +++ src/Magnum/Buffer.cpp | 4 ---- src/Magnum/Buffer.h | 16 ++-------------- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index e05a92e9f..4fbb3b5cf 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -91,7 +91,7 @@ OpenGL function | Matching API @fn_gl{CopyTexSubImage1D}, \n `glCopyTextureSubImage1D()`, \n @fn_gl_extension{CopyTextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{CopyTexSubImage2D}, \n `glCopyTextureSubImage2D()`, \n @fn_gl_extension{CopyTextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{CopyTexSubImage3D}, \n `glCopyTextureSubImage3D()`, \n @fn_gl_extension{CopyTextureSubImage3D,EXT,direct_state_access} | | @fn_gl{CreateProgram}, @fn_gl{DeleteProgram} | @ref AbstractShaderProgram constructor and destructor @fn_gl{CreateShader}, @fn_gl{DeleteShader} | @ref Shader constructor and destructor -@fn_gl{CreateShaderProgram} | | +@fn_gl{CreateShaderProgram} | | @fn_gl{CullFace} | @ref Renderer::setFaceCullingMode() @fn_gl{DebugMessageCallback} | @ref DebugMessage::setCallback() @fn_gl{DebugMessageControl} | @ref DebugMessage::setEnabled() @@ -277,7 +277,6 @@ OpenGL function | Matching API @def_gl{BLEND}, \n @def_gl{COLOR_LOGIC_OP}, \n @def_gl{CULL_FACE}, \n @def_gl{DEBUG_OUTPUT}, \n @def_gl{DEBUG_OUTPUT_SYNCHRONOUS}, \n @def_gl{DEPTH_CLAMP}, \n @def_gl{DEPTH_TEST}, \n @def_gl{DITHER}, \n @def_gl{MULTISAMPLE}, \n @def_gl{POLYGON_OFFSET_FILL}, \n @def_gl{POLYGON_OFFSET_LINE}, \n @def_gl{POLYGON_OFFSET_POINT}, \n @def_gl{PROGRAM_POINT_SIZE}, \n @def_gl{SCISSOR}, \n @def_gl{TEXTURE_CUBE_MAP_SEAMLESS}, \n @def_gl{STENCIL_TEST} | not queryable, @ref Renderer::setFeature() setter only @def_gl{COLOR_CLEAR_VALUE}, \n @def_gl{DEPTH_CLEAR_VALUE}, \n @def_gl{STENCIL_CLEAR_VALUE} | not queryable, @ref Renderer::setClearColor(), \n @ref Renderer::setClearDepth() and \n @ref Renderer::setClearStencil() setters only @def_gl{COLOR_WRITEMASK}, \n @def_gl{DEPTH_WRITEMASK}, \n @def_gl{STENCIL_BACK_WRITEMASK}, \n @def_gl{STENCIL_WRITEMASK} | not queryable, @ref Renderer::setColorMask(), \n @ref Renderer::setDepthMask() and \n @ref Renderer::setStencilMask() setters only -@def_gl{COMPRESSED_TEXTURE_FORMATS} | | @def_gl{CONTEXT_FLAGS} | @ref Context::flags() @def_gl{CURRENT_PROGRAM} | not queryable but tracked internally @def_gl{DEBUG_GROUP_STACK_DEPTH} | | @@ -337,7 +336,7 @@ OpenGL function | Matching API @def_gl{MAX_SERVER_WAIT_TIMEOUT} | | @def_gl{MAX_SHADER_STORAGE_BLOCK_SIZE} | @ref AbstractShaderProgram::maxShaderStorageBlockSize() @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS} | @ref Buffer::maxShaderStorageBindings() -@def_gl{MAX_TEXTURE_BUFFER_SIZE} | | +@def_gl{MAX_TEXTURE_BUFFER_SIZE} | @ref BufferTexture::maxSize() @def_gl_extension{MAX_TEXTURE_MAX_ANISOTROPY,EXT,texture_filter_anisotropic} | @ref Sampler::maxMaxAnisotropy() @def_gl{MAX_TEXTURE_LOD_BIAS} | @ref AbstractTexture::maxLodBias() @def_gl{MAX_UNIFORM_BLOCK_SIZE} | @ref AbstractShaderProgram::maxUniformBlockSize() @@ -350,7 +349,7 @@ OpenGL function | Matching API @def_gl{MAX_VIEWPORT_DIMS} | @ref AbstractFramebuffer::maxViewportSize() @def_gl{MIN_MAP_BUFFER_ALIGNMENT} | @ref Buffer::minMapAlignment() @def_gl{MIN_PROGRAM_TEXEL_OFFSET}, \n @def_gl{MAX_PROGRAM_TEXEL_OFFSET} | @ref AbstractShaderProgram::minTexelOffset(), \n @ref AbstractShaderProgram::maxTexelOffset() -@def_gl{NUM_COMPRESSED_TEXTURE_FORMATS} | | +@def_gl{NUM_COMPRESSED_TEXTURE_FORMATS}, \n @def_gl{COMPRESSED_TEXTURE_FORMATS} | | @def_gl{NUM_EXTENSIONS} | @ref Context::supportedExtensions() @def_gl{NUM_PROGRAM_BINARY_FORMATS}, \n @def_gl{PROGRAM_BINARY_FORMATS} | | @def_gl{NUM_SHADER_BINARY_FORMATS}, \n @def_gl{SHADER_BINARY_FORMATS} | | diff --git a/src/Magnum/AbstractQuery.cpp b/src/Magnum/AbstractQuery.cpp index 2de393661..5cc789740 100644 --- a/src/Magnum/AbstractQuery.cpp +++ b/src/Magnum/AbstractQuery.cpp @@ -153,9 +153,9 @@ void AbstractQuery::begin(const GLenum target) { CORRADE_ASSERT(!_target, "AbstractQuery::begin(): the query is already running", ); #ifndef MAGNUM_TARGET_GLES2 - glBeginQuery(_target = target, id()); + glBeginQuery(_target = target, _id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glBeginQueryEXT(_target = target, id()); + glBeginQueryEXT(_target = target, _id); #else static_cast(target); CORRADE_ASSERT_UNREACHABLE(); diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 2279646ac..bb7c14d4b 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -80,8 +80,7 @@ MyShader() { CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); // Attach the shaders - attachShader(vert); - attachShader(frag); + attachShader({vert, frag}); // Link the program together CORRADE_INTERNAL_ASSERT_OUTPUT(link()); @@ -236,7 +235,7 @@ layout(binding = 1) uniform sampler2D specularTexture; @endcode If you don't have the required extension, declare the uniforms without the -`layout()` qualifier and set the texture binding unit using +`binding` qualifier and set the texture binding unit using @ref setUniform(Int, const T&) "setUniform(Int, Int)". Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0. @code @@ -688,6 +687,10 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * The same as @ref bindFragmentDataLocationIndexed(), but with `index` * set to `0`. * @see @fn_gl{BindFragDataLocation} + * @deprecated_gl Preferred usage is to specify attribute location + * explicitly in the shader instead of using this function. See + * @ref AbstractShaderProgram-attribute-location "class documentation" + * for more information. * @requires_gl30 %Extension @extension{EXT,gpu_shader4} * @requires_gl Use explicit location specification in OpenGL ES 3.0 * and `gl_FragData[n]` provided by @es_extension2{NV,draw_buffers,GL_NV_draw_buffers} diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 2cdf30902..fed9b90c5 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -211,6 +211,9 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * texture unit is unbound. If @extension{ARB,multi_bind} (part of * OpenGL 4.4) is not available, the feature is emulated with sequence * of @ref bind(Int) / @ref unbind() calls. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. * @see @fn_gl{BindTextures}, eventually @fn_gl{ActiveTexture}, * @fn_gl{BindTexture} or @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} */ diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 627b92f70..467de1adf 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -98,9 +98,7 @@ Int Buffer::shaderStorageOffsetAlignment() { return value; } -#endif -#ifndef MAGNUM_TARGET_GLES2 Int Buffer::maxUniformBindings() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) @@ -114,9 +112,7 @@ Int Buffer::maxUniformBindings() { return value; } -#endif -#ifndef MAGNUM_TARGET_GLES2 void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const GLintptr writeOffset, const GLsizeiptr size) { Context::current()->state().buffer->copyImplementation(read, write, readOffset, writeOffset, size); } diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index f3697b092..ce53e89ba 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -227,9 +227,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * 3.0 and older. */ AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, - #endif - #ifndef MAGNUM_TARGET_GLES2 /** * Source for copies. See @ref copy(). * @requires_gl31 %Extension @extension{ARB,copy_buffer} @@ -245,9 +243,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * 2.0. */ CopyWrite = GL_COPY_WRITE_BUFFER, - #endif - #ifndef MAGNUM_TARGET_GLES2 /** * Indirect compute dispatch commands. * @requires_gl43 %Extension @extension{ARB,compute_shader} @@ -266,11 +262,9 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif /** Used for storing vertex indices. */ - ElementArray = GL_ELEMENT_ARRAY_BUFFER + ElementArray = GL_ELEMENT_ARRAY_BUFFER, #ifndef MAGNUM_TARGET_GLES2 - , - /** * Target for pixel pack operations. * @requires_gles30 Pixel buffer objects are not available in @@ -284,9 +278,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * OpenGL ES 2.0. */ PixelUnpack = GL_PIXEL_UNPACK_BUFFER, - #endif - #ifndef MAGNUM_TARGET_GLES2 /** * Used for shader storage. * @requires_gl43 %Extension @extension{ARB,shader_storage_buffer_object} @@ -489,9 +481,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int shaderStorageOffsetAlignment(); - #endif - #ifndef MAGNUM_TARGET_GLES2 /** * @brief Max supported uniform buffer binding count * @@ -499,12 +489,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * OpenGL calls. If extension @extension{ARB,uniform_buffer_object} * (part of OpenGL 3.1) is not available, returns `0`. * @see @fn_gl{Get} with @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} - * @requires_gles30 Uniform blocks are not available in OpenGL ES 2.0. + * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 */ static Int maxUniformBindings(); - #endif - #ifndef MAGNUM_TARGET_GLES2 /** * @brief Copy one buffer to another * @param read %Buffer from which to read From dfd7de8df18bc605de36aa2376625b0a868beffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 24 Aug 2014 18:35:51 +0200 Subject: [PATCH 31/72] Return 1 as implicit alignment value. Previously 0 was returned, which would fail at runtime for division-by-zero in the following sanity check: CORRADE_INTERNAL_ASSERT(!(offset % BufferTexture::offsetAlignment())); --- src/Magnum/Buffer.cpp | 4 ++-- src/Magnum/Buffer.h | 4 ++-- src/Magnum/BufferTexture.cpp | 2 +- src/Magnum/BufferTexture.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 467de1adf..03696dc1b 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -39,7 +39,7 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES Int Buffer::minMapAlignment() { if(!Context::current()->isExtensionSupported()) - return 0; + return 1; GLint& value = Context::current()->state().buffer->minMapAlignment; @@ -89,7 +89,7 @@ Int Buffer::shaderStorageOffsetAlignment() { #else if(!Context::current()->isVersionSupported(Version::GLES310)) #endif - return 0; + return 1; GLint& value = Context::current()->state().buffer->shaderStorageOffsetAlignment; diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index ce53e89ba..af196e214 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -441,7 +441,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * * The result is cached, repeated queries don't result in repeated * OpenGL calls. If extension @extension{ARB,map_buffer_alignment} - * (part of OpenGL 4.2) is not available, returns `0`. + * (part of OpenGL 4.2) is not available, returns `1`. * @see @ref map(), @fn_gl{Get} with @def_gl{MIN_MAP_BUFFER_ALIGNMENT} * @requires_gl No minimal value is specified for OpenGL ES. */ @@ -476,7 +476,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * * The result is cached, repeated queries don't result in repeated * OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object} - * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`. + * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `1`. * @see @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT} * @requires_gles30 Not defined in OpenGL ES 2.0 */ diff --git a/src/Magnum/BufferTexture.cpp b/src/Magnum/BufferTexture.cpp index 84b5ad87b..54384f45a 100644 --- a/src/Magnum/BufferTexture.cpp +++ b/src/Magnum/BufferTexture.cpp @@ -49,7 +49,7 @@ Int BufferTexture::maxSize() { Int BufferTexture::offsetAlignment() { if(!Context::current()->isExtensionSupported()) - return 0; + return 1; GLint& value = Context::current()->state().texture->bufferOffsetAlignment; diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index cf8fabf80..402edc063 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -217,7 +217,7 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { * * The result is cached, repeated queries don't result in repeated * OpenGL calls. If extension @extension{ARB,texture_buffer_range} - * (part of OpenGL 4.3) is not available, returns `0`. + * (part of OpenGL 4.3) is not available, returns `1`. * @see @fn_gl{Get} with @def_gl{TEXTURE_BUFFER_OFFSET_ALIGNMENT} */ static Int offsetAlignment(); From af4fbcd9827b35b84d773a5e04bfbc1509e37556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 13:05:28 +0200 Subject: [PATCH 32/72] Fix BufferTextureGLTest. Somehow my NVidia now reports 256 (!) as offset alignment. Horrible waste of memory. --- src/Magnum/Test/BufferTextureGLTest.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Test/BufferTextureGLTest.cpp b/src/Magnum/Test/BufferTextureGLTest.cpp index b67180ea9..710c6b5a3 100644 --- a/src/Magnum/Test/BufferTextureGLTest.cpp +++ b/src/Magnum/Test/BufferTextureGLTest.cpp @@ -100,6 +100,9 @@ void BufferTextureGLTest::setBufferOffset() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); + /* Check that we have correct offset alignment */ + CORRADE_INTERNAL_ASSERT(256 % BufferTexture::offsetAlignment() == 0); + BufferTexture texture; Buffer buffer; constexpr UnsignedByte data[] = { @@ -108,8 +111,9 @@ void BufferTextureGLTest::setBufferOffset() { 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; - buffer.setData(data, BufferUsage::StaticDraw); - texture.setBuffer(BufferTextureFormat::R8UI, buffer, 16, 8); + buffer.setData({nullptr, 1024}, BufferUsage::StaticDraw); + buffer.setSubData(256 - 16, data); + texture.setBuffer(BufferTextureFormat::R8UI, buffer, 256, 8); MAGNUM_VERIFY_NO_ERROR(); } From 5ad9ef56f4488be254d278aeaab4a5d50c60ce47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 24 Aug 2014 18:39:57 +0200 Subject: [PATCH 33/72] Added Buffer::uniformOffsetAlignment() limit query. --- doc/opengl-mapping.dox | 2 +- src/Magnum/Buffer.cpp | 14 ++++++++++++++ src/Magnum/Buffer.h | 11 +++++++++++ src/Magnum/Implementation/BufferState.cpp | 2 +- src/Magnum/Implementation/BufferState.h | 1 + src/Magnum/Platform/magnum-info.cpp | 1 + 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 4fbb3b5cf..7f99a768d 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -377,7 +377,7 @@ OpenGL function | Matching API @def_gl{TEXTURE_BUFFER_OFFSET_ALIGNMENT} | @ref BufferTexture::offsetAlignment() @def_gl{TIMESTAMP} | | @def_gl{TRANSFORM_FEEDBACK_BUFFER_BINDING}, \n @def_gl{TRANSFORM_FEEDBACK_BUFFER_SIZE}, \n @def_gl{TRANSFORM_FEEDBACK_BUFFER_START} | not queryable -@def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} | | +@def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} | @ref Buffer::uniformOffsetAlignment() @def_gl{UNIFORM_BUFFER_BINDING}, \n @def_gl{UNIFORM_BUFFER_SIZE}, \n @def_gl{UNIFORM_BUFFER_START} | not queryable @def_gl{VERTEX_BINDING_DIVISOR}, \n @def_gl{VERTEX_BINDING_OFFSET}, \n @def_gl{VERTEX_BINDING_STRIDE} | not queryable @def_gl{VERTEX_PROGRAM_POINT_SIZE} | not queryable diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 03696dc1b..b42b95d09 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -99,6 +99,20 @@ Int Buffer::shaderStorageOffsetAlignment() { return value; } +Int Buffer::uniformOffsetAlignment() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + return 1; + #endif + + GLint& value = Context::current()->state().buffer->uniformOffsetAlignment; + + if(value == 0) + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value); + + return value; +} + Int Buffer::maxUniformBindings() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index af196e214..f04773764 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -471,6 +471,17 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { */ static Int maxShaderStorageBindings(); + /** + * @brief Alignment of uniform buffer binding offset + * + * The result is cached, repeated queries don't result in repeated + * OpenGL calls. If extension @extension{ARB,uniform_buffer_object} + * (part of OpenGL 3.1) is not available, returns `1`. + * @see @fn_gl{Get} with @def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} + * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 + */ + static Int uniformOffsetAlignment(); + /** * @brief Alignment of shader storage buffer binding offset * diff --git a/src/Magnum/Implementation/BufferState.cpp b/src/Magnum/Implementation/BufferState.cpp index 618dff7f0..7d285ed78 100644 --- a/src/Magnum/Implementation/BufferState.cpp +++ b/src/Magnum/Implementation/BufferState.cpp @@ -83,7 +83,7 @@ BufferState::BufferState(Context& context, std::vector& extensions) #ifndef MAGNUM_TARGET_GLES , minMapAlignment(0) #endif - , maxAtomicCounterBindings(0), maxShaderStorageBindings(0), shaderStorageOffsetAlignment(0), maxUniformBindings(0) + , maxAtomicCounterBindings{0}, maxShaderStorageBindings{0}, shaderStorageOffsetAlignment{0}, uniformOffsetAlignment{0}, maxUniformBindings{0} #endif { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Implementation/BufferState.h b/src/Magnum/Implementation/BufferState.h index 48ccba415..38d9e101e 100644 --- a/src/Magnum/Implementation/BufferState.h +++ b/src/Magnum/Implementation/BufferState.h @@ -74,6 +74,7 @@ struct BufferState { maxAtomicCounterBindings, maxShaderStorageBindings, shaderStorageOffsetAlignment, + uniformOffsetAlignment, maxUniformBindings; #endif }; diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index 52016ab2b..d36e4e059 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -513,6 +513,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _h(ARB::uniform_buffer_object) #endif + _l(Buffer::uniformOffsetAlignment()) _l(Shader::maxUniformBlocks(Shader::Type::Vertex)) #ifndef MAGNUM_TARGET_GLES _l(Shader::maxUniformBlocks(Shader::Type::TessellationControl)) From e193aa15c702e7b1e37d1ec1a9060e3d981cbb22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 24 Aug 2014 18:42:35 +0200 Subject: [PATCH 34/72] Added Mesh::maxElementIndex() limit query. --- doc/opengl-mapping.dox | 2 +- src/Magnum/Implementation/MeshState.cpp | 2 +- src/Magnum/Implementation/MeshState.h | 1 + src/Magnum/Mesh.cpp | 15 +++++++++++++++ src/Magnum/Mesh.h | 19 ++++++++++++++++--- src/Magnum/Platform/magnum-info.cpp | 1 + 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 7f99a768d..31f85dcf0 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -320,9 +320,9 @@ OpenGL function | Matching API @def_gl{MAX_COLOR_TEXTURE_SAMPLES}, \n @def_gl{MAX_DEPTH_TEXTURE_SAMPLES}, \n @def_gl{MAX_INTEGER_SAMPLES} | @ref AbstractTexture::maxColorSamples(), \n @ref AbstractTexture::maxDepthSamples(), \n @ref AbstractTexture::maxIntegerSamples() @def_gl{MAX_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDrawBuffers() @def_gl{MAX_DUAL_SOURCE_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDualSourceDrawBuffers() +@def_gl{MAX_ELEMENT_INDEX} | @ref Mesh::maxElementIndex() @def_gl{MAX_ELEMENTS_INDICES} | @ref Mesh::maxElementsIndices() @def_gl{MAX_ELEMENTS_VERTICES} | @ref Mesh::maxElementsVertices() -@def_gl{MAX_ELEMENT_INDEX} | | @def_gl{MAX_FRAMEBUFFER_HEIGHT} | | @def_gl{MAX_FRAMEBUFFER_LAYERS} | | @def_gl{MAX_FRAMEBUFFER_SAMPLES} | | diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index 308099769..d7297925b 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -35,7 +35,7 @@ namespace Magnum { namespace Implementation { MeshState::MeshState(Context& context, std::vector& extensions): currentVAO(0) #ifndef MAGNUM_TARGET_GLES2 - , maxElementsIndices(0), maxElementsVertices(0) + , maxElementIndex{0}, maxElementsIndices{0}, maxElementsVertices{0} #endif { #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Implementation/MeshState.h b/src/Magnum/Implementation/MeshState.h index 0b0349cec..9095a6ff0 100644 --- a/src/Magnum/Implementation/MeshState.h +++ b/src/Magnum/Implementation/MeshState.h @@ -64,6 +64,7 @@ struct MeshState { GLuint currentVAO; #ifndef MAGNUM_TARGET_GLES2 + GLint64 maxElementIndex; GLint maxElementsIndices, maxElementsVertices; #endif }; diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index 0a2794e63..b530fc704 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -41,6 +41,21 @@ namespace Magnum { Int Mesh::maxVertexAttributes() { return AbstractShaderProgram::maxVertexAttributes(); } #ifndef MAGNUM_TARGET_GLES2 +Long Mesh::maxElementIndex() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + return 0xFFFFFFFFl; + #endif + + GLint64& value = Context::current()->state().mesh->maxElementIndex; + + /* Get the value, if not already cached */ + if(value == 0) + glGetInteger64v(GL_MAX_ELEMENT_INDEX, &value); + + return value; +} + Int Mesh::maxElementsIndices() { GLint& value = Context::current()->state().mesh->maxElementsIndices; diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index b79df2367..7de09d816 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -375,6 +375,19 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { static Int maxVertexAttributes(); #ifndef MAGNUM_TARGET_GLES2 + /** + * @brief Max supported index value + * + * The result is cached, repeated queries don't result in repeated + * OpenGL calls. If extension @extension{ARB,ES3_compatibility} (part + * of OpenGL 4.3) is not available, returns max representable 32-bit + * value (@f$ 2^32 - 1 @f$). + * @see @ref setIndexBuffer(), @fn_gl{Get} with @def_gl{MAX_ELEMENT_INDEX} + * @requires_gles30 No upper limit is specified for index values in + * OpenGL ES 2.0 + */ + static Long maxElementIndex(); + /** * @brief Max recommended index count * @@ -744,9 +757,9 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is * available, the vertex array object is used to hold the parameters. * - * @see @ref maxElementsIndices(), @ref maxElementsVertices(), - * @ref setCount(), @ref isIndexed(), @fn_gl{BindVertexArray}, - * @fn_gl{BindBuffer} + * @see @ref maxElementIndex(), @ref maxElementsIndices(), + * @ref maxElementsVertices(), @ref setCount(), @ref isIndexed(), + * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} */ Mesh& setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end); diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index d36e4e059..1b164d895 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -291,6 +291,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _l(AbstractFramebuffer::maxDrawBuffers()) _l(Framebuffer::maxColorAttachments()) #ifndef MAGNUM_TARGET_GLES2 + _l(Mesh::maxElementIndex()) _l(Mesh::maxElementsIndices()) _l(Mesh::maxElementsVertices()) #endif From 3f56109ec185a29a251de5097114bb724e48010d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 12:40:12 +0200 Subject: [PATCH 35/72] Platform: include GL 4.5 and ES 3.1 in magnum-info output. --- src/Magnum/Platform/magnum-info.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index 1b164d895..126a17c4d 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -245,8 +245,10 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat Version::GL420, Version::GL430, Version::GL440, + Version::GL450, #else Version::GLES300, + Version::GLES310, #endif Version::None }; From 3e84a1848fcddfe23d90ebd2f383f92bf38d06b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 12:22:17 +0200 Subject: [PATCH 36/72] Added multi-unbind function to AbstractTexture. More efficient (no allocation) and also more convenient than calling e.g. unbind(7, {nullptr, nullptr, nullptr}). --- src/Magnum/AbstractTexture.cpp | 37 ++++++++++--------- src/Magnum/AbstractTexture.h | 26 ++++++++++--- src/Magnum/Implementation/TextureState.h | 2 +- src/Magnum/Test/BufferTextureGLTest.cpp | 4 ++ src/Magnum/Test/CubeMapTextureArrayGLTest.cpp | 4 ++ src/Magnum/Test/CubeMapTextureGLTest.cpp | 4 ++ src/Magnum/Test/MultisampleTextureGLTest.cpp | 8 ++++ src/Magnum/Test/RectangleTextureGLTest.cpp | 4 ++ src/Magnum/Test/TextureArrayGLTest.cpp | 8 ++++ src/Magnum/Test/TextureGLTest.cpp | 12 ++++++ 10 files changed, 86 insertions(+), 23 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index f4e31d568..419437537 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -151,42 +151,45 @@ void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) { } #endif +void AbstractTexture::unbind(const Int firstTextureUnit, const std::size_t count) { + /* State tracker is updated in the implementations */ + Context::current()->state().texture->bindMultiImplementation(firstTextureUnit, {nullptr, count}); +} + +/** @todoc const std::initializer_list makes Doxygen grumpy */ void AbstractTexture::bind(const Int firstTextureUnit, std::initializer_list textures) { /* State tracker is updated in the implementations */ - Context::current()->state().texture->bindMultiImplementation(firstTextureUnit, textures); + Context::current()->state().texture->bindMultiImplementation(firstTextureUnit, {textures.begin(), textures.size()}); } -void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, std::initializer_list textures) { - Int unit = firstTextureUnit; - for(AbstractTexture* const texture: textures) { - if(texture) texture->bind(unit); - else unbind(unit); - ++unit; - } +void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, const Containers::ArrayReference textures) { + for(std::size_t i = 0; i != textures.size(); ++i) + textures && textures[i] ? textures[i]->bind(firstTextureUnit + i) : unbind(firstTextureUnit + i); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, std::initializer_list textures) { +void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, const Containers::ArrayReference textures) { Implementation::TextureState* const textureState = Context::current()->state().texture; /* Create array of IDs and also update bindings in state tracker */ - Containers::Array ids{textures.size()}; - Int i{}; + Containers::Array ids{textures ? textures.size() : 0}; bool different = false; - for(AbstractTexture* const texture: textures) { - if(texture) texture->createIfNotAlready(); + for(std::size_t i = 0; i != textures.size(); ++i) { + const GLuint id = textures && textures[i] ? textures[i]->_id : 0; + + if(textures) { + if(textures[i]) textures[i]->createIfNotAlready(); + ids[i] = id; + } - const GLuint id = ids[i] = texture ? texture->_id : 0; if(textureState->bindings[firstTextureUnit + i].second != id) { different = true; textureState->bindings[firstTextureUnit + i].second = id; } - - ++i; } /* Avoid doing the binding if there is nothing different */ - if(different) glBindTextures(firstTextureUnit, ids.size(), ids); + if(different) glBindTextures(firstTextureUnit, textures.size(), ids); } #endif diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index fed9b90c5..4f2308490 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -203,6 +203,21 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { */ static void unbind(Int textureUnit); + /** + * @brief Unbind textures in given range of texture units + * + * Unbinds all texture in the range @f$ [ firstTextureUnit ; firstTextureUnit + count ) @f$. + * If @extension{ARB,multi_bind} (part of OpenGL 4.4) is not available, + * the feature is emulated with sequence of @ref unbind(Int) calls. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures}, + * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} or + * @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} + */ + static void unbind(Int firstTextureUnit, std::size_t count); + /** * @brief Bind textures to given range of texture units * @@ -210,12 +225,13 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * `firstTextureUnit + 1` etc. If any texture is `nullptr`, given * texture unit is unbound. If @extension{ARB,multi_bind} (part of * OpenGL 4.4) is not available, the feature is emulated with sequence - * of @ref bind(Int) / @ref unbind() calls. + * of @ref bind(Int) / @ref unbind(Int) calls. * @note This function is meant to be used only internally from * @ref AbstractShaderProgram subclasses. See its documentation * for more information. - * @see @fn_gl{BindTextures}, eventually @fn_gl{ActiveTexture}, - * @fn_gl{BindTexture} or @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} + * @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures}, + * eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} or + * @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} */ static void bind(Int firstTextureUnit, std::initializer_list textures); @@ -358,9 +374,9 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { static void MAGNUM_LOCAL unbindImplementationDSA(GLint textureUnit); #endif - static void MAGNUM_LOCAL bindImplementationFallback(GLint firstTextureUnit, std::initializer_list textures); + static void MAGNUM_LOCAL bindImplementationFallback(GLint firstTextureUnit, Containers::ArrayReference textures); #ifndef MAGNUM_TARGET_GLES - static void MAGNUM_LOCAL bindImplementationMulti(GLint firstTextureUnit, std::initializer_list textures); + static void MAGNUM_LOCAL bindImplementationMulti(GLint firstTextureUnit, Containers::ArrayReference textures); #endif void MAGNUM_LOCAL createIfNotAlready(); diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index b361d04fd..79650690a 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -40,7 +40,7 @@ struct TextureState { void reset(); void(*unbindImplementation)(GLint); - void(*bindMultiImplementation)(GLint, std::initializer_list); + void(*bindMultiImplementation)(GLint, Containers::ArrayReference); void(AbstractTexture::*bindImplementation)(GLint); void(AbstractTexture::*parameteriImplementation)(GLenum, GLint); void(AbstractTexture::*parameterfImplementation)(GLenum, GLfloat); diff --git a/src/Magnum/Test/BufferTextureGLTest.cpp b/src/Magnum/Test/BufferTextureGLTest.cpp index 710c6b5a3..4c74c33fb 100644 --- a/src/Magnum/Test/BufferTextureGLTest.cpp +++ b/src/Magnum/Test/BufferTextureGLTest.cpp @@ -78,6 +78,10 @@ void BufferTextureGLTest::bind() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } void BufferTextureGLTest::setBuffer() { diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index 908ae7cc9..6ec415ff8 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -114,6 +114,10 @@ void CubeMapTextureArrayGLTest::bind() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } void CubeMapTextureArrayGLTest::sampling() { diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index d93507960..e71d10b2c 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -139,6 +139,10 @@ void CubeMapTextureGLTest::bind() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } void CubeMapTextureGLTest::sampling() { diff --git a/src/Magnum/Test/MultisampleTextureGLTest.cpp b/src/Magnum/Test/MultisampleTextureGLTest.cpp index 0ccde3e5e..c90cc8de3 100644 --- a/src/Magnum/Test/MultisampleTextureGLTest.cpp +++ b/src/Magnum/Test/MultisampleTextureGLTest.cpp @@ -146,6 +146,10 @@ void MultisampleTextureGLTest::bind2D() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } #ifndef MAGNUM_TARGET_GLES @@ -165,6 +169,10 @@ void MultisampleTextureGLTest::bind2DArray() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } #endif diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index 0bc52e25a..1af159aea 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -112,6 +112,10 @@ void RectangleTextureGLTest::bind() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } void RectangleTextureGLTest::sampling() { diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index 775bfcc91..af82f9db3 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -244,6 +244,10 @@ void TextureArrayGLTest::bind1D() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } #endif @@ -265,6 +269,10 @@ void TextureArrayGLTest::bind2D() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index 7fe72cfb5..7a422e78e 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -303,6 +303,10 @@ void TextureGLTest::bind1D() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } #endif @@ -319,6 +323,10 @@ void TextureGLTest::bind2D() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } void TextureGLTest::bind3D() { @@ -339,6 +347,10 @@ void TextureGLTest::bind3D() { AbstractTexture::bind(7, {&texture, nullptr, &texture}); MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbind(7, 3); + + MAGNUM_VERIFY_NO_ERROR(); } #ifndef MAGNUM_TARGET_GLES From e921d4f3464a7c7dcb0fb9b9db0f4b8dc2fbb731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 12:15:12 +0200 Subject: [PATCH 37/72] Run forgotten test cases in BufferGLTest. --- src/Magnum/Test/BufferGLTest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Magnum/Test/BufferGLTest.cpp b/src/Magnum/Test/BufferGLTest.cpp index ab36e04d7..f6ffb3220 100644 --- a/src/Magnum/Test/BufferGLTest.cpp +++ b/src/Magnum/Test/BufferGLTest.cpp @@ -58,6 +58,8 @@ class BufferGLTest: public AbstractOpenGLTester { BufferGLTest::BufferGLTest() { addTests({&BufferGLTest::construct, + &BufferGLTest::constructCopy, + &BufferGLTest::constructMove, &BufferGLTest::label, &BufferGLTest::data, &BufferGLTest::map, From dc312cda0d78b60d1ca1f79912cf8f2d86c4d0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 24 Aug 2014 19:01:51 +0200 Subject: [PATCH 38/72] Implemented indexed buffer binding. The indexed binding is allowed for only some types (atomic counters, uniforms, shader storage and transform feedback), thus we need separate enum for that. Because the bind() function will be used far more often than setTargetHint(), the original Target enum is now renamed to TargetHint and the new Target enum contains (in non-deprecated build) only three values. For backwards compatibility, though, we need to have all original Target values, thus the new Target enum contains also all other values from TargetHint, but they are marked as deprecated and (at least) run-time checked in bind() so they aren't accidentaly used for indexed binding. Similarly there are also deprecated Target overloads of Buffer() and setTargetHint(). It's ugly, but hopefully will suffice for now. This mess will be removed as soon as possible in some upcoming version. --- doc/opengl-mapping.dox | 2 +- doc/opengl-support.dox | 6 +- src/Magnum/AbstractFramebuffer.cpp | 2 +- src/Magnum/AbstractTexture.cpp | 26 +- src/Magnum/Buffer.cpp | 151 +++++++- src/Magnum/Buffer.h | 341 +++++++++++++++++- src/Magnum/BufferImage.cpp | 4 +- src/Magnum/DebugTools/ForceRenderer.cpp | 4 +- .../Implementation/AbstractShapeRenderer.cpp | 8 +- src/Magnum/DebugTools/ObjectRenderer.cpp | 4 +- src/Magnum/Implementation/BufferState.cpp | 71 ++-- src/Magnum/Implementation/BufferState.h | 6 +- src/Magnum/Mesh.cpp | 12 +- src/Magnum/MeshTools/Compile.cpp | 8 +- src/Magnum/Test/BufferGLTest.cpp | 64 +++- src/Magnum/Test/MeshGLTest.cpp | 20 +- src/Magnum/Text/Renderer.cpp | 2 +- 17 files changed, 630 insertions(+), 101 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 31f85dcf0..e4b3988e5 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -49,7 +49,7 @@ OpenGL function | Matching API @fn_gl{BeginTransformFeedback}, `glEndTransformFeedback()` | | @fn_gl{BindAttribLocation} | @ref AbstractShaderProgram::bindAttributeLocation() @fn_gl{BindBuffer} | not needed, handled internally in @ref Buffer and elsewhere -@fn_gl{BindBufferBase}, \n @fn_gl{BindBuffersBase}, \n @fn_gl{BindBufferRange}, \n @fn_gl{BindBuffersRange} | | +@fn_gl{BindBufferBase}, \n @fn_gl{BindBuffersBase}, \n @fn_gl{BindBufferRange}, \n @fn_gl{BindBuffersRange} | @ref Buffer::bind(), \n @ref Buffer::unbind() @fn_gl{BindFragDataLocation} | @ref AbstractShaderProgram::bindFragmentDataLocation() @fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() @fn_gl{BindFramebuffer} | @ref Framebuffer::bind() diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index fb75af729..e86d2a38a 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -81,7 +81,7 @@ following: @extension{ARB,texture_rectangle} | done @extension{ARB,draw_instanced} | done @extension{ARB,texture_buffer_object} | done -@extension{ARB,uniform_buffer_object} | | +@extension{ARB,uniform_buffer_object} | missing uniform block binding @extension{ARB,copy_buffer} | done @extension{EXT,texture_snorm} | done @extension{NV,primitive_restart} | | @@ -156,7 +156,7 @@ following: @extension{ARB,conservative_depth} | done (shading language only) @extension{ARB,internalformat_query} | | @extension{ARB,map_buffer_alignment} | done -@extension{ARB,shader_atomic_counters} | | +@extension{ARB,shader_atomic_counters} | done @extension{ARB,shader_image_load_store} | | @extension{ARB,shading_language_packing} | done (shading language only) @extension{ARB,texture_storage} | done @@ -198,7 +198,7 @@ following: @extension{ARB,buffer_storage} | | @extension{ARB,clear_texture} | | @extension{ARB,enhanced_layouts} | done (shading language only) -@extension{ARB,multi_bind} | only texture binding +@extension{ARB,multi_bind} | only texture and buffer binding @extension{ARB,query_buffer_object} | | @extension{ARB,texture_mirror_clamp_to_edge} | done @extension{ARB,texture_stencil8} | done diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index 03b5ab92c..fcc26147d 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -237,7 +237,7 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf if(image.size() != size) image.setData(image.format(), image.type(), size, nullptr, usage); - image.buffer().bindInternal(Buffer::Target::PixelPack); + image.buffer().bindInternal(Buffer::TargetHint::PixelPack); (Context::current()->state().framebuffer->readImplementation)(offset, size, image.format(), image.type(), image.dataSize(size), nullptr); } #endif diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 419437537..912200142 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1211,7 +1211,7 @@ template void AbstractTexture::image(GLenum target, GLin if(image.size() != size) image.setData(image.format(), image.type(), size, nullptr, usage); - image.buffer().bindInternal(Buffer::Target::PixelPack); + image.buffer().bindInternal(Buffer::TargetHint::PixelPack); (this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr); } @@ -1279,78 +1279,78 @@ void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& text #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) { - Buffer::unbindInternal(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); } void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) { - image.buffer().bindInternal(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) { - Buffer::unbindInternal(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); } void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) { - image.buffer().bindInternal(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference2D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbindInternal(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif (texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { - image.buffer().bindInternal(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, const ImageReference2D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbindInternal(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif (texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) { - image.buffer().bindInternal(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbindInternal(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif (texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) { - image.buffer().bindInternal(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr); } #endif void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, const ImageReference3D& image) { #ifndef MAGNUM_TARGET_GLES2 - Buffer::unbindInternal(Buffer::Target::PixelUnpack); + Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif (texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data()); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) { - image.buffer().bindInternal(Buffer::Target::PixelUnpack); + image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); (texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr); } #endif diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index b42b95d09..4529c0290 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -127,12 +127,42 @@ Int Buffer::maxUniformBindings() { return value; } +void Buffer::unbind(const Target target, const UnsignedInt index) { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); + #endif + glBindBufferBase(GLenum(target), index, 0); +} + +void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std::size_t count) { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); + #endif + Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count}); +} + +/** @todoc const std::initializer_list makes Doxygen grumpy */ +void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list> buffers) { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); + #endif + Context::current()->state().buffer->bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); +} + +/** @todoc const std::initializer_list makes Doxygen grumpy */ +void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initializer_list buffers) { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); + #endif + Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); +} + void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const GLintptr writeOffset, const GLsizeiptr size) { Context::current()->state().buffer->copyImplementation(read, write, readOffset, writeOffset, size); } #endif -Buffer::Buffer(const Target targetHint): _targetHint{targetHint}, +Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, #ifdef CORRADE_TARGET_NACL _mappedBuffer{nullptr}, #endif @@ -186,7 +216,7 @@ Buffer& Buffer::setLabelInternal(const Containers::ArrayReference la return *this; } -void Buffer::bindInternal(const Target target, Buffer* const buffer) { +void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { const GLuint id = buffer ? buffer->_id : 0; GLuint& bound = Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; @@ -199,7 +229,7 @@ void Buffer::bindInternal(const Target target, Buffer* const buffer) { glBindBuffer(GLenum(target), id); } -Buffer::Target Buffer::bindSomewhereInternal(Target hint) { +auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint { GLuint* bindings = Context::current()->state().buffer->bindings; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)]; @@ -218,6 +248,24 @@ Buffer::Target Buffer::bindSomewhereInternal(Target hint) { return hint; } +#ifndef MAGNUM_TARGET_GLES2 +Buffer& Buffer::bind(const Target target, const UnsignedInt index, const GLintptr offset, const GLsizeiptr size) { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); + #endif + glBindBufferRange(GLenum(target), index, _id, offset, size); + return *this; +} + +Buffer& Buffer::bind(const Target target, const UnsignedInt index) { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(target == Target::AtomicCounter || target == Target::ShaderStorage || target == Target::Uniform); + #endif + glBindBufferBase(GLenum(target), index, _id); + return *this; +} +#endif + Int Buffer::size() { /** * @todo there is something like glGetBufferParameteri64v in 3.2 (I @@ -296,8 +344,59 @@ void Buffer::subDataInternal(GLintptr offset, GLsizeiptr size, GLvoid* data) { #endif #ifndef MAGNUM_TARGET_GLES2 +void Buffer::bindImplementationFallback(const Target target, const GLuint firstIndex, Containers::ArrayReference buffers) { + for(std::size_t i = 0; i != buffers.size(); ++i) { + if(buffers && buffers[i]) buffers[i]->bind(target, firstIndex + i); + else unbind(target, firstIndex + i); + } +} + +#ifndef MAGNUM_TARGET_GLES +void Buffer::bindImplementationMulti(const Target target, const GLuint firstIndex, Containers::ArrayReference buffers) { + Containers::Array ids{buffers ? buffers.size() : 0}; + if(buffers) for(std::size_t i = 0; i != buffers.size(); ++i) { + if(buffers[i]) { + buffers[i]->createIfNotAlready(); + ids[i] = buffers[i]->_id; + } else { + ids[i] = 0; + } + } + + glBindBuffersBase(GLenum(target), firstIndex, buffers.size(), ids); +} +#endif + +void Buffer::bindImplementationFallback(const Target target, const GLuint firstIndex, const Containers::ArrayReference> buffers) { + for(std::size_t i = 0; i != buffers.size(); ++i) { + if(buffers && std::get<0>(buffers[i])) + std::get<0>(buffers[i])->bind(target, firstIndex + i, std::get<1>(buffers[i]), std::get<2>(buffers[i])); + else unbind(target, firstIndex + i); + } +} + +#ifndef MAGNUM_TARGET_GLES +void Buffer::bindImplementationMulti(const Target target, const GLuint firstIndex, const Containers::ArrayReference> buffers) { + /** @todo use ArrayTuple */ + Containers::Array ids{buffers ? buffers.size() : 0}; + Containers::Array offsetsSizes{buffers ? buffers.size()*2 : 0}; + if(buffers) for(std::size_t i = 0; i != buffers.size(); ++i) { + if(std::get<0>(buffers[i])) { + std::get<0>(buffers[i])->createIfNotAlready(); + ids[i] = std::get<0>(buffers[i])->_id; + std::tie(std::ignore, offsetsSizes[i], offsetsSizes[buffers.size() + i]) = buffers[i]; + } else { + ids[i] = 0; + offsetsSizes[i] = offsetsSizes[buffers.size() + i] = 0; + } + } + + glBindBuffersRange(GLenum(target), firstIndex, buffers.size(), ids, offsetsSizes, offsetsSizes + buffers.size()); +} +#endif + void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { - glCopyBufferSubData(GLenum(read.bindSomewhereInternal(Target::CopyRead)), GLenum(write.bindSomewhereInternal(Target::CopyWrite)), readOffset, writeOffset, size); + glCopyBufferSubData(GLenum(read.bindSomewhereInternal(TargetHint::CopyRead)), GLenum(write.bindSomewhereInternal(TargetHint::CopyWrite)), readOffset, writeOffset, size); } #ifndef MAGNUM_TARGET_GLES @@ -445,9 +544,9 @@ bool Buffer::unmapImplementationDSA() { #endif #ifndef DOXYGEN_GENERATING_OUTPUT -Debug operator<<(Debug debug, Buffer::Target value) { +Debug operator<<(Debug debug, Buffer::TargetHint value) { switch(value) { - #define _c(value) case Buffer::Target::value: return debug << "Buffer::Target::" #value; + #define _c(value) case Buffer::TargetHint::value: return debug << "Buffer::TargetHint::" #value; _c(Array) #ifndef MAGNUM_TARGET_GLES2 _c(AtomicCounter) @@ -472,8 +571,48 @@ Debug operator<<(Debug debug, Buffer::Target value) { #undef _c } + return debug << "Buffer::TargetHint::(invalid)"; +} +#endif + +#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_BUILD_DEPRECATED) +#ifndef DOXYGEN_GENERATING_OUTPUT +Debug operator<<(Debug debug, Buffer::Target value) { + switch(value) { + #ifndef MAGNUM_TARGET_GLES2 + #define _c(value) case Buffer::Target::value: return debug << "Buffer::Target::" #value; + _c(AtomicCounter) + _c(ShaderStorage) + _c(Uniform) + #undef _c + #endif + + #ifdef MAGNUM_BUILD_DEPRECATED + case Buffer::Target::Array: + #ifndef MAGNUM_TARGET_GLES2 + case Buffer::Target::CopyRead: + case Buffer::Target::CopyWrite: + case Buffer::Target::DispatchIndirect: + case Buffer::Target::DrawIndirect: + #endif + case Buffer::Target::ElementArray: + #ifndef MAGNUM_TARGET_GLES2 + case Buffer::Target::PixelPack: + case Buffer::Target::PixelUnpack: + #endif + #ifndef MAGNUM_TARGET_GLES + case Buffer::Target::Texture: + #endif + #ifndef MAGNUM_TARGET_GLES2 + case Buffer::Target::TransformFeedback: + #endif + return debug << static_cast(value); + #endif + } + return debug << "Buffer::Target::(invalid)"; } #endif +#endif } diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index f04773764..200b185cd 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -215,7 +215,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * * @see @ref Buffer(), @ref setTargetHint() */ - enum class Target: GLenum { + enum class TargetHint: GLenum { /** Used for storing vertex attributes. */ Array = GL_ARRAY_BUFFER, @@ -316,6 +316,139 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif }; + #if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_BUILD_DEPRECATED) + /** + * @brief %Buffer binding target + * + * @see @ref bind(), @ref unbind() + */ + enum class Target: GLenum { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copydoc TargetHint::Array + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::Array "TargetHint::Array" + * instead. + */ + Array = GL_ARRAY_BUFFER, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Atomic counter binding + * @requires_gl42 %Extension @extension{ARB,shader_atomic_counters} + * @requires_gles31 Atomic counters are not available in OpenGL ES + * 3.0 and older + */ + AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, + #endif + + #ifdef MAGNUM_BUILD_DEPRECATED + #ifndef MAGNUM_TARGET_GLES2 + /** + * @copydoc TargetHint::CopyRead + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::CopyRead "TargetHint::CopyRead" + * instead. + */ + CopyRead = GL_COPY_READ_BUFFER, + + /** + * @copydoc TargetHint::CopyWrite + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::CopyWrite "TargetHint::CopyWrite" + * instead. + */ + CopyWrite = GL_COPY_WRITE_BUFFER, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * @copydoc TargetHint::DispatchIndirect + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::DispatchIndirect "TargetHint::DispatchIndirect" + * instead. + */ + DispatchIndirect = GL_DISPATCH_INDIRECT_BUFFER, + + /** + * @copydoc TargetHint::DrawIndirect + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::DrawIndirect "TargetHint::DrawIndirect" + * instead. + */ + DrawIndirect = GL_DRAW_INDIRECT_BUFFER, + #endif + + /** + * @copydoc TargetHint::ElementArray + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::ElementArray "TargetHint::ElementArray" + * instead. + */ + ElementArray = GL_ELEMENT_ARRAY_BUFFER, + + #ifndef MAGNUM_TARGET_GLES2 + /** + * @copydoc TargetHint::PixelPack + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::PixelPack "TargetHint::PixelPack" + * instead. + */ + PixelPack = GL_PIXEL_PACK_BUFFER, + + /** + * @copydoc TargetHint::PixelUnpack + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::PixelUnpack "TargetHint::PixelUnpack" + * instead. + */ + PixelUnpack = GL_PIXEL_UNPACK_BUFFER, + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Shader storage binding + * @requires_gl43 %Extension @extension{ARB,shader_storage_buffer_object} + * @requires_gles31 Shader storage is not available in OpenGL ES + * 3.0 and older + */ + ShaderStorage = GL_SHADER_STORAGE_BUFFER, + #endif + + #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES) + /** + * @copydoc TargetHint::Texture + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::Texture "TargetHint::Texture" + * instead. + */ + Texture = GL_TEXTURE_BUFFER, + #endif + + #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(MAGNUM_TARGET_GLES2) + /** + * @copydoc TargetHint::TransformFeedback + * @deprecated For @ref Magnum::Buffer::setTargetHint() "setTargetHint()" + * only, use @ref Magnum::Buffer::TargetHint::TransformFeedback "TargetHint::TransformFeedback" + * instead. + */ + TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** + * Uniform binding + * @requires_gl31 %Extension @extension{ARB,uniform_buffer_object} + * @requires_gles30 Uniform buffers are not available in OpenGL ES + * 2.0 + */ + Uniform = GL_UNIFORM_BUFFER + #endif + }; + #endif + #ifdef MAGNUM_BUILD_DEPRECATED /** * @copybrief BufferUsage @@ -455,7 +588,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * The result is cached, repeated queries don't result in repeated * OpenGL calls. If neither extension @extension{ARB,shader_atomic_counters} * (part of OpenGL 4.2) nor OpenGL ES 3.1 is available, returns `0`. - * @see @fn_gl{Get} with @def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS} + * @see @ref bind(), @ref unbind(), @fn_gl{Get} with + * @def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS} * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int maxAtomicCounterBindings(); @@ -466,7 +600,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * The result is cached, repeated queries don't result in repeated * OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object} * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `0`. - * @see @fn_gl{Get} with @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS} + * @see @ref bind(), @ref unbind(), @fn_gl{Get} with + * @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS} * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int maxShaderStorageBindings(); @@ -477,7 +612,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * The result is cached, repeated queries don't result in repeated * OpenGL calls. If extension @extension{ARB,uniform_buffer_object} * (part of OpenGL 3.1) is not available, returns `1`. - * @see @fn_gl{Get} with @def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} + * @see @ref bind(), @fn_gl{Get} with @def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 */ static Int uniformOffsetAlignment(); @@ -488,7 +623,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * The result is cached, repeated queries don't result in repeated * OpenGL calls. If neither extension @extension{ARB,shader_storage_buffer_object} * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns `1`. - * @see @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT} + * @see @ref bind(), @fn_gl{Get} with @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT} * @requires_gles30 Not defined in OpenGL ES 2.0 */ static Int shaderStorageOffsetAlignment(); @@ -499,11 +634,108 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * The result is cached, repeated queries don't result in repeated * OpenGL calls. If extension @extension{ARB,uniform_buffer_object} * (part of OpenGL 3.1) is not available, returns `0`. - * @see @fn_gl{Get} with @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} + * @see @ref bind(), @ref unbind(), @fn_gl{Get} with + * @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 */ static Int maxUniformBindings(); + /** + * @brief Unbind any buffer from given indexed target + * + * The @p index parameter must respect limits for given @p target. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bind(), @ref maxAtomicCounterBindings(), + * @ref maxShaderStorageBindings(), @ref maxUniformBindings(), + * @fn_gl{BindBufferBase} + * @requires_gl30 No form of indexed buffer binding is available in + * OpenGL 2.1, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @requires_gles30 No form of indexed buffer binding is available in + * OpenGL ES 2.0, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + */ + static void unbind(Target target, UnsignedInt index); + + /** + * @brief Unbind given range of indexed targets + * + * Unbinds all buffers in given target in range @f$ [ firstIndex ; firstIndex + count ] @f$. + * The range of indices must respect limits for given @p target. If + * @extension{ARB,multi_bind} (part of OpenGL 4.4) is not available, + * the feature is emulated with sequence of @ref unbind(Target, UnsignedInt) + * calls. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref unbind(Target, UnsignedInt), @ref maxAtomicCounterBindings(), + * @ref maxShaderStorageBindings(), @ref maxUniformBindings(), + * @fn_gl{BindBuffersBase} or @fn_gl{BindBufferBase} + * @requires_gl30 No form of indexed buffer binding is available in + * OpenGL 2.1, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @requires_gles30 No form of indexed buffer binding is available in + * OpenGL ES 2.0, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + */ + static void unbind(Target target, UnsignedInt firstIndex, std::size_t count); + + /** + * @brief Bind ranges of buffers to given range of indexed targets + * + * Binds first buffer in the list to @p firstIndex, second to + * `firstIndex + 1` etc. Second parameter is offset, third is size. If + * any buffer is `nullptr`, given indexed target is unbound. The range + * of indices must respect limits for given @p target. The offsets must + * respect alignment, which is 4 bytes for @ref Target::AtomicCounter + * and implementation-defined for other targets. If @extension{ARB,multi_bind} + * (part of OpenGL 4.4) is not available, the feature is emulated with + * sequence of @ref bind(Target, UnsignedInt, GLintptr, GLsizeiptr) / + * @ref unbind(Target, UnsignedInt) calls. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bind(Target, UnsignedInt, GLintptr, GLsizeiptr), + * @ref maxAtomicCounterBindings(), @ref maxShaderStorageBindings(), + * @ref maxUniformBindings(), @ref shaderStorageOffsetAlignment(), + * @ref uniformOffsetAlignment(), @fn_gl{BindBuffersRange} or + * @fn_gl{BindBufferRange} + * @requires_gl30 No form of indexed buffer binding is available in + * OpenGL 2.1, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @requires_gles30 No form of indexed buffer binding is available in + * OpenGL ES 2.0, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + */ + static void bind(Target target, UnsignedInt firstIndex, std::initializer_list> buffers); + + /** + * @brief Bind buffers to given range of indexed targets + * + * Binds first buffer in the list to @p firstIndex, second to + * `firstIndex + 1` etc. If any buffer is `nullptr`, given indexed + * target is unbound. The range of indices must respect limits for + * given @p target. If @extension{ARB,multi_bind} (part of OpenGL 4.4) + * is not available, the feature is emulated with sequence of + * @ref bind(Target, UnsignedInt) / @ref unbind(Target, UnsignedInt) + * calls. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bind(Target, UnsignedInt), @ref maxAtomicCounterBindings(), + * @ref maxShaderStorageBindings(), @ref maxUniformBindings(), + * @fn_gl{BindBuffersBase} or @fn_gl{BindBufferBase} + * @requires_gl30 No form of indexed buffer binding is available in + * OpenGL 2.1, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @requires_gles30 No form of indexed buffer binding is available in + * OpenGL ES 2.0, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + */ + static void bind(Target target, UnsignedInt firstIndex, std::initializer_list buffers); + /** * @brief Copy one buffer to another * @param read %Buffer from which to read @@ -532,7 +764,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * Creates new OpenGL buffer. * @see @fn_gl{GenBuffers} */ - explicit Buffer(Target targetHint = Target::Array); + explicit Buffer(TargetHint targetHint = TargetHint::Array); + + /** + * @copybrief Buffer(TargetHint) + * @deprecated Use @ref Magnum::Buffer::Buffer(Magnum::Buffer::TargetHint) "Buffer(TargetHint)" + * instead. + */ + CORRADE_DEPRECATED("use Buffer(TargetHint) instead") explicit Buffer(Target targetHint): Buffer{static_cast(targetHint)} {} /** @brief Copying is not allowed */ Buffer(const Buffer&) = delete; @@ -591,7 +830,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { } /** @brief Target hint */ - Target targetHint() const { return _targetHint; } + TargetHint targetHint() const { return _targetHint; } /** * @brief Set target hint @@ -608,11 +847,65 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * http://www.opengl.org/wiki/Vertex_Specification#Index_buffers * ... damned GL state */ - Buffer& setTargetHint(Target hint) { + Buffer& setTargetHint(TargetHint hint) { _targetHint = hint; return *this; } + /** + * @copybrief setTargetHint(TargetHint) + * @deprecated Use @ref Magnum::Buffer::setTargetHint(Magnum::Buffer::TargetHint) "setTargetHint(TargetHint)" + * instead. + */ + CORRADE_DEPRECATED("use setTargetHint(TargetHint) instead") Buffer& setTargetHint(Target hint) { + return setTargetHint(static_cast(hint)); + } + + #ifndef MAGNUM_TARGET_GLES2 + /** + * @brief Bind buffer range to given binding index + * + * The @p index parameter must respect limits for given @p target. The + * @p offset parameter must respect alignment, which is 4 bytes for + * @ref Target::AtomicCounter and implementation-defined for other + * targets. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bind(Target, UnsignedInt, std::initializer_list>), + * @ref maxAtomicCounterBindings(), @ref maxShaderStorageBindings(), + * @ref maxUniformBindings(), @ref shaderStorageOffsetAlignment(), + * @ref uniformOffsetAlignment(), @fn_gl{BindBufferRange} + * @requires_gl30 No form of indexed buffer binding is available in + * OpenGL 2.1, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @requires_gles30 No form of indexed buffer binding is available in + * OpenGL ES 2.0, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @todo State tracking for indexed binding + */ + Buffer& bind(Target target, UnsignedInt index, GLintptr offset, GLsizeiptr size); + + /** + * @brief Bind buffer to given binding index + * + * The @p index parameter must respect limits for given @p target. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bind(Target, UnsignedInt, std::initializer_list), + * @ref maxAtomicCounterBindings(), @ref maxShaderStorageBindings(), + * @ref maxUniformBindings(), @fn_gl{BindBufferBase} + * @requires_gl30 No form of indexed buffer binding is available in + * OpenGL 2.1, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + * @requires_gles30 No form of indexed buffer binding is available in + * OpenGL ES 2.0, see particular @ref Magnum::Buffer::Target "Target" + * values for version requirements. + */ + Buffer& bind(Target target, UnsignedInt index); + #endif + /** * @brief %Buffer size * @@ -850,13 +1143,26 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #ifdef DOXYGEN_GENERATING_OUTPUT private: #endif - /* There should be no need to use these from user code */ - static void unbindInternal(Target target) { bindInternal(target, nullptr); } - void bindInternal(Target target) { bindInternal(target, this); } + /* There should be no need to use these from user code. Also it's a bit + unfortunate to have the parameter typed as TargetHint while in this + case it is no hint at all, but it allows to have cleaner public + binding API (just with short Target name) */ + static void unbindInternal(TargetHint target) { bindInternal(target, nullptr); } + void bindInternal(TargetHint target) { bindInternal(target, this); } private: - static void bindInternal(Target hint, Buffer* buffer); - Target MAGNUM_LOCAL bindSomewhereInternal(Target hint); + static void bindInternal(TargetHint hint, Buffer* buffer); + TargetHint MAGNUM_LOCAL bindSomewhereInternal(TargetHint hint); + + static void MAGNUM_LOCAL bindImplementationFallback(Target target, GLuint first, Containers::ArrayReference buffers); + #ifndef MAGNUM_TARGET_GLES + static void MAGNUM_LOCAL bindImplementationMulti(Target target, GLuint first, Containers::ArrayReference buffers); + #endif + + static void MAGNUM_LOCAL bindImplementationFallback(Target target, GLuint first, Containers::ArrayReference> buffers); + #ifndef MAGNUM_TARGET_GLES + static void MAGNUM_LOCAL bindImplementationMulti(Target target, GLuint first, Containers::ArrayReference> buffers); + #endif #ifndef MAGNUM_TARGET_GLES2 static void MAGNUM_LOCAL copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); @@ -924,7 +1230,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif GLuint _id; - Target _targetHint; + TargetHint _targetHint; #ifdef CORRADE_TARGET_NACL void* _mappedBuffer; #endif @@ -933,8 +1239,13 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags) +/** @debugoperatorclassenum{Magnum::Buffer,Magnum::Buffer::TargetHint} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::TargetHint value); + +#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_BUILD_DEPRECATED) /** @debugoperatorclassenum{Magnum::Buffer,Magnum::Buffer::Target} */ Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::Target value); +#endif inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, #ifdef CORRADE_TARGET_NACL diff --git a/src/Magnum/BufferImage.cpp b/src/Magnum/BufferImage.cpp index 38fa069a2..30556b7f6 100644 --- a/src/Magnum/BufferImage.cpp +++ b/src/Magnum/BufferImage.cpp @@ -28,11 +28,11 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES2 -template BufferImage::BufferImage(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data, BufferUsage usage): AbstractImage(format, type), _size(size), _buffer(Buffer::Target::PixelPack) { +template BufferImage::BufferImage(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data, BufferUsage usage): AbstractImage(format, type), _size(size), _buffer(Buffer::TargetHint::PixelPack) { _buffer.setData({data, dataSize(size)}, usage); } -template BufferImage::BufferImage(ColorFormat format, ColorType type): AbstractImage(format, type), _buffer(Buffer::Target::PixelPack) {} +template BufferImage::BufferImage(ColorFormat format, ColorType type): AbstractImage(format, type), _buffer(Buffer::TargetHint::PixelPack) {} template void BufferImage::setData(ColorFormat format, ColorType type, const VectorTypeFor& size, const void* data, BufferUsage usage) { _format = format; diff --git a/src/Magnum/DebugTools/ForceRenderer.cpp b/src/Magnum/DebugTools/ForceRenderer.cpp index e46a301ea..46a61e9b3 100644 --- a/src/Magnum/DebugTools/ForceRenderer.cpp +++ b/src/Magnum/DebugTools/ForceRenderer.cpp @@ -68,8 +68,8 @@ template ForceRenderer::ForceRenderer(SceneG if(mesh) return; /* Create the mesh */ - Buffer* vertexBuffer = new Buffer(Buffer::Target::Array); - Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray); + Buffer* vertexBuffer = new Buffer{Buffer::TargetHint::Array}; + Buffer* indexBuffer = new Buffer{Buffer::TargetHint::ElementArray}; vertexBuffer->setData(positions, BufferUsage::StaticDraw); ResourceManager::instance().set(this->vertexBuffer.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); diff --git a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp index 0258e6609..ce3eb0316 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp @@ -46,7 +46,7 @@ template void create(typename MeshData::Type template<> void create<2>(Trade::MeshData2D& data, Resource& meshResource, Resource& vertexBufferResource, Resource& indexBufferResource) { /* Vertex buffer */ - Buffer* buffer = new Buffer(Buffer::Target::Array); + Buffer* buffer = new Buffer{Buffer::TargetHint::Array}; buffer->setData(data.positions(0), BufferUsage::StaticDraw); ResourceManager::instance().set(vertexBufferResource.key(), buffer, ResourceDataState::Final, ResourcePolicy::Manual); @@ -65,7 +65,7 @@ template<> void create<2>(Trade::MeshData2D& data, Resource& meshResource, UnsignedInt indexStart, indexEnd; std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(data.indices()); - Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray); + Buffer* indexBuffer = new Buffer{Buffer::TargetHint::ElementArray}; indexBuffer->setData(indexData, BufferUsage::StaticDraw); mesh->setCount(data.indices().size()) .setIndexBuffer(*indexBuffer, 0, indexType, indexStart, indexEnd); @@ -78,7 +78,7 @@ template<> void create<2>(Trade::MeshData2D& data, Resource& meshResource, template<> void create<3>(Trade::MeshData3D& data, Resource& meshResource, Resource& vertexBufferResource, Resource& indexBufferResource) { /* Vertex buffer */ - Buffer* vertexBuffer = new Buffer(Buffer::Target::Array); + Buffer* vertexBuffer = new Buffer{Buffer::TargetHint::Array}; vertexBuffer->setData(data.positions(0), BufferUsage::StaticDraw); ResourceManager::instance().set(vertexBufferResource.key(), vertexBuffer, ResourceDataState::Final, ResourcePolicy::Manual); @@ -97,7 +97,7 @@ template<> void create<3>(Trade::MeshData3D& data, Resource& meshResource, UnsignedInt indexStart, indexEnd; std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(data.indices()); - Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray); + Buffer* indexBuffer = new Buffer{Buffer::TargetHint::ElementArray}; indexBuffer->setData(indexData, BufferUsage::StaticDraw); mesh->setCount(data.indices().size()) .setIndexBuffer(*indexBuffer, 0, indexType, indexStart, indexEnd); diff --git a/src/Magnum/DebugTools/ObjectRenderer.cpp b/src/Magnum/DebugTools/ObjectRenderer.cpp index d7be15cf6..75d2da791 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.cpp +++ b/src/Magnum/DebugTools/ObjectRenderer.cpp @@ -156,8 +156,8 @@ template ObjectRenderer::ObjectRenderer(Scen if(mesh) return; /* Create the mesh */ - Buffer* vertexBuffer = new Buffer(Buffer::Target::Array); - Buffer* indexBuffer = new Buffer(Buffer::Target::ElementArray); + Buffer* vertexBuffer = new Buffer{Buffer::TargetHint::Array}; + Buffer* indexBuffer = new Buffer{Buffer::TargetHint::ElementArray}; Mesh* mesh = new Mesh; vertexBuffer->setData(MeshTools::interleave(Renderer::positions, Renderer::colors), BufferUsage::StaticDraw); diff --git a/src/Magnum/Implementation/BufferState.cpp b/src/Magnum/Implementation/BufferState.cpp index 7d285ed78..12ea300ae 100644 --- a/src/Magnum/Implementation/BufferState.cpp +++ b/src/Magnum/Implementation/BufferState.cpp @@ -34,43 +34,43 @@ namespace Magnum { namespace Implementation { -const Buffer::Target BufferState::targetForIndex[] = { - Buffer::Target::Array, - Buffer::Target::ElementArray, +const Buffer::TargetHint BufferState::targetForIndex[] = { + Buffer::TargetHint::Array, + Buffer::TargetHint::ElementArray, #ifndef MAGNUM_TARGET_GLES2 - Buffer::Target::CopyRead, - Buffer::Target::CopyWrite, - Buffer::Target::PixelPack, - Buffer::Target::PixelUnpack, - Buffer::Target::TransformFeedback, - Buffer::Target::Uniform, - Buffer::Target::AtomicCounter, - Buffer::Target::DispatchIndirect, - Buffer::Target::DrawIndirect, - Buffer::Target::ShaderStorage, + Buffer::TargetHint::CopyRead, + Buffer::TargetHint::CopyWrite, + Buffer::TargetHint::PixelPack, + Buffer::TargetHint::PixelUnpack, + Buffer::TargetHint::TransformFeedback, + Buffer::TargetHint::Uniform, + Buffer::TargetHint::AtomicCounter, + Buffer::TargetHint::DispatchIndirect, + Buffer::TargetHint::DrawIndirect, + Buffer::TargetHint::ShaderStorage, #ifndef MAGNUM_TARGET_GLES - Buffer::Target::Texture + Buffer::TargetHint::Texture #endif #endif }; -std::size_t BufferState::indexForTarget(Buffer::Target target) { +std::size_t BufferState::indexForTarget(Buffer::TargetHint target) { switch(target) { - case Buffer::Target::Array: return 1; - case Buffer::Target::ElementArray: return 2; + case Buffer::TargetHint::Array: return 1; + case Buffer::TargetHint::ElementArray: return 2; #ifndef MAGNUM_TARGET_GLES2 - case Buffer::Target::CopyRead: return 3; - case Buffer::Target::CopyWrite: return 4; - case Buffer::Target::PixelPack: return 5; - case Buffer::Target::PixelUnpack: return 6; - case Buffer::Target::TransformFeedback: return 7; - case Buffer::Target::Uniform: return 8; - case Buffer::Target::AtomicCounter: return 9; - case Buffer::Target::DispatchIndirect: return 10; - case Buffer::Target::DrawIndirect: return 11; - case Buffer::Target::ShaderStorage: return 12; + case Buffer::TargetHint::CopyRead: return 3; + case Buffer::TargetHint::CopyWrite: return 4; + case Buffer::TargetHint::PixelPack: return 5; + case Buffer::TargetHint::PixelUnpack: return 6; + case Buffer::TargetHint::TransformFeedback: return 7; + case Buffer::TargetHint::Uniform: return 8; + case Buffer::TargetHint::AtomicCounter: return 9; + case Buffer::TargetHint::DispatchIndirect: return 10; + case Buffer::TargetHint::DrawIndirect: return 11; + case Buffer::TargetHint::ShaderStorage: return 12; #ifndef MAGNUM_TARGET_GLES - case Buffer::Target::Texture: return 13; + case Buffer::TargetHint::Texture: return 13; #endif #endif } @@ -130,6 +130,21 @@ BufferState::BufferState(Context& context, std::vector& extensions) invalidateSubImplementation = &Buffer::invalidateSubImplementationNoOp; } + #ifndef MAGNUM_TARGET_GLES2 + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::multi_bind::string()); + + bindBasesImplementation = &Buffer::bindImplementationMulti; + bindRangesImplementation = &Buffer::bindImplementationMulti; + } else + #endif + { + bindBasesImplementation = &Buffer::bindImplementationFallback; + bindRangesImplementation = &Buffer::bindImplementationFallback; + } + #endif + #ifdef MAGNUM_TARGET_GLES static_cast(context); static_cast(extensions); diff --git a/src/Magnum/Implementation/BufferState.h b/src/Magnum/Implementation/BufferState.h index 38d9e101e..41a8dc908 100644 --- a/src/Magnum/Implementation/BufferState.h +++ b/src/Magnum/Implementation/BufferState.h @@ -39,14 +39,16 @@ struct BufferState { #endif /* Target <-> index mapping */ - static std::size_t indexForTarget(Buffer::Target target); - static const Buffer::Target targetForIndex[TargetCount-1]; + static std::size_t indexForTarget(Buffer::TargetHint target); + static const Buffer::TargetHint targetForIndex[TargetCount-1]; explicit BufferState(Context& context, std::vector& extensions); void reset(); #ifndef MAGNUM_TARGET_GLES2 + void(*bindBasesImplementation)(Buffer::Target, UnsignedInt, Containers::ArrayReference); + void(*bindRangesImplementation)(Buffer::Target, UnsignedInt, Containers::ArrayReference>); void(*copyImplementation)(Buffer&, Buffer&, GLintptr, GLintptr, GLsizeiptr); #endif void(Buffer::*getParameterImplementation)(GLenum, GLint*); diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index b530fc704..e14d72d21 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -392,7 +392,7 @@ void Mesh::attributePointerImplementationDSA(const Attribute& attribute) { void Mesh::vertexAttribPointer(const Attribute& attribute) { glEnableVertexAttribArray(attribute.location); - attribute.buffer->bindInternal(Buffer::Target::Array); + attribute.buffer->bindInternal(Buffer::TargetHint::Array); glVertexAttribPointer(attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, reinterpret_cast(attribute.offset)); if(attribute.divisor) { #ifndef MAGNUM_TARGET_GLES2 @@ -428,7 +428,7 @@ void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute) void Mesh::vertexAttribPointer(const IntegerAttribute& attribute) { glEnableVertexAttribArray(attribute.location); - attribute.buffer->bindInternal(Buffer::Target::Array); + attribute.buffer->bindInternal(Buffer::TargetHint::Array); glVertexAttribIPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); if(attribute.divisor) glVertexAttribDivisor(attribute.location, attribute.divisor); } @@ -457,7 +457,7 @@ void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) { void Mesh::vertexAttribPointer(const LongAttribute& attribute) { glEnableVertexAttribArray(attribute.location); - attribute.buffer->bindInternal(Buffer::Target::Array); + attribute.buffer->bindInternal(Buffer::TargetHint::Array); glVertexAttribLPointer(attribute.location, attribute.size, attribute.type, attribute.stride, reinterpret_cast(attribute.offset)); if(attribute.divisor) glVertexAttribDivisor(attribute.location, attribute.divisor); } @@ -502,9 +502,9 @@ void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { /* Reset ElementArray binding to force explicit glBindBuffer call later */ /** @todo Do this cleaner way */ - Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::Target::ElementArray)] = 0; + Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::TargetHint::ElementArray)] = 0; - buffer.bindInternal(Buffer::Target::ElementArray); + buffer.bindInternal(Buffer::TargetHint::ElementArray); } void Mesh::bindImplementationDefault() { @@ -523,7 +523,7 @@ void Mesh::bindImplementationDefault() { #endif /* Bind index buffer, if the mesh is indexed */ - if(_indexBuffer) _indexBuffer->bindInternal(Buffer::Target::ElementArray); + if(_indexBuffer) _indexBuffer->bindInternal(Buffer::TargetHint::ElementArray); } void Mesh::bindImplementationVAO() { diff --git a/src/Magnum/MeshTools/Compile.cpp b/src/Magnum/MeshTools/Compile.cpp index 4f0c979d4..adc585a6d 100644 --- a/src/Magnum/MeshTools/Compile.cpp +++ b/src/Magnum/MeshTools/Compile.cpp @@ -49,7 +49,7 @@ std::tuple, std::unique_ptr> compile(const stride += sizeof(Shaders::Generic2D::TextureCoordinates::Type); /* Create vertex buffer */ - std::unique_ptr vertexBuffer{new Buffer{Buffer::Target::Array}}; + std::unique_ptr vertexBuffer{new Buffer{Buffer::TargetHint::Array}}; /* Interleave positions */ Containers::Array data = MeshTools::interleave( @@ -82,7 +82,7 @@ std::tuple, std::unique_ptr> compile(const UnsignedInt indexStart, indexEnd; std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(meshData.indices()); - indexBuffer.reset(new Buffer{Buffer::Target::ElementArray}); + indexBuffer.reset(new Buffer{Buffer::TargetHint::ElementArray}); indexBuffer->setData(indexData, usage); mesh.setCount(meshData.indices().size()) .setIndexBuffer(*indexBuffer, 0, indexType, indexStart, indexEnd); @@ -109,7 +109,7 @@ std::tuple, std::unique_ptr> compile(const stride += sizeof(Shaders::Generic3D::TextureCoordinates::Type); /* Create vertex buffer */ - std::unique_ptr vertexBuffer{new Buffer{Buffer::Target::Array}}; + std::unique_ptr vertexBuffer{new Buffer{Buffer::TargetHint::Array}}; /* Interleave positions */ Containers::Array data = MeshTools::interleave( @@ -154,7 +154,7 @@ std::tuple, std::unique_ptr> compile(const UnsignedInt indexStart, indexEnd; std::tie(indexData, indexType, indexStart, indexEnd) = MeshTools::compressIndices(meshData.indices()); - indexBuffer.reset(new Buffer{Buffer::Target::ElementArray}); + indexBuffer.reset(new Buffer{Buffer::TargetHint::ElementArray}); indexBuffer->setData(indexData, usage); mesh.setCount(meshData.indices().size()) .setIndexBuffer(*indexBuffer, 0, indexType, indexStart, indexEnd); diff --git a/src/Magnum/Test/BufferGLTest.cpp b/src/Magnum/Test/BufferGLTest.cpp index f6ffb3220..495cd8059 100644 --- a/src/Magnum/Test/BufferGLTest.cpp +++ b/src/Magnum/Test/BufferGLTest.cpp @@ -43,6 +43,12 @@ class BufferGLTest: public AbstractOpenGLTester { void constructMove(); void label(); + + #ifndef MAGNUM_TARGET_GLES2 + void bindBase(); + void bindRange(); + #endif + void data(); void map(); #ifdef MAGNUM_TARGET_GLES2 @@ -60,7 +66,14 @@ BufferGLTest::BufferGLTest() { addTests({&BufferGLTest::construct, &BufferGLTest::constructCopy, &BufferGLTest::constructMove, + &BufferGLTest::label, + + #ifndef MAGNUM_TARGET_GLES2 + &BufferGLTest::bindBase, + &BufferGLTest::bindRange, + #endif + &BufferGLTest::data, &BufferGLTest::map, #ifdef MAGNUM_TARGET_GLES2 @@ -80,7 +93,7 @@ void BufferGLTest::construct() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(buffer.id() > 0); - CORRADE_COMPARE(buffer.targetHint(), Buffer::Target::Array); + CORRADE_COMPARE(buffer.targetHint(), Buffer::TargetHint::Array); CORRADE_COMPARE(buffer.size(), 0); } @@ -131,6 +144,55 @@ void BufferGLTest::label() { CORRADE_COMPARE(buffer.label(), "MyBuffer"); } +#ifndef MAGNUM_TARGET_GLES2 +void BufferGLTest::bindBase() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::uniform_buffer_object::string() + std::string{" is not supported."}); + #endif + + Buffer buffer; + buffer.bind(Buffer::Target::Uniform, 15); + + MAGNUM_VERIFY_NO_ERROR(); + + Buffer::unbind(Buffer::Target::Uniform, 15); + + MAGNUM_VERIFY_NO_ERROR(); + + Buffer::bind(Buffer::Target::Uniform, 7, {&buffer, nullptr, &buffer}); + + MAGNUM_VERIFY_NO_ERROR(); + + Buffer::unbind(Buffer::Target::Uniform, 7, 3); + + MAGNUM_VERIFY_NO_ERROR(); +} + +void BufferGLTest::bindRange() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::uniform_buffer_object::string() + std::string{" is not supported."}); + #endif + + /* Check that we have correct offset alignment */ + CORRADE_INTERNAL_ASSERT(256 % Buffer::uniformOffsetAlignment() == 0); + + Buffer buffer; + buffer.setData({nullptr, 1024}, BufferUsage::StaticDraw) + .bind(Buffer::Target::Uniform, 15, 256, 13); + + MAGNUM_VERIFY_NO_ERROR(); + + /** @todo C++14: get rid of std::make_tuple */ + Buffer::bind(Buffer::Target::Uniform, 7, { + std::make_tuple(&buffer, 256, 13), {}, + std::make_tuple(&buffer, 768, 64)}); + + MAGNUM_VERIFY_NO_ERROR(); +} +#endif + void BufferGLTest::data() { Buffer buffer; diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 603b3501a..51bbf2764 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -1262,7 +1262,7 @@ void MeshGLTest::setIndexBuffer() { vertices.setData(indexedVertexData, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1289,7 +1289,7 @@ void MeshGLTest::setIndexBufferRange() { vertices.setData(indexedVertexData, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1321,7 +1321,7 @@ void MeshGLTest::setIndexBufferUnsignedInt() { vertices.setData(indexedVertexData, BufferUsage::StaticDraw); constexpr UnsignedInt indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1352,7 +1352,7 @@ void MeshGLTest::setBaseVertex() { vertices.setData(indexedVertexDataBaseVertex, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1428,7 +1428,7 @@ void MeshGLTest::setInstanceCountIndexed() { vertices.setData(indexedVertexData, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1500,7 +1500,7 @@ void MeshGLTest::setInstanceCountBaseInstanceIndexed() { vertices.setData(indexedVertexData, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1534,7 +1534,7 @@ void MeshGLTest::setInstanceCountBaseVertex() { vertices.setData(indexedVertexDataBaseVertex, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1570,7 +1570,7 @@ void MeshGLTest::setInstanceCountBaseVertexBaseInstance() { vertices.setData(indexedVertexDataBaseVertex, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1788,7 +1788,7 @@ void MeshGLTest::multiDrawIndexed() { vertices.setData(indexedVertexData, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; @@ -1813,7 +1813,7 @@ void MeshGLTest::multiDrawBaseVertex() { vertices.setData(indexedVertexDataBaseVertex, BufferUsage::StaticDraw); constexpr UnsignedShort indexData[] = { 2, 1, 0 }; - Buffer indices(Buffer::Target::ElementArray); + Buffer indices{Buffer::TargetHint::ElementArray}; indices.setData(indexData, BufferUsage::StaticDraw); Mesh mesh; diff --git a/src/Magnum/Text/Renderer.cpp b/src/Magnum/Text/Renderer.cpp index ed767bca0..77ba77b7d 100644 --- a/src/Magnum/Text/Renderer.cpp +++ b/src/Magnum/Text/Renderer.cpp @@ -301,7 +301,7 @@ void AbstractRenderer::bufferUnmapImplementationDefault(Buffer& buffer) #endif } -AbstractRenderer::AbstractRenderer(AbstractFont& font, const GlyphCache& cache, const Float size, const Alignment alignment): _vertexBuffer(Buffer::Target::Array), _indexBuffer(Buffer::Target::ElementArray), font(font), cache(cache), size(size), _alignment(alignment), _capacity(0) { +AbstractRenderer::AbstractRenderer(AbstractFont& font, const GlyphCache& cache, const Float size, const Alignment alignment): _vertexBuffer{Buffer::TargetHint::Array}, _indexBuffer{Buffer::TargetHint::ElementArray}, font(font), cache(cache), size(size), _alignment(alignment), _capacity(0) { #ifndef MAGNUM_TARGET_GLES MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::map_buffer_range); #elif defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN) From 4b30beaba1610fb8ddda0e4eb7390e90827c9e53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 13:25:34 +0200 Subject: [PATCH 39/72] Apparently NVidia drivers don't accept zero size in glBindBuffersRange(). Why should I specify non-zero size for zero buffer ID? --- src/Magnum/Buffer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 4529c0290..950cfab21 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -387,7 +387,9 @@ void Buffer::bindImplementationMulti(const Target target, const GLuint firstInde std::tie(std::ignore, offsetsSizes[i], offsetsSizes[buffers.size() + i]) = buffers[i]; } else { ids[i] = 0; - offsetsSizes[i] = offsetsSizes[buffers.size() + i] = 0; + offsetsSizes[i] = 0; + /** @todo fix workaround when NVidia 343.13 accepts zero sizes */ + offsetsSizes[buffers.size() + i] = 1; } } From b75d26be7bfd62ec154ad89bc1197570f433656f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 13:52:56 +0200 Subject: [PATCH 40/72] Fix non-deprecated build. --- src/Magnum/Buffer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 200b185cd..f2270afd6 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -766,12 +766,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { */ explicit Buffer(TargetHint targetHint = TargetHint::Array); + #ifdef MAGNUM_BUILD_DEPRECATED /** * @copybrief Buffer(TargetHint) * @deprecated Use @ref Magnum::Buffer::Buffer(Magnum::Buffer::TargetHint) "Buffer(TargetHint)" * instead. */ CORRADE_DEPRECATED("use Buffer(TargetHint) instead") explicit Buffer(Target targetHint): Buffer{static_cast(targetHint)} {} + #endif /** @brief Copying is not allowed */ Buffer(const Buffer&) = delete; @@ -852,6 +854,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { return *this; } + #ifdef MAGNUM_BUILD_DEPRECATED /** * @copybrief setTargetHint(TargetHint) * @deprecated Use @ref Magnum::Buffer::setTargetHint(Magnum::Buffer::TargetHint) "setTargetHint(TargetHint)" @@ -860,6 +863,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { CORRADE_DEPRECATED("use setTargetHint(TargetHint) instead") Buffer& setTargetHint(Target hint) { return setTargetHint(static_cast(hint)); } + #endif #ifndef MAGNUM_TARGET_GLES2 /** From 9a0ebae1d55ff270e50f591ce67ffe950a6df00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Aug 2014 13:58:15 +0200 Subject: [PATCH 41/72] Fix non-deprecated ES2 build. Thanks, Jenkins (again). --- src/Magnum/Buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index f2270afd6..3e16a3b4a 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -1158,6 +1158,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { static void bindInternal(TargetHint hint, Buffer* buffer); TargetHint MAGNUM_LOCAL bindSomewhereInternal(TargetHint hint); + #ifndef MAGNUM_TARGET_GLES2 static void MAGNUM_LOCAL bindImplementationFallback(Target target, GLuint first, Containers::ArrayReference buffers); #ifndef MAGNUM_TARGET_GLES static void MAGNUM_LOCAL bindImplementationMulti(Target target, GLuint first, Containers::ArrayReference buffers); @@ -1168,7 +1169,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { static void MAGNUM_LOCAL bindImplementationMulti(Target target, GLuint first, Containers::ArrayReference> buffers); #endif - #ifndef MAGNUM_TARGET_GLES2 static void MAGNUM_LOCAL copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #ifndef MAGNUM_TARGET_GLES static void MAGNUM_LOCAL copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); From fca7facd6dcab7bcaf9795eb5f350af1cc866652 Mon Sep 17 00:00:00 2001 From: Siim Kallas Date: Mon, 1 Sep 2014 19:44:26 +0300 Subject: [PATCH 42/72] Switched SDL2 application's wheel direction --- src/Magnum/Platform/Sdl2Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index b2b4a5794..be70f2b9f 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -271,7 +271,7 @@ void Sdl2Application::mainLoop() { case SDL_MOUSEWHEEL: if(event.wheel.y != 0) { - MouseEvent e(event.wheel.y < 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}); + MouseEvent e(event.wheel.y > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {event.wheel.x, event.wheel.y}); mousePressEvent(e); } break; From a5c2efc8c0a29349962e4b3eac5fe490f5f5115d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 7 Sep 2014 21:17:40 +0200 Subject: [PATCH 43/72] Support glProgramUniform*() calls from OpenGL ES 3.1. The code both supports new features *and* is shorter, yay! --- src/Magnum/AbstractShaderProgram.cpp | 310 +++++------------- src/Magnum/AbstractShaderProgram.h | 112 ++++--- .../Implementation/ShaderProgramState.cpp | 103 +++--- 3 files changed, 214 insertions(+), 311 deletions(-) diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 43d636f75..5a5c6e8c5 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -394,10 +394,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform1fv(location, count, values); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const GLfloat* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform1fv(_id, location, count, values); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLfloat* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform1fvEXT(_id, location, count, values); #else static_cast(location); @@ -407,12 +411,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const GLfloat* const values) { - glProgramUniform1fvEXT(_id, location, count, values); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniform2fvImplementation)(location, count, values); } @@ -422,10 +420,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform2fv(location, count, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform2fv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform2fvEXT(_id, location, count, values[0].data()); #else static_cast(location); @@ -435,12 +437,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { - glProgramUniform2fvEXT(_id, location, count, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniform3fvImplementation)(location, count, values); } @@ -450,10 +446,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform3fv(location, count, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform3fv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform3fvEXT(_id, location, count, values[0].data()); #else static_cast(location); @@ -463,12 +463,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { - glProgramUniform3fvEXT(_id, location, count, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniform4fvImplementation)(location, count, values); } @@ -478,10 +472,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform4fv(location, count, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform4fv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform4fvEXT(_id, location, count, values[0].data()); #else static_cast(location); @@ -491,12 +489,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { - glProgramUniform4fvEXT(_id, location, count, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Int* const values) { (this->*Context::current()->state().shaderProgram->uniform1ivImplementation)(location, count, values); } @@ -506,10 +498,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform1iv(location, count, values); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const GLint* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform1iv(_id, location, count, values); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLint* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform1ivEXT(_id, location, count, values); #else static_cast(location); @@ -519,12 +515,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const GLint* const values) { - glProgramUniform1ivEXT(_id, location, count, values); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, Int>* const values) { (this->*Context::current()->state().shaderProgram->uniform2ivImplementation)(location, count, values); } @@ -534,10 +524,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform2iv(location, count, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform2iv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform2ivEXT(_id, location, count, values[0].data()); #else static_cast(location); @@ -547,12 +541,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { - glProgramUniform2ivEXT(_id, location, count, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, Int>* const values) { (this->*Context::current()->state().shaderProgram->uniform3ivImplementation)(location, count, values); } @@ -562,10 +550,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform3iv(location, count, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform3iv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform3ivEXT(_id, location, count, values[0].data()); #else static_cast(location); @@ -575,12 +567,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { - glProgramUniform3ivEXT(_id, location, count, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, Int>* const values) { (this->*Context::current()->state().shaderProgram->uniform4ivImplementation)(location, count, values); } @@ -590,10 +576,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniform4iv(location, count, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform4iv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniform4ivEXT(_id, location, count, values[0].data()); #else static_cast(location); @@ -603,12 +593,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { - glProgramUniform4ivEXT(_id, location, count, values[0].data()); -} -#endif - #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const UnsignedInt* const values) { (this->*Context::current()->state().shaderProgram->uniform1uivImplementation)(location, count, values); @@ -620,23 +604,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const GLuint* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform1uiv(_id, location, count, values); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniform1uivEXT(_id, location, count, values); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const GLuint* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLuint* const values) { glProgramUniform1uivEXT(_id, location, count, values); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<2, UnsignedInt>* const values) { (this->*Context::current()->state().shaderProgram->uniform2uivImplementation)(location, count, values); @@ -648,23 +621,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform2uiv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniform2uivEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) { glProgramUniform2uivEXT(_id, location, count, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<3, UnsignedInt>* const values) { (this->*Context::current()->state().shaderProgram->uniform3uivImplementation)(location, count, values); @@ -676,23 +638,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform3uiv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniform3uivEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) { glProgramUniform3uivEXT(_id, location, count, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::Vector<4, UnsignedInt>* const values) { (this->*Context::current()->state().shaderProgram->uniform4uivImplementation)(location, count, values); @@ -704,24 +655,13 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniform4uiv(_id, location, count, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniform4uivEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) { glProgramUniform4uivEXT(_id, location, count, values[0].data()); } #endif -#endif #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Double* const values) { @@ -737,7 +677,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniform1dv(_id, location, count, values); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const GLdouble* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const GLdouble* const values) { glProgramUniform1dvEXT(_id, location, count, values); } @@ -754,7 +694,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniform2dv(_id, location, count, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<2, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLdouble>* const values) { glProgramUniform2dvEXT(_id, location, count, values[0].data()); } @@ -771,7 +711,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniform3dv(_id, location, count, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<3, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLdouble>* const values) { glProgramUniform3dvEXT(_id, location, count, values[0].data()); } @@ -788,7 +728,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniform4dv(_id, location, count, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::Vector<4, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLdouble>* const values) { glProgramUniform4dvEXT(_id, location, count, values[0].data()); } #endif @@ -802,10 +742,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniformMatrix2fv(location, count, GL_FALSE, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix2fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniformMatrix2fvEXT(_id, location, count, GL_FALSE, values[0].data()); #else static_cast(location); @@ -815,12 +759,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { - glProgramUniformMatrix2fvEXT(_id, location, count, GL_FALSE, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 3, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix3fvImplementation)(location, count, values); } @@ -830,10 +768,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniformMatrix3fv(location, count, GL_FALSE, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix3fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniformMatrix3fvEXT(_id, location, count, GL_FALSE, values[0].data()); #else static_cast(location); @@ -843,12 +785,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { - glProgramUniformMatrix3fvEXT(_id, location, count, GL_FALSE, values[0].data()); -} -#endif - void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 4, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix4fvImplementation)(location, count, values); } @@ -858,10 +794,14 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c glUniformMatrix4fv(location, count, GL_FALSE, values[0].data()); } +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix4fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) +} +#endif + +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniformMatrix4fvEXT(_id, location, count, GL_FALSE, values[0].data()); #else static_cast(location); @@ -871,12 +811,6 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { - glProgramUniformMatrix4fvEXT(_id, location, count, GL_FALSE, values[0].data()); -} -#endif - #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 3, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix2x3fvImplementation)(location, count, values); @@ -888,23 +822,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix2x3fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniformMatrix2x3fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) { glProgramUniformMatrix2x3fvEXT(_id, location, count, GL_FALSE, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 2, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix3x2fvImplementation)(location, count, values); @@ -916,23 +839,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES - glProgramUniformMatrix3x2fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) glProgramUniformMatrix3x2fv(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) { glProgramUniformMatrix3x2fvEXT(_id, location, count, GL_FALSE, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 4, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix2x4fvImplementation)(location, count, values); @@ -944,23 +856,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix2x4fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniformMatrix2x4fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) { glProgramUniformMatrix2x4fvEXT(_id, location, count, GL_FALSE, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 2, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix4x2fvImplementation)(location, count, values); @@ -972,23 +873,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix4x2fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniformMatrix4x2fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) { glProgramUniformMatrix4x2fvEXT(_id, location, count, GL_FALSE, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<3, 4, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix3x4fvImplementation)(location, count, values); @@ -1000,23 +890,12 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix3x4fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniformMatrix3x4fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) { glProgramUniformMatrix3x4fvEXT(_id, location, count, GL_FALSE, values[0].data()); } -#endif void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<4, 3, Float>* const values) { (this->*Context::current()->state().shaderProgram->uniformMatrix4x3fvImplementation)(location, count, values); @@ -1028,24 +907,13 @@ void AbstractShaderProgram::uniformImplementationDefault(const GLint location, c } void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) { - #ifndef MAGNUM_TARGET_GLES glProgramUniformMatrix4x3fv(_id, location, count, GL_FALSE, values[0].data()); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) - glProgramUniformMatrix4x3fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); - #endif } -#ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) { glProgramUniformMatrix4x3fvEXT(_id, location, count, GL_FALSE, values[0].data()); } #endif -#endif #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::setUniform(const Int location, const UnsignedInt count, const Math::RectangularMatrix<2, 2, Double>* const values) { @@ -1061,7 +929,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix2dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* const values) { glProgramUniformMatrix2dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1078,7 +946,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix3dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* const values) { glProgramUniformMatrix3dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1095,7 +963,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix4dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* const values) { glProgramUniformMatrix4dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1112,7 +980,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix2x3dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* const values) { glProgramUniformMatrix2x3dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1129,7 +997,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix3x2dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* const values) { glProgramUniformMatrix3x2dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1146,7 +1014,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix2x4dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* const values) { glProgramUniformMatrix2x4dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1163,7 +1031,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix4x2dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* const values) { glProgramUniformMatrix4x2dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1180,7 +1048,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix3x4dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* const values) { glProgramUniformMatrix3x4dvEXT(_id, location, count, GL_FALSE, values[0].data()); } @@ -1197,7 +1065,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const glProgramUniformMatrix4x3dv(_id, location, count, GL_FALSE, values[0].data()); } -void AbstractShaderProgram::uniformImplementationDSA(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* const values) { +void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* const values) { glProgramUniformMatrix4x3dvEXT(_id, location, count, GL_FALSE, values[0].data()); } #endif diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index bb7c14d4b..b9305c99a 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -319,10 +319,10 @@ also @ref Attribute::DataType enum for additional type options. queries don't result in repeated @fn_gl{Get} calls. If extension @extension{ARB,separate_shader_objects} (part of OpenGL 4.1), -@extension{EXT,direct_state_access} or @es_extension{EXT,separate_shader_objects} -on OpenGL ES is available, uniform setting functions use DSA functions to avoid -unnecessary calls to @fn_gl{UseProgram}. See @ref setUniform() documentation -for more information. +@extension{EXT,direct_state_access} desktop extension, @es_extension{EXT,separate_shader_objects} +OpenGL ES extension or OpenGL ES 3.1 is available, uniform setting functions +use DSA functions to avoid unnecessary calls to @fn_gl{UseProgram}. See +@ref setUniform() documentation for more information. To achieve least state changes, set all uniforms in one run -- method chaining comes in handy. @@ -779,9 +779,10 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @param values Values * * If neither @extension{ARB,separate_shader_objects} (part of OpenGL - * 4.1) nor @extension{EXT,direct_state_access} nor - * @es_extension{EXT,separate_shader_objects} (on OpenGL ES) is - * available, the shader is marked for use before the operation. + * 4.1) nor @extension{EXT,direct_state_access} desktop extension nor + * @es_extension{EXT,separate_shader_objects} OpenGL ES extension nor + * OpenGL ES 3.1 is available, the shader is marked for use before the + * operation. * @see @ref setUniform(Int, const T&), @fn_gl{UseProgram}, @fn_gl{Uniform} * or @fn_gl{ProgramUniform}/@fn_gl_extension{ProgramUniform,EXT,direct_state_access}. */ @@ -866,6 +867,27 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void use(); #endif + /* + Currently, there are four supported ways to call glProgramUniform(): + + - EXT_direct_state_access (desktop GL only, EXT suffix) + - EXT_separate_shader_objects (OpenGL ES extension, EXT suffix) + - ARB_separate_shader_objects (desktop GL only, no suffix) + - OpenGL ES 3.1, no suffix + + To avoid copypasta and filesize bloat, this is merged to just two + variants of implementation functions: + + - uniformImplementationSSO() - functions without suffix, used if + ARB_separate_shader_objects desktop extension or OpenGL ES 3.1 + is available, completely disabled for ES2 + - uniformImplementationDSAEXT_SSOEXT() / uniformImplementationDSAEXT() -- + functions with EXT suffix, used if EXT_direct_state_access + desktop exttension or EXT_separate_shader_objects ES 2.0 / ES 3.0 + extension is available, functions which don't have equivalents + on ES (double arguments) don't have the _SSOEXT suffix + */ + void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const GLfloat* values); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::Vector<2, GLfloat>* values); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::Vector<3, GLfloat>* values); @@ -886,6 +908,7 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::Vector<3, GLdouble>* values); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::Vector<4, GLdouble>* values); #endif + #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const GLfloat* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<2, GLfloat>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<3, GLfloat>* values); @@ -894,7 +917,6 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<2, GLint>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<3, GLint>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<4, GLint>* values); - #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const GLuint* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<2, GLuint>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<3, GLuint>* values); @@ -906,23 +928,25 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<3, GLdouble>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::Vector<4, GLdouble>* values); #endif + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const GLfloat* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<2, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<3, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<4, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const GLint* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<2, GLint>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<3, GLint>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<4, GLint>* values); + #ifndef MAGNUM_TARGET_GLES2 + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const GLuint* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<2, GLuint>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<3, GLuint>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::Vector<4, GLuint>* values); + #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const GLfloat* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<2, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<3, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<4, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const GLint* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<2, GLint>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<3, GLint>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<4, GLint>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const GLuint* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<2, GLuint>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<3, GLuint>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<4, GLuint>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const GLdouble* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<2, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<3, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::Vector<4, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const GLdouble* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::Vector<2, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::Vector<3, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::Vector<4, GLdouble>* values); #endif void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* values); @@ -947,10 +971,10 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* values); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* values); #endif + #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* values); - #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* values); @@ -969,25 +993,27 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* values); void MAGNUM_LOCAL uniformImplementationSSO(GLint location, GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* values); #endif + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* values); + #ifndef MAGNUM_TARGET_GLES2 + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT_SSOEXT(GLint location, GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* values); + #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* values); - void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* values); + void MAGNUM_LOCAL uniformImplementationDSAEXT(GLint location, GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* values); #endif GLuint _id; diff --git a/src/Magnum/Implementation/ShaderProgramState.cpp b/src/Magnum/Implementation/ShaderProgramState.cpp index 37fc7aa32..e55a22313 100644 --- a/src/Magnum/Implementation/ShaderProgramState.cpp +++ b/src/Magnum/Implementation/ShaderProgramState.cpp @@ -41,16 +41,15 @@ ShaderProgramState::ShaderProgramState(Context& context, std::vector()) #else - if(context.isExtensionSupported()) + if(context.isVersionSupported(Version::GLES310)) #endif { #ifndef MAGNUM_TARGET_GLES extensions.push_back(Extensions::GL::ARB::separate_shader_objects::string()); - #else - extensions.push_back(Extensions::GL::EXT::separate_shader_objects::string()); #endif uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationSSO; @@ -61,12 +60,10 @@ ShaderProgramState::ShaderProgramState(Context& context, std::vector()) { + if(context.isExtensionSupported()) + #else + if(context.isExtensionSupported()) + #endif + { + #ifndef MAGNUM_TARGET_GLES extensions.push_back(Extensions::GL::EXT::direct_state_access::string()); + #else + extensions.push_back(Extensions::GL::EXT::separate_shader_objects::string()); + #endif - uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform3fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform4fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform1ivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform2ivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform3ivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform4ivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform1uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform2uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform3uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform4uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform1dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniform4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - - uniformMatrix2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix3fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix4fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix2x3fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix3x2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix2x4fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix4x2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix3x4fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix4x3fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix2x3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix3x2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix2x4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix4x2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix3x4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - uniformMatrix4x3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - } - #endif + uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform3fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform4fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform1ivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform2ivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform3ivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform4ivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + #ifndef MAGNUM_TARGET_GLES2 + uniform1uivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform2uivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform3uivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniform4uivImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + #endif + #ifndef MAGNUM_TARGET_GLES + uniform1dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniform2dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniform3dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniform4dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + #endif - else { + uniformMatrix2fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix3fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix4fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + #ifndef MAGNUM_TARGET_GLES2 + uniformMatrix2x3fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix3x2fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix2x4fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix4x2fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix3x4fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + uniformMatrix4x3fvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT; + #endif + #ifndef MAGNUM_TARGET_GLES + uniformMatrix2dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix3dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix4dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix2x3dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix3x2dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix2x4dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix4x2dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix3x4dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + uniformMatrix4x3dvImplementation = &AbstractShaderProgram::uniformImplementationDSAEXT; + #endif + } else { uniform1fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; uniform2fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; uniform3fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; From b251b1b0c5a4cf1ca707f56427eb6b397fc2db25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 7 Sep 2014 22:20:21 +0200 Subject: [PATCH 44/72] Mark also all GL 4.5 extensions as supported if GL 4.5 is supported. Oh god, it got to the point where I should write an HOWTO *for myself*. --- src/Magnum/Context.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 81d8d783e..0add782d0 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -408,6 +408,7 @@ Context::Context(void functionLoader()) { Version::GL420, Version::GL430, Version::GL440, + Version::GL450, #else Version::GLES200, Version::GLES300, From b0741493f9a50d0e4fa15035e1bb9e568ecc0279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 7 Sep 2014 21:55:35 +0200 Subject: [PATCH 45/72] Preparation for ARB_direct_state_access GL 4.5 feature. Renamed all EXT_direct_state_access implementations to reflect the fact that these aren't using the ARB extension. --- src/Magnum/AbstractFramebuffer.cpp | 8 +-- src/Magnum/AbstractFramebuffer.h | 8 +-- src/Magnum/AbstractTexture.cpp | 44 ++++++++-------- src/Magnum/AbstractTexture.h | 44 ++++++++-------- src/Magnum/Buffer.cpp | 18 +++---- src/Magnum/Buffer.h | 18 +++---- src/Magnum/BufferTexture.cpp | 4 +- src/Magnum/BufferTexture.h | 4 +- src/Magnum/Framebuffer.cpp | 8 +-- src/Magnum/Framebuffer.h | 8 +-- src/Magnum/Implementation/BufferState.cpp | 18 +++---- .../Implementation/FramebufferState.cpp | 20 ++++---- src/Magnum/Implementation/MeshState.cpp | 6 +-- src/Magnum/Implementation/TextureState.cpp | 50 +++++++++---------- src/Magnum/Mesh.cpp | 6 +-- src/Magnum/Mesh.h | 6 +-- src/Magnum/Renderbuffer.cpp | 4 +- src/Magnum/Renderbuffer.h | 4 +- 18 files changed, 139 insertions(+), 139 deletions(-) diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index fcc26147d..80477b214 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -270,7 +270,7 @@ GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTa } #ifndef MAGNUM_TARGET_GLES -GLenum AbstractFramebuffer::checkStatusImplementationDSA(const FramebufferTarget target) { +GLenum AbstractFramebuffer::checkStatusImplementationDSAEXT(const FramebufferTarget target) { _created = true; return glCheckNamedFramebufferStatusEXT(_id, GLenum(target)); } @@ -295,7 +295,7 @@ void AbstractFramebuffer::drawBuffersImplementationDefault(GLsizei count, const } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::drawBuffersImplementationDSA(GLsizei count, const GLenum* buffers) { +void AbstractFramebuffer::drawBuffersImplementationDSAEXT(GLsizei count, const GLenum* buffers) { _created = true; glFramebufferDrawBuffersEXT(_id, count, buffers); } @@ -321,7 +321,7 @@ void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) { } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::drawBufferImplementationDSA(GLenum buffer) { +void AbstractFramebuffer::drawBufferImplementationDSAEXT(GLenum buffer) { _created = true; glFramebufferDrawBufferEXT(_id, buffer); } @@ -345,7 +345,7 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) { } #ifndef MAGNUM_TARGET_GLES -void AbstractFramebuffer::readBufferImplementationDSA(GLenum buffer) { +void AbstractFramebuffer::readBufferImplementationDSAEXT(GLenum buffer) { _created = true; glFramebufferReadBufferEXT(_id, buffer); } diff --git a/src/Magnum/AbstractFramebuffer.h b/src/Magnum/AbstractFramebuffer.h index dea83a065..70d79403b 100644 --- a/src/Magnum/AbstractFramebuffer.h +++ b/src/Magnum/AbstractFramebuffer.h @@ -347,22 +347,22 @@ class MAGNUM_EXPORT AbstractFramebuffer { GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target); #ifndef MAGNUM_TARGET_GLES - GLenum MAGNUM_LOCAL checkStatusImplementationDSA(FramebufferTarget target); + GLenum MAGNUM_LOCAL checkStatusImplementationDSAEXT(FramebufferTarget target); #endif void MAGNUM_LOCAL drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL drawBuffersImplementationDSA(GLsizei count, const GLenum* buffers); + void MAGNUM_LOCAL drawBuffersImplementationDSAEXT(GLsizei count, const GLenum* buffers); #endif void MAGNUM_LOCAL drawBufferImplementationDefault(GLenum buffer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL drawBufferImplementationDSA(GLenum buffer); + void MAGNUM_LOCAL drawBufferImplementationDSAEXT(GLenum buffer); #endif void MAGNUM_LOCAL readBufferImplementationDefault(GLenum buffer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer); + void MAGNUM_LOCAL readBufferImplementationDSAEXT(GLenum buffer); #endif static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 912200142..a563911fc 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -143,7 +143,7 @@ void AbstractTexture::unbindImplementationMulti(const GLint textureUnit) { glBindTextures(textureUnit, 1, &zero); } -void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) { +void AbstractTexture::unbindImplementationDSAEXT(const GLint textureUnit) { Implementation::TextureState* const textureState = Context::current()->state().texture; CORRADE_INTERNAL_ASSERT(textureState->bindings[textureUnit].first != 0); @@ -261,7 +261,7 @@ void AbstractTexture::bindImplementationMulti(GLint textureUnit) { glBindTextures(textureUnit, 1, &_id); } -void AbstractTexture::bindImplementationDSA(GLint textureUnit) { +void AbstractTexture::bindImplementationDSAEXT(GLint textureUnit) { _created = true; glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, _id); } @@ -388,7 +388,7 @@ void AbstractTexture::mipmapImplementationDefault() { } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::mipmapImplementationDSA() { +void AbstractTexture::mipmapImplementationDSAEXT() { _created = true; glGenerateTextureMipmapEXT(_id, _target); } @@ -797,7 +797,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint val } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(GLenum parameter, GLint value) { +void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLint value) { _created = true; glTextureParameteriEXT(_id, _target, parameter, value); } @@ -809,7 +809,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLfloat v } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(GLenum parameter, GLfloat value) { +void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLfloat value) { _created = true; glTextureParameterfEXT(_id, _target, parameter, value); } @@ -822,7 +822,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLi } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLint* values) { +void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLint* values) { _created = true; glTextureParameterivEXT(_id, _target, parameter, values); } @@ -835,7 +835,7 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLf } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::parameterImplementationDSA(GLenum parameter, const GLfloat* values) { +void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLfloat* values) { _created = true; glTextureParameterfvEXT(_id, _target, parameter, values); } @@ -847,7 +847,7 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL glTexParameterIuiv(_target, parameter, values); } -void AbstractTexture::parameterIImplementationDSA(GLenum parameter, const GLuint* values) { +void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLuint* values) { _created = true; glTextureParameterIuivEXT(_id, _target, parameter, values); } @@ -857,7 +857,7 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL glTexParameterIiv(_target, parameter, values); } -void AbstractTexture::parameterIImplementationDSA(GLenum parameter, const GLint* values) { +void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLint* values) { _created = true; glTextureParameterIivEXT(_id, _target, parameter, values); } @@ -876,7 +876,7 @@ void AbstractTexture::getLevelParameterImplementationDefault(GLenum target, GLin } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values) { +void AbstractTexture::getLevelParameterImplementationDSAEXT(GLenum target, GLint level, GLenum parameter, GLint* values) { _created = true; glGetTextureLevelParameterivEXT(_id, target, level, parameter, values); } @@ -900,7 +900,7 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels glTexStorage1D(target, levels, GLenum(internalFormat), size[0]); } -void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { +void AbstractTexture::storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { _created = true; glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]); } @@ -961,7 +961,7 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { +void AbstractTexture::storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) { _created = true; glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y()); } @@ -1016,7 +1016,7 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { +void AbstractTexture::storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) { _created = true; glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); } @@ -1037,7 +1037,7 @@ void AbstractTexture::storageMultisampleImplementationDefault(const GLenum targe #endif #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::storageMultisampleImplementationDSA(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { +void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { _created = true; glTextureStorage2DMultisampleEXT(_id, target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); } @@ -1052,7 +1052,7 @@ void AbstractTexture::storageMultisampleImplementationDefault(const GLenum targe glTexStorage3DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } -void AbstractTexture::storageMultisampleImplementationDSA(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { +void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { _created = true; glTextureStorage3DMultisampleEXT(_id, target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } @@ -1064,7 +1064,7 @@ void AbstractTexture::getImageImplementationDefault(const GLenum target, const G glGetTexImage(target, level, GLenum(format), GLenum(type), data); } -void AbstractTexture::getImageImplementationDSA(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) { +void AbstractTexture::getImageImplementationDSAEXT(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) { _created = true; glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data); } @@ -1081,7 +1081,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex glTexImage1D(target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data); } -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { _created = true; glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data); } @@ -1093,7 +1093,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { _created = true; glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data); } @@ -1118,7 +1118,7 @@ void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, Tex } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { +void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { _created = true; glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data); } @@ -1130,7 +1130,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, glTexSubImage1D(target, level, offset[0], size[0], GLenum(format), GLenum(type), data); } -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSAEXT(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) { _created = true; glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], GLenum(format), GLenum(type), data); } @@ -1142,7 +1142,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSAEXT(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) { _created = true; glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } @@ -1167,7 +1167,7 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { +void AbstractTexture::subImageImplementationDSAEXT(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) { _created = true; glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); } diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 4f2308490..247bc6788 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -371,7 +371,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { static void MAGNUM_LOCAL unbindImplementationDefault(GLint textureUnit); #ifndef MAGNUM_TARGET_GLES static void MAGNUM_LOCAL unbindImplementationMulti(GLint textureUnit); - static void MAGNUM_LOCAL unbindImplementationDSA(GLint textureUnit); + static void MAGNUM_LOCAL unbindImplementationDSAEXT(GLint textureUnit); #endif static void MAGNUM_LOCAL bindImplementationFallback(GLint firstTextureUnit, Containers::ArrayReference textures); @@ -384,7 +384,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL bindImplementationMulti(GLint textureUnit); - void MAGNUM_LOCAL bindImplementationDSA(GLint textureUnit); + void MAGNUM_LOCAL bindImplementationDSAEXT(GLint textureUnit); #endif void MAGNUM_LOCAL parameterImplementationDefault(GLenum parameter, GLint value); @@ -398,12 +398,12 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL parameterIImplementationDefault(GLenum parameter, const GLint* values); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLint value); - void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLfloat value); - void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLint* values); - void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLfloat* values); - void MAGNUM_LOCAL parameterIImplementationDSA(GLenum parameter, const GLuint* values); - void MAGNUM_LOCAL parameterIImplementationDSA(GLenum parameter, const GLint* values); + void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, GLint value); + void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, GLfloat value); + void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, const GLint* values); + void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, const GLfloat* values); + void MAGNUM_LOCAL parameterIImplementationDSAEXT(GLenum parameter, const GLuint* values); + void MAGNUM_LOCAL parameterIImplementationDSAEXT(GLenum parameter, const GLint* values); #endif void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat); @@ -412,31 +412,31 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values); + void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLenum target, GLint level, GLenum parameter, GLint* values); #endif #endif void MAGNUM_LOCAL mipmapImplementationDefault(); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL mipmapImplementationDSA(); + void MAGNUM_LOCAL mipmapImplementationDSAEXT(); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); - void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); + void MAGNUM_LOCAL storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size); #endif void MAGNUM_LOCAL storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); + void MAGNUM_LOCAL storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size); #endif void MAGNUM_LOCAL storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageImplementationDSA(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); + void MAGNUM_LOCAL storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); #endif #ifndef MAGNUM_TARGET_GLES @@ -446,49 +446,49 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); + void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); - void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); + void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL getImageImplementationDefault(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationDSA(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationDSAEXT(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); #endif void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL imageImplementationDSA(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSAEXT(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data); #endif void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSAEXT(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSAEXT(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data); #endif void MAGNUM_LOCAL invalidateImageImplementationNoOp(GLint level); diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 950cfab21..5670a5714 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -402,7 +402,7 @@ void Buffer::copyImplementationDefault(Buffer& read, Buffer& write, GLintptr rea } #ifndef MAGNUM_TARGET_GLES -void Buffer::copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { +void Buffer::copyImplementationDSAEXT(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) { read._created = write._created = true; glNamedCopyBufferSubDataEXT(read._id, write._id, readOffset, writeOffset, size); } @@ -414,7 +414,7 @@ void Buffer::getParameterImplementationDefault(const GLenum value, GLint* const } #ifndef MAGNUM_TARGET_GLES -void Buffer::getParameterImplementationDSA(const GLenum value, GLint* const data) { +void Buffer::getParameterImplementationDSAEXT(const GLenum value, GLint* const data) { _created = true; glGetNamedBufferParameterivEXT(_id, value, data); } @@ -425,7 +425,7 @@ void Buffer::getSubDataImplementationDefault(const GLintptr offset, const GLsize glGetBufferSubData(GLenum(bindSomewhereInternal(_targetHint)), offset, size, data); } -void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { +void Buffer::getSubDataImplementationDSAEXT(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { _created = true; glGetNamedBufferSubDataEXT(_id, offset, size, data); } @@ -436,7 +436,7 @@ void Buffer::dataImplementationDefault(GLsizeiptr size, const GLvoid* data, Buff } #ifndef MAGNUM_TARGET_GLES -void Buffer::dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUsage usage) { +void Buffer::dataImplementationDSAEXT(GLsizeiptr size, const GLvoid* data, BufferUsage usage) { _created = true; glNamedBufferDataEXT(_id, size, data, GLenum(usage)); } @@ -447,7 +447,7 @@ void Buffer::subDataImplementationDefault(GLintptr offset, GLsizeiptr size, cons } #ifndef MAGNUM_TARGET_GLES -void Buffer::subDataImplementationDSA(GLintptr offset, GLsizeiptr size, const GLvoid* data) { +void Buffer::subDataImplementationDSAEXT(GLintptr offset, GLsizeiptr size, const GLvoid* data) { _created = true; glNamedBufferSubDataEXT(_id, offset, size, data); } @@ -483,7 +483,7 @@ void* Buffer::mapImplementationDefault(MapAccess access) { } #ifndef MAGNUM_TARGET_GLES -void* Buffer::mapImplementationDSA(MapAccess access) { +void* Buffer::mapImplementationDSAEXT(MapAccess access) { _created = true; return glMapNamedBufferEXT(_id, GLenum(access)); } @@ -503,7 +503,7 @@ void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, } #ifndef MAGNUM_TARGET_GLES -void* Buffer::mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapFlags access) { +void* Buffer::mapRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length, MapFlags access) { _created = true; return glMapNamedBufferRangeEXT(_id, offset, length, GLenum(access)); } @@ -522,7 +522,7 @@ void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr l } #ifndef MAGNUM_TARGET_GLES -void Buffer::flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr length) { +void Buffer::flushMappedRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length) { _created = true; glFlushMappedNamedBufferRangeEXT(_id, offset, length); } @@ -539,7 +539,7 @@ bool Buffer::unmapImplementationDefault() { } #ifndef MAGNUM_TARGET_GLES -bool Buffer::unmapImplementationDSA() { +bool Buffer::unmapImplementationDSAEXT() { _created = true; return glUnmapNamedBufferEXT(_id); } diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 3e16a3b4a..3f4927cba 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -1171,7 +1171,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { static void MAGNUM_LOCAL copyImplementationDefault(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #ifndef MAGNUM_TARGET_GLES - static void MAGNUM_LOCAL copyImplementationDSA(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + static void MAGNUM_LOCAL copyImplementationDSAEXT(Buffer& read, Buffer& write, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); #endif #endif @@ -1185,22 +1185,22 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { void MAGNUM_LOCAL getParameterImplementationDefault(GLenum value, GLint* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL getParameterImplementationDSA(GLenum value, GLint* data); + void MAGNUM_LOCAL getParameterImplementationDSAEXT(GLenum value, GLint* data); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL getSubDataImplementationDefault(GLintptr offset, GLsizeiptr size, GLvoid* data); - void MAGNUM_LOCAL getSubDataImplementationDSA(GLintptr offset, GLsizeiptr size, GLvoid* data); + void MAGNUM_LOCAL getSubDataImplementationDSAEXT(GLintptr offset, GLsizeiptr size, GLvoid* data); #endif void MAGNUM_LOCAL dataImplementationDefault(GLsizeiptr size, const GLvoid* data, BufferUsage usage); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL dataImplementationDSA(GLsizeiptr size, const GLvoid* data, BufferUsage usage); + void MAGNUM_LOCAL dataImplementationDSAEXT(GLsizeiptr size, const GLvoid* data, BufferUsage usage); #endif void MAGNUM_LOCAL subDataImplementationDefault(GLintptr offset, GLsizeiptr size, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subDataImplementationDSA(GLintptr offset, GLsizeiptr size, const GLvoid* data); + void MAGNUM_LOCAL subDataImplementationDSAEXT(GLintptr offset, GLsizeiptr size, const GLvoid* data); #endif void MAGNUM_LOCAL invalidateImplementationNoOp(); @@ -1215,22 +1215,22 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { void MAGNUM_LOCAL * mapImplementationDefault(MapAccess access); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL * mapImplementationDSA(MapAccess access); + void MAGNUM_LOCAL * mapImplementationDSAEXT(MapAccess access); #endif void MAGNUM_LOCAL * mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL * mapRangeImplementationDSA(GLintptr offset, GLsizeiptr length, MapFlags access); + void MAGNUM_LOCAL * mapRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length, MapFlags access); #endif void MAGNUM_LOCAL flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL flushMappedRangeImplementationDSA(GLintptr offset, GLsizeiptr length); + void MAGNUM_LOCAL flushMappedRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length); #endif bool MAGNUM_LOCAL unmapImplementationDefault(); #ifndef MAGNUM_TARGET_GLES - bool MAGNUM_LOCAL unmapImplementationDSA(); + bool MAGNUM_LOCAL unmapImplementationDSAEXT(); #endif GLuint _id; diff --git a/src/Magnum/BufferTexture.cpp b/src/Magnum/BufferTexture.cpp index 54384f45a..0c45eb264 100644 --- a/src/Magnum/BufferTexture.cpp +++ b/src/Magnum/BufferTexture.cpp @@ -75,7 +75,7 @@ void BufferTexture::setBufferImplementationDefault(BufferTextureFormat internalF glTexBuffer(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id()); } -void BufferTexture::setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer) { +void BufferTexture::setBufferImplementationDSAEXT(BufferTextureFormat internalFormat, Buffer& buffer) { glTextureBufferEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id()); } @@ -84,7 +84,7 @@ void BufferTexture::setBufferRangeImplementationDefault(BufferTextureFormat inte glTexBufferRange(GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size); } -void BufferTexture::setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { +void BufferTexture::setBufferRangeImplementationDSAEXT(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size) { glTextureBufferRangeEXT(id(), GL_TEXTURE_BUFFER, GLenum(internalFormat), buffer.id(), offset, size); } diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index 402edc063..2ce20a191 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -277,10 +277,10 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { private: void MAGNUM_LOCAL setBufferImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer); - void MAGNUM_LOCAL setBufferImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer); + void MAGNUM_LOCAL setBufferImplementationDSAEXT(BufferTextureFormat internalFormat, Buffer& buffer); void MAGNUM_LOCAL setBufferRangeImplementationDefault(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); - void MAGNUM_LOCAL setBufferRangeImplementationDSA(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); + void MAGNUM_LOCAL setBufferRangeImplementationDSAEXT(BufferTextureFormat internalFormat, Buffer& buffer, GLintptr offset, GLsizeiptr size); }; } diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index a1357979f..0e910038d 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -257,7 +257,7 @@ void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer) { +void Framebuffer::renderbufferImplementationDSAEXT(BufferAttachment attachment, Renderbuffer& renderbuffer) { _created = true; glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id()); } @@ -266,7 +266,7 @@ void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, GL glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); } -void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { +void Framebuffer::texture1DImplementationDSAEXT(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { _created = true; glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); } @@ -277,7 +277,7 @@ void Framebuffer::texture2DImplementationDefault(BufferAttachment attachment, GL } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::texture2DImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint mipLevel) { +void Framebuffer::texture2DImplementationDSAEXT(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint mipLevel) { _created = true; glNamedFramebufferTexture2DEXT(_id, GLenum(attachment), textureTarget, textureId, mipLevel); } @@ -298,7 +298,7 @@ void Framebuffer::textureLayerImplementationDefault(BufferAttachment attachment, } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::textureLayerImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { +void Framebuffer::textureLayerImplementationDSAEXT(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { _created = true; glNamedFramebufferTextureLayerEXT(_id, GLenum(attachment), textureId, mipLevel, layer); } diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index c264aa0bf..2c9cdc3f9 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -639,22 +639,22 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer); + void MAGNUM_LOCAL renderbufferImplementationDSAEXT(BufferAttachment attachment, Renderbuffer& renderbuffer); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level); - void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint level); + void MAGNUM_LOCAL texture1DImplementationDSAEXT(BufferAttachment attachment, GLuint textureId, GLint level); #endif void MAGNUM_LOCAL texture2DImplementationDefault(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL texture2DImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); + void MAGNUM_LOCAL texture2DImplementationDSAEXT(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); #endif void MAGNUM_LOCAL textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL textureLayerImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); + void MAGNUM_LOCAL textureLayerImplementationDSAEXT(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); #endif }; diff --git a/src/Magnum/Implementation/BufferState.cpp b/src/Magnum/Implementation/BufferState.cpp index 12ea300ae..42102971e 100644 --- a/src/Magnum/Implementation/BufferState.cpp +++ b/src/Magnum/Implementation/BufferState.cpp @@ -90,15 +90,15 @@ BufferState::BufferState(Context& context, std::vector& extensions) if(context.isExtensionSupported()) { extensions.push_back(Extensions::GL::EXT::direct_state_access::string()); - copyImplementation = &Buffer::copyImplementationDSA; - getParameterImplementation = &Buffer::getParameterImplementationDSA; - getSubDataImplementation = &Buffer::getSubDataImplementationDSA; - dataImplementation = &Buffer::dataImplementationDSA; - subDataImplementation = &Buffer::subDataImplementationDSA; - mapImplementation = &Buffer::mapImplementationDSA; - mapRangeImplementation = &Buffer::mapRangeImplementationDSA; - flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDSA; - unmapImplementation = &Buffer::unmapImplementationDSA; + copyImplementation = &Buffer::copyImplementationDSAEXT; + getParameterImplementation = &Buffer::getParameterImplementationDSAEXT; + getSubDataImplementation = &Buffer::getSubDataImplementationDSAEXT; + dataImplementation = &Buffer::dataImplementationDSAEXT; + subDataImplementation = &Buffer::subDataImplementationDSAEXT; + mapImplementation = &Buffer::mapImplementationDSAEXT; + mapRangeImplementation = &Buffer::mapRangeImplementationDSAEXT; + flushMappedRangeImplementation = &Buffer::flushMappedRangeImplementationDSAEXT; + unmapImplementation = &Buffer::unmapImplementationDSAEXT; } else #endif { diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index 0d49ab50a..34dbfdb58 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -43,17 +43,17 @@ FramebufferState::FramebufferState(Context& context, std::vector& e if(context.isExtensionSupported()) { extensions.push_back(Extensions::GL::EXT::direct_state_access::string()); - checkStatusImplementation = &AbstractFramebuffer::checkStatusImplementationDSA; - drawBuffersImplementation = &AbstractFramebuffer::drawBuffersImplementationDSA; - drawBufferImplementation = &AbstractFramebuffer::drawBufferImplementationDSA; - readBufferImplementation = &AbstractFramebuffer::readBufferImplementationDSA; + checkStatusImplementation = &AbstractFramebuffer::checkStatusImplementationDSAEXT; + drawBuffersImplementation = &AbstractFramebuffer::drawBuffersImplementationDSAEXT; + drawBufferImplementation = &AbstractFramebuffer::drawBufferImplementationDSAEXT; + readBufferImplementation = &AbstractFramebuffer::readBufferImplementationDSAEXT; - renderbufferImplementation = &Framebuffer::renderbufferImplementationDSA; - texture1DImplementation = &Framebuffer::texture1DImplementationDSA; - texture2DImplementation = &Framebuffer::texture2DImplementationDSA; - textureLayerImplementation = &Framebuffer::textureLayerImplementationDSA; + renderbufferImplementation = &Framebuffer::renderbufferImplementationDSAEXT; + texture1DImplementation = &Framebuffer::texture1DImplementationDSAEXT; + texture2DImplementation = &Framebuffer::texture2DImplementationDSAEXT; + textureLayerImplementation = &Framebuffer::textureLayerImplementationDSAEXT; - renderbufferStorageImplementation = &Renderbuffer::storageImplementationDSA; + renderbufferStorageImplementation = &Renderbuffer::storageImplementationDSAEXT; } else #endif { @@ -120,7 +120,7 @@ FramebufferState::FramebufferState(Context& context, std::vector& e if(context.isExtensionSupported()) { /* Extension added above */ - renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDSA; + renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDSAEXT; } else #endif { diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index d7297925b..03977de2a 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -60,9 +60,9 @@ MeshState::MeshState(Context& context, std::vector& extensions): cu if(context.isExtensionSupported()) { extensions.push_back(Extensions::GL::EXT::direct_state_access::string()); - attributePointerImplementation = &Mesh::attributePointerImplementationDSA; - attributeIPointerImplementation = &Mesh::attributePointerImplementationDSA; - attributeLPointerImplementation = &Mesh::attributePointerImplementationDSA; + attributePointerImplementation = &Mesh::attributePointerImplementationDSAEXT; + attributeIPointerImplementation = &Mesh::attributePointerImplementationDSAEXT; + attributeLPointerImplementation = &Mesh::attributePointerImplementationDSAEXT; } else #endif { diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index b043280e9..0e3399229 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -69,9 +69,9 @@ TextureState::TextureState(Context& context, std::vector& extension } else if(context.isExtensionSupported()) { /* Extension name added below */ - unbindImplementation = &AbstractTexture::unbindImplementationDSA; + unbindImplementation = &AbstractTexture::unbindImplementationDSAEXT; bindMultiImplementation = &AbstractTexture::bindImplementationFallback; - bindImplementation = &AbstractTexture::bindImplementationDSA; + bindImplementation = &AbstractTexture::bindImplementationDSAEXT; } else #endif @@ -86,24 +86,24 @@ TextureState::TextureState(Context& context, std::vector& extension if(context.isExtensionSupported()) { extensions.push_back(Extensions::GL::EXT::direct_state_access::string()); - parameteriImplementation = &AbstractTexture::parameterImplementationDSA; - parameterfImplementation = &AbstractTexture::parameterImplementationDSA; - parameterivImplementation = &AbstractTexture::parameterImplementationDSA; - parameterfvImplementation = &AbstractTexture::parameterImplementationDSA; - parameterIuivImplementation = &AbstractTexture::parameterIImplementationDSA; - parameterIivImplementation = &AbstractTexture::parameterIImplementationDSA; - getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDSA; - mipmapImplementation = &AbstractTexture::mipmapImplementationDSA; - getImageImplementation = &AbstractTexture::getImageImplementationDSA; - image1DImplementation = &AbstractTexture::imageImplementationDSA; - image2DImplementation = &AbstractTexture::imageImplementationDSA; - image3DImplementation = &AbstractTexture::imageImplementationDSA; - subImage1DImplementation = &AbstractTexture::subImageImplementationDSA; - subImage2DImplementation = &AbstractTexture::subImageImplementationDSA; - subImage3DImplementation = &AbstractTexture::subImageImplementationDSA; - - setBufferImplementation = &BufferTexture::setBufferImplementationDSA; - setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSA; + parameteriImplementation = &AbstractTexture::parameterImplementationDSAEXT; + parameterfImplementation = &AbstractTexture::parameterImplementationDSAEXT; + parameterivImplementation = &AbstractTexture::parameterImplementationDSAEXT; + parameterfvImplementation = &AbstractTexture::parameterImplementationDSAEXT; + parameterIuivImplementation = &AbstractTexture::parameterIImplementationDSAEXT; + parameterIivImplementation = &AbstractTexture::parameterIImplementationDSAEXT; + getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDSAEXT; + mipmapImplementation = &AbstractTexture::mipmapImplementationDSAEXT; + getImageImplementation = &AbstractTexture::getImageImplementationDSAEXT; + image1DImplementation = &AbstractTexture::imageImplementationDSAEXT; + image2DImplementation = &AbstractTexture::imageImplementationDSAEXT; + image3DImplementation = &AbstractTexture::imageImplementationDSAEXT; + subImage1DImplementation = &AbstractTexture::subImageImplementationDSAEXT; + subImage2DImplementation = &AbstractTexture::subImageImplementationDSAEXT; + subImage3DImplementation = &AbstractTexture::subImageImplementationDSAEXT; + + setBufferImplementation = &BufferTexture::setBufferImplementationDSAEXT; + setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSAEXT; } else #endif { @@ -178,9 +178,9 @@ TextureState::TextureState(Context& context, std::vector& extension #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { - storage1DImplementation = &AbstractTexture::storageImplementationDSA; - storage2DImplementation = &AbstractTexture::storageImplementationDSA; - storage3DImplementation = &AbstractTexture::storageImplementationDSA; + storage1DImplementation = &AbstractTexture::storageImplementationDSAEXT; + storage2DImplementation = &AbstractTexture::storageImplementationDSAEXT; + storage3DImplementation = &AbstractTexture::storageImplementationDSAEXT; } else #endif { @@ -208,8 +208,8 @@ TextureState::TextureState(Context& context, std::vector& extension extensions.push_back(Extensions::GL::ARB::texture_storage_multisample::string()); if(context.isExtensionSupported()) { - storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDSA; - storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDSA; + storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDSAEXT; + storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDSAEXT; } else { storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index e14d72d21..c55e01ec6 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -382,7 +382,7 @@ void Mesh::attributePointerImplementationVAO(const Attribute& attribute) { } #ifndef MAGNUM_TARGET_GLES -void Mesh::attributePointerImplementationDSA(const Attribute& attribute) { +void Mesh::attributePointerImplementationDSAEXT(const Attribute& attribute) { _created = true; glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.normalized, attribute.stride, attribute.offset); @@ -418,7 +418,7 @@ void Mesh::attributePointerImplementationVAO(const IntegerAttribute& attribute) } #ifndef MAGNUM_TARGET_GLES -void Mesh::attributePointerImplementationDSA(const IntegerAttribute& attribute) { +void Mesh::attributePointerImplementationDSAEXT(const IntegerAttribute& attribute) { _created = true; glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribIOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.stride, attribute.offset); @@ -448,7 +448,7 @@ void Mesh::attributePointerImplementationVAO(const LongAttribute& attribute) { vertexAttribPointer(attribute); } -void Mesh::attributePointerImplementationDSA(const LongAttribute& attribute) { +void Mesh::attributePointerImplementationDSAEXT(const LongAttribute& attribute) { _created = true; glEnableVertexArrayAttribEXT(_id, attribute.location); glVertexArrayVertexAttribLOffsetEXT(_id, attribute.buffer->id(), attribute.location, attribute.size, attribute.type, attribute.stride, attribute.offset); diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index 7de09d816..072cd654c 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -962,7 +962,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { void MAGNUM_LOCAL attributePointerImplementationDefault(const Attribute& attribute); void MAGNUM_LOCAL attributePointerImplementationVAO(const Attribute& attribute); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL attributePointerImplementationDSA(const Attribute& attribute); + void MAGNUM_LOCAL attributePointerImplementationDSAEXT(const Attribute& attribute); #endif void MAGNUM_LOCAL vertexAttribPointer(const Attribute& attribute); @@ -971,7 +971,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { void MAGNUM_LOCAL attributePointerImplementationDefault(const IntegerAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationVAO(const IntegerAttribute& attribute); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL attributePointerImplementationDSA(const IntegerAttribute& attribute); + void MAGNUM_LOCAL attributePointerImplementationDSAEXT(const IntegerAttribute& attribute); #endif void MAGNUM_LOCAL vertexAttribPointer(const IntegerAttribute& attribute); #endif @@ -980,7 +980,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { void attributePointerInternal(const LongAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationDefault(const LongAttribute& attribute); void MAGNUM_LOCAL attributePointerImplementationVAO(const LongAttribute& attribute); - void MAGNUM_LOCAL attributePointerImplementationDSA(const LongAttribute& attribute); + void MAGNUM_LOCAL attributePointerImplementationDSAEXT(const LongAttribute& attribute); void MAGNUM_LOCAL vertexAttribPointer(const LongAttribute& attribute); #endif diff --git a/src/Magnum/Renderbuffer.cpp b/src/Magnum/Renderbuffer.cpp index 5f0292c12..580bcb162 100644 --- a/src/Magnum/Renderbuffer.cpp +++ b/src/Magnum/Renderbuffer.cpp @@ -124,7 +124,7 @@ void Renderbuffer::storageImplementationDefault(RenderbufferFormat internalForma } #ifndef MAGNUM_TARGET_GLES -void Renderbuffer::storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size) { +void Renderbuffer::storageImplementationDSAEXT(RenderbufferFormat internalFormat, const Vector2i& size) { _created = true; glNamedRenderbufferStorageEXT(_id, GLenum(internalFormat), size.x(), size.y()); } @@ -162,7 +162,7 @@ void Renderbuffer::storageMultisampleImplementationNV(const GLsizei samples, con #endif #ifndef MAGNUM_TARGET_GLES -void Renderbuffer::storageMultisampleImplementationDSA(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size) { +void Renderbuffer::storageMultisampleImplementationDSAEXT(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size) { _created = true; glNamedRenderbufferStorageMultisampleEXT(_id, samples, GLenum(internalFormat), size.x(), size.y()); } diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index 6764ace61..69b7021a2 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -184,13 +184,13 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size); + void MAGNUM_LOCAL storageImplementationDSAEXT(RenderbufferFormat internalFormat, const Vector2i& size); #endif #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); + void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); #endif #else void MAGNUM_LOCAL storageMultisampleImplementationANGLE(GLsizei samples, RenderbufferFormat internalFormat, const Vector2i& size); From 1c543cd26b360d94796a288d9276ec0bb2390824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 7 Sep 2014 22:15:00 +0200 Subject: [PATCH 46/72] ARB_direct_state_access support for creating textures. --- src/Magnum/AbstractTexture.cpp | 16 ++++++++++++++-- src/Magnum/AbstractTexture.h | 5 +++++ src/Magnum/BufferTexture.h | 7 +++++-- src/Magnum/CubeMapTexture.h | 7 +++++-- src/Magnum/CubeMapTextureArray.h | 7 +++++-- src/Magnum/Implementation/TextureState.cpp | 12 ++++++++++++ src/Magnum/Implementation/TextureState.h | 1 + src/Magnum/MultisampleTexture.h | 9 ++++++--- src/Magnum/RectangleTexture.h | 7 +++++-- src/Magnum/Texture.h | 9 ++++++--- src/Magnum/TextureArray.h | 8 +++++--- 11 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index a563911fc..e6fe1e761 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -193,11 +193,23 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, cons } #endif -AbstractTexture::AbstractTexture(GLenum target): _target{target}, _created{false} { - glGenTextures(1, &_id); +AbstractTexture::AbstractTexture(GLenum target): _target{target} { + (this->*Context::current()->state().texture->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } +void AbstractTexture::createImplementationDefault() { + glGenTextures(1, &_id); + _created = false; +} + +#ifndef MAGNUM_TARGET_GLES +void AbstractTexture::createImplementationDSA() { + glCreateTextures(_target, 1, &_id); + _created = true; +} +#endif + AbstractTexture::~AbstractTexture() { /* Moved out, nothing to do */ if(!_id) return; diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 247bc6788..6fc7e3db3 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -379,6 +379,11 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { static void MAGNUM_LOCAL bindImplementationMulti(GLint firstTextureUnit, Containers::ArrayReference textures); #endif + void MAGNUM_LOCAL createImplementationDefault(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationDSA(); + #endif + void MAGNUM_LOCAL createIfNotAlready(); void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit); diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index 2ce20a191..79a9f25c0 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -225,8 +225,11 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_BUFFER} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_BUFFER}, eventually + * @fn_gl{GenTextures} */ explicit BufferTexture(): AbstractTexture(GL_TEXTURE_BUFFER) {} diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 61a34cff8..a29e42a51 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -103,8 +103,11 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_CUBE_MAP} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_CUBE_MAP}, + * eventually @fn_gl{GenTextures} */ explicit CubeMapTexture(): AbstractTexture(GL_TEXTURE_CUBE_MAP) {} diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index e067c98b9..4762af11f 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -87,8 +87,11 @@ class CubeMapTextureArray: public AbstractTexture { /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_CUBE_MAP_ARRAY} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_CUBE_MAP_ARRAY}, + * eventually @fn_gl{GenTextures} */ explicit CubeMapTextureArray(): AbstractTexture(GL_TEXTURE_CUBE_MAP_ARRAY) {} diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index 0e3399229..0edf4ff3d 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -57,6 +57,18 @@ TextureState::TextureState(Context& context, std::vector& extension , bufferOffsetAlignment(0) #endif { + /* Create implementation */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); + createImplementation = &AbstractTexture::createImplementationDSA; + + } else + #endif + { + createImplementation = &AbstractTexture::createImplementationDefault; + } + /* Bind implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index 79650690a..fbe4988fd 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -41,6 +41,7 @@ struct TextureState { void(*unbindImplementation)(GLint); void(*bindMultiImplementation)(GLint, Containers::ArrayReference); + void(AbstractTexture::*createImplementation)(); void(AbstractTexture::*bindImplementation)(GLint); void(AbstractTexture::*parameteriImplementation)(GLenum, GLint); void(AbstractTexture::*parameterfImplementation)(GLenum, GLfloat); diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index 90cc63268..a22eb4170 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -113,9 +113,12 @@ template class MultisampleTexture: public AbstractTextur /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_2D_MULTISAMPLE} or - * @def_gl{TEXTURE_2D_MULTISAMPLE_ARRAY} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_2D_MULTISAMPLE} or + * @def_gl{TEXTURE_2D_MULTISAMPLE_ARRAY}, eventually + * @fn_gl{GenTextures} */ explicit MultisampleTexture(): AbstractTexture(Implementation::multisampleTextureTarget()) {} diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index cf98b51e9..1b61b727b 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -83,8 +83,11 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_RECTANGLE} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_RECTANGLE}, + * eventually @fn_gl{GenTextures} */ explicit RectangleTexture(): AbstractTexture(GL_TEXTURE_RECTANGLE) {} diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 5df42e37c..736441b76 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -159,9 +159,12 @@ template class Texture: public AbstractTexture { /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_1D}, @def_gl{TEXTURE_2D} - * or @def_gl{TEXTURE_3D} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_1D}, + * @def_gl{TEXTURE_2D} or @def_gl{TEXTURE_3D}, eventually + * @fn_gl{GenTextures} */ explicit Texture(): AbstractTexture(Implementation::textureTarget()) {} diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index b4f6b1582..f240deab2 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -110,9 +110,11 @@ template class TextureArray: public AbstractTexture { /** * @brief Constructor * - * Creates new OpenGL texture object. - * @see @fn_gl{GenTextures} with @def_gl{TEXTURE_1D_ARRAY} or - * @def_gl{TEXTURE_2D_ARRAY} + * Creates new OpenGL texture object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the texture is created on + * first use. + * @see @fn_gl{CreateTextures} with @def_gl{TEXTURE_1D_ARRAY} or + * @def_gl{TEXTURE_2D_ARRAY}, eventually @fn_gl{GenTextures} */ explicit TextureArray(): AbstractTexture(Implementation::textureArrayTarget()) {} From db5b17938b9971c6eaf10fc09fcc242c25d1e968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 7 Sep 2014 22:28:49 +0200 Subject: [PATCH 47/72] ARB_direct_state_access support for creating buffers. --- src/Magnum/Buffer.cpp | 19 +++++++++++++++---- src/Magnum/Buffer.h | 13 ++++++++++--- src/Magnum/Implementation/BufferState.cpp | 12 ++++++++++++ src/Magnum/Implementation/BufferState.h | 1 + 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 5670a5714..c992b72b4 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -162,16 +162,27 @@ void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const } #endif -Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, +Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint} #ifdef CORRADE_TARGET_NACL - _mappedBuffer{nullptr}, + , _mappedBuffer{nullptr} #endif - _created{false} { - glGenBuffers(1, &_id); + (this->*Context::current()->state().buffer->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } +void Buffer::createImplementationDefault() { + glGenBuffers(1, &_id); + _created = false; +} + +#ifndef MAGNUM_TARGET_GLES +void Buffer::createImplementationDSA() { + glCreateBuffers(1, &_id); + _created = true; +} +#endif + Buffer::~Buffer() { /* Moved out, nothing to do */ if(!_id) return; diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 3f4927cba..060a6778e 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -761,8 +761,10 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @param targetHint Target hint, see @ref setTargetHint() for more * information * - * Creates new OpenGL buffer. - * @see @fn_gl{GenBuffers} + * Creates new OpenGL buffer object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the buffer is created on + * first use. + * @see @fn_gl{CreateBuffers}, eventually @fn_gl{GenBuffers} */ explicit Buffer(TargetHint targetHint = TargetHint::Array); @@ -784,7 +786,7 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { /** * @brief Destructor * - * Deletes associated OpenGL buffer. + * Deletes associated OpenGL buffer object. * @see @fn_gl{DeleteBuffers} */ ~Buffer(); @@ -1175,6 +1177,11 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif #endif + void MAGNUM_LOCAL createImplementationDefault(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationDSA(); + #endif + void MAGNUM_LOCAL createIfNotAlready(); Buffer& setLabelInternal(Containers::ArrayReference label); diff --git a/src/Magnum/Implementation/BufferState.cpp b/src/Magnum/Implementation/BufferState.cpp index 42102971e..3e4114f00 100644 --- a/src/Magnum/Implementation/BufferState.cpp +++ b/src/Magnum/Implementation/BufferState.cpp @@ -86,6 +86,18 @@ BufferState::BufferState(Context& context, std::vector& extensions) , maxAtomicCounterBindings{0}, maxShaderStorageBindings{0}, shaderStorageOffsetAlignment{0}, uniformOffsetAlignment{0}, maxUniformBindings{0} #endif { + /* Create implementation */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); + createImplementation = &Buffer::createImplementationDSA; + + } else + #endif + { + createImplementation = &Buffer::createImplementationDefault; + } + #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { extensions.push_back(Extensions::GL::EXT::direct_state_access::string()); diff --git a/src/Magnum/Implementation/BufferState.h b/src/Magnum/Implementation/BufferState.h index 41a8dc908..29eaabec0 100644 --- a/src/Magnum/Implementation/BufferState.h +++ b/src/Magnum/Implementation/BufferState.h @@ -51,6 +51,7 @@ struct BufferState { void(*bindRangesImplementation)(Buffer::Target, UnsignedInt, Containers::ArrayReference>); void(*copyImplementation)(Buffer&, Buffer&, GLintptr, GLintptr, GLsizeiptr); #endif + void(Buffer::*createImplementation)(); void(Buffer::*getParameterImplementation)(GLenum, GLint*); #ifndef MAGNUM_TARGET_GLES2 void(Buffer::*getSubDataImplementation)(GLintptr, GLsizeiptr, GLvoid*); From 9f041b5d5b45573b858e41003c7caf868bc69d50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 9 Sep 2014 10:16:32 +0200 Subject: [PATCH 48/72] ARB_direct_state_access support for creating framebuffers. --- src/Magnum/Framebuffer.cpp | 14 ++++++++++++-- src/Magnum/Framebuffer.h | 14 +++++++++++--- src/Magnum/Implementation/FramebufferState.cpp | 12 ++++++++++++ src/Magnum/Implementation/FramebufferState.h | 1 + 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index 0e910038d..b2884c749 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -81,12 +81,22 @@ Int Framebuffer::maxColorAttachments() { Framebuffer::Framebuffer(const Range2Di& viewport) { _viewport = viewport; - _created = false; + (this->*Context::current()->state().framebuffer->createImplementation)(); + CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); +} +void Framebuffer::createImplementationDefault() { glGenFramebuffers(1, &_id); - CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); + _created = false; } +#ifndef MAGNUM_TARGET_GLES +void Framebuffer::createImplementationDSA() { + glCreateFramebuffers(1, &_id); + _created = true; +} +#endif + Framebuffer::~Framebuffer() { /* Moved out, nothing to do */ if(!_id) return; diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 2c9cdc3f9..b9b5e920b 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -302,8 +302,11 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje /** * @brief Constructor * - * Generates new OpenGL framebuffer. - * @see @ref setViewport(), @fn_gl{GenFramebuffers} + * Generates new OpenGL framebuffer object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the framebuffer is created on + * first use. + * @see @ref setViewport(), @fn_gl{CreateFramebuffers}, eventually + * @fn_gl{GenFramebuffers} */ explicit Framebuffer(const Range2Di& viewport); @@ -316,7 +319,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje /** * @brief Destructor * - * Deletes associated OpenGL framebuffer. + * Deletes associated OpenGL framebuffer object. * @see @fn_gl{DeleteFramebuffers} */ ~Framebuffer(); @@ -635,6 +638,11 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje #endif private: + void MAGNUM_LOCAL createImplementationDefault(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationDSA(); + #endif + Framebuffer& setLabelInternal(Containers::ArrayReference label); void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer); diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index 34dbfdb58..00134418c 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -38,6 +38,18 @@ FramebufferState::FramebufferState(Context& context, std::vector& e , maxDualSourceDrawBuffers(0) #endif { + /* Create implementation */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); + createImplementation = &Framebuffer::createImplementationDSA; + + } else + #endif + { + createImplementation = &Framebuffer::createImplementationDefault; + } + /* DSA/non-DSA implementation */ #ifndef MAGNUM_TARGET_GLES if(context.isExtensionSupported()) { diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index e4c498942..541ebd138 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -49,6 +49,7 @@ struct FramebufferState { void(AbstractFramebuffer::*invalidateSubImplementation)(GLsizei, const GLenum*, const Range2Di&); #endif + void(Framebuffer::*createImplementation)(); void(Framebuffer::*renderbufferImplementation)(Framebuffer::BufferAttachment, Renderbuffer&); #ifndef MAGNUM_TARGET_GLES void(Framebuffer::*texture1DImplementation)(Framebuffer::BufferAttachment, GLuint, GLint); From 8aeb85875dd82cf3981d683e5ceadbaeb545265f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 9 Sep 2014 10:17:15 +0200 Subject: [PATCH 49/72] ARB_direct_state_access support for creating renderbuffers. --- src/Magnum/Implementation/FramebufferState.cpp | 2 ++ src/Magnum/Implementation/FramebufferState.h | 1 + src/Magnum/Renderbuffer.cpp | 16 +++++++++++++++- src/Magnum/Renderbuffer.h | 13 ++++++++++--- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index 00134418c..f7fe3540b 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -43,11 +43,13 @@ FramebufferState::FramebufferState(Context& context, std::vector& e if(context.isExtensionSupported()) { extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); createImplementation = &Framebuffer::createImplementationDSA; + createRenderbufferImplementation = &Renderbuffer::createImplementationDSA; } else #endif { createImplementation = &Framebuffer::createImplementationDefault; + createRenderbufferImplementation = &Renderbuffer::createImplementationDefault; } /* DSA/non-DSA implementation */ diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index 541ebd138..1096ac6c7 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -57,6 +57,7 @@ struct FramebufferState { void(Framebuffer::*texture2DImplementation)(Framebuffer::BufferAttachment, GLenum, GLuint, GLint); void(Framebuffer::*textureLayerImplementation)(Framebuffer::BufferAttachment, GLuint, GLint, GLint); + void(Renderbuffer::*createRenderbufferImplementation)(); void(Renderbuffer::*renderbufferStorageImplementation)(RenderbufferFormat, const Vector2i&); void(Renderbuffer::*renderbufferStorageMultisampleImplementation)(GLsizei, RenderbufferFormat, const Vector2i&); diff --git a/src/Magnum/Renderbuffer.cpp b/src/Magnum/Renderbuffer.cpp index 580bcb162..298cb63ed 100644 --- a/src/Magnum/Renderbuffer.cpp +++ b/src/Magnum/Renderbuffer.cpp @@ -64,7 +64,21 @@ Int Renderbuffer::maxSamples() { return value; } -Renderbuffer::Renderbuffer(): _created{false} { glGenRenderbuffers(1, &_id); } +Renderbuffer::Renderbuffer() { + (this->*Context::current()->state().framebuffer->createRenderbufferImplementation)(); +} + +void Renderbuffer::createImplementationDefault() { + glGenRenderbuffers(1, &_id); + _created = false; +} + +#ifndef MAGNUM_TARGET_GLES +void Renderbuffer::createImplementationDSA() { + glCreateRenderbuffers(1, &_id); + _created = true; +} +#endif Renderbuffer::~Renderbuffer() { /* Moved out, nothing to do */ diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index 69b7021a2..b398642c1 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -85,8 +85,10 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { /** * @brief Constructor * - * Generates new OpenGL renderbuffer. - * @see @fn_gl{GenRenderbuffers} + * Generates new OpenGL renderbuffer object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the renderbuffer is created + * on first use. + * @see @fn_gl{CreateRenderbuffers}, eventually @fn_gl{GenRenderbuffers} */ explicit Renderbuffer(); @@ -99,7 +101,7 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { /** * @brief Destructor * - * Deletes associated OpenGL renderbuffer. + * Deletes associated OpenGL renderbuffer object. * @see @fn_gl{DeleteRenderbuffers} */ ~Renderbuffer(); @@ -178,6 +180,11 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size); private: + void MAGNUM_LOCAL createImplementationDefault(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationDSA(); + #endif + void MAGNUM_LOCAL createIfNotAlready(); Renderbuffer& setLabelInternal(Containers::ArrayReference label); From e4119157b6c3e47c28d3f43989eff14238384747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 9 Sep 2014 10:18:10 +0200 Subject: [PATCH 50/72] ARB_direct_state_access support for creating meshes. --- src/Magnum/Implementation/MeshState.cpp | 8 ++++++++ src/Magnum/Mesh.cpp | 9 ++++++++- src/Magnum/Mesh.h | 12 +++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index 03977de2a..e2e595c91 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -96,6 +96,14 @@ MeshState::MeshState(Context& context, std::vector& extensions): cu } #endif + #ifndef MAGNUM_TARGET_GLES + /* DSA create implementation (other cases handled above) */ + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); + createImplementation = &Mesh::createImplementationVAODSA; + } + #endif + #ifdef MAGNUM_TARGET_GLES /* Multi draw implementation on ES */ if(context.isExtensionSupported()) { diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index c55e01ec6..ceb4cb7f6 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -335,7 +335,6 @@ void Mesh::createImplementationDefault() { } void Mesh::createImplementationVAO() { - _created = false; #ifndef MAGNUM_TARGET_GLES2 glGenVertexArrays(1, &_id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) @@ -343,9 +342,17 @@ void Mesh::createImplementationVAO() { #else CORRADE_ASSERT_UNREACHABLE(); #endif + _created = false; CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } +#ifndef MAGNUM_TARGET_GLES +void Mesh::createImplementationVAODSA() { + glCreateVertexArrays(1, &_id); + _created = true; +} +#endif + void Mesh::destroyImplementationDefault() {} void Mesh::destroyImplementationVAO() { diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index 072cd654c..fbae5fe19 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -424,8 +424,11 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is - * available, vertex array object is created. - * @see @ref setPrimitive(), @ref setCount(), @fn_gl{GenVertexArrays} + * available, vertex array object is created. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the vertex array object is + * created on first use. + * @see @ref setPrimitive(), @ref setCount(), @fn_gl{CreateVertexArrays}, + * eventually @fn_gl{GenVertexArrays} */ explicit Mesh(MeshPrimitive primitive = MeshPrimitive::Triangles); @@ -440,7 +443,7 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * * If @extension{ARB,vertex_array_object} (part of OpenGL 3.0), OpenGL * ES 3.0 or @es_extension{OES,vertex_array_object} in OpenGL ES 2.0 is - * available, vertex array object is deleted. + * available, associated vertex array object is deleted. * @see @fn_gl{DeleteVertexArrays} */ ~Mesh(); @@ -954,6 +957,9 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { void MAGNUM_LOCAL createImplementationDefault(); void MAGNUM_LOCAL createImplementationVAO(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationVAODSA(); + #endif void MAGNUM_LOCAL destroyImplementationDefault(); void MAGNUM_LOCAL destroyImplementationVAO(); From 0adae2245eb32c5be8c0ac749fa6a3f29d070c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 9 Sep 2014 10:30:35 +0200 Subject: [PATCH 51/72] doc++ --- doc/opengl-support.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index e86d2a38a..bf3a367c4 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -213,7 +213,7 @@ following: @extension{ARB,conditional_render_inverted} | done @extension{ARB,cull_distance} | | @extension{ARB,derivative_control} | done (shading language only) -@extension{ARB,direct_state_access} | | +@extension{ARB,direct_state_access} | object creation subset only @extension{ARB,get_texture_sub_image} | | @extension{ARB,shader_texture_image_samples} | done (shading language only) @extension{ARB,texture_barrier} | | From dfa690957a87f79014559ce832224f9eca00ea22 Mon Sep 17 00:00:00 2001 From: Olga Turanksaya Date: Fri, 12 Sep 2014 18:56:50 +0400 Subject: [PATCH 52/72] Gentoo ebuild --- package/gentoo/dev-libs/magnum/Manifest | 1 + .../gentoo/dev-libs/magnum/magnum-9999.ebuild | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 package/gentoo/dev-libs/magnum/Manifest create mode 100644 package/gentoo/dev-libs/magnum/magnum-9999.ebuild diff --git a/package/gentoo/dev-libs/magnum/Manifest b/package/gentoo/dev-libs/magnum/Manifest new file mode 100644 index 000000000..e6854f5fe --- /dev/null +++ b/package/gentoo/dev-libs/magnum/Manifest @@ -0,0 +1 @@ +EBUILD magnum-9999.ebuild 1122 SHA256 c71b5825632f6161fdad24f221c875c926d20cad848c6312e6dea3fa448ab486 SHA512 e46cf2e44ea7b7ed316aea9e71604c0e5c2b05b40202bfc212d9b621e403d87d9355ae6ec1bfbe7cef749c1a7d767da4dfceacf29f69faed4f8f7b9d3442e971 WHIRLPOOL b08ee4efee6cab255e0fc38b6e4ccd9925300e4ec682b18401203e7152b42cd442f81ab588ddd9e1df85b484ed734119b8b23cde9146b4fd76544ba1b647b272 diff --git a/package/gentoo/dev-libs/magnum/magnum-9999.ebuild b/package/gentoo/dev-libs/magnum/magnum-9999.ebuild new file mode 100644 index 000000000..1cd38ed5d --- /dev/null +++ b/package/gentoo/dev-libs/magnum/magnum-9999.ebuild @@ -0,0 +1,52 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=5 + +EGIT_REPO_URI="git://github.com/mosra/magnum.git" + +inherit cmake-utils git-r3 + +DESCRIPTION="C++11 and OpenGL 2D/3D graphics engine" +HOMEPAGE="http://mosra.cz/blog/magnum.php" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="" + +RDEPEND=" + dev-libs/corrade + media-libs/openal + media-libs/freeglut + media-libs/libsdl2 +" +DEPEND="${RDEPEND}" + +src_configure() { + local mycmakeargs=( + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" + -DCMAKE_BUILD_TYPE=Debug \ + -DWITH_AUDIO=ON \ + -DWITH_GLUTAPPLICATION=ON \ + -DWITH_GLXAPPLICATION=ON \ + -DWITH_SDL2APPLICATION=ON \ + -DWITH_WINDOWLESSGLXAPPLICATION=ON \ + -DWITH_EGLCONTEXT=ON \ + -DWITH_GLXCONTEXT=ON \ + -DWITH_MAGNUMFONT=ON \ + -DWITH_MAGNUMFONTCONVERTER=ON \ + -DWITH_OBJIMPORTER=ON \ + -DWITH_TGAIMAGECONVERTER=ON \ + -DWITH_TGAIMPORTER=ON \ + -DWITH_WAVAUDIOIMPORTER=ON \ + -DWITH_DISTANCEFIELDCONVERTER=ON \ + -DWITH_FONTCONVERTER=ON \ + -DWITH_MAGNUMINFO=ON \ + -DBUILD_TESTS=ON \ + -DBUILD_GL_TESTS=ON + ) + cmake-utils_src_configure +} + From 0a95090bd09368956ec3067c8eb1282d865ce894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 16:53:33 +0200 Subject: [PATCH 53/72] Doc++, updated credits. --- CREDITS.md | 4 ++++ doc/building.dox | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CREDITS.md b/CREDITS.md index ce9d3beed..8697d8ae2 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -17,5 +17,9 @@ Contributors to Magnum library port improvements * Stefan Wasilewski ([@smw](https://github.com/smw)) -- Mac OS X port improvements +* Konstantinos Chatzilygeroudis ([@costashatz](https://github.com/costashatz)) -- + Debian package +* Olga Turanksaya ([@olga-python](https://github.com/olga-python)) -- Gentoo + ebuild Big thanks to everyone involved! diff --git a/doc/building.dox b/doc/building.dox index 22471272f..663bb0a75 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -315,6 +315,10 @@ project root: makepkg -p package/archlinux/ +@subsection building-packages-gentoo Gentoo ebuilds + +Gentoo Git ebuild is available in `package/gentoo` directory. + @subsection building-packages-deb DEB packages There is also `package/debian/` directory with all files needed for building From 34de2eff1ef11792274bbe05146116b2cd3d3db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 17:36:38 +0200 Subject: [PATCH 54/72] doc: GL mapping cleanup, separated the table by letters. --- doc/opengl-mapping.dox | 474 ++++++++++++++++++++++++----------------- 1 file changed, 283 insertions(+), 191 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index e4b3988e5..a3e151999 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -38,81 +38,108 @@ Legend: @section opengl-mapping-functions Functions -OpenGL function | Matching API --------------------------------------- | ------------ -@fn_gl{ActiveShaderProgram} | not needed as @fn_gl{ProgramUniform} calls are used -@fn_gl{ActiveTexture} | @ref AbstractTexture::bind() -@fn_gl{AttachShader} | @ref AbstractShaderProgram::attachShader() +@subsection opengl-mapping-functions-a A + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{ActiveShaderProgram} | not needed as @fn_gl{ProgramUniform} calls are used +@fn_gl{ActiveTexture} | @ref AbstractTexture::bind() +@fn_gl{AttachShader} | @ref AbstractShaderProgram::attachShader() + +@subsection opengl-mapping-functions-b B + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{BeginConditionalRender}, `glEndConditionalRender()` | @ref SampleQuery::beginConditionalRender(), \n @ref SampleQuery::endConditionalRender() -@fn_gl{BeginQuery}, `glEndQuery()` | @ref PrimitiveQuery::begin(), \n @ref SampleQuery::begin(), \n @ref TimeQuery::begin(), \n @ref AbstractQuery::end() +@fn_gl{BeginQuery}, `glEndQuery()` | @ref PrimitiveQuery::begin(), \n @ref SampleQuery::begin(), \n @ref TimeQuery::begin(), \n @ref AbstractQuery::end() @fn_gl{BeginQueryIndexed}, `glEndQueryIndexed()` | | @fn_gl{BeginTransformFeedback}, `glEndTransformFeedback()` | | -@fn_gl{BindAttribLocation} | @ref AbstractShaderProgram::bindAttributeLocation() -@fn_gl{BindBuffer} | not needed, handled internally in @ref Buffer and elsewhere +@fn_gl{BindAttribLocation} | @ref AbstractShaderProgram::bindAttributeLocation() +@fn_gl{BindBuffer} | not needed, handled internally in @ref Buffer and elsewhere @fn_gl{BindBufferBase}, \n @fn_gl{BindBuffersBase}, \n @fn_gl{BindBufferRange}, \n @fn_gl{BindBuffersRange} | @ref Buffer::bind(), \n @ref Buffer::unbind() -@fn_gl{BindFragDataLocation} | @ref AbstractShaderProgram::bindFragmentDataLocation() -@fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() -@fn_gl{BindFramebuffer} | @ref Framebuffer::bind() +@fn_gl{BindFragDataLocation} | @ref AbstractShaderProgram::bindFragmentDataLocation() +@fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() +@fn_gl{BindFramebuffer} | @ref Framebuffer::bind() @fn_gl{BindImageTexture}, \n @fn_gl{BindImageTextures} | | -@fn_gl{BindProgramPipeline} | | -@fn_gl{BindRenderbuffer} | not needed, handled internally in @ref Renderbuffer +@fn_gl{BindProgramPipeline} | | +@fn_gl{BindRenderbuffer} | not needed, handled internally in @ref Renderbuffer @fn_gl{BindSampler}, \n @fn_gl{BindSamplers} | | @fn_gl{BindTexture}, \n @fn_gl{BindTextureUnit}, \n @fn_gl{BindTextures}, \n @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} | @ref AbstractTexture::bind() -@fn_gl{BindTransformFeedback} | | -@fn_gl{BindVertexArray} | not needed, handled internally in @ref Mesh +@fn_gl{BindTransformFeedback} | | +@fn_gl{BindVertexArray} | not needed, handled internally in @ref Mesh @fn_gl{BindVertexBuffer}, \n `glVertexArrayVertexBuffer()`, \n @fn_gl_extension{VertexArrayBindVertexBuffer,EXT,direct_state_access} \n @fn_gl{BindVertexBuffers}, \n `glVertexArrayVertexBuffers()` | | -@fn_gl{BlendColor} | @ref Renderer::setBlendColor() +@fn_gl{BlendColor} | @ref Renderer::setBlendColor() @fn_gl{BlendEquation}, \n @fn_gl{BlendEquationSeparate} | @ref Renderer::setBlendEquation() @fn_gl{BlendFunc}, \n @fn_gl{BlendFuncSeparate} | @ref Renderer::setBlendFunction() @fn_gl{BlitFramebuffer}, \n `glBlitNamedFramebuffer()` | @ref AbstractFramebuffer::blit() @fn_gl{BufferData}, \n `glNamedBufferData()`, \n @fn_gl_extension{NamedBufferData,EXT,direct_state_access} | @ref Buffer::setData() @fn_gl{BufferStorage}, \n `glNamedBufferStorage()`, \n @fn_gl_extension{NamedBufferStorage,EXT,direct_state_access} | | @fn_gl{BufferSubData}, \n `glNamedBufferSubData()`, \n @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access} | @ref Buffer::setSubData() + +@subsection opengl-mapping-functions-c C + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{CheckFramebufferStatus}, \n `glCheckNamedFramebufferStatus()`, \n @fn_gl_extension{CheckNamedFramebufferStatus,EXT,direct_state_access} | @ref DefaultFramebuffer::checkStatus(), \n @ref Framebuffer::checkStatus() -@fn_gl{ClampColor} | | -@fn_gl{Clear} | @ref AbstractFramebuffer::clear() +@fn_gl{ClampColor} | | +@fn_gl{Clear} | @ref AbstractFramebuffer::clear() @fn_gl{ClearBuffer}, \n `glClearNamedFramebuffer()` | | @fn_gl{ClearBufferData}, \n `glClearNamedBufferData()`, \n @fn_gl_extension{ClearNamedBufferData,EXT,direct_state_access} | | @fn_gl{ClearBufferSubData}, \n `glClearNamedBufferSubData()`, \n @fn_gl_extension{ClearNamedBufferSubData,EXT,direct_state_access} | | -@fn_gl{ClearColor} | @ref Renderer::setClearColor() -@fn_gl{ClearDepth} | @ref Renderer::setClearDepth() -@fn_gl{ClearStencil} | @ref Renderer::setClearStencil() -@fn_gl{ClearTexImage} | | -@fn_gl{ClearTexSubImage} | | -@fn_gl{ClientWaitSync} | | -@fn_gl{ClipControl} | | -@fn_gl{ColorMask} | @ref Renderer::setColorMask() -@fn_gl{CompileShader} | @ref Shader::compile() +@fn_gl{ClearColor} | @ref Renderer::setClearColor() +@fn_gl{ClearDepth} | @ref Renderer::setClearDepth() +@fn_gl{ClearStencil} | @ref Renderer::setClearStencil() +@fn_gl{ClearTexImage} | | +@fn_gl{ClearTexSubImage} | | +@fn_gl{ClientWaitSync} | | +@fn_gl{ClipControl} | | +@fn_gl{ColorMask} | @ref Renderer::setColorMask() +@fn_gl{CompileShader} | @ref Shader::compile() @fn_gl{CompressedTexImage1D}, \n @fn_gl_extension{CompressedTextureImage1D,EXT,direct_state_access}, \n @fn_gl{CompressedTexImage2D}, \n @fn_gl_extension{CompressedTextureImage2D,EXT,direct_state_access}, \n @fn_gl{CompressedTexImage3D}, \n @fn_gl_extension{CompressedTextureImage3D,EXT,direct_state_access} | | @fn_gl{CompressedTexSubImage1D}, \n `glCompressedTextureSubImage1D()`, \n @fn_gl_extension{CompressedTextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{CompressedTexSubImage2D}, \n `glCompressedTextureSubImage2D()`, \n @fn_gl_extension{CompressedTextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{CompressedTexSubImage3D}, \n `glCompressedTextureSubImage3D()`, \n @fn_gl_extension{CompressedTextureSubImage3D,EXT,direct_state_access} | | @fn_gl{CopyBufferSubData}, \n `glCopyNamedBufferSubData()`, \n @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access} | @ref Buffer::copy() -@fn_gl{CopyImageSubData} | | +@fn_gl{CopyImageSubData} | | @fn_gl{CopyTexImage1D}, \n @fn_gl_extension{CopyTextureImage1D,EXT,direct_state_access}, \n @fn_gl{CopyTexImage2D}, \n @fn_gl_extension{CopyTextureImage2D,EXT,direct_state_access} | | @fn_gl{CopyTexSubImage1D}, \n `glCopyTextureSubImage1D()`, \n @fn_gl_extension{CopyTextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{CopyTexSubImage2D}, \n `glCopyTextureSubImage2D()`, \n @fn_gl_extension{CopyTextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{CopyTexSubImage3D}, \n `glCopyTextureSubImage3D()`, \n @fn_gl_extension{CopyTextureSubImage3D,EXT,direct_state_access} | | @fn_gl{CreateProgram}, @fn_gl{DeleteProgram} | @ref AbstractShaderProgram constructor and destructor @fn_gl{CreateShader}, @fn_gl{DeleteShader} | @ref Shader constructor and destructor -@fn_gl{CreateShaderProgram} | | -@fn_gl{CullFace} | @ref Renderer::setFaceCullingMode() -@fn_gl{DebugMessageCallback} | @ref DebugMessage::setCallback() -@fn_gl{DebugMessageControl} | @ref DebugMessage::setEnabled() +@fn_gl{CreateShaderProgram} | | +@fn_gl{CullFace} | @ref Renderer::setFaceCullingMode() + +@subsection opengl-mapping-functions-d D + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{DebugMessageCallback} | @ref DebugMessage::setCallback() +@fn_gl{DebugMessageControl} | @ref DebugMessage::setEnabled() @fn_gl{DebugMessageInsert}, \n @fn_gl_extension2{InsertEventMarker,EXT,debug_marker}, \n @fn_gl_extension{StringMarker,GREMEDY,string_marker} | @ref DebugMessage::insert() -@fn_gl{DepthFunc} | @ref Renderer::setDepthFunction() -@fn_gl{DepthMask} | @ref Renderer::setDepthMask() -@fn_gl{DepthRange} | | -@fn_gl{DepthRangeArray} | | -@fn_gl{DepthRangeIndexed} | | -@fn_gl{DetachShader} | | -@fn_gl{DispatchCompute} | | -@fn_gl{DispatchComputeIndirect} | | +@fn_gl{DepthFunc} | @ref Renderer::setDepthFunction() +@fn_gl{DepthMask} | @ref Renderer::setDepthMask() +@fn_gl{DepthRange} | | +@fn_gl{DepthRangeArray} | | +@fn_gl{DepthRangeIndexed} | | +@fn_gl{DetachShader} | | +@fn_gl{DispatchCompute} | | +@fn_gl{DispatchComputeIndirect} | | @fn_gl{DrawArrays}, \n @fn_gl{DrawArraysInstanced}, \n @fn_gl{DrawArraysInstancedBaseInstance}, \n @fn_gl{DrawElements}, \n @fn_gl{DrawRangeElements}, \n @fn_gl{DrawElementsBaseVertex}, \n @fn_gl{DrawRangeElementsBaseVertex}, \n @fn_gl{DrawElementsInstanced}, \n @fn_gl{DrawElementsInstancedBaseInstance}, \n @fn_gl{DrawElementsInstancedBaseVertex}, \n @fn_gl{DrawElementsInstancedBaseVertexBaseInstance} | @ref Mesh::draw(), \n @ref MeshView::draw() @fn_gl{DrawArraysIndirect}, \n @fn_gl{DrawElementsIndirect}, \n @fn_gl{MultiDrawArraysIndirect}, \n @fn_gl{MultiDrawElementsIndirect} | | @fn_gl{DrawBuffer}, \n `glNamedFramebufferDrawBuffer()`, \n @fn_gl_extension{FramebufferDrawBuffer,EXT,direct_state_access}, \n @fn_gl{DrawBuffers}, \n `glNamedFramebufferDrawBuffers()`, \n @fn_gl_extension{FramebufferDrawBuffers,EXT,direct_state_access} | @ref DefaultFramebuffer::mapForDraw(), \n @ref Framebuffer::mapForDraw() @fn_gl{DrawTransformFeedback}, \n @fn_gl{DrawTransformFeedbackInstanced}, \n @fn_gl{DrawTransformFeedbackStream}, \n @fn_gl{DrawTransformFeedbackStreamInstanced} | | -@fn_gl{Enable}, `glDisable()` | @ref Renderer::setFeature() -@fn_gl{EnableVertexAttribArray}, \n `glEnableVertexArrayAttrib()`, \n @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access} \n `glDisableVertexAttribArray()`, \n `glDisableVertexArrayAttrib()`, \n `glDisableVertexArrayAttribEXT()` | @ref Mesh::addVertexBuffer() -@fn_gl{FenceSync}, @fn_gl{DeleteSync} | | -@fn_gl{Finish} | @ref Renderer::finish() -@fn_gl{Flush} | @ref Renderer::flush() + +@subsection opengl-mapping-functions-e E + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{Enable}, `glDisable()` | @ref Renderer::setFeature() +@fn_gl{EnableVertexAttribArray}, \n `glEnableVertexArrayAttrib()`, \n @fn_gl_extension{EnableVertexArrayAttrib,EXT,direct_state_access}, \n `glDisableVertexAttribArray()`, \n `glDisableVertexArrayAttrib()`, \n `glDisableVertexArrayAttribEXT()` | @ref Mesh::addVertexBuffer() + +@subsection opengl-mapping-functions-f F + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{FenceSync}, @fn_gl{DeleteSync} | | +@fn_gl{Finish} | @ref Renderer::finish() +@fn_gl{Flush} | @ref Renderer::flush() @fn_gl{FlushMappedBufferRange}, \n `glFlushMappedNamedBufferRange()`, \n @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access} | @ref Buffer::flushMappedRange() @fn_gl2{FramebufferParameter,FramebufferParameteri}, \n `glNamedFramebufferParameter()`, \n @fn_gl_extension{NamedFramebufferParameter,EXT,direct_state_access} | | @fn_gl{FramebufferRenderbuffer}, \n `glNamedFramebufferRenderbuffer()`, \n @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} | @ref Framebuffer::attachRenderbuffer() @@ -120,7 +147,12 @@ OpenGL function | Matching API @fn_gl2{FramebufferTexture1D,FramebufferTexture}, \n @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access}, \n `glFramebufferTexture2D()`, \n `glNamedFramebufferTexture2DEXT()` | @ref Framebuffer::attachTexture() @fn_gl2{FramebufferTexture3D,FramebufferTexture} | not used, @fn_gl{FramebufferTextureLayer} has more complete features @fn_gl{FramebufferTextureLayer}, \n `glNamedFramebufferTextureLayer()`, \n @fn_gl_extension{NamedFramebufferTextureLayer,EXT,direct_state_access} | @ref Framebuffer::attachTextureLayer() -@fn_gl{FrontFace} | @ref Renderer::setFrontFace() +@fn_gl{FrontFace} | @ref Renderer::setFrontFace() + +@subsection opengl-mapping-functions-g G + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{GenBuffers}, \n @fn_gl{CreateBuffers}, \n @fn_gl{DeleteBuffers} | @ref Buffer constructor and destructor @fn_gl{GenFramebuffers}, \n @fn_gl{CreateFramebuffers}, \n @fn_gl{DeleteFramebuffers} | @ref Framebuffer constructor and destructor @fn_gl{GenProgramPipelines}, \n @fn_gl{CreateProgramPipelines}, \n @fn_gl{DeleteProgramPipelines} | | @@ -131,107 +163,152 @@ OpenGL function | Matching API @fn_gl{GenTransformFeedbacks}, \n @fn_gl{CreateTransformFeedbacks}, \n @fn_gl{DeleteTransformFeedbacks} | | @fn_gl{GenVertexArrays}, \n @fn_gl{CreateVertexArrays}, \n @fn_gl{DeleteVertexArrays} | @ref Mesh constructor and destructor @fn_gl{GenerateMipmap}, \n `glGenerateTextureMipmap()`, \n @fn_gl_extension{GenerateTextureMipmap,EXT,direct_state_access} | @ref Texture::generateMipmap(), \n @ref TextureArray::generateMipmap(), \n @ref CubeMapTexture::generateMipmap(), \n @ref CubeMapTextureArray::generateMipmap() -@fn_gl{Get} | see @ref opengl-mapping-state "table below" +@fn_gl{Get} | see @ref opengl-mapping-state "table below" @fn_gl2{GetActiveAtomicCounterBuffer,GetActiveAtomicCounterBufferiv} | not queryable @fn_gl{GetActiveAttrib}, \n @fn_gl{GetActiveSubroutineName}, \n @fn_gl{GetActiveSubroutineUniform}, \n @fn_gl{GetActiveSubroutineUniformName}, \n @fn_gl{GetActiveUniform}, \n @fn_gl{GetActiveUniformBlock}, \n @fn_gl{GetActiveUniformBlockName}, \n @fn_gl{GetActiveUniformName}, \n @fn_gl{GetActiveUniforms} | not queryable -@fn_gl{GetAttachedShaders} | not queryable, @ref AbstractShaderProgram::attachShader() setter only -@fn_gl{GetAttribLocation} | not queryable, @ref AbstractShaderProgram::bindAttributeLocation() setter only +@fn_gl{GetAttachedShaders} | not queryable, @ref AbstractShaderProgram::attachShader() setter only +@fn_gl{GetAttribLocation} | not queryable, @ref AbstractShaderProgram::bindAttributeLocation() setter only @fn_gl{GetBufferParameter}, \n `glGetNamedBufferParameter()`, \n @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access} | @ref Buffer::size() @fn_gl2{GetBufferPointer,GetBufferPointerv}, \n `glGetNamedBufferPointer()`, \n @fn_gl_extension{GetNamedBufferPointer,EXT,direct_state_access} | not queryable, @ref Buffer::map() setter only @fn_gl{GetBufferSubData}, \n `glGetNamedBufferSubData()`, \n @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access} | @ref Buffer::data(), \n @ref Buffer::subData() @fn_gl{GetCompressedTexImage}, \n `glGetnCompressedTexImage()`, \n @fn_gl_extension{GetnCompressedTexImage,ARB,robustness}, \n `glGetCompressedTextureImage()`, \n @fn_gl_extension{GetCompressedTextureImage,EXT,direct_state_access} | | -@fn_gl{GetCompressedTextureSubImage} | | -@fn_gl{GetDebugMessageLog} | | -@fn_gl{GetError} | @ref Renderer::error() +@fn_gl{GetCompressedTextureSubImage} | | +@fn_gl{GetDebugMessageLog} | | +@fn_gl{GetError} | @ref Renderer::error() @fn_gl{GetFragDataIndex}, @fn_gl{GetFragDataLocation} | not queryable, @ref AbstractShaderProgram::bindFragmentDataLocation() and \n @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() setters only @fn_gl{GetFramebufferAttachmentParameter}, \n `glGetNamedFramebufferAttachmentParameter()`, \n @fn_gl_extension{GetNamedFramebufferAttachmentParameter,EXT,direct_state_access} | not queryable, @ref Framebuffer setters only @fn_gl{GetFramebufferParameter}, \n `glGetNamedFramebufferParameter()`, \n @fn_gl_extension{GetNamedFramebufferParameter,EXT,direct_state_access} | not queryable, @ref DefaultFramebuffer and \n @ref Framebuffer setters only @fn_gl{GetGraphicsResetStatus}, \n @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness} | @ref Renderer::graphicsResetStatus() -@fn_gl{GetInternalformat} | | -@fn_gl{GetMultisample} | | +@fn_gl{GetInternalformat} | | +@fn_gl{GetMultisample} | | @fn_gl{GetObjectLabel}, \n @fn_gl{GetObjectPtrLabel} | @ref AbstractShaderProgram::label(), \n @ref AbstractQuery::label(), \n @ref AbstractTexture::label(), \n @ref Buffer::label(), \n @ref Framebuffer::label(), \n @ref Mesh::label(), \n @ref Renderbuffer::label(), \n @ref Shader::label() @fn_gl{GetProgram}, \n @fn_gl{GetProgramInfoLog} | @ref AbstractShaderProgram::link(), \n @ref AbstractShaderProgram::validate() -@fn_gl{GetProgramBinary} | | -@fn_gl{GetProgramInterface} | | -@fn_gl{GetProgramPipeline} | | -@fn_gl{GetProgramPipelineInfoLog} | | -@fn_gl{GetProgramResource} | | -@fn_gl{GetProgramResourceIndex} | | -@fn_gl{GetProgramResourceLocation} | | -@fn_gl{GetProgramResourceLocationIndex}| | -@fn_gl{GetProgramResourceName} | | -@fn_gl{GetProgramStage} | | -@fn_gl{GetQueryIndexed} | | -@fn_gl{GetQueryObject} | @ref AbstractQuery::result() -@fn_gl2{GetQuery,GetQueryiv} | | +@fn_gl{GetProgramBinary} | | +@fn_gl{GetProgramInterface} | | +@fn_gl{GetProgramPipeline} | | +@fn_gl{GetProgramPipelineInfoLog} | | +@fn_gl{GetProgramResource} | | +@fn_gl{GetProgramResourceIndex} | | +@fn_gl{GetProgramResourceLocation} | | +@fn_gl{GetProgramResourceLocationIndex} | | +@fn_gl{GetProgramResourceName} | | +@fn_gl{GetProgramStage} | | +@fn_gl{GetQueryIndexed} | | +@fn_gl{GetQueryObject} | @ref AbstractQuery::result() +@fn_gl2{GetQuery,GetQueryiv} | | @fn_gl{GetRenderbufferParameter}, \n `glGetNamedRenderbufferParameter()`, \n @fn_gl_extension{GetNamedRenderbufferParameter,EXT,direct_state_access} | not queryable, @ref Renderbuffer::setStorage() and \n @ref Renderbuffer::setStorageMultisample() setter only -@fn_gl{GetSamplerParameter} | | +@fn_gl{GetSamplerParameter} | | @fn_gl{GetShader}, \n @fn_gl{GetShaderInfoLog} | @ref Shader::compile() -@fn_gl{GetShaderPrecisionFormat} | | -@fn_gl{GetShaderSource} | not queryable but tracked in @ref Shader::sources() -@fn_gl{GetString} | @ref Context::supportedExtensions(), \n @ref Context::rendererString(), \n @ref Context::shadingLanguageVersionString(), \n @ref Context::vendorString(), \n @ref Context::versionString() -@fn_gl{GetSubroutineIndex} | | -@fn_gl{GetSubroutineUniformLocation} | | -@fn_gl{GetSync} | | +@fn_gl{GetShaderPrecisionFormat} | | +@fn_gl{GetShaderSource} | not queryable but tracked in @ref Shader::sources() +@fn_gl{GetString} | @ref Context::supportedExtensions(), \n @ref Context::rendererString(), \n @ref Context::shadingLanguageVersionString(), \n @ref Context::vendorString(), \n @ref Context::versionString() +@fn_gl{GetSubroutineIndex} | | +@fn_gl{GetSubroutineUniformLocation} | | +@fn_gl{GetSync} | | @fn_gl{GetTexImage}, \n `glGetnTexImage()`, \n @fn_gl_extension{GetnTexImage,ARB,robustness}, \n `glGetTextureImage()`, \n @fn_gl_extension{GetTextureImage,EXT,direct_state_access} | @ref Texture::image(), \n @ref TextureArray::image(), \n @ref CubeMapTexture::image(), \n @ref CubeMapTextureArray::image(), \n @ref RectangleTexture::image() @fn_gl{GetTexLevelParameter}, \n `glGetTextureLevelParameter()`, \n @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} | @ref Texture::imageSize(), \n @ref TextureArray::imageSize(), \n @ref CubeMapTexture::imageSize(), \n @ref CubeMapTextureArray::imageSize(), \n @ref RectangleTexture::imageSize() @fn_gl{GetTexParameter}, \n `glGetTextureParameter()`, \n @fn_gl_extension{GetTextureParameter,EXT,direct_state_access} | | -@fn_gl{GetTextureSubImage} | | -@fn_gl{GetTransformFeedback} | | -@fn_gl{GetTransformFeedbackVarying} | | +@fn_gl{GetTextureSubImage} | | +@fn_gl{GetTransformFeedback} | | +@fn_gl{GetTransformFeedbackVarying} | | @fn_gl{GetUniform}, \n `glGetnUniform()`, \n @fn_gl_extension{GetnUniform,ARB,robustness} | not queryable, @ref AbstractShaderProgram::setUniform() setter only -@fn_gl{GetUniformBlockIndex} | | -@fn_gl{GetUniformIndices} | | -@fn_gl{GetUniformLocation} | @ref AbstractShaderProgram::uniformLocation() -@fn_gl{GetUniformSubroutine} | | +@fn_gl{GetUniformBlockIndex} | | +@fn_gl{GetUniformIndices} | | +@fn_gl{GetUniformLocation} | @ref AbstractShaderProgram::uniformLocation() +@fn_gl{GetUniformSubroutine} | | @fn_gl{GetVertexAttrib}, \n @fn_gl{GetVertexArray}, \n @fn_gl_extension{GetVertexArray,EXT,direct_state_access} | not queryable, @ref Mesh::addVertexBuffer() setter only -@fn_gl{InvalidateBufferData} | @ref Buffer::invalidateData() -@fn_gl{InvalidateBufferSubData} | @ref Buffer::invalidateSubData() + +@subsection opengl-mapping-functions-i I + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{InvalidateBufferData} | @ref Buffer::invalidateData() +@fn_gl{InvalidateBufferSubData} | @ref Buffer::invalidateSubData() @fn_gl{InvalidateFramebuffer}, \n `glInvalidateNamedFramebufferData()`, \n @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate() @fn_gl{InvalidateSubFramebuffer}, \n `glInvalidateNamedFramebufferSubData()` | @ref DefaultFramebuffer::invalidate(), \n @ref Framebuffer::invalidate() -@fn_gl{InvalidateTexImage} | @ref Texture::invalidateImage(), \n @ref TextureArray::invalidateImage(), \n @ref CubeMapTexture::invalidateImage(), \n @ref CubeMapTextureArray::invalidateImage(), \n @ref RectangleTexture::invalidateImage(), \n @ref MultisampleTexture::invalidateImage() -@fn_gl{InvalidateTexSubImage} | @ref Texture::invalidateSubImage(), \n @ref TextureArray::invalidateSubImage(), \n @ref CubeMapTexture::invalidateSubImage(), \n @ref CubeMapTextureArray::invalidateSubImage(), \n @ref RectangleTexture::invalidateSubImage(), \n @ref MultisampleTexture::invalidateSubImage() +@fn_gl{InvalidateTexImage} | @ref Texture::invalidateImage(), \n @ref TextureArray::invalidateImage(), \n @ref CubeMapTexture::invalidateImage(), \n @ref CubeMapTextureArray::invalidateImage(), \n @ref RectangleTexture::invalidateImage(), \n @ref MultisampleTexture::invalidateImage() +@fn_gl{InvalidateTexSubImage} | @ref Texture::invalidateSubImage(), \n @ref TextureArray::invalidateSubImage(), \n @ref CubeMapTexture::invalidateSubImage(), \n @ref CubeMapTextureArray::invalidateSubImage(), \n @ref RectangleTexture::invalidateSubImage(), \n @ref MultisampleTexture::invalidateSubImage() @fn_gl{IsBuffer}, \n @fn_gl{IsFramebuffer}, \n @fn_gl{IsProgram}, \n @fn_gl{IsProgramPipeline}, \n @fn_gl{IsQuery}, \n @fn_gl{IsRenderbuffer}, \n @fn_gl{IsSampler}, \n @fn_gl{IsShader}, \n @fn_gl{IsSync}, \n @fn_gl{IsTexture}, \n @fn_gl{IsTransformFeedback}, \n @fn_gl{IsVertexArray} | not needed, objects are strongly typed -@fn_gl{IsEnabled} | not queryable, @ref Renderer::setFeature() setter only -@fn_gl{LineWidth} | @ref Renderer::setLineWidth() -@fn_gl{LinkProgram} | @ref AbstractShaderProgram::link() -@fn_gl{LogicOp} | @ref Renderer::setLogicOperation() +@fn_gl{IsEnabled} | not queryable, @ref Renderer::setFeature() setter only + +@subsection opengl-mapping-functions-l L + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{LineWidth} | @ref Renderer::setLineWidth() +@fn_gl{LinkProgram} | @ref AbstractShaderProgram::link() +@fn_gl{LogicOp} | @ref Renderer::setLogicOperation() + +@subsection opengl-mapping-functions-m M + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{MapBuffer}, \n `glMapNamedBuffer()`, \n @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, \n @fn_gl{MapBufferRange}, \n `glMapNamedBufferRange()`, \n @fn_gl_extension{MapNamedBufferRange,EXT,direct_state_access}, \n @fn_gl{UnmapBuffer}, \n `glUnmapNamedBuffer()`, \n @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access} | @ref Buffer::map(), @ref Buffer::unmap() @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}, @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub} | @ref Buffer::mapSub(), @ref Buffer::unmapSub() @fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | | -@fn_gl{MinSampleShading} | | +@fn_gl{MinSampleShading} | | @fn_gl{MultiDrawArrays}, \n @fn_gl{MultiDrawElements}, \n @fn_gl{MultiDrawElementsBaseVertex} | @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list>) + +@subsection opengl-mapping-functions-o O + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{ObjectLabel}, \n @fn_gl{ObjectPtrLabel}, \n @fn_gl_extension2{LabelObject,EXT,debug_label} | @ref AbstractShaderProgram::setLabel(), \n @ref AbstractQuery::setLabel(), \n @ref AbstractTexture::setLabel(), \n @ref Buffer::setLabel(), \n @ref Framebuffer::setLabel(), \n @ref Mesh::setLabel(), \n @ref Renderbuffer::setLabel(), \n @ref Shader::setLabel() -@fn_gl{PatchParameter} | | + +@subsection opengl-mapping-functions-p P + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{PatchParameter} | | @fn_gl{PauseTransformFeedback}, @fn_gl{ResumeTransformFeedback} | | -@fn_gl{PixelStore} | | -@fn_gl{PointParameter} | | -@fn_gl{PointSize} | @ref Renderer::setPointSize() -@fn_gl{PolygonMode} | @ref Renderer::setPolygonMode() -@fn_gl{PolygonOffset} | @ref Renderer::setPolygonOffset() -@fn_gl{PrimitiveRestartIndex} | | -@fn_gl{ProgramBinary} | | -@fn_gl{ProgramParameter} | @ref AbstractShaderProgram::setRetrievableBinary(), \n @ref AbstractShaderProgram::setSeparable() -@fn_gl{ProvokingVertex} | @ref Renderer::setProvokingVertex() +@fn_gl{PixelStore} | | +@fn_gl{PointParameter} | | +@fn_gl{PointSize} | @ref Renderer::setPointSize() +@fn_gl{PolygonMode} | @ref Renderer::setPolygonMode() +@fn_gl{PolygonOffset} | @ref Renderer::setPolygonOffset() +@fn_gl{PrimitiveRestartIndex} | | +@fn_gl{ProgramBinary} | | +@fn_gl{ProgramParameter} | @ref AbstractShaderProgram::setRetrievableBinary(), \n @ref AbstractShaderProgram::setSeparable() +@fn_gl{ProvokingVertex} | @ref Renderer::setProvokingVertex() @fn_gl{PushDebugGroup}, @fn_gl{PopDebugGroup} | | -@fn_gl{QueryCounter} | @ref TimeQuery::timestamp() + +@subsection opengl-mapping-functions-q Q + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{QueryCounter} | @ref TimeQuery::timestamp() + +@subsection opengl-mapping-functions-r R + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{ReadBuffer}, \n `glNamedFramebufferReadBuffer()`, \n @fn_gl_extension{FramebufferReadBuffer,EXT,direct_state_access} | @ref DefaultFramebuffer::mapForRead(), \n @ref Framebuffer::mapForRead() @fn_gl{ReadPixels}, \n `glReadnPixels()`, \n @fn_gl_extension{ReadnPixels,ARB,robustness} | @ref DefaultFramebuffer::read(), \n @ref Framebuffer::read() -@fn_gl{ReleaseShaderCompiler} | | +@fn_gl{ReleaseShaderCompiler} | | @fn_gl{RenderbufferStorage}, \n `glNamedRenderbufferStorage()`, \n @fn_gl_extension{NamedRenderbufferStorage,EXT,direct_state_access} | @ref Renderbuffer::setStorage() @fn_gl{RenderbufferStorageMultisample}, \n `glNamedRenderbufferStorageMultisample()`, \n @fn_gl_extension{NamedRenderbufferStorageMultisample,EXT,direct_state_access} | @ref Renderbuffer::setStorageMultisample() -@fn_gl{SampleCoverage} | | -@fn_gl{SampleMaski} | | -@fn_gl{SamplerParameter} | | -@fn_gl{Scissor} | @ref Renderer::setScissor() -@fn_gl{ScissorArray} | | -@fn_gl{ScissorIndexed} | | -@fn_gl{ShaderBinary} | | -@fn_gl{ShaderSource} | @ref Shader::addFile(), \n @ref Shader::addSource() -@fn_gl{ShaderStorageBlockBinding} | | + +@subsection opengl-mapping-functions-s S + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{SampleCoverage} | | +@fn_gl{SampleMaski} | | +@fn_gl{SamplerParameter} | | +@fn_gl{Scissor} | @ref Renderer::setScissor() +@fn_gl{ScissorArray} | | +@fn_gl{ScissorIndexed} | | +@fn_gl{ShaderBinary} | | +@fn_gl{ShaderSource} | @ref Shader::addFile(), \n @ref Shader::addSource() +@fn_gl{ShaderStorageBlockBinding} | | @fn_gl{StencilFunc}, \n @fn_gl{StencilFuncSeparate} | @ref Renderer::setStencilFunction() @fn_gl{StencilMask}, \n @fn_gl{StencilMaskSeparate} | @ref Renderer::setStencilMask() @fn_gl{StencilOp}, \n @fn_gl{StencilOpSeparate} | @ref Renderer::setStencilOperation() + +@subsection opengl-mapping-functions-t T + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{TexBuffer}, \n `glTextureBuffer()`, \n @fn_gl_extension{TextureBuffer,EXT,direct_state_access}, \n @fn_gl{TexBufferRange}, \n `glTextureBufferRange()`, \n @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} | @ref BufferTexture::setBuffer() @fn_gl{TexImage1D}, \n @fn_gl_extension{TextureImage1D,EXT,direct_state_access} \n @fn_gl{TexImage2D}, \n @fn_gl_extension{TextureImage2D,EXT,direct_state_access}, \n @fn_gl{TexImage3D}, \n @fn_gl_extension{TextureImage3D,EXT,direct_state_access} | @ref Texture::setImage(), \n @ref TextureArray::setImage(), \n @ref CubeMapTexture::setImage(), \n @ref CubeMapTextureArray::setImage(), \n @ref RectangleTexture::setImage() @fn_gl{TexImage2DMultisample}, \n @fn_gl{TexImage3DMultisample} | @ref MultisampleTexture::setStorage() @@ -239,60 +316,75 @@ OpenGL function | Matching API @fn_gl{TexStorage1D}, \n `glTextureStorage1D()`, \n @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}, \n @fn_gl{TexStorage2D}, \n `glTextureStorage2D()`, \n @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, \n @fn_gl{TexStorage3D}, \n `glTextureStorage3D()`, \n @fn_gl_extension{TextureStorage3D,EXT,direct_state_access} | @ref Texture::setStorage(), \n @ref TextureArray::setStorage(), \n @ref CubeMapTexture::setStorage(), \n @ref CubeMapTextureArray::setStorage(), \n @ref RectangleTexture::setStorage() @fn_gl{TexStorage2DMultisample}, \n `glTextureStorage2DMultisample()`, \n @fn_gl_extension{TextureStorage2DMultisample,EXT,direct_state_access}, \n @fn_gl{TexStorage3DMultisample}, \n `glTextureStorage3DMultisample()`, \n @fn_gl_extension{TextureStorage3DMultisample,EXT,direct_state_access} | @ref MultisampleTexture::setStorage() @fn_gl{TexSubImage1D}, \n `glTextureSubImage1D()`, \n @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{TexSubImage2D}, \n `glTextureSubImage2D()`, \n @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{TexSubImage3D}, \n `glTextureSubImage3D()`, \n @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} | @ref Texture::setSubImage(), \n @ref TextureArray::setSubImage(), \n @ref CubeMapTexture::setSubImage(), \n @ref CubeMapTextureArray::setSubImage(), \n @ref RectangleTexture::setSubImage() -@fn_gl{TextureBarrier} | | -@fn_gl{TextureView} | | +@fn_gl{TextureBarrier} | | +@fn_gl{TextureView} | | @fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | | -@fn_gl{TransformFeedbackVaryings} | | +@fn_gl{TransformFeedbackVaryings} | | + +@subsection opengl-mapping-functions-u U + +OpenGL function | Matching API +--------------------------------------- | ------------ @fn_gl{Uniform}, \n @fn_gl{ProgramUniform}, \n @fn_gl_extension{ProgramUniform,EXT,direct_state_access} | @ref AbstractShaderProgram::setUniform() -@fn_gl{UniformBlockBinding} | | -@fn_gl{UniformSubroutines} | | -@fn_gl{UseProgram} | @ref Mesh::draw(), @ref MeshView::draw() -@fn_gl{UseProgramStages} | | -@fn_gl{ValidateProgram} | @ref AbstractShaderProgram::validate() -@fn_gl{ValidateProgramPipeline} | | -@fn_gl{VertexArrayElementBuffer} | | -@fn_gl{VertexAttrib} | not supported (@ref opengl-unsupported "details") +@fn_gl{UniformBlockBinding} | | +@fn_gl{UniformSubroutines} | | +@fn_gl{UseProgram} | @ref Mesh::draw(), @ref MeshView::draw() +@fn_gl{UseProgramStages} | | + +@subsection opengl-mapping-functions-v V + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{ValidateProgram} | @ref AbstractShaderProgram::validate() +@fn_gl{ValidateProgramPipeline} | | +@fn_gl{VertexArrayElementBuffer} | | +@fn_gl{VertexAttrib} | not supported (@ref opengl-unsupported "details") @fn_gl{VertexAttribBinding}, \n `glVertexArrayAttribBinding()`, \n @fn_gl_extension{VertexArrayVertexAttribBinding,EXT,direct_state_access} | | @fn_gl{VertexAttribDivisor}, \n @fn_gl_extension{VertexArrayVertexAttribDivisor,EXT,direct_state_access} | @ref Mesh::addVertexBufferInstanced() @fn_gl{VertexAttribFormat}, \n `glVertexArrayAttribFormat()`, \n @fn_gl_extension{VertexArrayVertexAttribFormat,EXT,direct_state_access} | | @fn_gl{VertexAttribPointer}, \n @fn_gl_extension{VertexArrayVertexAttribOffset,EXT,direct_state_access} | @ref Mesh::addVertexBuffer() @fn_gl{VertexBindingDivisor}, \n `glVertexArrayBindingDivisor()`, \n @fn_gl_extension{VertexArrayVertexBindingDivisor,EXT,direct_state_access} | | -@fn_gl{Viewport} | @ref DefaultFramebuffer::setViewport(), \n @ref Framebuffer::setViewport() -@fn_gl{ViewportArray} | | -@fn_gl{ViewportIndexed} | | -@fn_gl{WaitSync} | | +@fn_gl{Viewport} | @ref DefaultFramebuffer::setViewport(), \n @ref Framebuffer::setViewport() +@fn_gl{ViewportArray} | | +@fn_gl{ViewportIndexed} | | + +@subsection opengl-mapping-functions-w W + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{WaitSync} | | @section opengl-mapping-state Limit and state queries @todo Things marked only as *not queryable* should have at least setter -@fn_gl{Get} parameter | Matching API --------------------------------------- | ------------ +@fn_gl{Get} parameter | Matching API +--------------------------------------- | ------------ @def_gl{ACTIVE_TEXTURE}, \n @def_gl{TEXTURE_BINDING_1D_ARRAY}, \n @def_gl{TEXTURE_BINDING_1D}, \n @def_gl{TEXTURE_BINDING_2D_ARRAY}, \n @def_gl{TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY}, \n @def_gl{TEXTURE_BINDING_2D_MULTISAMPLE}, \n @def_gl{TEXTURE_BINDING_2D} , \n @def_gl{TEXTURE_BINDING_3D}, \n @def_gl{TEXTURE_BINDING_BUFFER}, \n @def_gl{TEXTURE_BINDING_BUFFER}, \n @def_gl{TEXTURE_BINDING_CUBE_MAP}, \n @def_gl{TEXTURE_BINDING_RECTANGLE} | not queryable but tracked internally -@def_gl{ALIASED_LINE_WIDTH_RANGE} | | +@def_gl{ALIASED_LINE_WIDTH_RANGE} | | @def_gl{ARRAY_BUFFER_BINDING}, \n @def_gl{DISPATCH_INDIRECT_BUFFER_BINDING}, \n @def_gl{ELEMENT_ARRAY_BUFFER_BINDING}, \n @def_gl{PIXEL_PACK_BUFFER_BINDING}, \n @def_gl{PIXEL_UNPACK_BUFFER_BINDING} | not queryable but tracked internally -@def_gl{BLEND_COLOR} | not queryable, @ref Renderer::setBlendColor() setter only +@def_gl{BLEND_COLOR} | not queryable, @ref Renderer::setBlendColor() setter only @def_gl{BLEND_DST_ALPHA}, \n @def_gl{BLEND_DST_RGB}, \n @def_gl{BLEND_SRC_ALPHA}, \n @def_gl{BLEND_SRC_RGB} | not queryable, @ref Renderer::setBlendFunction() setter only @def_gl{BLEND_EQUATION_ALPHA}, \n @def_gl{BLEND_EQUATION_RGB} | not queryable, @ref Renderer::setBlendEquation() setter only @def_gl{BLEND}, \n @def_gl{COLOR_LOGIC_OP}, \n @def_gl{CULL_FACE}, \n @def_gl{DEBUG_OUTPUT}, \n @def_gl{DEBUG_OUTPUT_SYNCHRONOUS}, \n @def_gl{DEPTH_CLAMP}, \n @def_gl{DEPTH_TEST}, \n @def_gl{DITHER}, \n @def_gl{MULTISAMPLE}, \n @def_gl{POLYGON_OFFSET_FILL}, \n @def_gl{POLYGON_OFFSET_LINE}, \n @def_gl{POLYGON_OFFSET_POINT}, \n @def_gl{PROGRAM_POINT_SIZE}, \n @def_gl{SCISSOR}, \n @def_gl{TEXTURE_CUBE_MAP_SEAMLESS}, \n @def_gl{STENCIL_TEST} | not queryable, @ref Renderer::setFeature() setter only @def_gl{COLOR_CLEAR_VALUE}, \n @def_gl{DEPTH_CLEAR_VALUE}, \n @def_gl{STENCIL_CLEAR_VALUE} | not queryable, @ref Renderer::setClearColor(), \n @ref Renderer::setClearDepth() and \n @ref Renderer::setClearStencil() setters only @def_gl{COLOR_WRITEMASK}, \n @def_gl{DEPTH_WRITEMASK}, \n @def_gl{STENCIL_BACK_WRITEMASK}, \n @def_gl{STENCIL_WRITEMASK} | not queryable, @ref Renderer::setColorMask(), \n @ref Renderer::setDepthMask() and \n @ref Renderer::setStencilMask() setters only -@def_gl{CONTEXT_FLAGS} | @ref Context::flags() -@def_gl{CURRENT_PROGRAM} | not queryable but tracked internally -@def_gl{DEBUG_GROUP_STACK_DEPTH} | | -@def_gl{DEPTH_FUNC} | not queryable, @ref Renderer::setDepthFunction() setter only -@def_gl{DEPTH_RANGE} | not queryable +@def_gl{CONTEXT_FLAGS} | @ref Context::flags() +@def_gl{CURRENT_PROGRAM} | not queryable but tracked internally +@def_gl{DEBUG_GROUP_STACK_DEPTH} | | +@def_gl{DEPTH_FUNC} | not queryable, @ref Renderer::setDepthFunction() setter only +@def_gl{DEPTH_RANGE} | not queryable @def_gl{DOUBLEBUFFER}, \n @def_gl{STEREO} | | @def_gl{DRAW_BUFFERi}, \n @def_gl{DRAW_BUFFER}, \n @def_gl{READ_BUFFER} | not queryable, @ref DefaultFramebuffer::mapForDraw(), \n @ref DefaultFramebuffer::mapForRead(), \n @ref Framebuffer::mapForDraw() and \n @ref Framebuffer::mapForRead() setters only @def_gl{DRAW_FRAMEBUFFER_BINDING}, \n @def_gl{READ_FRAMEBUFFER_BINDING} | not queryable but tracked internally @def_gl{FRAGMENT_SHADER_DERIVATIVE_HINT}, \n @def_gl{LINE_SMOOTH_HINT}, \n @def_gl{POLYGON_SMOOTH_HINT}, \n @def_gl{TEXTURE_COMPRESSION_HINT} | not queryable @def_gl{IMPLEMENTATION_COLOR_READ_FORMAT} | | @def_gl{IMPLEMENTATION_COLOR_READ_TYPE} | | -@def_gl{LAYER_PROVOKING_VERTEX} | | +@def_gl{LAYER_PROVOKING_VERTEX} | | @def_gl{LINE_SMOOTH}, \n @def_gl{POLYGON_SMOOTH} | not supported (@ref opengl-unsupported "details") @def_gl{LINE_WIDTH_GRANULARITY}, \n @def_gl{LINE_WIDTH_RANGE} | | -@def_gl{LINE_WIDTH} | not queryable, @ref Renderer::setLineWidth() setter only -@def_gl{LOGIC_OP_MODE} | not queryable, @ref Renderer::setLogicOperation() setter only +@def_gl{LINE_WIDTH} | not queryable, @ref Renderer::setLineWidth() setter only +@def_gl{LOGIC_OP_MODE} | not queryable, @ref Renderer::setLogicOperation() setter only @def_gl{MAJOR_VERSION}, \n @def_gl{MINOR_VERSION} | @ref Context::version() `GL_MAX_*_ATOMIC_COUNTER_BUFFERS`, \n @def_gl{MAX_COMBINED_ATOMIC_COUNTER_BUFFERS} | @ref Shader::maxAtomicCounterBuffers(), \n @ref Shader::maxCombinedAtomicCounterBuffers() `GL_MAX_*_ATOMIC_COUNTERS`, \n @def_gl{MAX_COMBINED_ATOMIC_COUNTERS} | @ref Shader::maxAtomicCounters(), \n @ref Shader::maxCombinedAtomicCounters() @@ -301,90 +393,90 @@ OpenGL function | Matching API `GL_MAX_*_TEXTURE_IMAGE_UNITS`, \n @def_gl{MAX_TEXTURE_IMAGE_UNITS}, \n @def_gl{MAX_COMBINED_TEXTURE_IMAGE_UNITS} | @ref Shader::maxTextureImageUnits(), \n @ref Shader::maxCombinedTextureImageUnits() `GL_MAX_*_UNIFORM_BLOCKS`, \n @def_gl{MAX_COMBINED_UNIFORM_BLOCKS} | @ref Shader::maxUniformBlocks(), \n @ref Shader::maxCombinedUniformBlocks() `GL_MAX_*_UNIFORM_COMPONENTS`, \n @def_gl{MAX_VERTEX_UNIFORM_VECTORS}, \n @def_gl{MAX_FRAGMENT_UNIFORM_VECTORS} | @ref Shader::maxUniformComponents() -`GL_MAX_COMBINED_*_UNIFORM_COMPONENTS` | @ref Shader::maxCombinedUniformComponents() +`GL_MAX_COMBINED_*_UNIFORM_COMPONENTS` | @ref Shader::maxCombinedUniformComponents() @def_gl{MAX_3D_TEXTURE_SIZE}, \n @def_gl{MAX_ARRAY_TEXTURE_LAYERS}, \n @def_gl{MAX_CUBE_MAP_TEXTURE_SIZE}, \n @def_gl{MAX_RECTANGLE_TEXTURE_SIZE}, \n @def_gl{MAX_TEXTURE_SIZE} | @ref Texture::maxSize(), \n @ref TextureArray::maxSize(), \n @ref CubeMapTexture::maxSize(), \n @ref CubeMapTextureArray::maxSize(), \n @ref RectangleTexture::maxSize(), \n @ref BufferTexture::maxSize(), \n @ref MultisampleTexture::maxSize() @def_gl{MAX_ATOMIC_COUNTER_BUFFER_SIZE} | @ref AbstractShaderProgram::maxAtomicCounterBufferSize() @def_gl{MAX_ATOMIC_COUNTER_BUFFER_BINDINGS} | @ref Buffer::maxAtomicCounterBindings() -@def_gl{MAX_COLOR_ATTACHMENTS} | @ref Framebuffer::maxColorAttachments() +@def_gl{MAX_COLOR_ATTACHMENTS} | @ref Framebuffer::maxColorAttachments() @def_gl{MAX_COMBINED_SHADER_OUTPUT_RESOURCES} | @ref AbstractShaderProgram::maxCombinedShaderOutputResources() @def_gl{MAX_COMPUTE_SHARED_MEMORY_SIZE} | @ref AbstractShaderProgram::maxComputeSharedMemorySize() -@def_gl{MAX_COMPUTE_WORK_GROUP_COUNT} | | +@def_gl{MAX_COMPUTE_WORK_GROUP_COUNT} | | @def_gl{MAX_COMPUTE_WORK_GROUP_INVOCATIONS} | @ref AbstractShaderProgram::maxComputeWorkGroupInvocations() -@def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | | -@def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugMessage::maxLoggedMessages() -@def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugMessage::maxMessageLength() -@def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | | -@def_gl{MAX_CLIP_DISTANCES} | | -@def_gl{MAX_CULL_DISTANCES} | | +@def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | | +@def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugMessage::maxLoggedMessages() +@def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugMessage::maxMessageLength() +@def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | | +@def_gl{MAX_CLIP_DISTANCES} | | +@def_gl{MAX_CULL_DISTANCES} | | @def_gl{MAX_COMBINED_CLIP_AND_CULL_DISTANCES} | | @def_gl{MAX_COLOR_TEXTURE_SAMPLES}, \n @def_gl{MAX_DEPTH_TEXTURE_SAMPLES}, \n @def_gl{MAX_INTEGER_SAMPLES} | @ref AbstractTexture::maxColorSamples(), \n @ref AbstractTexture::maxDepthSamples(), \n @ref AbstractTexture::maxIntegerSamples() -@def_gl{MAX_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDrawBuffers() -@def_gl{MAX_DUAL_SOURCE_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDualSourceDrawBuffers() -@def_gl{MAX_ELEMENT_INDEX} | @ref Mesh::maxElementIndex() -@def_gl{MAX_ELEMENTS_INDICES} | @ref Mesh::maxElementsIndices() -@def_gl{MAX_ELEMENTS_VERTICES} | @ref Mesh::maxElementsVertices() -@def_gl{MAX_FRAMEBUFFER_HEIGHT} | | -@def_gl{MAX_FRAMEBUFFER_LAYERS} | | -@def_gl{MAX_FRAMEBUFFER_SAMPLES} | | -@def_gl{MAX_FRAMEBUFFER_WIDTH} | | +@def_gl{MAX_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDrawBuffers() +@def_gl{MAX_DUAL_SOURCE_DRAW_BUFFERS} | @ref AbstractFramebuffer::maxDualSourceDrawBuffers() +@def_gl{MAX_ELEMENT_INDEX} | @ref Mesh::maxElementIndex() +@def_gl{MAX_ELEMENTS_INDICES} | @ref Mesh::maxElementsIndices() +@def_gl{MAX_ELEMENTS_VERTICES} | @ref Mesh::maxElementsVertices() +@def_gl{MAX_FRAMEBUFFER_HEIGHT} | | +@def_gl{MAX_FRAMEBUFFER_LAYERS} | | +@def_gl{MAX_FRAMEBUFFER_SAMPLES} | | +@def_gl{MAX_FRAMEBUFFER_WIDTH} | | @def_gl{MAX_FRAGMENT_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_OUTPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VERTEX_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VARYING_COMPONENTS}, \n @def_gl{MAX_VARYING_FLOATS}, \n @def_gl{MAX_VARYING_VECTORS} | @ref Shader::maxFragmentInputComponents(), \n @ref Shader::maxGeometryInputComponents(), \n @ref Shader::maxGeometryOutputComponents(), \n @ref Shader::maxGeometryTotalOutputComponents(), \n @ref Shader::maxTessellationControlInputComponents(), \n @ref Shader::maxTessellationControlOutputComponents(), \n @ref Shader::maxTessellationControlTotalOutputComponents(), \n @ref Shader::maxTessellationEvaluationInputComponents(), \n @ref Shader::maxTessellationEvaluationOutputComponents(), \n @ref Shader::maxVertexOutputComponents() -@def_gl{MAX_IMAGE_SAMPLES} | @ref AbstractShaderProgram::maxImageSamples() -@def_gl{MAX_IMAGE_UNITS} | @ref AbstractShaderProgram::maxImageUnits() -@def_gl{MAX_LABEL_LENGTH} | @ref AbstractObject::maxLabelLength() -@def_gl{MAX_RENDERBUFFER_SIZE} | @ref Renderbuffer::maxSize() -@def_gl{MAX_SAMPLE_MASK_WORDS} | | -@def_gl{MAX_SERVER_WAIT_TIMEOUT} | | -@def_gl{MAX_SHADER_STORAGE_BLOCK_SIZE} | @ref AbstractShaderProgram::maxShaderStorageBlockSize() +@def_gl{MAX_IMAGE_SAMPLES} | @ref AbstractShaderProgram::maxImageSamples() +@def_gl{MAX_IMAGE_UNITS} | @ref AbstractShaderProgram::maxImageUnits() +@def_gl{MAX_LABEL_LENGTH} | @ref AbstractObject::maxLabelLength() +@def_gl{MAX_RENDERBUFFER_SIZE} | @ref Renderbuffer::maxSize() +@def_gl{MAX_SAMPLE_MASK_WORDS} | | +@def_gl{MAX_SERVER_WAIT_TIMEOUT} | | +@def_gl{MAX_SHADER_STORAGE_BLOCK_SIZE} | @ref AbstractShaderProgram::maxShaderStorageBlockSize() @def_gl{MAX_SHADER_STORAGE_BUFFER_BINDINGS} | @ref Buffer::maxShaderStorageBindings() -@def_gl{MAX_TEXTURE_BUFFER_SIZE} | @ref BufferTexture::maxSize() +@def_gl{MAX_TEXTURE_BUFFER_SIZE} | @ref BufferTexture::maxSize() @def_gl_extension{MAX_TEXTURE_MAX_ANISOTROPY,EXT,texture_filter_anisotropic} | @ref Sampler::maxMaxAnisotropy() -@def_gl{MAX_TEXTURE_LOD_BIAS} | @ref AbstractTexture::maxLodBias() -@def_gl{MAX_UNIFORM_BLOCK_SIZE} | @ref AbstractShaderProgram::maxUniformBlockSize() -@def_gl{MAX_UNIFORM_BUFFER_BINDINGS} | @ref Buffer::maxUniformBindings() -@def_gl{MAX_UNIFORM_LOCATIONS} | @ref AbstractShaderProgram::maxUniformLocations() -@def_gl{MAX_VERTEX_ATTRIBS} | @ref AbstractShaderProgram::maxVertexAttributes() -@def_gl{MAX_VERTEX_ATTRIB_BINDINGS} | | +@def_gl{MAX_TEXTURE_LOD_BIAS} | @ref AbstractTexture::maxLodBias() +@def_gl{MAX_UNIFORM_BLOCK_SIZE} | @ref AbstractShaderProgram::maxUniformBlockSize() +@def_gl{MAX_UNIFORM_BUFFER_BINDINGS} | @ref Buffer::maxUniformBindings() +@def_gl{MAX_UNIFORM_LOCATIONS} | @ref AbstractShaderProgram::maxUniformLocations() +@def_gl{MAX_VERTEX_ATTRIBS} | @ref AbstractShaderProgram::maxVertexAttributes() +@def_gl{MAX_VERTEX_ATTRIB_BINDINGS} | | @def_gl{MAX_VERTEX_ATTRIB_RELATIVE_OFFSET} | | -@def_gl{MAX_VIEWPORTS} | | -@def_gl{MAX_VIEWPORT_DIMS} | @ref AbstractFramebuffer::maxViewportSize() -@def_gl{MIN_MAP_BUFFER_ALIGNMENT} | @ref Buffer::minMapAlignment() +@def_gl{MAX_VIEWPORTS} | | +@def_gl{MAX_VIEWPORT_DIMS} | @ref AbstractFramebuffer::maxViewportSize() +@def_gl{MIN_MAP_BUFFER_ALIGNMENT} | @ref Buffer::minMapAlignment() @def_gl{MIN_PROGRAM_TEXEL_OFFSET}, \n @def_gl{MAX_PROGRAM_TEXEL_OFFSET} | @ref AbstractShaderProgram::minTexelOffset(), \n @ref AbstractShaderProgram::maxTexelOffset() @def_gl{NUM_COMPRESSED_TEXTURE_FORMATS}, \n @def_gl{COMPRESSED_TEXTURE_FORMATS} | | -@def_gl{NUM_EXTENSIONS} | @ref Context::supportedExtensions() +@def_gl{NUM_EXTENSIONS} | @ref Context::supportedExtensions() @def_gl{NUM_PROGRAM_BINARY_FORMATS}, \n @def_gl{PROGRAM_BINARY_FORMATS} | | @def_gl{NUM_SHADER_BINARY_FORMATS}, \n @def_gl{SHADER_BINARY_FORMATS} | | @def_gl{PACK_ALIGNMENT}, \n @def_gl{PACK_IMAGE_HEIGHT}, \n @def_gl{PACK_LSB_FIRST}, \n @def_gl{PACK_ROW_LENGTH}, \n @def_gl{PACK_SKIP_IMAGES}, \n @def_gl{PACK_SKIP_PIXELS}, \n @def_gl{PACK_SKIP_ROWS}, \n @def_gl{PACK_SWAP_BYTES}, \n @def_gl{UNPACK_ALIGNMENT}, \n @def_gl{UNPACK_IMAGE_HEIGHT}, \n @def_gl{UNPACK_LSB_FIRST}, \n @def_gl{UNPACK_ROW_LENGTH}, \n @def_gl{UNPACK_SKIP_IMAGES}, \n @def_gl{UNPACK_SKIP_PIXELS}, \n @def_gl{UNPACK_SKIP_ROWS}, \n @def_gl{UNPACK_SWAP_BYTES} | not queryable -@def_gl{POINT_FADE_THRESHOLD_SIZE} | | +@def_gl{POINT_FADE_THRESHOLD_SIZE} | | @def_gl{POINT_SIZE_GRANULARITY}, \n @def_gl{POINT_SIZE_RANGE} | | -@def_gl{POINT_SIZE} | not queryable, @ref Renderer::setPointSize() setter only +@def_gl{POINT_SIZE} | not queryable, @ref Renderer::setPointSize() setter only @def_gl{POLYGON_OFFSET_FACTOR}, \n @def_gl{POLYGON_OFFSET_UNITS} | not queryable, @ref Renderer::setPolygonOffset() setter only -@def_gl{PRIMITIVE_RESTART_INDEX} | not queryable -@def_gl{PROGRAM_PIPELINE_BINDING} | not queryable -@def_gl{PROVOKING_VERTEX} | not queryable, @ref Renderer::setProvokingVertex() setter only -@def_gl{RENDERBUFFER_BINDING} | not queryable but tracked internally -@def_gl{SAMPLER_BINDING} | not queryable -@def_gl{SAMPLES} | @ref Renderbuffer::maxSamples() -@def_gl{SAMPLE_BUFFERS} | | +@def_gl{PRIMITIVE_RESTART_INDEX} | not queryable +@def_gl{PROGRAM_PIPELINE_BINDING} | not queryable +@def_gl{PROVOKING_VERTEX} | not queryable, @ref Renderer::setProvokingVertex() setter only +@def_gl{RENDERBUFFER_BINDING} | not queryable but tracked internally +@def_gl{SAMPLER_BINDING} | not queryable +@def_gl{SAMPLES} | @ref Renderbuffer::maxSamples() +@def_gl{SAMPLE_BUFFERS} | | @def_gl{SAMPLE_COVERAGE_INVERT}, \n @def_gl{SAMPLE_COVERAGE_VALUE} | | -@def_gl{SCISSOR_BOX} | not queryable, @ref Renderer::setScissor() setter only -@def_gl{SHADER_COMPILER} | not supported (@ref opengl-unsupported "details") +@def_gl{SCISSOR_BOX} | not queryable, @ref Renderer::setScissor() setter only +@def_gl{SHADER_COMPILER} | not supported (@ref opengl-unsupported "details") @def_gl{SHADER_STORAGE_BUFFER_BINDING}, \n @def_gl{SHADER_STORAGE_BUFFER_SIZE}, \n @def_gl{SHADER_STORAGE_BUFFER_START} | not queryable @def_gl{SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT} | @ref Buffer::shaderStorageOffsetAlignment() @def_gl{SMOOTH_LINE_WIDTH_GRANULARITY}, \n @def_gl{SMOOTH_LINE_WIDTH_RANGE} | | @def_gl{STENCIL_BACK_FUNC}, \n @def_gl{STENCIL_BACK_REF}, \n @def_gl{STENCIL_BACK_VALUE_MASK}, \n @def_gl{STENCIL_FUNC}, \n @def_gl{STENCIL_REF}, \n @def_gl{STENCIL_VALUE_MASK} | not queryable, @ref Renderer::setStencilFunction() setter only @def_gl{STENCIL_BACK_FAIL}, \n @def_gl{STENCIL_BACK_PASS_DEPTH_FAIL}, \n @def_gl{STENCIL_BACK_PASS_DEPTH_PASS}, \n @def_gl{STENCIL_FAIL}, \n @def_gl{STENCIL_PASS_DEPTH_FAIL}, \n @def_gl{STENCIL_PASS_DEPTH_PASS} | not queryable, @ref Renderer::setStencilOperation() setter only -@def_gl{SUBPIXEL_BITS} | | +@def_gl{SUBPIXEL_BITS} | | @def_gl{TEXTURE_BUFFER_OFFSET_ALIGNMENT} | @ref BufferTexture::offsetAlignment() -@def_gl{TIMESTAMP} | | +@def_gl{TIMESTAMP} | | @def_gl{TRANSFORM_FEEDBACK_BUFFER_BINDING}, \n @def_gl{TRANSFORM_FEEDBACK_BUFFER_SIZE}, \n @def_gl{TRANSFORM_FEEDBACK_BUFFER_START} | not queryable @def_gl{UNIFORM_BUFFER_OFFSET_ALIGNMENT} | @ref Buffer::uniformOffsetAlignment() @def_gl{UNIFORM_BUFFER_BINDING}, \n @def_gl{UNIFORM_BUFFER_SIZE}, \n @def_gl{UNIFORM_BUFFER_START} | not queryable @def_gl{VERTEX_BINDING_DIVISOR}, \n @def_gl{VERTEX_BINDING_OFFSET}, \n @def_gl{VERTEX_BINDING_STRIDE} | not queryable -@def_gl{VERTEX_PROGRAM_POINT_SIZE} | not queryable -@def_gl{VIEWPORT_BOUNDS_RANGE} | | +@def_gl{VERTEX_PROGRAM_POINT_SIZE} | not queryable +@def_gl{VIEWPORT_BOUNDS_RANGE} | | @def_gl{VIEWPORT_INDEX_PROVOKING_VERTEX} | | -@def_gl{VIEWPORT_SUBPIXEL_BITS} | | -@def_gl{VIEWPORT} | not queryable but tracked in @ref AbstractFramebuffer::viewport() +@def_gl{VIEWPORT_SUBPIXEL_BITS} | | +@def_gl{VIEWPORT} | not queryable but tracked in @ref AbstractFramebuffer::viewport() */ From e423424b27497ccf4c8d41d35ebb1a0f5a4fe42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 17:37:53 +0200 Subject: [PATCH 55/72] doc: added forgotten glHint() to mapping table. There are probably more. --- doc/opengl-mapping.dox | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index a3e151999..ffe559281 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -218,6 +218,12 @@ OpenGL function | Matching API @fn_gl{GetUniformSubroutine} | | @fn_gl{GetVertexAttrib}, \n @fn_gl{GetVertexArray}, \n @fn_gl_extension{GetVertexArray,EXT,direct_state_access} | not queryable, @ref Mesh::addVertexBuffer() setter only +@subsection opengl-mapping-functions-h H + +OpenGL function | Matching API +--------------------------------------- | ------------ +@fn_gl{Hint} | @ref Renderer::setHint() + @subsection opengl-mapping-functions-i I OpenGL function | Matching API From 265dc435a71c1e771153f6f64195f99e552131bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 17:38:15 +0200 Subject: [PATCH 56/72] doc: added upcoming glGetQueryBufferObject() to mapping. Added as bugfix to ARB_direct_state_access (GL 4.5), mentioned in https://twitter.com/piers_daniell/status/510106059348770817. --- doc/opengl-mapping.dox | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index ffe559281..1849650fd 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -195,6 +195,7 @@ OpenGL function | Matching API @fn_gl{GetProgramStage} | | @fn_gl{GetQueryIndexed} | | @fn_gl{GetQueryObject} | @ref AbstractQuery::result() +@fn_gl{GetQueryBufferObject} | | @fn_gl2{GetQuery,GetQueryiv} | | @fn_gl{GetRenderbufferParameter}, \n `glGetNamedRenderbufferParameter()`, \n @fn_gl_extension{GetNamedRenderbufferParameter,EXT,direct_state_access} | not queryable, @ref Renderbuffer::setStorage() and \n @ref Renderbuffer::setStorageMultisample() setter only @fn_gl{GetSamplerParameter} | | From 1a092604217f9217c8664b3e9d959922e9a08463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 17:44:30 +0200 Subject: [PATCH 57/72] doc: cleaned up GL support table to have the col separator at tab stop. --- doc/opengl-support.dox | 388 ++++++++++++++++++++--------------------- 1 file changed, 194 insertions(+), 194 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index bf3a367c4..ec28d2023 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -51,174 +51,174 @@ following: @todo Add @extension{ARB,depth_buffer_float} and implement the missing @fn_gl{DepthRange} function, but keep (and implement) @extension{NV,depth_buffer_float} for non-linear depth buffer @todo @extension{ARB,half_float_pixel}, @extension{ARB,half_float_vertex}? -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,map_buffer_range} | done -@extension{ARB,color_buffer_float} | | -@extension{ARB,half_float_pixel} | done -@extension{ARB,texture_float} | done -@extension{ARB,depth_buffer_float} | done -@extension{ARB,texture_rg} | done -@extension{ARB,vertex_array_object} | done -@extension{ARB,framebuffer_object} | done -@extension{EXT,gpu_shader4} | done -@extension{EXT,packed_float} | done -@extension{EXT,texture_array} | done -@extension{EXT,texture_compression_rgtc} | done -@extension{EXT,texture_shared_exponent} | done -@extension{EXT,framebuffer_sRGB} | | -@extension{EXT,draw_buffers2} | | -@extension{EXT,texture_integer} | done (GL 3.0 subset) -@extension{EXT,transform_feedback} | | -@extension{NV,half_float} | done (GL 3.0 subset) -@extension{NV,depth_buffer_float} | | -@extension{NV,conditional_render} | done +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,map_buffer_range} | done +@extension{ARB,color_buffer_float} | | +@extension{ARB,half_float_pixel} | done +@extension{ARB,texture_float} | done +@extension{ARB,depth_buffer_float} | done +@extension{ARB,texture_rg} | done +@extension{ARB,vertex_array_object} | done +@extension{ARB,framebuffer_object} | done +@extension{EXT,gpu_shader4} | done +@extension{EXT,packed_float} | done +@extension{EXT,texture_array} | done +@extension{EXT,texture_compression_rgtc} | done +@extension{EXT,texture_shared_exponent} | done +@extension{EXT,framebuffer_sRGB} | | +@extension{EXT,draw_buffers2} | | +@extension{EXT,texture_integer} | done (GL 3.0 subset) +@extension{EXT,transform_feedback} | | +@extension{NV,half_float} | done (GL 3.0 subset) +@extension{NV,depth_buffer_float} | | +@extension{NV,conditional_render} | done @subsection opengl-support-31 OpenGL 3.1 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,texture_rectangle} | done -@extension{ARB,draw_instanced} | done -@extension{ARB,texture_buffer_object} | done -@extension{ARB,uniform_buffer_object} | missing uniform block binding -@extension{ARB,copy_buffer} | done -@extension{EXT,texture_snorm} | done -@extension{NV,primitive_restart} | | +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,texture_rectangle} | done +@extension{ARB,draw_instanced} | done +@extension{ARB,texture_buffer_object} | done +@extension{ARB,uniform_buffer_object} | missing uniform block binding +@extension{ARB,copy_buffer} | done +@extension{EXT,texture_snorm} | done +@extension{NV,primitive_restart} | | @subsection opengl-support-32 OpenGL 3.2 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,geometry_shader4} | missing layered attachments -@extension{ARB,depth_clamp} | done -@extension{ARB,draw_elements_base_vertex} | done -@extension{ARB,fragment_coord_conventions} | done (shading language only) -@extension{ARB,provoking_vertex} | done -@extension{ARB,seamless_cube_map} | done -@extension{ARB,sync} | | -@extension{ARB,texture_multisample} | missing sample location queries and sample mask -@extension{ARB,vertex_array_bgra} | done +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,geometry_shader4} | missing layered attachments +@extension{ARB,depth_clamp} | done +@extension{ARB,draw_elements_base_vertex} | done +@extension{ARB,fragment_coord_conventions} | done (shading language only) +@extension{ARB,provoking_vertex} | done +@extension{ARB,seamless_cube_map} | done +@extension{ARB,sync} | | +@extension{ARB,texture_multisample} | missing sample location queries and sample mask +@extension{ARB,vertex_array_bgra} | done @subsection opengl-support-33 OpenGL 3.3 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,instanced_arrays} | done -@extension{ARB,blend_func_extended} | done -@extension{ARB,explicit_attrib_location} | done (shading language only) -@extension{ARB,occlusion_query2} | done -@extension{ARB,sampler_objects} | | -@extension{ARB,shader_bit_encoding} | done (shading language only) -@extension{ARB,texture_rgb10_a2ui} | done -@extension{ARB,texture_swizzle} | done -@extension{ARB,timer_query} | missing direct query -@extension{ARB,vertex_type_2_10_10_10_rev} | done +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,instanced_arrays} | done +@extension{ARB,blend_func_extended} | done +@extension{ARB,explicit_attrib_location} | done (shading language only) +@extension{ARB,occlusion_query2} | done +@extension{ARB,sampler_objects} | | +@extension{ARB,shader_bit_encoding} | done (shading language only) +@extension{ARB,texture_rgb10_a2ui} | done +@extension{ARB,texture_swizzle} | done +@extension{ARB,timer_query} | missing direct query +@extension{ARB,vertex_type_2_10_10_10_rev} | done @subsection opengl-support-40 OpenGL 4.0 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,draw_buffers_blend} | | -@extension{ARB,sample_shading} | | -@extension{ARB,texture_cube_map_array} | done -@extension{ARB,texture_gather} | missing limit queries -@extension{ARB,texture_query_lod} | done (shading language only) -@extension{ARB,draw_indirect} | | -@extension{ARB,gpu_shader5} | missing limit queries -@extension{ARB,gpu_shader_fp64} | done -@extension{ARB,shader_subroutine} | | -@extension{ARB,tessellation_shader} | missing some limit queries and patch parameter specification function -@extension{ARB,texture_buffer_object_rgb32} | done -@extension{ARB,transform_feedback2} | | -@extension{ARB,transform_feedback3} | | +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,draw_buffers_blend} | | +@extension{ARB,sample_shading} | | +@extension{ARB,texture_cube_map_array} | done +@extension{ARB,texture_gather} | missing limit queries +@extension{ARB,texture_query_lod} | done (shading language only) +@extension{ARB,draw_indirect} | | +@extension{ARB,gpu_shader5} | missing limit queries +@extension{ARB,gpu_shader_fp64} | done +@extension{ARB,shader_subroutine} | | +@extension{ARB,tessellation_shader} | missing some limit queries and patch parameter specification function +@extension{ARB,texture_buffer_object_rgb32} | done +@extension{ARB,transform_feedback2} | | +@extension{ARB,transform_feedback3} | | @subsection opengl-support-41 OpenGL 4.1 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,ES2_compatibility} | only float depth clear -@extension{ARB,get_program_binary} | | -@extension{ARB,separate_shader_objects} | only direct uniform binding -@extension{ARB,shader_precision} | done (shading language only) -@extension{ARB,vertex_attrib_64bit} | done -@extension{ARB,viewport_array} | | +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,ES2_compatibility} | only float depth clear +@extension{ARB,get_program_binary} | | +@extension{ARB,separate_shader_objects} | only direct uniform binding +@extension{ARB,shader_precision} | done (shading language only) +@extension{ARB,vertex_attrib_64bit} | done +@extension{ARB,viewport_array} | | @subsection opengl-support-42 OpenGL 4.2 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,texture_compression_bptc} | done -@extension{ARB,base_instance} | done -@extension{ARB,shading_language_420pack} | done (shading language only) +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,texture_compression_bptc} | done +@extension{ARB,base_instance} | done +@extension{ARB,shading_language_420pack} | done (shading language only) @extension{ARB,transform_feedback_instanced} | | @extension{ARB,compressed_texture_pixel_storage} | | -@extension{ARB,conservative_depth} | done (shading language only) -@extension{ARB,internalformat_query} | | -@extension{ARB,map_buffer_alignment} | done -@extension{ARB,shader_atomic_counters} | done -@extension{ARB,shader_image_load_store} | | -@extension{ARB,shading_language_packing} | done (shading language only) -@extension{ARB,texture_storage} | done +@extension{ARB,conservative_depth} | done (shading language only) +@extension{ARB,internalformat_query} | | +@extension{ARB,map_buffer_alignment} | done +@extension{ARB,shader_atomic_counters} | done +@extension{ARB,shader_image_load_store} | | +@extension{ARB,shading_language_packing} | done (shading language only) +@extension{ARB,texture_storage} | done @subsection opengl-support-43 OpenGL 4.3 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,arrays_of_arrays} | done (shading language only) -@extension{ARB,ES3_compatibility} | only conservative sample query -@extension{ARB,clear_buffer_object} | | -@extension{ARB,compute_shader} | | -@extension{ARB,copy_image} | | -@extension{KHR,debug} (also in ES) | missing log retrieval, sync, pipeline, transform feedback and sampler label and debug groups -@extension{ARB,explicit_uniform_location} | done -@extension{ARB,fragment_layer_viewport} | done (shading language only) -@extension{ARB,framebuffer_no_attachments} | | -@extension{ARB,internalformat_query2} | | -@extension{ARB,invalidate_subdata} | done -@extension{ARB,multi_draw_indirect} | | -@extension{ARB,program_interface_query} | | +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,arrays_of_arrays} | done (shading language only) +@extension{ARB,ES3_compatibility} | only conservative sample query +@extension{ARB,clear_buffer_object} | | +@extension{ARB,compute_shader} | | +@extension{ARB,copy_image} | | +@extension{KHR,debug} (also in ES) | missing log retrieval, sync, pipeline, transform feedback and sampler label and debug groups +@extension{ARB,explicit_uniform_location} | done +@extension{ARB,fragment_layer_viewport} | done (shading language only) +@extension{ARB,framebuffer_no_attachments} | | +@extension{ARB,internalformat_query2} | | +@extension{ARB,invalidate_subdata} | done +@extension{ARB,multi_draw_indirect} | | +@extension{ARB,program_interface_query} | | @extension{ARB,robust_buffer_access_behavior} | done (nothing to do) -@extension{ARB,shader_image_size} | done (shading language only) +@extension{ARB,shader_image_size} | done (shading language only) @extension{ARB,shader_storage_buffer_object} | only limit queries -@extension{ARB,stencil_texturing} | done -@extension{ARB,texture_buffer_range} | done -@extension{ARB,texture_query_levels} | done (shading language only) -@extension{ARB,texture_storage_multisample} | done -@extension{ARB,texture_view} | | -@extension{ARB,vertex_attrib_binding} | | +@extension{ARB,stencil_texturing} | done +@extension{ARB,texture_buffer_range} | done +@extension{ARB,texture_query_levels} | done (shading language only) +@extension{ARB,texture_storage_multisample} | done +@extension{ARB,texture_view} | | +@extension{ARB,vertex_attrib_binding} | | @subsection opengl-support-44 OpenGL 4.4 @todo Also fallback to @extension{AMD,query_buffer_object} @todo @extension{AMD,pinned_memory} "fallback" for @extension{ARB,buffer_storage} -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,buffer_storage} | | -@extension{ARB,clear_texture} | | -@extension{ARB,enhanced_layouts} | done (shading language only) -@extension{ARB,multi_bind} | only texture and buffer binding -@extension{ARB,query_buffer_object} | | +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,buffer_storage} | | +@extension{ARB,clear_texture} | | +@extension{ARB,enhanced_layouts} | done (shading language only) +@extension{ARB,multi_bind} | only texture and buffer binding +@extension{ARB,query_buffer_object} | | @extension{ARB,texture_mirror_clamp_to_edge} | done -@extension{ARB,texture_stencil8} | done -@extension{ARB,vertex_type_10f_11f_11f_rev} | done +@extension{ARB,texture_stencil8} | done +@extension{ARB,vertex_type_10f_11f_11f_rev} | done @subsection opengl-support-45 OpenGL 4.5 -%Extension | Status --------------------------------------------- | ------ -@extension{ARB,ES3_1_compatibility} | | -@extension{ARB,clip_control} | | -@extension{ARB,conditional_render_inverted} | done -@extension{ARB,cull_distance} | | -@extension{ARB,derivative_control} | done (shading language only) -@extension{ARB,direct_state_access} | object creation subset only -@extension{ARB,get_texture_sub_image} | | +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,ES3_1_compatibility} | | +@extension{ARB,clip_control} | | +@extension{ARB,conditional_render_inverted} | done +@extension{ARB,cull_distance} | | +@extension{ARB,derivative_control} | done (shading language only) +@extension{ARB,direct_state_access} | object creation subset only +@extension{ARB,get_texture_sub_image} | | @extension{ARB,shader_texture_image_samples} | done (shading language only) -@extension{ARB,texture_barrier} | | +@extension{ARB,texture_barrier} | | @extension{KHR,context_flush_control} (also in ES) | | -@extension{KHR,robustness} (also in ES) | | +@extension{KHR,robustness} (also in ES) | | @subsection opengl-support-extensions OpenGL extensions @@ -226,20 +226,20 @@ following: @todo @extension{ATI,meminfo}, @extension{NVX,gpu_memory_info}, GPU temperature @todo @extension{AMD,performance_monitor}, @extension{INTEL,performance_query} -%Extension | Status --------------------------------------------- | ------ -@extension{AMD,vertex_shader_layer} | done (shading language only) -@extension{AMD,shader_trinary_minmax} | done (shading language only) -@extension{ARB,robustness} | done -@extension{ATI,texture_mirror_once} | done (GL 4.4 subset) +%Extension | Status +------------------------------------------- | ------ +@extension{AMD,vertex_shader_layer} | done (shading language only) +@extension{AMD,shader_trinary_minmax} | done (shading language only) +@extension{ARB,robustness} | done +@extension{ATI,texture_mirror_once} | done (GL 4.4 subset) @extension{EXT,texture_filter_anisotropic} (also in ES) | done -@extension{EXT,texture_mirror_clamp} | only GL 4.4 subset -@extension{EXT,direct_state_access} | done for implemented functionality +@extension{EXT,texture_mirror_clamp} | only GL 4.4 subset +@extension{EXT,direct_state_access} | done for implemented functionality @extension{EXT,texture_sRGB_decode} (also in ES) | done @extension{EXT,shader_integer_mix} (also in ES) | done (shading language only) -@extension2{EXT,debug_label} (also in ES) | missing pipeline, transform feedback and sampler label -@extension2{EXT,debug_marker} (also in ES) | missing marker groups -@extension{GREMEDY,string_marker} | done +@extension2{EXT,debug_label} (also in ES) | missing pipeline, transform feedback and sampler label +@extension2{EXT,debug_marker} (also in ES) | missing marker groups +@extension{GREMEDY,string_marker} | done @subsection opengl-support-es20 OpenGL ES 2.0 @@ -258,50 +258,50 @@ supported. @subsection opengl-support-es30-extensions OpenGL ES 2.0 extensions to match ES 3.0 functionality -%Extension | Status --------------------------------------------- | ------ -@es_extension{ANGLE,framebuffer_blit} | done +%Extension | Status +------------------------------------------- | ------ +@es_extension{ANGLE,framebuffer_blit} | done @es_extension{ANGLE,framebuffer_multisample} | done -@es_extension{ANGLE,instanced_arrays} | done -@es_extension{ANGLE,depth_texture} | done +@es_extension{ANGLE,instanced_arrays} | done +@es_extension{ANGLE,depth_texture} | done @es_extension{APPLE,framebuffer_multisample} | done (ES 3.0 subset) -@es_extension{APPLE,texture_max_level} | done -@es_extension{ARM,rgba8} | done +@es_extension{APPLE,texture_max_level} | done +@es_extension{ARM,rgba8} | done @es_extension{EXT,texture_type_2_10_10_10_REV} | done -@es_extension{EXT,discard_framebuffer} | done +@es_extension{EXT,discard_framebuffer} | done @es_extension2{EXT,blend_minmax,blend_minmax} | done -@es_extension{EXT,shader_texture_lod} | done (shading language only) -@es_extension{EXT,occlusion_query_boolean} | done -@es_extension{EXT,shadow_samplers} | done -@es_extension{EXT,texture_rg} | done -@es_extension{EXT,texture_storage} | done -@es_extension{EXT,map_buffer_range} | done -@es_extension{EXT,instanced_arrays} | done +@es_extension{EXT,shader_texture_lod} | done (shading language only) +@es_extension{EXT,occlusion_query_boolean} | done +@es_extension{EXT,shadow_samplers} | done +@es_extension{EXT,texture_rg} | done +@es_extension{EXT,texture_storage} | done +@es_extension{EXT,map_buffer_range} | done +@es_extension{EXT,instanced_arrays} | done @es_extension2{EXT,draw_instanced,draw_instanced} | done -@es_extension{NV,draw_buffers} | done -@es_extension{NV,fbo_color_attachments} | done -@es_extension{NV,read_buffer} | done -@es_extension{NV,draw_instanced} | done -@es_extension{NV,framebuffer_blit} | done -@es_extension{NV,framebuffer_multisample} | done -@es_extension{NV,instanced_arrays} | done -@es_extension{NV,shadow_samplers_array} | done (shading language only) -@es_extension{NV,shadow_samplers_cube} | done (shading language only) -@es_extension{OES,depth24} | done -@es_extension{OES,element_index_uint} | done -@es_extension{OES,rgb8_rgba8} | done (desktop-compatible subset) -@es_extension{OES,texture_3D} | done +@es_extension{NV,draw_buffers} | done +@es_extension{NV,fbo_color_attachments} | done +@es_extension{NV,read_buffer} | done +@es_extension{NV,draw_instanced} | done +@es_extension{NV,framebuffer_blit} | done +@es_extension{NV,framebuffer_multisample} | done +@es_extension{NV,instanced_arrays} | done +@es_extension{NV,shadow_samplers_array} | done (shading language only) +@es_extension{NV,shadow_samplers_cube} | done (shading language only) +@es_extension{OES,depth24} | done +@es_extension{OES,element_index_uint} | done +@es_extension{OES,rgb8_rgba8} | done (desktop-compatible subset) +@es_extension{OES,texture_3D} | done @es_extension2{OES,texture_half_float_linear,OES_texture_float_linear} | done -@es_extension{OES,texture_float_linear} | done +@es_extension{OES,texture_float_linear} | done @es_extension2{OES,texture_half_float,OES_texture_float} | done -@es_extension{OES,texture_float} | done -@es_extension{OES,vertex_half_float} | done -@es_extension{OES,packed_depth_stencil} | done -@es_extension{OES,depth_texture} | done -@es_extension{OES,standard_derivatives} | done -@es_extension{OES,vertex_array_object} | done -@es_extension{OES,required_internalformat} | done (desktop-compatible subset) -@es_extension{OES,surfaceless_context} | done +@es_extension{OES,texture_float} | done +@es_extension{OES,vertex_half_float} | done +@es_extension{OES,packed_depth_stencil} | done +@es_extension{OES,depth_texture} | done +@es_extension{OES,standard_derivatives} | done +@es_extension{OES,vertex_array_object} | done +@es_extension{OES,required_internalformat} | done (desktop-compatible subset) +@es_extension{OES,surfaceless_context} | done @subsection opengl-support-es-extensions OpenGL ES extensions to match desktop functionality @@ -311,27 +311,27 @@ Only extensions not already listed in above tables are included here. @todo Support also IMG_multisampled_render_to_texture? It has different enum values (!) -%Extension | Status --------------------------------------------- | ------ +%Extension | Status +------------------------------------------- | ------ @es_extension{APPLE,texture_format_BGRA8888} | done -@es_extension{CHROMIUM,map_sub} | only buffer mapping -@es_extension{EXT,texture_format_BGRA8888} | done -@es_extension{EXT,read_format_bgra} | done +@es_extension{CHROMIUM,map_sub} | only buffer mapping +@es_extension{EXT,texture_format_BGRA8888} | done +@es_extension{EXT,read_format_bgra} | done @es_extension2{EXT,multi_draw_arrays,multi_draw_arrays} | done -@es_extension{EXT,disjoint_timer_query} | only time elapsed query -@es_extension{EXT,separate_shader_objects} | only direct uniform binding -@es_extension{EXT,sRGB} | done +@es_extension{EXT,disjoint_timer_query} | only time elapsed query +@es_extension{EXT,separate_shader_objects} | only direct uniform binding +@es_extension{EXT,sRGB} | done @es_extension{EXT,multisampled_render_to_texture} | only renderbuffer storage -@es_extension{EXT,robustness} | done +@es_extension{EXT,robustness} | done @es_extension2{NV,read_buffer_front,NV_read_buffer} | done @es_extension2{NV,read_depth,NV_read_depth_stencil} | done @es_extension2{NV,read_stencil,NV_read_depth_stencil} | done -@es_extension{NV,read_depth_stencil} | done -@es_extension{NV,texture_border_clamp} | done -@es_extension{OES,depth32} | done -@es_extension{OES,mapbuffer} | done -@es_extension{OES,stencil1} | done -@es_extension{OES,stencil4} | done +@es_extension{NV,read_depth_stencil} | done +@es_extension{NV,texture_border_clamp} | done +@es_extension{OES,depth32} | done +@es_extension{OES,mapbuffer} | done +@es_extension{OES,stencil1} | done +@es_extension{OES,stencil4} | done @section opengl-unsupported Unsupported OpenGL features From c3f9e6f32f06047704974a217730111cfe477540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 17:45:05 +0200 Subject: [PATCH 58/72] doc: added GL_MAX_VERTEX_ATTRIB_STRIDE to mapping and support table. Added in 4.4 but not backed by any extension. --- doc/opengl-mapping.dox | 1 + doc/opengl-support.dox | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 1849650fd..179223bac 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -442,6 +442,7 @@ OpenGL function | Matching API @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} | @ref Buffer::maxUniformBindings() @def_gl{MAX_UNIFORM_LOCATIONS} | @ref AbstractShaderProgram::maxUniformLocations() @def_gl{MAX_VERTEX_ATTRIBS} | @ref AbstractShaderProgram::maxVertexAttributes() +@def_gl{MAX_VERTEX_ATTRIB_STRIDE} | | @def_gl{MAX_VERTEX_ATTRIB_BINDINGS} | | @def_gl{MAX_VERTEX_ATTRIB_RELATIVE_OFFSET} | | @def_gl{MAX_VIEWPORTS} | | diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index ec28d2023..4edb0d4a6 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -195,6 +195,7 @@ following: %Extension | Status ------------------------------------------- | ------ +@def_gl{MAX_VERTEX_ATTRIB_STRIDE} | | @extension{ARB,buffer_storage} | | @extension{ARB,clear_texture} | | @extension{ARB,enhanced_layouts} | done (shading language only) From bf7e126dcc0d8d281b113816b4c1898c17d86e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 18:02:13 +0200 Subject: [PATCH 59/72] doc: removed deprecated GL features from the mapping table. --- doc/opengl-mapping.dox | 3 +-- doc/opengl-support.dox | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index 179223bac..7d7c55992 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -426,7 +426,7 @@ OpenGL function | Matching API @def_gl{MAX_FRAMEBUFFER_LAYERS} | | @def_gl{MAX_FRAMEBUFFER_SAMPLES} | | @def_gl{MAX_FRAMEBUFFER_WIDTH} | | -@def_gl{MAX_FRAGMENT_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_OUTPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VERTEX_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VARYING_COMPONENTS}, \n @def_gl{MAX_VARYING_FLOATS}, \n @def_gl{MAX_VARYING_VECTORS} | @ref Shader::maxFragmentInputComponents(), \n @ref Shader::maxGeometryInputComponents(), \n @ref Shader::maxGeometryOutputComponents(), \n @ref Shader::maxGeometryTotalOutputComponents(), \n @ref Shader::maxTessellationControlInputComponents(), \n @ref Shader::maxTessellationControlOutputComponents(), \n @ref Shader::maxTessellationControlTotalOutputComponents(), \n @ref Shader::maxTessellationEvaluationInputComponents(), \n @ref Shader::maxTessellationEvaluationOutputComponents(), \n @ref Shader::maxVertexOutputComponents() +@def_gl{MAX_FRAGMENT_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_INPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_OUTPUT_COMPONENTS}, \n @def_gl{MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_INPUT_COMPONENTS}, \n @def_gl{MAX_TESS_EVALUATION_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VERTEX_OUTPUT_COMPONENTS}, \n @def_gl{MAX_VARYING_VECTORS} | @ref Shader::maxFragmentInputComponents(), \n @ref Shader::maxGeometryInputComponents(), \n @ref Shader::maxGeometryOutputComponents(), \n @ref Shader::maxGeometryTotalOutputComponents(), \n @ref Shader::maxTessellationControlInputComponents(), \n @ref Shader::maxTessellationControlOutputComponents(), \n @ref Shader::maxTessellationControlTotalOutputComponents(), \n @ref Shader::maxTessellationEvaluationInputComponents(), \n @ref Shader::maxTessellationEvaluationOutputComponents(), \n @ref Shader::maxVertexOutputComponents() @def_gl{MAX_IMAGE_SAMPLES} | @ref AbstractShaderProgram::maxImageSamples() @def_gl{MAX_IMAGE_UNITS} | @ref AbstractShaderProgram::maxImageUnits() @def_gl{MAX_LABEL_LENGTH} | @ref AbstractObject::maxLabelLength() @@ -449,7 +449,6 @@ OpenGL function | Matching API @def_gl{MAX_VIEWPORT_DIMS} | @ref AbstractFramebuffer::maxViewportSize() @def_gl{MIN_MAP_BUFFER_ALIGNMENT} | @ref Buffer::minMapAlignment() @def_gl{MIN_PROGRAM_TEXEL_OFFSET}, \n @def_gl{MAX_PROGRAM_TEXEL_OFFSET} | @ref AbstractShaderProgram::minTexelOffset(), \n @ref AbstractShaderProgram::maxTexelOffset() -@def_gl{NUM_COMPRESSED_TEXTURE_FORMATS}, \n @def_gl{COMPRESSED_TEXTURE_FORMATS} | | @def_gl{NUM_EXTENSIONS} | @ref Context::supportedExtensions() @def_gl{NUM_PROGRAM_BINARY_FORMATS}, \n @def_gl{PROGRAM_BINARY_FORMATS} | | @def_gl{NUM_SHADER_BINARY_FORMATS}, \n @def_gl{SHADER_BINARY_FORMATS} | | diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 4edb0d4a6..3fa53891c 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -342,6 +342,10 @@ add any performance gains, is not supported in %Magnum. See also @subsection opengl-unsupported-features Unsupported features +- API that is not part of core profile or is marked as deprecated (but still + supported in core profile) in the latest version of OpenGL specification is + not supported. The only exception are features that are needed for some + OpenGL ES 2.0 implementations (such as luminance texture formats). - State queries (various `glIs*()`, `glGet*()` functions) are not supported. %Magnum API is designed to prevent the need for majority of them, many of them are tracked internally to avoid redundant state changes and in many From fcde4b10b4160c05236999dded7665af5c2d1926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 18:02:52 +0200 Subject: [PATCH 60/72] doc: explicitly mention that we support all GLSL versions. The support is just a matter of adding a value to switch in Shader.cpp, but even that must be done by someone. --- doc/opengl-support.dox | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 3fa53891c..9cbd9e238 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -53,6 +53,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 1.30 | done @extension{ARB,map_buffer_range} | done @extension{ARB,color_buffer_float} | | @extension{ARB,half_float_pixel} | done @@ -78,6 +79,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 1.40 | done @extension{ARB,texture_rectangle} | done @extension{ARB,draw_instanced} | done @extension{ARB,texture_buffer_object} | done @@ -90,6 +92,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 1.50 | done @extension{ARB,geometry_shader4} | missing layered attachments @extension{ARB,depth_clamp} | done @extension{ARB,draw_elements_base_vertex} | done @@ -104,6 +107,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 3.30 | done @extension{ARB,instanced_arrays} | done @extension{ARB,blend_func_extended} | done @extension{ARB,explicit_attrib_location} | done (shading language only) @@ -119,6 +123,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 4.00 | done @extension{ARB,draw_buffers_blend} | | @extension{ARB,sample_shading} | | @extension{ARB,texture_cube_map_array} | done @@ -137,6 +142,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 4.10 | done @extension{ARB,ES2_compatibility} | only float depth clear @extension{ARB,get_program_binary} | | @extension{ARB,separate_shader_objects} | only direct uniform binding @@ -148,6 +154,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 4.20 | done @extension{ARB,texture_compression_bptc} | done @extension{ARB,base_instance} | done @extension{ARB,shading_language_420pack} | done (shading language only) @@ -165,6 +172,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 4.30 | done @extension{ARB,arrays_of_arrays} | done (shading language only) @extension{ARB,ES3_compatibility} | only conservative sample query @extension{ARB,clear_buffer_object} | | @@ -195,6 +203,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 4.40 | done @def_gl{MAX_VERTEX_ATTRIB_STRIDE} | | @extension{ARB,buffer_storage} | | @extension{ARB,clear_texture} | | @@ -209,6 +218,7 @@ following: %Extension | Status ------------------------------------------- | ------ +GLSL 4.50 | done @extension{ARB,ES3_1_compatibility} | | @extension{ARB,clip_control} | | @extension{ARB,conditional_render_inverted} | done @@ -245,17 +255,17 @@ following: @subsection opengl-support-es20 OpenGL ES 2.0 Features that have their equivalents implemented in desktop version are -supported. +supported. ESSL 1.00 is supported. @subsection opengl-support-es30 OpenGL ES 3.0 Features that have their equivalents implemented in desktop version are -supported. +supported. ESSL 3.00 is supported. @subsection opengl-support-es31 OpenGL ES 3.1 Features that have their equivalents implemented in desktop version are -supported. +supported. ESSL 3.10 is supported. @subsection opengl-support-es30-extensions OpenGL ES 2.0 extensions to match ES 3.0 functionality From 64e85966de7150a7485125d16ad1c184ea0cb139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 18:17:19 +0200 Subject: [PATCH 61/72] Replaced NV_half_float with hopefully more standard ARB_half_float. According to reports on delphigl.de this extension is far more supported in comparison to the NV version (and also there's much less FF cruft in the specification). --- doc/opengl-support.dox | 3 +-- src/Magnum/AbstractShaderProgram.h | 2 +- src/Magnum/ColorFormat.h | 2 +- src/Magnum/Context.cpp | 2 +- src/Magnum/Extensions.h | 2 +- src/Magnum/Test/MeshGLTest.cpp | 4 ++-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 9cbd9e238..cef8bbf91 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -49,7 +49,6 @@ following: @todo @extension{EXT,texture_array} overlaps with @extension{ARB,framebuffer_object} @todo Add @extension{ARB,depth_buffer_float} and implement the missing @fn_gl{DepthRange} function, but keep (and implement) @extension{NV,depth_buffer_float} for non-linear depth buffer -@todo @extension{ARB,half_float_pixel}, @extension{ARB,half_float_vertex}? %Extension | Status ------------------------------------------- | ------ @@ -62,6 +61,7 @@ GLSL 1.30 | done @extension{ARB,texture_rg} | done @extension{ARB,vertex_array_object} | done @extension{ARB,framebuffer_object} | done +@extension{ARB,half_float_vertex} | done @extension{EXT,gpu_shader4} | done @extension{EXT,packed_float} | done @extension{EXT,texture_array} | done @@ -71,7 +71,6 @@ GLSL 1.30 | done @extension{EXT,draw_buffers2} | | @extension{EXT,texture_integer} | done (GL 3.0 subset) @extension{EXT,transform_feedback} | | -@extension{NV,half_float} | done (GL 3.0 subset) @extension{NV,depth_buffer_float} | | @extension{NV,conditional_render} | done diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index b9305c99a..4d0ba00b5 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -1137,7 +1137,7 @@ template class AbstractShaderProgram::Attribute { /** * Half float. Only for float attribute types. - * @requires_gl30 %Extension @extension{NV,half_float} + * @requires_gl30 %Extension @extension{ARB,half_float_vertex} * @requires_gles30 %Extension @es_extension{OES,vertex_half_float} * in OpenGL ES 2.0 */ diff --git a/src/Magnum/ColorFormat.h b/src/Magnum/ColorFormat.h index ecfc6ee6e..f7d2f52a4 100644 --- a/src/Magnum/ColorFormat.h +++ b/src/Magnum/ColorFormat.h @@ -331,7 +331,7 @@ enum class ColorType: GLenum { /** * Each component half float. - * @requires_gl30 %Extension @extension{NV,half_float} / @extension{ARB,half_float_pixel} + * @requires_gl30 %Extension @extension{ARB,half_float_pixel} * @requires_gles30 For texture data only, extension * @es_extension2{OES,texture_half_float,OES_texture_float} in OpenGL * ES 2.0 diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 0add782d0..9fd8c97c7 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -80,6 +80,7 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,ARB,texture_rg), _extension(GL,ARB,vertex_array_object), _extension(GL,ARB,framebuffer_object), + _extension(GL,ARB,half_float_vertex), _extension(GL,EXT,gpu_shader4), _extension(GL,EXT,packed_float), _extension(GL,EXT,texture_array), @@ -89,7 +90,6 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,draw_buffers2), _extension(GL,EXT,texture_integer), _extension(GL,EXT,transform_feedback), - _extension(GL,NV,half_float), _extension(GL,NV,depth_buffer_float), _extension(GL,NV,conditional_render)}; static const std::vector extensions310{ diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 9032773cf..bb2d8b7c3 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -82,6 +82,7 @@ namespace GL { _extension(GL,ARB,draw_instanced, GL210, GL310) // #44 _extension(GL,ARB,framebuffer_object, GL210, GL300) // #45 _extension(GL,ARB,geometry_shader4, GL210, GL320) // #47 + _extension(GL,ARB,half_float_vertex, GL210, GL300) // #48 _extension(GL,ARB,instanced_arrays, GL210, GL330) // #49 _extension(GL,ARB,map_buffer_range, GL210, GL300) // #50 _extension(GL,ARB,texture_buffer_object, GL210, GL310) // #51 @@ -207,7 +208,6 @@ namespace GL { _extension(GL,KHR,context_flush_control, GL210, GL450) // #168 _extension(GL,KHR,robustness, GL320, GL450) // #170 } namespace NV { - _extension(GL,NV,half_float, GL210, GL300) // #283 _extension(GL,NV,primitive_restart, GL210, GL310) // #285 _extension(GL,NV,depth_buffer_float, GL210, GL300) // #334 _extension(GL,NV,conditional_render, GL210, GL300) // #346 diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 51bbf2764..a064dfe8b 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -896,8 +896,8 @@ void MeshGLTest::addVertexBufferIntWithShort() { void MeshGLTest::addVertexBufferFloatWithHalfFloat() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::NV::half_float::string() + std::string(" is not supported.")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::half_float_vertex::string() + std::string(" is not supported.")); #elif defined(MAGNUM_TARGET_GLES2) if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::vertex_half_float::string() + std::string(" is not supported.")); From d3b17273b0584f16e9289c5cf54d781b4474ba01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 19:42:56 +0200 Subject: [PATCH 62/72] doc: cleanup. --- doc/opengl-support.dox | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index cef8bbf91..c41f88abe 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -382,11 +382,12 @@ add any performance gains, is not supported in %Magnum. See also @subsection opengl-unsupported-extensions Unsupported extensions -- @extension{INTEL,map_texture} negatively affects texture access performance. - Combination of buffer mapping and pixel buffers might be of the same or - better performance, without affecting texture access speed. -- @extension{NV,draw_texture} can be done with framebuffer blitting and - doesn't make any full-screen postprocessing easier, as shaders are excluded. +- @extension{INTEL,map_texture} negatively affects texture access + performance. Combination of buffer mapping and pixel buffers might be of + the same or better performance, without affecting texture access speed. +- @extension{NV,draw_texture} can be done with framebuffer blitting and + doesn't make any full-screen postprocessing easier, as shaders are + excluded. */ From 1d8b0ba26897e0619ce2078a4cd4ed101c66c3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 19:46:00 +0200 Subject: [PATCH 63/72] Added remaining non-core ARB/KHR extensions to the list. --- Doxyfile | 1 + doc/opengl-support.dox | 32 +++++++++++++++++++++++++++++--- src/Magnum/Context.cpp | 20 ++++++++++++++++++-- src/Magnum/Extensions.h | 20 +++++++++++++++++--- 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/Doxyfile b/Doxyfile index 3cf913f0b..0335627a3 100644 --- a/Doxyfile +++ b/Doxyfile @@ -262,6 +262,7 @@ ALIASES = \ "requires_extension=@xrefitem requires-extension \"Requires OpenGL extension\" \"Functionality requiring specific OpenGL extension\"" \ "extension{2}=\1_\2" \ "extension2{2}=\1_\2" \ + "extension3{3}=\1_\2" \ "requires_gles30=@xrefitem requires-gles30 \"Requires OpenGL ES 3.0\" \"Functionality requiring OpenGL ES 3.0\"" \ "requires_gles31=@xrefitem requires-gles31 \"Requires OpenGL ES 3.1\" \"Functionality requiring OpenGL ES 3.1\"" \ "requires_gl=@xrefitem requires-gl \"Requires desktop OpenGL\" \"Functionality requiring desktop OpenGL (not available in OpenGL ES)\"" \ diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index c41f88abe..3a3ad8c25 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -230,7 +230,26 @@ GLSL 4.50 | done @extension{KHR,context_flush_control} (also in ES) | | @extension{KHR,robustness} (also in ES) | | -@subsection opengl-support-extensions OpenGL extensions +@subsection opengl-support-extensions ARB / Khronos OpenGL extensions + +%Extension | Status +------------------------------------------- | ------ +@extension{ARB,robustness} | done +@extension3{KHR,texture_compression_astc_ldr,texture_compression_astc_hdr} (also in ES) | | +@extension{KHR,texture_compression_astc_hdr} (also in ES) | | +@extension{ARB,robustness_isolation} | | +@extension{ARB,bindless_texture} | | +@extension{ARB,compute_variable_group_size} | | +@extension{ARB,indirect_parameters} | | +@extension{ARB,seamless_cubemap_per_texture} | | +@extension{ARB,shader_draw_parameters} | done (shading language only) +@extension{ARB,shader_group_vote} | done (shading language only) +@extension{ARB,sparse_texture} | | +@extension{ARB,pipeline_statistics_query} | | +@extension{ARB,sparse_buffer} | | +@extension{ARB,transform_feedback_overflow_query} | | + +@subsection opengl-support-extensions-vendor Vendor OpenGL extensions @todo @extension{ARB,sparse_texture}, @extension{ARB,bindless_texture} + their vendor equivalents @todo @extension{ATI,meminfo}, @extension{NVX,gpu_memory_info}, GPU temperature @@ -240,7 +259,6 @@ GLSL 4.50 | done ------------------------------------------- | ------ @extension{AMD,vertex_shader_layer} | done (shading language only) @extension{AMD,shader_trinary_minmax} | done (shading language only) -@extension{ARB,robustness} | done @extension{ATI,texture_mirror_once} | done (GL 4.4 subset) @extension{EXT,texture_filter_anisotropic} (also in ES) | done @extension{EXT,texture_mirror_clamp} | only GL 4.4 subset @@ -333,6 +351,7 @@ Only extensions not already listed in above tables are included here. @es_extension{EXT,sRGB} | done @es_extension{EXT,multisampled_render_to_texture} | only renderbuffer storage @es_extension{EXT,robustness} | done +@es_extension{KHR,robust_buffer_access_behavior} | done (nothing to do) @es_extension2{NV,read_buffer_front,NV_read_buffer} | done @es_extension2{NV,read_depth,NV_read_depth_stencil} | done @es_extension2{NV,read_stencil,NV_read_depth_stencil} | done @@ -380,7 +399,14 @@ add any performance gains, is not supported in %Magnum. See also - Direct vertex data specification (as opposed to using buffers) is not supported, as it encourages bad practices. -@subsection opengl-unsupported-extensions Unsupported extensions +@subsection opengl-unsupported-extensions Unsupported ARB / Khronos extensions + +- @extension{ARB,shading_language_include} is overly complicated and + supported exclusively by NVidia +- @extension{ARB,cl_event} seems to be not supported anywhere +- @extension{ARB,shader_stencil_export} is supported exclusively by AMD + +@subsection opengl-unsupported-extensions-vendor Unsupported vendor extensions - @extension{INTEL,map_texture} negatively affects texture access performance. Combination of buffer mapping and pixel buffers might be of diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 9fd8c97c7..9e2062824 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -62,6 +62,17 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,AMD,vertex_shader_layer), _extension(GL,AMD,shader_trinary_minmax), _extension(GL,ARB,robustness), + _extension(GL,ARB,robustness_isolation), + _extension(GL,ARB,bindless_texture), + _extension(GL,ARB,compute_variable_group_size), + _extension(GL,ARB,indirect_parameters), + _extension(GL,ARB,seamless_cubemap_per_texture), + _extension(GL,ARB,shader_draw_parameters), + _extension(GL,ARB,shader_group_vote), + _extension(GL,ARB,sparse_texture), + _extension(GL,ARB,pipeline_statistics_query), + _extension(GL,ARB,sparse_buffer), + _extension(GL,ARB,transform_feedback_overflow_query), _extension(GL,ATI,texture_mirror_once), _extension(GL,EXT,texture_filter_anisotropic), _extension(GL,EXT,texture_mirror_clamp), @@ -70,7 +81,9 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,shader_integer_mix), _extension(GL,EXT,debug_label), _extension(GL,EXT,debug_marker), - _extension(GL,GREMEDY,string_marker)}; + _extension(GL,GREMEDY,string_marker), + _extension(GL,KHR,texture_compression_astc_ldr), + _extension(GL,KHR,texture_compression_astc_hdr)}; static const std::vector extensions300{ _extension(GL,ARB,map_buffer_range), _extension(GL,ARB,color_buffer_float), @@ -217,9 +230,12 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,sRGB), _extension(GL,EXT,multisampled_render_to_texture), _extension(GL,EXT,robustness), + _extension(GL,KHR,texture_compression_astc_ldr), + _extension(GL,KHR,texture_compression_astc_hdr), _extension(GL,KHR,debug), - _extension(GL,KHR,context_flush_control), _extension(GL,KHR,robustness), + _extension(GL,KHR,robust_buffer_access_behavior), + _extension(GL,KHR,context_flush_control), _extension(GL,NV,read_buffer_front), _extension(GL,NV,read_depth), _extension(GL,NV,read_stencil), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index bb2d8b7c3..262779e5d 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -145,6 +145,7 @@ namespace GL { _extension(GL,ARB,copy_image, GL210, GL430) // #123 _extension(GL,ARB,texture_view, GL210, GL430) // #124 _extension(GL,ARB,vertex_attrib_binding, GL210, GL430) // #125 + _extension(GL,ARB,robustness_isolation, GL210, None) // #126 _extension(GL,ARB,ES3_compatibility, GL330, GL430) // #127 _extension(GL,ARB,explicit_uniform_location, GL210, GL430) // #128 _extension(GL,ARB,fragment_layer_viewport, GL300, GL430) // #129 @@ -168,6 +169,13 @@ namespace GL { _extension(GL,ARB,texture_mirror_clamp_to_edge, GL210, GL440) // #149 _extension(GL,ARB,texture_stencil8, GL210, GL440) // #150 _extension(GL,ARB,vertex_type_10f_11f_11f_rev, GL300, GL440) // #151 + _extension(GL,ARB,bindless_texture, GL400, None) // #152 + _extension(GL,ARB,compute_variable_group_size, GL420, None) // #153 + _extension(GL,ARB,indirect_parameters, GL420, None) // #154 + _extension(GL,ARB,seamless_cubemap_per_texture, GL320, None) // #155 + _extension(GL,ARB,shader_draw_parameters, GL310, None) // #156 + _extension(GL,ARB,shader_group_vote, GL420, None) // #157 + _extension(GL,ARB,sparse_texture, GL210, None) // #158 _extension(GL,ARB,ES3_1_compatibility, GL440, GL450) // #159 _extension(GL,ARB,clip_control, GL210, GL450) // #160 _extension(GL,ARB,conditional_render_inverted, GL300, GL450) // #161 @@ -177,6 +185,9 @@ namespace GL { _extension(GL,ARB,get_texture_sub_image, GL210, GL450) // #165 _extension(GL,ARB,shader_texture_image_samples, GL430, GL450) // #166 _extension(GL,ARB,texture_barrier, GL210, GL450) // #167 + _extension(GL,ARB,pipeline_statistics_query, GL300, None) // #171 + _extension(GL,ARB,sparse_buffer, GL210, None) // #172 + _extension(GL,ARB,transform_feedback_overflow_query, GL300, None) // #173 } namespace ATI { _extension(GL,ATI,texture_mirror_once, GL210, None) // #221 } namespace EXT { @@ -201,9 +212,9 @@ namespace GL { _extension(GL,EXT,debug_marker, GL210, None) // #440 } namespace GREMEDY { _extension(GL,GREMEDY,string_marker, GL210, None) // #311 - } namespace INTEL { - /* INTEL_map_texture not supported */ // #429 } namespace KHR { + _extension(GL,KHR,texture_compression_astc_ldr, GL210, None) // #118 + _extension(GL,KHR,texture_compression_astc_hdr, GL210, None) // #118 _extension(GL,KHR,debug, GL210, GL430) // #119 _extension(GL,KHR,context_flush_control, GL210, GL450) // #168 _extension(GL,KHR,robustness, GL320, GL450) // #170 @@ -213,7 +224,7 @@ namespace GL { _extension(GL,NV,conditional_render, GL210, GL300) // #346 /* NV_draw_texture not supported */ // #430 } - /* IMPORTANT: if this line is > 226 (66 + size), don't forget to update array size in Context.h */ + /* IMPORTANT: if this line is > 233 (73 + size), don't forget to update array size in Context.h */ #else #line 1 namespace ANGLE { @@ -279,8 +290,11 @@ namespace GL { _extension(GL,EXT,shader_integer_mix, GLES300, None) // #161 #endif } namespace KHR { + _extension(GL,KHR,texture_compression_astc_ldr, GLES200, None) // #117 + _extension(GL,KHR,texture_compression_astc_hdr, GLES200, None) // #117 _extension(GL,KHR,debug, GLES200, None) // #118 _extension(GL,KHR,robustness, GLES200, None) // #170 + _extension(GL,KHR,robust_buffer_access_behavior, GLES200, None) // #189 _extension(GL,KHR,context_flush_control, GLES200, None) // #191 } namespace NV { #ifdef MAGNUM_TARGET_GLES2 From 4c86d040426a0e522b5cc8b22a6604ffaf123b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 19:51:09 +0200 Subject: [PATCH 64/72] Support for ARB_robustness_isolation. Easier than forgetting about what I read and then learning that all again later. --- doc/opengl-support.dox | 2 +- src/Magnum/Context.cpp | 2 ++ src/Magnum/Extensions.h | 2 ++ src/Magnum/Platform/Sdl2Application.h | 7 +++++-- src/Magnum/Renderer.h | 23 ++++++++++++++++++++++- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 3a3ad8c25..e885670c9 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -237,7 +237,7 @@ GLSL 4.50 | done @extension{ARB,robustness} | done @extension3{KHR,texture_compression_astc_ldr,texture_compression_astc_hdr} (also in ES) | | @extension{KHR,texture_compression_astc_hdr} (also in ES) | | -@extension{ARB,robustness_isolation} | | +@extension{ARB,robustness_isolation} | done @extension{ARB,bindless_texture} | | @extension{ARB,compute_variable_group_size} | | @extension{ARB,indirect_parameters} | | diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 9e2062824..a5861b97b 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -63,6 +63,8 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,AMD,shader_trinary_minmax), _extension(GL,ARB,robustness), _extension(GL,ARB,robustness_isolation), + _extension(GL,ARB,robustness_application_isolation), + _extension(GL,ARB,robustness_share_group_isolation), _extension(GL,ARB,bindless_texture), _extension(GL,ARB,compute_variable_group_size), _extension(GL,ARB,indirect_parameters), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 262779e5d..78e6fb118 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -146,6 +146,8 @@ namespace GL { _extension(GL,ARB,texture_view, GL210, GL430) // #124 _extension(GL,ARB,vertex_attrib_binding, GL210, GL430) // #125 _extension(GL,ARB,robustness_isolation, GL210, None) // #126 + _extension(GL,ARB,robustness_application_isolation, GL210, None) // #126 + _extension(GL,ARB,robustness_share_group_isolation, GL210, None) // #126 _extension(GL,ARB,ES3_compatibility, GL330, GL430) // #127 _extension(GL,ARB,explicit_uniform_location, GL210, GL430) // #128 _extension(GL,ARB,fragment_layer_viewport, GL300, GL430) // #129 diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index f963ed86a..f7af7e6ce 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -436,7 +436,10 @@ class Sdl2Application::Configuration { Debug = SDL_GL_CONTEXT_DEBUG_FLAG, /**< Create debug context */ /** Create context with robust access */ - RobustAccess = SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG + RobustAccess = SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG, + + /** Create context with reset isolation */ + ResetIsolation = SDL_GL_CONTEXT_RESET_ISOLATION_FLAG }; /** @@ -447,7 +450,7 @@ class Sdl2Application::Configuration { */ #ifndef DOXYGEN_GENERATING_OUTPUT typedef Containers::EnumSet Flags; + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG|SDL_GL_CONTEXT_RESET_ISOLATION_FLAG> Flags; #else typedef Containers::EnumSet Flags; #endif diff --git a/src/Magnum/Renderer.h b/src/Magnum/Renderer.h index 90d0cdf26..f36701e06 100644 --- a/src/Magnum/Renderer.h +++ b/src/Magnum/Renderer.h @@ -1040,6 +1040,12 @@ class MAGNUM_EXPORT Renderer { * OpenGL calls. If OpenGL extension @extension{ARB,robustness} or ES * extension @es_extension{EXT,robustness} is not available, this * function always returns @ref ResetNotificationStrategy::NoResetNotification. + * + * For the reset notification to work, additionally to the extension + * support the context must be created with + * @ref Platform::Sdl2Application::Configuration::Flag::RobustAccess "Platform::*Application::Configuration::Flag::RobustAccess" + * flag. + * * @see @ref graphicsResetStatus(), @fn_gl{Get} with * @def_gl{RESET_NOTIFICATION_STRATEGY_ARB} */ @@ -1084,7 +1090,22 @@ class MAGNUM_EXPORT Renderer { * Reset causes all context state to be lost. If OpenGL extension * @extension{ARB,robustness} or ES extension @es_extension{EXT,robustness} * is not available, this function always returns @ref GraphicsResetStatus::NoError. - * @see @ref resetNotificationStrategy(), @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness} + * + * For the reset notification to work, additionally to the extension + * support the context must be created with + * @ref Platform::Sdl2Application::Configuration::Flag::RobustAccess "Platform::*Application::Configuration::Flag::RobustAccess" + * flag. + * + * If the reset occurs, @extension{ARB,robustness_isolation} + * extension is supported and context is created with + * @ref Platform::Sdl2Application::Configuration::Flag::ResetIsolation "Platform::*Application::Configuration::Flag::ResetIsolation", + * advertised support for @extension{ARB,robustness_application_isolation} + * indicates that no other application on the system will be affected + * by the graphics reset. Advertised support for + * @extension{ARB,robustness_share_group_isolation} indicates that no + * other share group will be affected by the graphics reset. + * @see @ref resetNotificationStrategy(), + * @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness} */ static GraphicsResetStatus graphicsResetStatus(); From e739c86e7201dbccd353d0ae04dea451f8eee29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 20:06:58 +0200 Subject: [PATCH 65/72] Replaced EXT_framebuffer_sRGB with ARB_framebuffer_sRGB. Also seems to have wider support than the EXT version. --- doc/opengl-support.dox | 2 +- src/Magnum/Context.cpp | 2 +- src/Magnum/Extensions.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index e885670c9..0f44e9385 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -61,13 +61,13 @@ GLSL 1.30 | done @extension{ARB,texture_rg} | done @extension{ARB,vertex_array_object} | done @extension{ARB,framebuffer_object} | done +@extension{ARB,framebuffer_sRGB} | | @extension{ARB,half_float_vertex} | done @extension{EXT,gpu_shader4} | done @extension{EXT,packed_float} | done @extension{EXT,texture_array} | done @extension{EXT,texture_compression_rgtc} | done @extension{EXT,texture_shared_exponent} | done -@extension{EXT,framebuffer_sRGB} | | @extension{EXT,draw_buffers2} | | @extension{EXT,texture_integer} | done (GL 3.0 subset) @extension{EXT,transform_feedback} | | diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index a5861b97b..ddaaf3c1a 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -95,13 +95,13 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,ARB,texture_rg), _extension(GL,ARB,vertex_array_object), _extension(GL,ARB,framebuffer_object), + _extension(GL,ARB,framebuffer_sRGB), _extension(GL,ARB,half_float_vertex), _extension(GL,EXT,gpu_shader4), _extension(GL,EXT,packed_float), _extension(GL,EXT,texture_array), _extension(GL,EXT,texture_compression_rgtc), _extension(GL,EXT,texture_shared_exponent), - _extension(GL,EXT,framebuffer_sRGB), _extension(GL,EXT,draw_buffers2), _extension(GL,EXT,texture_integer), _extension(GL,EXT,transform_feedback), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 78e6fb118..7e8312138 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -81,6 +81,7 @@ namespace GL { _extension(GL,ARB,depth_buffer_float, GL210, GL300) // #43 _extension(GL,ARB,draw_instanced, GL210, GL310) // #44 _extension(GL,ARB,framebuffer_object, GL210, GL300) // #45 + _extension(GL,ARB,framebuffer_sRGB, GL210, GL300) // #46 _extension(GL,ARB,geometry_shader4, GL210, GL320) // #47 _extension(GL,ARB,half_float_vertex, GL210, GL300) // #48 _extension(GL,ARB,instanced_arrays, GL210, GL330) // #49 @@ -202,7 +203,6 @@ namespace GL { _extension(GL,EXT,texture_array, GL210, GL300) // #329 _extension(GL,EXT,texture_compression_rgtc, GL210, GL300) // #332 _extension(GL,EXT,texture_shared_exponent, GL210, GL300) // #333 - _extension(GL,EXT,framebuffer_sRGB, GL210, GL300) // #337 _extension(GL,EXT,draw_buffers2, GL210, GL300) // #340 _extension(GL,EXT,texture_integer, GL210, GL300) // #343 _extension(GL,EXT,transform_feedback, GL210, GL300) // #352 From 2c998d2a385b77fde4c96c7b22beaec8e7849609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 14 Sep 2014 20:14:40 +0200 Subject: [PATCH 66/72] Support ARB_framebuffer_sRGB. Hell, this extension (and EXT_sRGB on ES) is written in so complicated language that I'm not sure at all if I understood it right and implemented completely. --- doc/opengl-support.dox | 2 +- src/Magnum/Renderer.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 0f44e9385..3b14aaf3d 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -61,7 +61,7 @@ GLSL 1.30 | done @extension{ARB,texture_rg} | done @extension{ARB,vertex_array_object} | done @extension{ARB,framebuffer_object} | done -@extension{ARB,framebuffer_sRGB} | | +@extension{ARB,framebuffer_sRGB} | done @extension{ARB,half_float_vertex} | done @extension{EXT,gpu_shader4} | done @extension{EXT,packed_float} | done diff --git a/src/Magnum/Renderer.h b/src/Magnum/Renderer.h index f36701e06..aaf574f4c 100644 --- a/src/Magnum/Renderer.h +++ b/src/Magnum/Renderer.h @@ -135,6 +135,14 @@ class MAGNUM_EXPORT Renderer { FaceCulling = GL_CULL_FACE, #ifndef MAGNUM_TARGET_GLES + /** + * sRGB encoding of the default framebuffer + * @requires_gl30 %Extension @extension{ARB,framebuffer_sRGB} + * @requires_gl sRGB encoding of the default framebuffer is + * implementation-defined in OpenGL ES. + */ + FramebufferSRGB = GL_FRAMEBUFFER_SRGB, + /** * Logical operation * @see @ref setLogicOperation() From bfb58d0b556ee9816e0d4f6e5cee6d494a996755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Sep 2014 17:31:55 +0200 Subject: [PATCH 67/72] ARB_direct_state_access support for creating queries. With DSA there is slightly different (but completely understandable) usage -- it's needed to specify the target upon creation, not deferring it to begin() call. Timestamp queries (TimeQuery::timestamp()) must now also be created with new TimeQuery::Target::Timestamp target. The old way (parameterless constructor and begin(Target)) is still supported, but is marked as deprecated and will be removed in future release. Also, using the old way the DSA function is simply not used. Also fixed SampleQuery test to account for cases where the driver might not support ARB_occlusion_query2. --- src/Magnum/AbstractQuery.cpp | 66 +++++++++++++++--------- src/Magnum/AbstractQuery.h | 30 ++++++++--- src/Magnum/CMakeLists.txt | 2 + src/Magnum/Implementation/QueryState.cpp | 52 +++++++++++++++++++ src/Magnum/Implementation/QueryState.h | 44 ++++++++++++++++ src/Magnum/Implementation/State.cpp | 2 + src/Magnum/Implementation/State.h | 2 + src/Magnum/PrimitiveQuery.h | 30 +++++++++-- src/Magnum/SampleQuery.h | 32 ++++++++++-- src/Magnum/Test/AbstractQueryGLTest.cpp | 35 ++++++++++--- src/Magnum/Test/PrimitiveQueryGLTest.cpp | 4 +- src/Magnum/Test/SampleQueryGLTest.cpp | 18 ++++--- src/Magnum/Test/TimeQueryGLTest.cpp | 14 ++--- src/Magnum/TimeQuery.h | 42 +++++++++++++-- 14 files changed, 304 insertions(+), 69 deletions(-) create mode 100644 src/Magnum/Implementation/QueryState.cpp create mode 100644 src/Magnum/Implementation/QueryState.h diff --git a/src/Magnum/AbstractQuery.cpp b/src/Magnum/AbstractQuery.cpp index 5cc789740..6221e3fad 100644 --- a/src/Magnum/AbstractQuery.cpp +++ b/src/Magnum/AbstractQuery.cpp @@ -29,19 +29,20 @@ #include "Magnum/Context.h" #include "Magnum/Implementation/DebugState.h" +#include "Magnum/Implementation/QueryState.h" #include "Magnum/Implementation/State.h" namespace Magnum { +AbstractQuery::AbstractQuery(GLenum target): _target{target} { + (this->*Context::current()->state().query->createImplementation)(); +} + +#ifdef MAGNUM_BUILD_DEPRECATED AbstractQuery::AbstractQuery(): _target{} { - #ifndef MAGNUM_TARGET_GLES2 - glGenQueries(1, &_id); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glGenQueriesEXT(1, &_id); - #else - CORRADE_ASSERT_UNREACHABLE(); - #endif + createImplementationDefault(); } +#endif AbstractQuery::~AbstractQuery() { /* Moved out, nothing to do */ @@ -56,6 +57,22 @@ AbstractQuery::~AbstractQuery() { #endif } +void AbstractQuery::createImplementationDefault() { + #ifndef MAGNUM_TARGET_GLES2 + glGenQueries(1, &_id); + #elif !defined(CORRADE_TARGET_EMSCRIPTEN) + glGenQueriesEXT(1, &_id); + #else + CORRADE_ASSERT_UNREACHABLE(); + #endif +} + +#ifndef MAGNUM_TARGET_GLES +void AbstractQuery::createImplementationDSA() { + glCreateQueries(_target, 1, &_id); +} +#endif + std::string AbstractQuery::label() const { #ifndef MAGNUM_TARGET_GLES return Context::current()->state().debug->getLabelImplementation(GL_QUERY, _id); @@ -74,8 +91,6 @@ AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayReference< } bool AbstractQuery::resultAvailable() { - CORRADE_ASSERT(!_target, "AbstractQuery::resultAvailable(): the query is currently running", false); - GLuint result; #ifndef MAGNUM_TARGET_GLES2 glGetQueryObjectuiv(_id, GL_QUERY_RESULT_AVAILABLE, &result); @@ -89,8 +104,6 @@ bool AbstractQuery::resultAvailable() { #ifndef DOXYGEN_GENERATING_OUTPUT template<> UnsignedInt AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - UnsignedInt result; #ifndef MAGNUM_TARGET_GLES2 glGetQueryObjectuiv(_id, GL_QUERY_RESULT, &result); @@ -105,8 +118,6 @@ template<> UnsignedInt AbstractQuery::result() { template<> bool AbstractQuery::result() { return result() != 0; } template<> Int AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - Int result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjectiv(_id, GL_QUERY_RESULT, &result); @@ -120,8 +131,6 @@ template<> Int AbstractQuery::result() { #ifndef MAGNUM_TARGET_WEBGL template<> UnsignedLong AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - UnsignedLong result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjectui64v(_id, GL_QUERY_RESULT, &result); @@ -134,8 +143,6 @@ template<> UnsignedLong AbstractQuery::result() { } template<> Long AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - Long result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result); @@ -149,21 +156,33 @@ template<> Long AbstractQuery::result() { #endif #endif -void AbstractQuery::begin(const GLenum target) { - CORRADE_ASSERT(!_target, "AbstractQuery::begin(): the query is already running", ); +void AbstractQuery::begin() { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(_target); + #endif #ifndef MAGNUM_TARGET_GLES2 - glBeginQuery(_target = target, _id); + glBeginQuery(_target, _id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glBeginQueryEXT(_target = target, _id); + glBeginQueryEXT(_target, _id); #else - static_cast(target); CORRADE_ASSERT_UNREACHABLE(); #endif } +#ifdef MAGNUM_BUILD_DEPRECATED +void AbstractQuery::begin(const GLenum target) { + CORRADE_INTERNAL_ASSERT(!_target || _target == target); + + _target = target; + begin(); +} +#endif + void AbstractQuery::end() { - CORRADE_ASSERT(_target, "AbstractQuery::end(): the query is not running", ); + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(_target); + #endif #ifndef MAGNUM_TARGET_GLES2 glEndQuery(_target); @@ -172,7 +191,6 @@ void AbstractQuery::end() { #else CORRADE_ASSERT_UNREACHABLE(); #endif - _target = {}; } } diff --git a/src/Magnum/AbstractQuery.h b/src/Magnum/AbstractQuery.h index 0dcd628d4..9077a635f 100644 --- a/src/Magnum/AbstractQuery.h +++ b/src/Magnum/AbstractQuery.h @@ -37,6 +37,8 @@ namespace Magnum { +namespace Implementation { class QueryState; } + /** @brief Base class for queries @@ -45,6 +47,8 @@ more information. @todo `QUERY_COUNTER_BITS` (not sure since when this is supported) */ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { + friend class Implementation::QueryState; + public: /** @brief Copying is not allowed */ AbstractQuery(const AbstractQuery&) = delete; @@ -120,6 +124,14 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { */ template T result(); + /** + * @brief Begin query + * + * Begins counting until @ref end() is called. + * @see @fn_gl{BeginQuery} + */ + void begin(); + /** * @brief End query * @@ -129,14 +141,6 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { void end(); protected: - /** - * @brief Constructor - * - * Generates one OpenGL query. - * @see @fn_gl{GenQueries} - */ - explicit AbstractQuery(); - /** * @brief Destructor * @@ -148,11 +152,21 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { #ifdef DOXYGEN_GENERATING_OUTPUT private: #endif + explicit AbstractQuery(GLenum target); + + #ifdef MAGNUM_BUILD_DEPRECATED + explicit AbstractQuery(); void begin(GLenum target); + #endif private: AbstractQuery& setLabelInternal(Containers::ArrayReference label); + void MAGNUM_LOCAL createImplementationDefault(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationDSA(); + #endif + GLuint _id; GLenum _target; }; diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index b560ce451..588bc6d3e 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -58,6 +58,7 @@ set(Magnum_SRCS Implementation/DebugState.cpp Implementation/FramebufferState.cpp Implementation/MeshState.cpp + Implementation/QueryState.cpp Implementation/RendererState.cpp Implementation/ShaderProgramState.cpp Implementation/State.cpp @@ -128,6 +129,7 @@ set(Magnum_PRIVATE_HEADERS Implementation/FramebufferState.h Implementation/maxTextureSize.h Implementation/MeshState.h + Implementation/QueryState.h Implementation/RendererState.h Implementation/ShaderProgramState.h Implementation/ShaderState.h diff --git a/src/Magnum/Implementation/QueryState.cpp b/src/Magnum/Implementation/QueryState.cpp new file mode 100644 index 000000000..bec5f3d00 --- /dev/null +++ b/src/Magnum/Implementation/QueryState.cpp @@ -0,0 +1,52 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + 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 "QueryState.h" + +#include "Magnum/Context.h" +#include "Magnum/Extensions.h" + +namespace Magnum { namespace Implementation { + +QueryState::QueryState(Context& context, std::vector& extensions) { + /* Create implementation */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); + createImplementation = &AbstractQuery::createImplementationDSA; + + } else + #endif + { + createImplementation = &AbstractQuery::createImplementationDefault; + } + + #ifdef MAGNUM_TARGET_GLES + static_cast(context); + static_cast(extensions); + #endif +} + +}} diff --git a/src/Magnum/Implementation/QueryState.h b/src/Magnum/Implementation/QueryState.h new file mode 100644 index 000000000..75d0f3d45 --- /dev/null +++ b/src/Magnum/Implementation/QueryState.h @@ -0,0 +1,44 @@ +#ifndef Magnum_Implementation_QueryState_h +#define Magnum_Implementation_QueryState_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + 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 + +#include "Magnum/AbstractQuery.h" + +namespace Magnum { namespace Implementation { + +struct QueryState { + explicit QueryState(Context& context, std::vector& extensions); + + void reset(); + + void(AbstractQuery::*createImplementation)(); +}; + +}} + +#endif diff --git a/src/Magnum/Implementation/State.cpp b/src/Magnum/Implementation/State.cpp index 82354e734..490989a1a 100644 --- a/src/Magnum/Implementation/State.cpp +++ b/src/Magnum/Implementation/State.cpp @@ -34,6 +34,7 @@ #include "DebugState.h" #include "FramebufferState.h" #include "MeshState.h" +#include "QueryState.h" #include "RendererState.h" #include "ShaderState.h" #include "ShaderProgramState.h" @@ -55,6 +56,7 @@ State::State(Context& context) { debug = new DebugState(context, extensions); framebuffer = new FramebufferState(context, extensions); mesh = new MeshState(context, extensions); + query = new QueryState(context, extensions); renderer = new RendererState(context, extensions); shader = new ShaderState; shaderProgram = new ShaderProgramState(context, extensions); diff --git a/src/Magnum/Implementation/State.h b/src/Magnum/Implementation/State.h index f8e9c6a7f..481e6ad73 100644 --- a/src/Magnum/Implementation/State.h +++ b/src/Magnum/Implementation/State.h @@ -34,6 +34,7 @@ struct BufferState; struct DebugState; struct FramebufferState; struct MeshState; +struct QueryState; struct RendererState; struct ShaderState; struct ShaderProgramState; @@ -51,6 +52,7 @@ struct State { DebugState* debug; FramebufferState* framebuffer; MeshState* mesh; + QueryState* query; RendererState* renderer; ShaderState* shader; ShaderProgramState* shaderProgram; diff --git a/src/Magnum/PrimitiveQuery.h b/src/Magnum/PrimitiveQuery.h index d196e95ca..ad7649f19 100644 --- a/src/Magnum/PrimitiveQuery.h +++ b/src/Magnum/PrimitiveQuery.h @@ -79,18 +79,38 @@ class PrimitiveQuery: public AbstractQuery { TransformFeedbackPrimitivesWritten = GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN }; - explicit PrimitiveQuery() {} + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief PrimitiveQuery(Target) + * @deprecated Use @ref Magnum::PrimitiveQuery::PrimitiveQuery(Target) "PrimitiveQuery(Target)" + * instead. + */ + CORRADE_DEPRECATED("use PrimitiveQuery(Target) instead") explicit PrimitiveQuery() {} + #endif /** - * @brief Begin query + * @brief Constructor * - * Begins counting of given @p target until @ref end() is called. - * @see @fn_gl{BeginQuery} + * Creates new OpenGL query object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the query is created on first + * use. + * @see @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries} + */ + explicit PrimitiveQuery(Target target): AbstractQuery(GLenum(target)) {} + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AbstractQuery::begin() + * @deprecated Use @ref Magnum::AbstractQuery::begin() "begin()" + * instead. */ - void begin(Target target) { + CORRADE_DEPRECATED("use begin() instead") void begin(Target target) { AbstractQuery::begin(GLenum(target)); } + using AbstractQuery::begin; + #endif + /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT PrimitiveQuery& setLabel(const std::string& label) { diff --git a/src/Magnum/SampleQuery.h b/src/Magnum/SampleQuery.h index 9fee36ccf..594659eb8 100644 --- a/src/Magnum/SampleQuery.h +++ b/src/Magnum/SampleQuery.h @@ -172,13 +172,39 @@ class SampleQuery: public AbstractQuery { }; #endif - explicit SampleQuery() {} - /** @copydoc PrimitiveQuery::begin() */ - void begin(Target target) { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief SampleQuery(Target) + * @deprecated Use @ref Magnum::SampleQuery::SampleQuery(Target) "SampleQuery(Target)" + * instead. + */ + CORRADE_DEPRECATED("use SampleQuery(Target) instead") explicit SampleQuery() {} + #endif + + /** + * @brief Constructor + * + * Creates new OpenGL query object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the query is created on first + * use. + * @see @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries} + */ + explicit SampleQuery(Target target): AbstractQuery(GLenum(target)) {} + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AbstractQuery::begin() + * @deprecated Use @ref Magnum::AbstractQuery::begin() "begin()" + * instead. + */ + CORRADE_DEPRECATED("use begin() instead") void begin(Target target) { AbstractQuery::begin(GLenum(target)); } + using AbstractQuery::begin; + #endif + #ifndef MAGNUM_TARGET_GLES /** * @brief Begin conditional rendering based on result value diff --git a/src/Magnum/Test/AbstractQueryGLTest.cpp b/src/Magnum/Test/AbstractQueryGLTest.cpp index 256fc236e..241133f62 100644 --- a/src/Magnum/Test/AbstractQueryGLTest.cpp +++ b/src/Magnum/Test/AbstractQueryGLTest.cpp @@ -54,7 +54,11 @@ void AbstractQueryGLTest::construct() { #endif { - const SampleQuery query; + #ifndef MAGNUM_TARGET_GLES + const SampleQuery query{SampleQuery::Target::SamplesPassed}; + #else + const SampleQuery query{SampleQuery::Target::AnySamplesPassed}; + #endif MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(query.id() > 0); @@ -74,7 +78,11 @@ void AbstractQueryGLTest::constructMove() { CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not supported.")); #endif - SampleQuery a; + #ifndef MAGNUM_TARGET_GLES + SampleQuery a{SampleQuery::Target::SamplesPassed}; + #else + SampleQuery a{SampleQuery::Target::AnySamplesPassed}; + #endif const Int id = a.id(); MAGNUM_VERIFY_NO_ERROR(); @@ -85,7 +93,11 @@ void AbstractQueryGLTest::constructMove() { CORRADE_COMPARE(a.id(), 0); CORRADE_COMPARE(b.id(), id); - SampleQuery c; + #ifndef MAGNUM_TARGET_GLES + SampleQuery c{SampleQuery::Target::SamplesPassed}; + #else + SampleQuery c{SampleQuery::Target::AnySamplesPassed}; + #endif const Int cId = c.id(); c = std::move(b); @@ -106,14 +118,21 @@ void AbstractQueryGLTest::label() { !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 { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + 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); } - SampleQuery query; - query.begin(SampleQuery::Target::AnySamplesPassed); - query.end(); CORRADE_COMPARE(query.label(), ""); diff --git a/src/Magnum/Test/PrimitiveQueryGLTest.cpp b/src/Magnum/Test/PrimitiveQueryGLTest.cpp index dcb2574a1..399f11c0a 100644 --- a/src/Magnum/Test/PrimitiveQueryGLTest.cpp +++ b/src/Magnum/Test/PrimitiveQueryGLTest.cpp @@ -94,8 +94,8 @@ void PrimitiveQueryGLTest::query() { MAGNUM_VERIFY_NO_ERROR(); - PrimitiveQuery q; - q.begin(PrimitiveQuery::Target::PrimitivesGenerated); + PrimitiveQuery q{PrimitiveQuery::Target::PrimitivesGenerated}; + q.begin(); framebuffer.bind(FramebufferTarget::ReadDraw); mesh.draw(shader); diff --git a/src/Magnum/Test/SampleQueryGLTest.cpp b/src/Magnum/Test/SampleQueryGLTest.cpp index 9d71a36bd..6e87c9621 100644 --- a/src/Magnum/Test/SampleQueryGLTest.cpp +++ b/src/Magnum/Test/SampleQueryGLTest.cpp @@ -117,12 +117,12 @@ void SampleQueryGLTest::querySamplesPassed() { MAGNUM_VERIFY_NO_ERROR(); - SampleQuery q; #ifndef MAGNUM_TARGET_GLES - q.begin(SampleQuery::Target::SamplesPassed); + SampleQuery q{SampleQuery::Target::SamplesPassed}; #else - q.begin(SampleQuery::Target::AnySamplesPassed); + SampleQuery q{SampleQuery::Target::AnySamplesPassed}; #endif + q.begin(); framebuffer.bind(FramebufferTarget::ReadDraw); mesh.draw(shader); @@ -167,16 +167,18 @@ void SampleQueryGLTest::conditionalRender() { MAGNUM_VERIFY_NO_ERROR(); - SampleQuery qYes, qNo, q; + SampleQuery qYes{SampleQuery::Target::SamplesPassed}, + qNo{SampleQuery::Target::SamplesPassed}, + q{SampleQuery::Target::SamplesPassed}; /* This should generate some samples */ - qYes.begin(SampleQuery::Target::SamplesPassed); + qYes.begin(); mesh.draw(shader); qYes.end(); /* Thus this should be rendered */ qYes.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); - q.begin(SampleQuery::Target::SamplesPassed); + q.begin(); mesh.draw(shader); q.end(); qYes.endConditionalRender(); @@ -186,12 +188,12 @@ void SampleQueryGLTest::conditionalRender() { CORRADE_VERIFY(q.result()); /* This shouldn't generate any samples */ - qNo.begin(SampleQuery::Target::SamplesPassed); + qNo.begin(); qNo.end(); /* Thus this should not be rendered */ qNo.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); - q.begin(SampleQuery::Target::SamplesPassed); + q.begin(); mesh.draw(shader); q.end(); qNo.endConditionalRender(); diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index c1741bd1f..440f5861d 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -50,15 +50,15 @@ void TimeQueryGLTest::queryTime() { CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif - TimeQuery q1; - q1.begin(TimeQuery::Target::TimeElapsed); + TimeQuery q1{TimeQuery::Target::TimeElapsed}; + q1.begin(); q1.end(); const auto result1 = q1.result(); MAGNUM_VERIFY_NO_ERROR(); - TimeQuery q2; - q2.begin(TimeQuery::Target::TimeElapsed); + TimeQuery q2{TimeQuery::Target::TimeElapsed}; + q2.begin(); Renderer::enable(Renderer::Feature::Blending); Renderer::finish(); q2.end(); @@ -74,11 +74,13 @@ void TimeQueryGLTest::queryTimestamp() { CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif - TimeQuery q1, q2, q; + TimeQuery q1{TimeQuery::Target::Timestamp}, + q2{TimeQuery::Target::Timestamp}, + q{TimeQuery::Target::TimeElapsed}; q1.timestamp(); - q.begin(TimeQuery::Target::TimeElapsed); + q.begin(); Renderer::enable(Renderer::Feature::Blending); Renderer::finish(); q.end(); diff --git a/src/Magnum/TimeQuery.h b/src/Magnum/TimeQuery.h index 23a005b21..497715fee 100644 --- a/src/Magnum/TimeQuery.h +++ b/src/Magnum/TimeQuery.h @@ -75,13 +75,37 @@ class TimeQuery: public AbstractQuery { enum class Target: GLenum { /** Elapsed time */ #ifndef MAGNUM_TARGET_GLES - TimeElapsed = GL_TIME_ELAPSED + TimeElapsed = GL_TIME_ELAPSED, #else - TimeElapsed = GL_TIME_ELAPSED_EXT + TimeElapsed = GL_TIME_ELAPSED_EXT, + #endif + + /** Timestamp (for use with @ref timestamp() only) */ + #ifndef MAGNUM_TARGET_GLES + Timestamp = GL_TIMESTAMP + #else + Timestamp = GL_TIMESTAMP_EXT #endif }; - explicit TimeQuery() {} + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief TimeQuery(Target) + * @deprecated Use @ref Magnum::TimeQuery::TimeQuery(Target) "TimeQuery(Target)" + * instead. + */ + CORRADE_DEPRECATED("use TimeQuery(Target) instead") explicit TimeQuery() {} + #endif + + /** + * @brief Constructor + * + * Creates new OpenGL query object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the query is created on first + * use. + * @see @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries} + */ + explicit TimeQuery(Target target): AbstractQuery(GLenum(target)) {} /** * @brief Query timestamp @@ -98,11 +122,19 @@ class TimeQuery: public AbstractQuery { #endif } - /** @copydoc PrimitiveQuery::begin() */ - void begin(Target target) { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AbstractQuery::begin() + * @deprecated Use @ref Magnum::AbstractQuery::begin() "begin()" + * instead. + */ + CORRADE_DEPRECATED("use begin() instead") void begin(Target target) { AbstractQuery::begin(GLenum(target)); } + using AbstractQuery::begin; + #endif + /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT TimeQuery& setLabel(const std::string& label) { From f0793d6aeab0971aff207f2526e73fca145987fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Sep 2014 22:23:44 +0200 Subject: [PATCH 68/72] Fixed access to nonexistent MagnumShaders resources in utilities. --- src/Magnum/Shaders/DistanceFieldVector.cpp | 4 ++-- src/Magnum/Shaders/Flat.cpp | 4 ++-- .../Shaders/Implementation/CreateCompatibilityShader.h | 4 ++-- src/Magnum/Shaders/MeshVisualizer.cpp | 6 +++--- src/Magnum/Shaders/Phong.cpp | 4 ++-- src/Magnum/Shaders/Vector.cpp | 4 ++-- src/Magnum/Shaders/VertexColor.cpp | 4 ++-- src/Magnum/TextureTools/DistanceField.cpp | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Magnum/Shaders/DistanceFieldVector.cpp b/src/Magnum/Shaders/DistanceFieldVector.cpp index 6faef96f9..b8964e70f 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.cpp +++ b/src/Magnum/Shaders/DistanceFieldVector.cpp @@ -50,8 +50,8 @@ template DistanceFieldVector::DistanceFieldV const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader frag = Implementation::createCompatibilityShader(version, Shader::Type::Vertex); - Shader vert = Implementation::createCompatibilityShader(version, Shader::Type::Fragment); + Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); + Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); frag.addSource(rs.get("generic.glsl")) .addSource(rs.get(vertexShaderName())); diff --git a/src/Magnum/Shaders/Flat.cpp b/src/Magnum/Shaders/Flat.cpp index b75bf4d53..dbd142ab2 100644 --- a/src/Magnum/Shaders/Flat.cpp +++ b/src/Magnum/Shaders/Flat.cpp @@ -53,8 +53,8 @@ template Flat::Flat(const Flags flags): tran const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert = Implementation::createCompatibilityShader(version, Shader::Type::Vertex); - Shader frag = Implementation::createCompatibilityShader(version, Shader::Type::Fragment); + Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); + Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(flags & Flag::Textured ? "#define TEXTURED\n" : "") .addSource(rs.get("generic.glsl")) diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h index b3cd0322f..5fa3fabd2 100644 --- a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h +++ b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h @@ -33,7 +33,7 @@ namespace Magnum { namespace Shaders { namespace Implementation { -inline Shader createCompatibilityShader(Version version, Shader::Type type) { +inline Shader createCompatibilityShader(const Utility::Resource& rs, Version version, Shader::Type type) { Shader shader(version, type); #ifndef MAGNUM_TARGET_GLES @@ -52,7 +52,7 @@ inline Shader createCompatibilityShader(Version version, Shader::Type type) { shader.addSource("#ifndef GL_ES\n#define GL_ES 1\n#endif\n"); #endif - shader.addSource(Utility::Resource("MagnumShaders").get("compatibility.glsl")); + shader.addSource(rs.get("compatibility.glsl")); return shader; } diff --git a/src/Magnum/Shaders/MeshVisualizer.cpp b/src/Magnum/Shaders/MeshVisualizer.cpp index d5c78e570..2ef15334d 100644 --- a/src/Magnum/Shaders/MeshVisualizer.cpp +++ b/src/Magnum/Shaders/MeshVisualizer.cpp @@ -56,8 +56,8 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert = Implementation::createCompatibilityShader(version, Shader::Type::Vertex); - Shader frag = Implementation::createCompatibilityShader(version, Shader::Type::Fragment); + Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); + Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") .addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "") @@ -76,7 +76,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP #ifndef MAGNUM_TARGET_GLES std::optional geom; if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) { - geom = Implementation::createCompatibilityShader(version, Shader::Type::Geometry); + geom = Implementation::createCompatibilityShader(rs, version, Shader::Type::Geometry); geom->addSource(rs.get("MeshVisualizer.geom")); } #endif diff --git a/src/Magnum/Shaders/Phong.cpp b/src/Magnum/Shaders/Phong.cpp index 5ae33d71c..24e0b89fb 100644 --- a/src/Magnum/Shaders/Phong.cpp +++ b/src/Magnum/Shaders/Phong.cpp @@ -53,8 +53,8 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert = Implementation::createCompatibilityShader(version, Shader::Type::Vertex); - Shader frag = Implementation::createCompatibilityShader(version, Shader::Type::Fragment); + Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); + Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(flags ? "#define TEXTURED\n" : "") .addSource(rs.get("generic.glsl")) diff --git a/src/Magnum/Shaders/Vector.cpp b/src/Magnum/Shaders/Vector.cpp index c3e855487..4a1709cb5 100644 --- a/src/Magnum/Shaders/Vector.cpp +++ b/src/Magnum/Shaders/Vector.cpp @@ -50,8 +50,8 @@ template Vector::Vector(): transformationPro const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert = Implementation::createCompatibilityShader(version, Shader::Type::Vertex); - Shader frag = Implementation::createCompatibilityShader(version, Shader::Type::Fragment); + Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); + Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(rs.get("generic.glsl")) .addSource(rs.get(vertexShaderName())); diff --git a/src/Magnum/Shaders/VertexColor.cpp b/src/Magnum/Shaders/VertexColor.cpp index f72450d4d..748eb7c55 100644 --- a/src/Magnum/Shaders/VertexColor.cpp +++ b/src/Magnum/Shaders/VertexColor.cpp @@ -50,8 +50,8 @@ template VertexColor::VertexColor(): transfo const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert = Implementation::createCompatibilityShader(version, Shader::Type::Vertex); - Shader frag = Implementation::createCompatibilityShader(version, Shader::Type::Fragment); + Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); + Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(rs.get("generic.glsl")) .addSource(rs.get(vertexShaderName())); diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index 42aadc390..d1ec0fac7 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -85,8 +85,8 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) const Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert = Shaders::Implementation::createCompatibilityShader(v, Shader::Type::Vertex); - Shader frag = Shaders::Implementation::createCompatibilityShader(v, Shader::Type::Fragment); + Shader vert = Shaders::Implementation::createCompatibilityShader(rs, v, Shader::Type::Vertex); + Shader frag = Shaders::Implementation::createCompatibilityShader(rs, v, Shader::Type::Fragment); vert.addSource(rs.get("FullScreenTriangle.glsl")) .addSource(rs.get("DistanceFieldShader.vert")); From 9f1fe58d662e2b9fd8ea6679b2058534cd9bc8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Sep 2014 22:25:50 +0200 Subject: [PATCH 69/72] TgaImporter: open the files as binary. Took me TWO CRAZY HOURS of blaming visual studio, as it stopped reading in the middle of the file without any reasonable error message ("stream error", haha). --- src/MagnumPlugins/TgaImporter/TgaImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp index 28d6d311d..d131c61b5 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp @@ -62,7 +62,7 @@ void TgaImporter::doOpenData(const Containers::ArrayReferencegood()) return; Error() << "Trade::TgaImporter::openFile(): cannot open file" << filename; From 391ceae0c3e771b8ddb976795ba3cbd57039d477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Sep 2014 22:28:37 +0200 Subject: [PATCH 70/72] Minor cleanup. --- src/Magnum/Implementation/detectedDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Implementation/detectedDriver.cpp b/src/Magnum/Implementation/detectedDriver.cpp index 60ada7803..ca52c6620 100644 --- a/src/Magnum/Implementation/detectedDriver.cpp +++ b/src/Magnum/Implementation/detectedDriver.cpp @@ -28,7 +28,7 @@ namespace Magnum { -auto Context::detectedDriver() -> Context::DetectedDrivers { +auto Context::detectedDriver() -> DetectedDrivers { if(_detectedDrivers) return *_detectedDrivers; _detectedDrivers = DetectedDrivers{}; From 1659f68d5977fcbd941a1acac8bc9acbd3563df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 27 Sep 2014 22:31:29 +0200 Subject: [PATCH 71/72] Print some more info when initializing Context. Then also don't display this information duplicated in magnum-info. --- src/Magnum/Context.cpp | 5 ++++- src/Magnum/Platform/magnum-info.cpp | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index ddaaf3c1a..cfdee5f81 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -479,7 +479,10 @@ Context::Context(void functionLoader()) { CORRADE_ASSERT(!_current, "Context: Another context currently active", ); _current = this; - /* Initialize state tracker */ + /* Print some info and initialize state tracker (which also prints some + more info) */ + Debug() << "Renderer:" << rendererString() << "by" << vendorString(); + Debug() << "OpenGL version:" << versionString(); _state = new Implementation::State(*this); /* Initialize functionality based on current OpenGL version and extensions */ diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index 126a17c4d..9dd6d4793 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -214,9 +214,6 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat place */ createContext(); Context* c = Context::current(); - Debug() << "Vendor:" << c->vendorString(); - Debug() << "Renderer:" << c->rendererString(); - Debug() << "OpenGL version:" << c->version() << '(' + c->versionString() + ')'; Debug() << "Context flags:"; #ifndef MAGNUM_TARGET_GLES From a13e9821058748dead9ec4f0242c487aefe438f2 Mon Sep 17 00:00:00 2001 From: Siim Kallas Date: Tue, 30 Sep 2014 23:12:48 +0300 Subject: [PATCH 72/72] Updated outdated Buffer::Target to Buffer::TargetHint --- src/Magnum/Mesh.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index ceb4cb7f6..0eb6a22a5 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -189,8 +189,8 @@ Mesh& Mesh::setLabelInternal(const Containers::ArrayReference label) Mesh& Mesh::setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end) { #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) - CORRADE_ASSERT(buffer.targetHint() == Buffer::Target::ElementArray, - "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::ElementArray << "but got" << buffer.targetHint(), *this); + CORRADE_ASSERT(buffer.targetHint() == Buffer::TargetHint::ElementArray, + "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::ElementArray << "but got" << buffer.targetHint(), *this); #endif _indexBuffer = &buffer; @@ -371,8 +371,8 @@ void Mesh::attributePointerInternal(const Attribute& attribute) { void Mesh::attributePointerImplementationDefault(const Attribute& attribute) { #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) - CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array, - "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), ); + CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::TargetHint::Array, + "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer->targetHint(), ); #endif _attributes.push_back(attribute); @@ -380,8 +380,8 @@ void Mesh::attributePointerImplementationDefault(const Attribute& attribute) { void Mesh::attributePointerImplementationVAO(const Attribute& attribute) { #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) - CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::Target::Array, - "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::Target::Array << "but got" << attribute.buffer->targetHint(), ); + CORRADE_ASSERT(attribute.buffer->targetHint() == Buffer::TargetHint::Array, + "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer->targetHint(), ); #endif bindVAO();