From 692cb4e173bd4b922c77426aa3e8e4de9d84e3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 28 Aug 2019 11:05:00 +0200 Subject: [PATCH] GL: test setting an empty buffer to BufferTexture and filling it after. The driver should recalculate the texture size after. This test fails when ARB_DSA is not present as the underlying GL buffer is not created yet at that point. --- src/Magnum/GL/Test/BufferTextureGLTest.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Magnum/GL/Test/BufferTextureGLTest.cpp b/src/Magnum/GL/Test/BufferTextureGLTest.cpp index e1805ab13..29d95d90d 100644 --- a/src/Magnum/GL/Test/BufferTextureGLTest.cpp +++ b/src/Magnum/GL/Test/BufferTextureGLTest.cpp @@ -45,6 +45,7 @@ struct BufferTextureGLTest: OpenGLTester { void bindImage(); void setBuffer(); + void setBufferEmptyFirst(); void setBufferOffset(); }; @@ -56,6 +57,7 @@ BufferTextureGLTest::BufferTextureGLTest() { &BufferTextureGLTest::bindImage, &BufferTextureGLTest::setBuffer, + &BufferTextureGLTest::setBufferEmptyFirst, &BufferTextureGLTest::setBufferOffset}); } @@ -195,6 +197,42 @@ void BufferTextureGLTest::setBuffer() { MAGNUM_VERIFY_NO_GL_ERROR(); } +void BufferTextureGLTest::setBufferEmptyFirst() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::ARB::texture_buffer_object::string() + std::string(" is not supported.")); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::EXT::texture_buffer::string() + std::string(" is not supported.")); + #endif + + BufferTexture texture; + Buffer buffer; + texture.setBuffer(BufferTextureFormat::RGBA8UI, buffer); + + MAGNUM_VERIFY_NO_GL_ERROR(); + + if(Context::current().isVersionSupported(Version::GLES310)) + CORRADE_COMPARE(texture.size(), 0); + + constexpr UnsignedByte data[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f + }; + buffer.setData(data, BufferUsage::StaticDraw); + + MAGNUM_VERIFY_NO_GL_ERROR(); + + #ifdef MAGNUM_TARGET_GLES + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing."); + #endif + + CORRADE_COMPARE(texture.size(), 4); + + MAGNUM_VERIFY_NO_GL_ERROR(); +} + void BufferTextureGLTest::setBufferOffset() { #ifndef MAGNUM_TARGET_GLES if(!Context::current().isExtensionSupported())