Browse Source

Fix (workaround) failing texture tests.

With ARB_multi_bind it is needed to associate the texture with some
target before calling glBindTextures(), otherwise the texture is
treated as invalid.
pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
2e3a00ab8b
  1. 4
      src/Magnum/AbstractTexture.h
  2. 13
      src/Magnum/Test/BufferTextureGLTest.cpp
  3. 9
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  4. 9
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  5. 14
      src/Magnum/Test/MultisampleTextureGLTest.cpp
  6. 9
      src/Magnum/Test/RectangleTextureGLTest.cpp
  7. 16
      src/Magnum/Test/TextureArrayGLTest.cpp
  8. 25
      src/Magnum/Test/TextureGLTest.cpp

4
src/Magnum/AbstractTexture.h

@ -108,6 +108,10 @@ functions do nothing.
@todo `GL_NUM_COMPRESSED_TEXTURE_FORMATS` when compressed textures are implemented
@todo `GL_MAX_SAMPLE_MASK_WORDS` when @extension{ARB,texture_multisample} is done
@todo Query for immutable levels (@extension{ARB,ES3_compatibility})
@bug If using @extension{ARB,multi_bind} and the texture is bound right after
construction, the @fn_gl{BindTextures} call will fail with
Renderer::Error::InvalidOperation, because the texture doesn't yet have
associated target
*/
class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
friend struct Implementation::TextureState;

13
src/Magnum/Test/BufferTextureGLTest.cpp

@ -67,6 +67,19 @@ void BufferTextureGLTest::bind() {
CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported."));
BufferTexture texture;
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();

9
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -94,6 +94,15 @@ void CubeMapTextureArrayGLTest::construct() {
void CubeMapTextureArrayGLTest::bind() {
CubeMapTextureArray texture;
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();

9
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -114,6 +114,15 @@ void CubeMapTextureGLTest::construct() {
void CubeMapTextureGLTest::bind() {
CubeMapTexture texture;
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();

14
src/Magnum/Test/MultisampleTextureGLTest.cpp

@ -120,6 +120,13 @@ void MultisampleTextureGLTest::bind2D() {
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
MultisampleTexture2D texture;
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it.");
CORRADE_VERIFY(false);
CORRADE_SKIP("...but we don't have any function to do that yet.");
}
texture.bind(15);
MAGNUM_VERIFY_NO_ERROR();
@ -138,6 +145,13 @@ void MultisampleTextureGLTest::bind2DArray() {
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported."));
MultisampleTexture2DArray texture;
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
CORRADE_EXPECT_FAIL("With ARB_multi_bind the texture must be associated with given target at least once before binding it.");
CORRADE_VERIFY(false);
CORRADE_SKIP("...but we don't have any function to do that yet.");
}
texture.bind(15);
MAGNUM_VERIFY_NO_ERROR();

9
src/Magnum/Test/RectangleTextureGLTest.cpp

@ -95,6 +95,15 @@ 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<Extensions::GL::ARB::multi_bind>()) {
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();

16
src/Magnum/Test/TextureArrayGLTest.cpp

@ -205,6 +205,13 @@ void TextureArrayGLTest::bind1D() {
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported."));
Texture1DArray texture;
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();
@ -226,6 +233,15 @@ void TextureArrayGLTest::bind2D() {
#endif
Texture2DArray texture;
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();

25
src/Magnum/Test/TextureGLTest.cpp

@ -254,6 +254,13 @@ void TextureGLTest::construct3D() {
#ifndef MAGNUM_TARGET_GLES
void TextureGLTest::bind1D() {
Texture1D texture;
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();
@ -270,6 +277,15 @@ void TextureGLTest::bind1D() {
void TextureGLTest::bind2D() {
Texture2D texture;
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();
@ -290,6 +306,15 @@ void TextureGLTest::bind3D() {
#endif
Texture3D texture;
#ifndef MAGNUM_TARGET_GLES
if(Context::current()->isExtensionSupported<Extensions::GL::ARB::multi_bind>()) {
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();

Loading…
Cancel
Save