From 6f2b39ea9496a8f07fc52aa0da6ed3644fb24250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 6 Jul 2015 11:12:31 +0200 Subject: [PATCH] Implemented OES_texture_storage_multisample_2d_array AEP extension. --- doc/opengl-support.dox | 2 +- src/Magnum/AbstractTexture.cpp | 13 +++- src/Magnum/AbstractTexture.h | 11 +-- src/Magnum/Implementation/TextureState.cpp | 1 + src/Magnum/Implementation/TextureState.h | 2 +- src/Magnum/Magnum.h | 2 - src/Magnum/MultisampleTexture.cpp | 7 +- src/Magnum/MultisampleTexture.h | 29 +++++--- src/Magnum/Platform/magnum-info.cpp | 2 - src/Magnum/Test/MultisampleTextureGLTest.cpp | 77 +++++++++----------- 10 files changed, 75 insertions(+), 71 deletions(-) diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index bcc7e0fb3..9296e5e4c 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -393,7 +393,7 @@ Extension | Status @es_extension{OES,shader_image_atomic} | done (shading language only) @es_extension{OES,shader_multisample_interpolation} | | @es_extension{OES,texture_stencil8} | | -@es_extension{OES,texture_storage_multisample_2d_array} | | +@es_extension{OES,texture_storage_multisample_2d_array} | done @subsection opengl-support-webgl10 WebGL 1.0 diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index f68972f62..849865d55 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1161,12 +1161,21 @@ void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei sam bindInternal(); glTexImage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } +#endif +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { bindInternal(); - glTexStorage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); + #ifndef MAGNUM_TARGET_GLES + glTexStorage3DMultisample + #else + glTexStorage3DMultisampleOES + #endif + (_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } +#endif +#ifndef MAGNUM_TARGET_GLES void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { glTextureStorage3DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); } @@ -1395,9 +1404,7 @@ void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { (texture.*Context::current()->state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); } -#endif -#ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { (texture.*Context::current()->state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); } diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 074e09f2d..4e1967dc6 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -507,19 +507,16 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); + void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); + void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); - void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); - #endif - - #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); - void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); + void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations); void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations); #endif @@ -626,7 +623,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector3i& size); - #ifndef MAGNUM_TARGET_GLES + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) static void setStorageMultisample(AbstractTexture& texture, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedSampleLocations); #endif diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index ac60559af..4fd45189c 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -314,6 +314,7 @@ TextureState::TextureState(Context& context, std::vector& extension } #elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; + storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault; #endif /* Anisotropic filter implementation */ diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index 348887ebb..19d9702ee 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -66,9 +66,9 @@ struct TextureState { #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void(AbstractTexture::*storage2DMultisampleImplementation)(GLsizei, TextureFormat, const Vector2i&, GLboolean); + void(AbstractTexture::*storage3DMultisampleImplementation)(GLsizei, TextureFormat, const Vector3i&, GLboolean); #endif #ifndef MAGNUM_TARGET_GLES - void(AbstractTexture::*storage3DMultisampleImplementation)(GLsizei, TextureFormat, const Vector3i&, GLboolean); void(AbstractTexture::*getImageImplementation)(GLint, ColorFormat, ColorType, std::size_t, GLvoid*); #endif #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 636a95fb1..79ae21062 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -489,10 +489,8 @@ class MeshView; /* MultisampleTextureSampleLocations enum used only in the function */ template class MultisampleTexture; typedef MultisampleTexture<2> MultisampleTexture2D; -#ifndef MAGNUM_TARGET_GLES typedef MultisampleTexture<3> MultisampleTexture2DArray; #endif -#endif /* ObjectFlag, ObjectFlags are used only in conjunction with *::wrap() function */ diff --git a/src/Magnum/MultisampleTexture.cpp b/src/Magnum/MultisampleTexture.cpp index 363921c33..ac44ef5b8 100644 --- a/src/Magnum/MultisampleTexture.cpp +++ b/src/Magnum/MultisampleTexture.cpp @@ -44,14 +44,17 @@ template<> Vector2i MAGNUM_EXPORT maxMultisampleTextureSize<2>() { return Vector2i{Implementation::maxTextureSideSize()}; } -#ifndef MAGNUM_TARGET_GLES template<> Vector3i MAGNUM_EXPORT maxMultisampleTextureSize<3>() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) return Vector3i{0}; + #else + if(!Context::current()->isExtensionSupported()) + return Vector3i{0}; + #endif return {Vector2i{Implementation::maxTextureSideSize()}, Implementation::max3DTextureDepth()}; } -#endif }} #endif diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index df5c36414..4407a0e27 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -41,15 +41,17 @@ namespace Magnum { namespace Implementation { template constexpr GLenum multisampleTextureTarget(); template<> constexpr GLenum multisampleTextureTarget<2>() { return GL_TEXTURE_2D_MULTISAMPLE; } - #ifndef MAGNUM_TARGET_GLES - template<> constexpr GLenum multisampleTextureTarget<3>() { return GL_TEXTURE_2D_MULTISAMPLE_ARRAY; } - #endif + template<> constexpr GLenum multisampleTextureTarget<3>() { + #ifndef MAGNUM_TARGET_GLES + return GL_TEXTURE_2D_MULTISAMPLE_ARRAY; + #else + return GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES; + #endif + } template VectorTypeFor maxMultisampleTextureSize(); template<> MAGNUM_EXPORT Vector2i maxMultisampleTextureSize<2>(); - #ifndef MAGNUM_TARGET_GLES template<> MAGNUM_EXPORT Vector3i maxMultisampleTextureSize<3>(); - #endif } /** @@ -87,10 +89,13 @@ shaders. @ref TextureArray, @ref CubeMapTexture, @ref CubeMapTextureArray, @ref RectangleTexture, @ref BufferTexture @requires_gl32 Extension @extension{ARB,texture_multisample} -@requires_gles31 Multisample textures are not available in OpenGL ES 3.0 and +@requires_gles31 Multisample 2D textures are not available in OpenGL ES 3.0 and older. -@requires_gl 2D array multisample textures are not available in OpenGL ES, only - 2D ones. No multisample textures are available in WebGL. +@requires_gles30 Multisample 2D array textures are not defined in OpenGL ES + 2.0. +@requires_es_extension Extension @es_extension{ANDROID,extension_pack_es31a}/ + @es_extension{OES,texture_storage_multisample_2d_array} for multisample 2D + array textures. @requires_gles Multisample textures are not available in WebGL. */ template class MultisampleTexture: public AbstractTexture { @@ -250,16 +255,16 @@ template class MultisampleTexture: public AbstractTextur */ typedef MultisampleTexture<2> MultisampleTexture2D; -#ifndef MAGNUM_TARGET_GLES /** @brief Two-dimensional multisample texture array @requires_gl32 Extension @extension{ARB,texture_multisample} -@requires_gl Only @ref MultisampleTexture2D is available in OpenGL ES. - No multisample textures are available in WebGL. +@requires_gles30 Not defined in OpenGL ES 2.0. +@requires_es_extension Extension @es_extension{ANDROID,extension_pack_es31a}/ + @es_extension{OES,texture_storage_multisample_2d_array} +@requires_gles Multisample textures are not available in WebGL. */ typedef MultisampleTexture<3> MultisampleTexture2DArray; -#endif } #else diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index 578a4fa57..5cdf7ebc5 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -515,9 +515,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _l(AbstractTexture::maxDepthSamples()) _l(AbstractTexture::maxIntegerSamples()) _lvec(MultisampleTexture2D::maxSize()) - #ifndef MAGNUM_TARGET_GLES _lvec(MultisampleTexture2DArray::maxSize()) - #endif } #endif diff --git a/src/Magnum/Test/MultisampleTextureGLTest.cpp b/src/Magnum/Test/MultisampleTextureGLTest.cpp index 3bb390fe5..f83f1ff51 100644 --- a/src/Magnum/Test/MultisampleTextureGLTest.cpp +++ b/src/Magnum/Test/MultisampleTextureGLTest.cpp @@ -36,71 +36,48 @@ struct MultisampleTextureGLTest: AbstractOpenGLTester { explicit MultisampleTextureGLTest(); void construct2D(); - void construct2DNoCreate(); - #ifndef MAGNUM_TARGET_GLES void construct2DArray(); + + void construct2DNoCreate(); void construct2DArrayNoCreate(); - #endif void wrap2D(); - #ifndef MAGNUM_TARGET_GLES void wrap2DArray(); - #endif void bind2D(); - #ifndef MAGNUM_TARGET_GLES void bind2DArray(); - #endif void storage2D(); - #ifndef MAGNUM_TARGET_GLES void storage2DArray(); - #endif void invalidateImage2D(); - #ifndef MAGNUM_TARGET_GLES void invalidateImage2DArray(); - #endif void invalidateSubImage2D(); - #ifndef MAGNUM_TARGET_GLES void invalidateSubImage2DArray(); - #endif }; MultisampleTextureGLTest::MultisampleTextureGLTest() { addTests({&MultisampleTextureGLTest::construct2D, - &MultisampleTextureGLTest::construct2DNoCreate, - #ifndef MAGNUM_TARGET_GLES &MultisampleTextureGLTest::construct2DArray, + + &MultisampleTextureGLTest::construct2DNoCreate, &MultisampleTextureGLTest::construct2DArrayNoCreate, - #endif &MultisampleTextureGLTest::wrap2D, - #ifndef MAGNUM_TARGET_GLES &MultisampleTextureGLTest::wrap2DArray, - #endif &MultisampleTextureGLTest::bind2D, - #ifndef MAGNUM_TARGET_GLES &MultisampleTextureGLTest::bind2DArray, - #endif &MultisampleTextureGLTest::storage2D, - #ifndef MAGNUM_TARGET_GLES &MultisampleTextureGLTest::storage2DArray, - #endif &MultisampleTextureGLTest::invalidateImage2D, - #ifndef MAGNUM_TARGET_GLES &MultisampleTextureGLTest::invalidateImage2DArray, - #endif &MultisampleTextureGLTest::invalidateSubImage2D, - #ifndef MAGNUM_TARGET_GLES - &MultisampleTextureGLTest::invalidateSubImage2DArray - #endif - }); + &MultisampleTextureGLTest::invalidateSubImage2DArray}); } void MultisampleTextureGLTest::construct2D() { @@ -133,10 +110,14 @@ void MultisampleTextureGLTest::construct2DNoCreate() { MAGNUM_VERIFY_NO_ERROR(); } -#ifndef MAGNUM_TARGET_GLES void MultisampleTextureGLTest::construct2DArray() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + #endif { MultisampleTexture2DArray texture; @@ -158,7 +139,6 @@ void MultisampleTextureGLTest::construct2DArrayNoCreate() { MAGNUM_VERIFY_NO_ERROR(); } -#endif void MultisampleTextureGLTest::wrap2D() { #ifndef MAGNUM_TARGET_GLES @@ -183,10 +163,14 @@ void MultisampleTextureGLTest::wrap2D() { glDeleteTextures(1, &id); } -#ifndef MAGNUM_TARGET_GLES void MultisampleTextureGLTest::wrap2DArray() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string{" is not supported."}); + CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + #endif GLuint id; glGenTextures(1, &id); @@ -201,7 +185,6 @@ void MultisampleTextureGLTest::wrap2DArray() { MultisampleTexture2DArray::wrap(id); glDeleteTextures(1, &id); } -#endif void MultisampleTextureGLTest::bind2D() { #ifndef MAGNUM_TARGET_GLES @@ -230,10 +213,14 @@ void MultisampleTextureGLTest::bind2D() { MAGNUM_VERIFY_NO_ERROR(); } -#ifndef MAGNUM_TARGET_GLES void MultisampleTextureGLTest::bind2DArray() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + #endif MultisampleTexture2DArray texture; texture.bind(15); @@ -252,7 +239,6 @@ void MultisampleTextureGLTest::bind2DArray() { MAGNUM_VERIFY_NO_ERROR(); } -#endif void MultisampleTextureGLTest::storage2D() { #ifndef MAGNUM_TARGET_GLES @@ -273,10 +259,14 @@ void MultisampleTextureGLTest::storage2D() { MAGNUM_VERIFY_NO_ERROR(); } -#ifndef MAGNUM_TARGET_GLES void MultisampleTextureGLTest::storage2DArray() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + #endif MultisampleTexture2DArray texture; texture.setStorage(4, TextureFormat::RGBA8, {16, 16, 5}); @@ -287,7 +277,6 @@ void MultisampleTextureGLTest::storage2DArray() { MAGNUM_VERIFY_NO_ERROR(); } -#endif void MultisampleTextureGLTest::invalidateImage2D() { #ifndef MAGNUM_TARGET_GLES @@ -305,10 +294,14 @@ void MultisampleTextureGLTest::invalidateImage2D() { MAGNUM_VERIFY_NO_ERROR(); } -#ifndef MAGNUM_TARGET_GLES void MultisampleTextureGLTest::invalidateImage2DArray() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + #endif MultisampleTexture2DArray texture; texture.setStorage(4, TextureFormat::RGBA8, {16, 16, 5}); @@ -316,7 +309,6 @@ void MultisampleTextureGLTest::invalidateImage2DArray() { MAGNUM_VERIFY_NO_ERROR(); } -#endif void MultisampleTextureGLTest::invalidateSubImage2D() { #ifndef MAGNUM_TARGET_GLES @@ -334,10 +326,14 @@ void MultisampleTextureGLTest::invalidateSubImage2D() { MAGNUM_VERIFY_NO_ERROR(); } -#ifndef MAGNUM_TARGET_GLES void MultisampleTextureGLTest::invalidateSubImage2DArray() { + #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + #else + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + #endif MultisampleTexture2DArray texture; texture.setStorage(4, TextureFormat::RGBA8, {16, 16, 5}); @@ -345,7 +341,6 @@ void MultisampleTextureGLTest::invalidateSubImage2DArray() { MAGNUM_VERIFY_NO_ERROR(); } -#endif }}