Browse Source

Implemented OES_texture_storage_multisample_2d_array AEP extension.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
6f2b39ea94
  1. 2
      doc/opengl-support.dox
  2. 13
      src/Magnum/AbstractTexture.cpp
  3. 11
      src/Magnum/AbstractTexture.h
  4. 1
      src/Magnum/Implementation/TextureState.cpp
  5. 2
      src/Magnum/Implementation/TextureState.h
  6. 2
      src/Magnum/Magnum.h
  7. 7
      src/Magnum/MultisampleTexture.cpp
  8. 29
      src/Magnum/MultisampleTexture.h
  9. 2
      src/Magnum/Platform/magnum-info.cpp
  10. 77
      src/Magnum/Test/MultisampleTextureGLTest.cpp

2
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

13
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);
}

11
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

1
src/Magnum/Implementation/TextureState.cpp

@ -314,6 +314,7 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
}
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
storage2DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault;
storage3DMultisampleImplementation = &AbstractTexture::storageMultisampleImplementationDefault;
#endif
/* Anisotropic filter implementation */

2
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

2
src/Magnum/Magnum.h

@ -489,10 +489,8 @@ class MeshView;
/* MultisampleTextureSampleLocations enum used only in the function */
template<UnsignedInt> 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 */

7
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<Extensions::GL::ARB::texture_multisample>())
return Vector3i{0};
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
return Vector3i{0};
#endif
return {Vector2i{Implementation::maxTextureSideSize()}, Implementation::max3DTextureDepth()};
}
#endif
}}
#endif

29
src/Magnum/MultisampleTexture.h

@ -41,15 +41,17 @@ namespace Magnum {
namespace Implementation {
template<UnsignedInt> 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<UnsignedInt dimensions> VectorTypeFor<dimensions, Int> 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<UnsignedInt dimensions> class MultisampleTexture: public AbstractTexture {
@ -250,16 +255,16 @@ template<UnsignedInt dimensions> 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

2
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

77
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<Extensions::GL::ARB::texture_multisample>())
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
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<Extensions::GL::ARB::texture_multisample>())
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<Extensions::GL::OES::texture_storage_multisample_2d_array>())
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<Extensions::GL::ARB::texture_multisample>())
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
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<Extensions::GL::ARB::texture_multisample>())
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
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<Extensions::GL::ARB::texture_multisample>())
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
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<Extensions::GL::ARB::texture_multisample>())
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
#else
if(!Context::current()->isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
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
}}

Loading…
Cancel
Save