diff --git a/package/ci/circleci.yml b/package/ci/circleci.yml index c5e5ac267d..10db1a0182 100644 --- a/package/ci/circleci.yml +++ b/package/ci/circleci.yml @@ -19,7 +19,7 @@ executors: xcode-11_6: macos: xcode: 11.6.0 - emscripten: + emscripten1: docker: # 1.39.0 is the oldest on Docker. Anything before 1.39.2 is useless as emar # randomly asserts: https://github.com/emscripten-core/emscripten/pull/9742 @@ -28,6 +28,12 @@ executors: # https://github.com/mosra/magnum/issues/413, # https://github.com/emscripten-core/emscripten/pull/10161 - image: emscripten/emsdk:1.39.6-upstream + emscripten2: + docker: + # Used by the webgl2 job. First version that exposes glGetBufferSubData() + # so GLES3 tests can read buffer data without having to check the + # Emscripten version. + - image: emscripten/emsdk:2.0.17 android-29: machine: image: android:202102-01 @@ -512,7 +518,7 @@ jobs: - lcov emscripten-webgl1: - executor: emscripten + executor: emscripten1 environment: # STUPID yml interprets unquoted ON as a boolean TARGET_GLES2: "ON" @@ -523,7 +529,7 @@ jobs: script: emscripten.sh emscripten-webgl2: - executor: emscripten + executor: emscripten2 environment: # STUPID yml interprets unquoted OFF as a boolean TARGET_GLES2: "OFF" diff --git a/src/Magnum/DebugTools/BufferData.h b/src/Magnum/DebugTools/BufferData.h index ada62a5ed0..8fa8af909b 100644 --- a/src/Magnum/DebugTools/BufferData.h +++ b/src/Magnum/DebugTools/BufferData.h @@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE. */ -#if defined(MAGNUM_TARGET_GL) && !defined(MAGNUM_TARGET_WEBGL) +#if defined(MAGNUM_TARGET_GL) && !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** @file * @brief Function @ref Magnum::DebugTools::bufferData(), @ref Magnum::DebugTools::bufferSubData() */ @@ -36,7 +36,7 @@ #include "Magnum/GL/Buffer.h" #include "Magnum/DebugTools/visibility.h" -#if defined(MAGNUM_TARGET_GL) && !defined(MAGNUM_TARGET_WEBGL) +#if defined(MAGNUM_TARGET_GL) && !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) namespace Magnum { namespace DebugTools { namespace Implementation { @@ -47,7 +47,8 @@ namespace Implementation { @brief Buffer subdata Emulates @ref GL::Buffer::subData() call on platforms that don't support it -(such as OpenGL ES) by using @ref GL::Buffer::map(). +(such as OpenGL ES) by using @ref GL::Buffer::mapRead(). On desktop GL and +WebGL 2.0 it's just an alias to @ref GL::Buffer::subData(). @note This function is available only if Magnum is compiled with @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @@ -55,19 +56,28 @@ Emulates @ref GL::Buffer::subData() call on platforms that don't support it @requires_gles30 Extension @gl_extension{EXT,map_buffer_range} in OpenGL ES 2.0. -@requires_gles Buffer mapping is not available in WebGL. +@requires_webgl20 Buffer data queries or buffer mapping are not available in + WebGL 1.0. */ -template Containers::Array inline bufferSubData(GL::Buffer& buffer, GLintptr offset, GLsizeiptr size) { +template Containers::Array inline bufferSubData(GL::Buffer& buffer, GLintptr offset, GLsizeiptr size) { + if(!size) return {}; + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_WEBGL) + Containers::Array data = buffer.subData(offset, size*sizeof(T)); + CORRADE_INTERNAL_ASSERT(!data.deleter()); + return Containers::Array{reinterpret_cast(data.release()), std::size_t(size)}; + #else Containers::Array data{std::size_t(size)}; - if(size) Implementation::bufferSubData(buffer, offset, size*sizeof(T), data); + Implementation::bufferSubData(buffer, offset, size*sizeof(T), data); return data; + #endif } /** @brief Buffer data Emulates @ref GL::Buffer::data() call on platforms that don't support it (such -as OpenGL ES) by using @ref GL::Buffer::map(). +as OpenGL ES) by using @ref GL::Buffer::mapRead(). On desktop GL and WebGL 2.0 +it's just an alias to @ref GL::Buffer::data(). @note This function is available only if Magnum is compiled with @ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See @@ -75,7 +85,8 @@ as OpenGL ES) by using @ref GL::Buffer::map(). @requires_gles30 Extension @gl_extension{EXT,map_buffer_range} in OpenGL ES 2.0. -@requires_gles Buffer mapping is not available in WebGL. +@requires_webgl20 Buffer data queries or buffer mapping are not available in + WebGL 1.0. */ template Containers::Array inline bufferData(GL::Buffer& buffer) { const Int bufferSize = buffer.size(); @@ -85,7 +96,7 @@ template Containers::Array inline bufferData(GL::Buffer& buff }} #else -#error this header is available only in the OpenGL (ES) build and not available in the WebGL build +#error this header is not available in the WebGL 1.0 build #endif #endif diff --git a/src/Magnum/DebugTools/CMakeLists.txt b/src/Magnum/DebugTools/CMakeLists.txt index f8ddeadfee..2618fbab73 100644 --- a/src/Magnum/DebugTools/CMakeLists.txt +++ b/src/Magnum/DebugTools/CMakeLists.txt @@ -72,7 +72,7 @@ if(TARGET_GL) endif() endif() - if(NOT MAGNUM_TARGET_WEBGL) + if(NOT (MAGNUM_TARGET_WEBGL AND MAGNUM_TARGET_GLES2)) list(APPEND MagnumDebugTools_SRCS BufferData.cpp) diff --git a/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp b/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp index 6b2871e59d..b697e69f0b 100644 --- a/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp +++ b/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp @@ -47,37 +47,51 @@ BufferDataGLTest::BufferDataGLTest() { constexpr Int Data[] = {2, 7, 5, 13, 25}; void BufferDataGLTest::data() { - #ifndef MAGNUM_TARGET_GLES - if(!GL::Context::current().isExtensionSupported()) - CORRADE_SKIP(GL::Extensions::ARB::map_buffer_range::string() << "is not supported."); - #elif defined(MAGNUM_TARGET_GLES2) + #ifdef MAGNUM_TARGET_GLES2 if(!GL::Context::current().isExtensionSupported()) CORRADE_SKIP(GL::Extensions::EXT::map_buffer_range::string() << "is not supported."); #endif GL::Buffer buffer; + + const Containers::Array emptyContents = bufferData(buffer); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_VERIFY(emptyContents.isEmpty()); + buffer.setData(Data, GL::BufferUsage::StaticDraw); - const Containers::Array contents = bufferData(buffer); + + const Containers::Array contents = bufferData(buffer); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(contents, + Containers::arrayCast(Containers::arrayView(Data)), + TestSuite::Compare::Container); + const Containers::Array intContents = bufferData(buffer); MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE_AS(contents, Containers::arrayView(Data), + CORRADE_COMPARE_AS(intContents, Containers::arrayView(Data), TestSuite::Compare::Container); } void BufferDataGLTest::subData() { - #ifndef MAGNUM_TARGET_GLES - if(!GL::Context::current().isExtensionSupported()) - CORRADE_SKIP(GL::Extensions::ARB::map_buffer_range::string() << "is not supported."); - #elif defined(MAGNUM_TARGET_GLES2) + #ifdef MAGNUM_TARGET_GLES2 if(!GL::Context::current().isExtensionSupported()) CORRADE_SKIP(GL::Extensions::EXT::map_buffer_range::string() << "is not supported."); #endif GL::Buffer buffer; buffer.setData(Data, GL::BufferUsage::StaticDraw); - const Containers::Array contents = bufferSubData(buffer, 4, 3); + + const Containers::Array contents = bufferSubData(buffer, 4, 3*4); MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE_AS(contents, Containers::arrayView(Data).slice(1, 4), + CORRADE_COMPARE_AS(contents, + Containers::arrayCast(Containers::arrayView(Data).slice(1, 4)), TestSuite::Compare::Container); + const Containers::Array intContents = bufferSubData(buffer, 4, 3); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(intContents, Containers::arrayView(Data).slice(1, 4), + TestSuite::Compare::Container); + const Containers::Array emptyContents = bufferSubData(buffer, 4, 0); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_VERIFY(emptyContents.isEmpty()); } }}}} diff --git a/src/Magnum/DebugTools/Test/CMakeLists.txt b/src/Magnum/DebugTools/Test/CMakeLists.txt index f71ed0a358..290695b4e4 100644 --- a/src/Magnum/DebugTools/Test/CMakeLists.txt +++ b/src/Magnum/DebugTools/Test/CMakeLists.txt @@ -118,7 +118,7 @@ if(TARGET_GL) corrade_add_test(DebugToolsTextureImageGLTest TextureImageGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) - if(NOT MAGNUM_TARGET_WEBGL) + if(NOT (MAGNUM_TARGET_WEBGL AND MAGNUM_TARGET_GLES2)) corrade_add_test(DebugToolsBufferDataGLTest BufferDataGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) endif() diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp index b3b544cda6..d839f4fd75 100644 --- a/src/Magnum/GL/Buffer.cpp +++ b/src/Magnum/GL/Buffer.cpp @@ -329,7 +329,7 @@ Int Buffer::size() { return size; } -#ifndef MAGNUM_TARGET_GLES +#if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) Containers::Array Buffer::data() { return subData(0, size()); } @@ -372,7 +372,7 @@ Buffer& Buffer::flushMappedRange(const GLintptr offset, const GLsizeiptr length) bool Buffer::unmap() { return (this->*Context::current().state().buffer.unmapImplementation)(); } #endif -#ifndef MAGNUM_TARGET_GLES +#if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) Containers::Array Buffer::subData(const GLintptr offset, const GLsizeiptr size) { Containers::Array data(size); if(size) (this->*Context::current().state().buffer.getSubDataImplementation)(offset, size, data); @@ -468,11 +468,13 @@ void Buffer::getParameterImplementationDSA(const GLenum value, GLint* const data } #endif -#ifndef MAGNUM_TARGET_GLES +#if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) void Buffer::getSubDataImplementationDefault(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { glGetBufferSubData(GLenum(bindSomewhereInternal(_targetHint)), offset, size, data); } +#endif +#ifndef MAGNUM_TARGET_GLES void Buffer::getSubDataImplementationDSA(const GLintptr offset, const GLsizeiptr size, GLvoid* const data) { glGetNamedBufferSubData(_id, offset, size, data); } diff --git a/src/Magnum/GL/Buffer.h b/src/Magnum/GL/Buffer.h index 076626f502..b88178298b 100644 --- a/src/Magnum/GL/Buffer.h +++ b/src/Magnum/GL/Buffer.h @@ -1089,7 +1089,7 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { */ Int size(); - #ifndef MAGNUM_TARGET_GLES + #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) /** * @brief Buffer data * @@ -1101,9 +1101,11 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { * eventually @fn_gl{BindBuffer} and @fn_gl{GetBufferParameter} * with @def_gl{BUFFER_SIZE}, then @fn_gl2_keyword{GetNamedBufferSubData,GetBufferSubData}, * eventually @fn_gl_keyword{GetBufferSubData} - * @requires_gl Buffer data queries are not available in OpenGL ES and - * WebGL. Use @ref map(), @ref mapRead() or @ref DebugTools::bufferData() - * in OpenGL ES instead. + * @requires_gl Buffer data queries are not available in OpenGL ES. Use + * @ref map(), @ref mapRead() or @ref DebugTools::bufferData() + * instead. + * @requires_webgl20 Buffer data queries are not available in + * WebGL 1.0. Emscripten 2.0.17 or higher is required in WebGL2. */ Containers::Array data(); @@ -1119,9 +1121,11 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { * @see @ref size(), @ref data(), @ref setSubData(), @ref setTargetHint(), * @fn_gl2_keyword{GetNamedBufferSubData,GetBufferSubData}, * eventually @fn_gl{BindBuffer} and @fn_gl_keyword{GetBufferSubData} - * @requires_gl Buffer data queries are not available in OpenGL ES and - * WebGL. Use @ref map(), @ref mapRead() or @ref DebugTools::bufferData() - * in OpenGL ES instead. + * @requires_gl Buffer data queries are not available in OpenGL ES. Use + * @ref map(), @ref mapRead() or @ref DebugTools::bufferData() in + * OpenGL ES instead. + * @requires_webgl20 Buffer data queries are not available in + * WebGL 1.0. Emscripten 2.0.17 or higher is required in WebGL2. */ Containers::Array subData(GLintptr offset, GLsizeiptr size); #endif @@ -1357,8 +1361,10 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject { void MAGNUM_GL_LOCAL getParameterImplementationDSA(GLenum value, GLint* data); #endif - #ifndef MAGNUM_TARGET_GLES + #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) void MAGNUM_GL_LOCAL getSubDataImplementationDefault(GLintptr offset, GLsizeiptr size, GLvoid* data); + #endif + #ifndef MAGNUM_TARGET_GLES void MAGNUM_GL_LOCAL getSubDataImplementationDSA(GLintptr offset, GLsizeiptr size, GLvoid* data); #endif diff --git a/src/Magnum/GL/Implementation/BufferState.cpp b/src/Magnum/GL/Implementation/BufferState.cpp index f71a537693..e1dbb85adc 100644 --- a/src/Magnum/GL/Implementation/BufferState.cpp +++ b/src/Magnum/GL/Implementation/BufferState.cpp @@ -126,7 +126,7 @@ BufferState::BufferState(Context& context, Containers::StaticArrayView= 20017) getSubDataImplementation = &Buffer::getSubDataImplementationDefault; #endif dataImplementation = &Buffer::dataImplementationDefault; diff --git a/src/Magnum/GL/Implementation/BufferState.h b/src/Magnum/GL/Implementation/BufferState.h index 93b74a08af..32760a70ce 100644 --- a/src/Magnum/GL/Implementation/BufferState.h +++ b/src/Magnum/GL/Implementation/BufferState.h @@ -59,7 +59,7 @@ struct BufferState { void(Buffer::*storageImplementation)(Containers::ArrayView, Buffer::StorageFlags); #endif void(Buffer::*getParameterImplementation)(GLenum, GLint*); - #ifndef MAGNUM_TARGET_GLES2 + #if !defined(MAGNUM_TARGET_GLES) || (defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) && __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ >= 20017) void(Buffer::*getSubDataImplementation)(GLintptr, GLsizeiptr, GLvoid*); #endif void(Buffer::*dataImplementation)(GLsizeiptr, const GLvoid*, BufferUsage); diff --git a/src/Magnum/GL/Test/BufferGLTest.cpp b/src/Magnum/GL/Test/BufferGLTest.cpp index ef6d42202e..171fa07fb6 100644 --- a/src/Magnum/GL/Test/BufferGLTest.cpp +++ b/src/Magnum/GL/Test/BufferGLTest.cpp @@ -34,6 +34,10 @@ #include "Magnum/GL/Extensions.h" #include "Magnum/GL/OpenGLTester.h" +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/DebugTools/BufferData.h" +#endif + #ifndef MAGNUM_TARGET_WEBGL #include #endif @@ -138,15 +142,14 @@ void BufferGLTest::constructFromData() { CORRADE_COMPARE(c.size(), 5*4); CORRADE_COMPARE(d.size(), 5*4); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE_AS(Containers::arrayCast(a.data()), + #ifndef MAGNUM_TARGET_GLES2 + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferData(a)), Containers::arrayView(data), TestSuite::Compare::Container); - CORRADE_COMPARE_AS(Containers::arrayCast(b.data()), + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferData(b)), Containers::arrayView(data), TestSuite::Compare::Container); - CORRADE_COMPARE_AS(Containers::arrayCast(c.data()), + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferData(c)), Containers::arrayView(data), TestSuite::Compare::Container); /* d's data is undefined, not testing */ @@ -307,10 +310,9 @@ void BufferGLTest::data() { MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(buffer.size(), 5*4); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE_AS(Containers::arrayCast(buffer.data()), + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferData(buffer)), Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -320,10 +322,9 @@ void BufferGLTest::data() { MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(buffer.size(), 5*4); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE_AS(Containers::arrayCast(buffer.data()), + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferData(buffer)), Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -334,10 +335,9 @@ void BufferGLTest::data() { MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(buffer.size(), 5*4); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE_AS(Containers::arrayCast(buffer.subData(4, 3*4)), + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferSubData(buffer, 4, 3*4)), Containers::arrayView(subData), TestSuite::Compare::Container); #endif @@ -347,10 +347,9 @@ void BufferGLTest::data() { MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(buffer.size(), 5*4); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 MAGNUM_VERIFY_NO_GL_ERROR(); - CORRADE_COMPARE_AS(Containers::arrayCast(buffer.subData(4, 3*4)), + CORRADE_COMPARE_AS(Containers::arrayCast(DebugTools::bufferSubData(buffer, 4, 3*4)), Containers::arrayView(subData), TestSuite::Compare::Container); #endif @@ -385,9 +384,8 @@ void BufferGLTest::map() { CORRADE_VERIFY(buffer.unmap()); MAGNUM_VERIFY_NO_GL_ERROR(); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES - Containers::Array changedContents = buffer.data(); + #ifndef MAGNUM_TARGET_GLES2 + Containers::Array changedContents = DebugTools::bufferData(buffer); CORRADE_COMPARE(changedContents.size(), 5); CORRADE_COMPARE(changedContents[3], 107); #endif @@ -417,9 +415,8 @@ void BufferGLTest::mapRange() { CORRADE_VERIFY(buffer.unmap()); MAGNUM_VERIFY_NO_GL_ERROR(); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES - Containers::Array changedContents = buffer.data(); + #ifndef MAGNUM_TARGET_GLES2 + Containers::Array changedContents = DebugTools::bufferData(buffer); CORRADE_COMPARE(changedContents.size(), 5); CORRADE_COMPARE(changedContents[4], 107); #endif @@ -457,9 +454,8 @@ void BufferGLTest::mapRangeExplicitFlush() { MAGNUM_VERIFY_NO_GL_ERROR(); /* Flushed range should be changed */ - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES - Containers::Array changedContents = buffer.data(); + #ifndef MAGNUM_TARGET_GLES2 + Containers::Array changedContents = DebugTools::bufferData(buffer); CORRADE_COMPARE(changedContents.size(), 5); CORRADE_COMPARE(changedContents[4], 107); #endif @@ -478,9 +474,8 @@ void BufferGLTest::copy() { Buffer::copy(buffer1, buffer2, 1, 2, 3); MAGNUM_VERIFY_NO_GL_ERROR(); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES - const Containers::Array subContents = buffer2.subData(2, 3); + #ifndef MAGNUM_TARGET_GLES2 + const Containers::Array subContents = DebugTools::bufferSubData(buffer2, 2, 3); CORRADE_COMPARE_AS(subContents, Containers::arrayView(data).slice(1, 4), TestSuite::Compare::Container); #endif diff --git a/src/Magnum/GL/Test/BufferImageGLTest.cpp b/src/Magnum/GL/Test/BufferImageGLTest.cpp index 915f485872..74691ce70a 100644 --- a/src/Magnum/GL/Test/BufferImageGLTest.cpp +++ b/src/Magnum/GL/Test/BufferImageGLTest.cpp @@ -33,6 +33,10 @@ #include "Magnum/GL/PixelFormat.h" #include "Magnum/GL/OpenGLTester.h" +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/DebugTools/BufferData.h" +#endif + namespace Magnum { namespace GL { namespace Test { namespace { struct BufferImageGLTest: OpenGLTester { @@ -98,10 +102,6 @@ void BufferImageGLTest::construct() { BufferImage2D a{PixelStorage{}.setAlignment(1), PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, data, BufferUsage::StaticDraw}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(a.storage().alignment(), 1); @@ -110,8 +110,9 @@ void BufferImageGLTest::construct() { CORRADE_COMPARE(a.size(), Vector2i(1, 3)); CORRADE_COMPARE(a.dataSize(), 3); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -122,10 +123,6 @@ void BufferImageGLTest::constructGeneric() { BufferImage2D a{PixelStorage{}.setAlignment(1), Magnum::PixelFormat::R8Unorm, {1, 3}, data, BufferUsage::StaticDraw}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(a.storage().alignment(), 1); @@ -134,8 +131,9 @@ void BufferImageGLTest::constructGeneric() { CORRADE_COMPARE(a.size(), Vector2i(1, 3)); CORRADE_COMPARE(a.dataSize(), 3); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -150,10 +148,6 @@ void BufferImageGLTest::constructCompressed() { CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, data, BufferUsage::StaticDraw}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); #ifndef MAGNUM_TARGET_GLES @@ -163,8 +157,9 @@ void BufferImageGLTest::constructCompressed() { CORRADE_COMPARE(a.size(), Vector2i(4, 4)); CORRADE_COMPARE(a.dataSize(), 8); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -179,10 +174,6 @@ void BufferImageGLTest::constructCompressedGeneric() { Magnum::CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data, BufferUsage::StaticDraw}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); #ifndef MAGNUM_TARGET_GLES @@ -192,8 +183,9 @@ void BufferImageGLTest::constructCompressedGeneric() { CORRADE_COMPARE(a.size(), Vector2i(4, 4)); CORRADE_COMPARE(a.dataSize(), 8); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -208,10 +200,6 @@ void BufferImageGLTest::constructBuffer() { BufferImage2D a{PixelStorage{}.setAlignment(1), PixelFormat::Red, PixelType::UnsignedByte, {1, 3}, std::move(buffer), sizeof(data)}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_VERIFY(!buffer.id()); @@ -222,8 +210,9 @@ void BufferImageGLTest::constructBuffer() { CORRADE_COMPARE(a.size(), Vector2i(1, 3)); CORRADE_COMPARE(a.dataSize(), 3); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -238,10 +227,6 @@ void BufferImageGLTest::constructBufferGeneric() { BufferImage2D a{PixelStorage{}.setAlignment(1), Magnum::PixelFormat::R8Unorm, {1, 3}, std::move(buffer), sizeof(data)}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_VERIFY(!buffer.id()); @@ -252,8 +237,9 @@ void BufferImageGLTest::constructBufferGeneric() { CORRADE_COMPARE(a.size(), Vector2i(1, 3)); CORRADE_COMPARE(a.dataSize(), 3); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -272,10 +258,6 @@ void BufferImageGLTest::constructBufferCompressed() { CompressedPixelFormat::RGBAS3tcDxt1, {4, 4}, std::move(buffer), sizeof(data)}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); #ifndef MAGNUM_TARGET_GLES @@ -287,8 +269,9 @@ void BufferImageGLTest::constructBufferCompressed() { CORRADE_COMPARE(a.size(), Vector2i(4, 4)); CORRADE_COMPARE(a.dataSize(), 8); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -307,10 +290,6 @@ void BufferImageGLTest::constructBufferCompressedGeneric() { Magnum::CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, std::move(buffer), sizeof(data)}; - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); #ifndef MAGNUM_TARGET_GLES @@ -322,8 +301,9 @@ void BufferImageGLTest::constructBufferCompressedGeneric() { CORRADE_COMPARE(a.size(), Vector2i(4, 4)); CORRADE_COMPARE(a.dataSize(), 8); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data), TestSuite::Compare::Container); #endif @@ -487,10 +467,6 @@ void BufferImageGLTest::setData() { const UnsignedShort data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 }; a.setData(PixelFormat::RGBA, PixelType::UnsignedShort, {1, 2}, data2, BufferUsage::StaticDraw); - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(a.storage().alignment(), 4); @@ -499,8 +475,9 @@ void BufferImageGLTest::setData() { CORRADE_COMPARE(a.size(), Vector2i(1, 2)); CORRADE_COMPARE(a.dataSize(), 16); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(data2), TestSuite::Compare::Container); @@ -515,10 +492,6 @@ void BufferImageGLTest::setDataGeneric() { const UnsignedShort data2[2*4] = { 1, 2, 3, 4, 5, 6, 7, 8 }; a.setData(Magnum::PixelFormat::RGBA16Unorm, {1, 2}, data2, BufferUsage::StaticDraw); - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(a.storage().alignment(), 4); @@ -527,8 +500,9 @@ void BufferImageGLTest::setDataGeneric() { CORRADE_COMPARE(a.size(), Vector2i(1, 2)); CORRADE_COMPARE(a.dataSize(), 16); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(Containers::arrayCast(imageData), Containers::arrayView(data2), TestSuite::Compare::Container); @@ -546,10 +520,6 @@ void BufferImageGLTest::setDataCompressed() { #endif CompressedPixelFormat::RGBAS3tcDxt3, {8, 4}, data2, BufferUsage::StaticDraw); - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); #ifndef MAGNUM_TARGET_GLES @@ -559,8 +529,9 @@ void BufferImageGLTest::setDataCompressed() { CORRADE_COMPARE(a.size(), Vector2i(8, 4)); CORRADE_COMPARE(a.dataSize(), 16); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data2), TestSuite::Compare::Container); #endif @@ -577,10 +548,6 @@ void BufferImageGLTest::setDataCompressedGeneric() { #endif Magnum::CompressedPixelFormat::Bc2RGBAUnorm, {8, 4}, data2, BufferUsage::StaticDraw); - #ifndef MAGNUM_TARGET_GLES - const auto imageData = a.buffer().data(); - #endif - MAGNUM_VERIFY_NO_GL_ERROR(); #ifndef MAGNUM_TARGET_GLES @@ -590,8 +557,9 @@ void BufferImageGLTest::setDataCompressedGeneric() { CORRADE_COMPARE(a.size(), Vector2i(8, 4)); CORRADE_COMPARE(a.dataSize(), 16); - /** @todo How to verify the contents in ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 + const auto imageData = DebugTools::bufferData(a.buffer()); + MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE_AS(imageData, Containers::arrayView(data2), TestSuite::Compare::Container); #endif diff --git a/src/Magnum/GL/Test/CMakeLists.txt b/src/Magnum/GL/Test/CMakeLists.txt index 5f9a38711e..651848fb5d 100644 --- a/src/Magnum/GL/Test/CMakeLists.txt +++ b/src/Magnum/GL/Test/CMakeLists.txt @@ -75,9 +75,7 @@ if(BUILD_GL_TESTS) find_package(Corrade REQUIRED PluginManager) corrade_add_test(GLAbstractTextureGLTest AbstractTextureGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) - corrade_add_test(GLBufferGLTest BufferGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(GLCubeMapTextureGLTest CubeMapTextureGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) - corrade_add_test(GLFramebufferGLTest FramebufferGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) corrade_add_test(GLMeshGLTest MeshGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) corrade_add_test(GLRenderbufferGLTest RenderbufferGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(GLTextureGLTest TextureGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) @@ -89,6 +87,16 @@ if(BUILD_GL_TESTS) ${GLAbstractShaderProgramGLTest_RES} LIBRARIES MagnumOpenGLTester) + corrade_add_test(GLBufferGLTest BufferGLTest.cpp LIBRARIES MagnumOpenGLTester) + if(NOT MAGNUM_TARGET_GLES2) + target_link_libraries(GLBufferGLTest PRIVATE MagnumDebugTools) + endif() + + corrade_add_test(GLFramebufferGLTest FramebufferGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) + if(NOT MAGNUM_TARGET_GLES2) + target_link_libraries(GLFramebufferGLTest PRIVATE MagnumDebugTools) + endif() + corrade_add_test(GLContextGLTest ContextGLTest.cpp LIBRARIES MagnumOpenGLTester) if(NOT CORRADE_TARGET_EMSCRIPTEN) set(THREADS_PREFER_PTHREAD_FLAG TRUE) @@ -162,10 +170,10 @@ if(BUILD_GL_TESTS) endif() if(NOT MAGNUM_TARGET_GLES2) - corrade_add_test(GLBufferImageGLTest BufferImageGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib) + corrade_add_test(GLBufferImageGLTest BufferImageGLTest.cpp LIBRARIES MagnumOpenGLTesterTestLib MagnumDebugTools) corrade_add_test(GLPrimitiveQueryGLTest PrimitiveQueryGLTest.cpp LIBRARIES MagnumOpenGLTester) corrade_add_test(GLTextureArrayGLTest TextureArrayGLTest.cpp LIBRARIES MagnumOpenGLTester) - corrade_add_test(GLTransformFeedbackGLTest TransformFeedbackGLTest.cpp LIBRARIES MagnumOpenGLTester) + corrade_add_test(GLTransformFeedbackGLTest TransformFeedbackGLTest.cpp LIBRARIES MagnumOpenGLTester MagnumDebugTools) endif() if(NOT MAGNUM_TARGET_GLES2 AND NOT MAGNUM_TARGET_WEBGL) diff --git a/src/Magnum/GL/Test/FramebufferGLTest.cpp b/src/Magnum/GL/Test/FramebufferGLTest.cpp index e9d1724c3d..798fb4b423 100644 --- a/src/Magnum/GL/Test/FramebufferGLTest.cpp +++ b/src/Magnum/GL/Test/FramebufferGLTest.cpp @@ -57,6 +57,10 @@ #include "Magnum/GL/RectangleTexture.h" #endif +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/DebugTools/BufferData.h" +#endif + namespace Magnum { namespace GL { namespace Test { namespace { struct FramebufferGLTest: OpenGLTester { @@ -1701,9 +1705,9 @@ void FramebufferGLTest::readBuffer() { CORRADE_COMPARE(colorImage.size(), Vector2i(8, 16)); MAGNUM_VERIFY_NO_GL_ERROR(); - /** @todo How to test this on ES? */ - #ifndef MAGNUM_TARGET_GLES - auto colorData = colorImage.buffer().data(); + + #ifndef MAGNUM_TARGET_GLES2 + auto colorData = DebugTools::bufferData(colorImage.buffer()); CORRADE_COMPARE(colorData.size(), (DataOffset + 8*16)*sizeof(Color4ub)); CORRADE_COMPARE(Containers::arrayCast(colorData)[DataOffset], Color4ub(128, 64, 32, 17)); #endif diff --git a/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp b/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp index 25a3b008f9..ec2863e538 100644 --- a/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp +++ b/src/Magnum/GL/Test/TransformFeedbackGLTest.cpp @@ -24,8 +24,11 @@ */ #include +#include #include +#include +#include "Magnum/DebugTools/BufferData.h" #include "Magnum/Image.h" #include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/Buffer.h" @@ -307,14 +310,11 @@ void TransformFeedbackGLTest::attachBase() { MAGNUM_VERIFY_NO_GL_ERROR(); - #ifdef MAGNUM_TARGET_WEBGL - CORRADE_SKIP("Can't map buffers on WebGL."); - #else - auto data = Containers::arrayCast(output.mapRead(0, 2*sizeof(Vector2))); - CORRADE_COMPARE(data[0], Vector2(1.0f, -1.0f)); - CORRADE_COMPARE(data[1], Vector2(0.0f, 0.0f)); - output.unmap(); - #endif + auto data = DebugTools::bufferData(output); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(Containers::arrayCast(data), + Containers::arrayView({{1.0f, -1.0f}, {0.0f, 0.0f}}), + TestSuite::Compare::Container); } void TransformFeedbackGLTest::attachRange() { @@ -354,14 +354,11 @@ void TransformFeedbackGLTest::attachRange() { MAGNUM_VERIFY_NO_GL_ERROR(); - #ifdef MAGNUM_TARGET_WEBGL - CORRADE_SKIP("Can't map buffers on WebGL."); - #else - auto data = Containers::arrayCast(output.mapRead(256, 2*sizeof(Vector2))); - CORRADE_COMPARE(data[0], Vector2(1.0f, -1.0f)); - CORRADE_COMPARE(data[1], Vector2(0.0f, 0.0f)); - output.unmap(); - #endif + auto data = DebugTools::bufferSubData(output, 256, 2*sizeof(Vector2)); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(Containers::arrayCast(data), + Containers::arrayView({{1.0f, -1.0f}, {0.0f, 0.0f}}), + TestSuite::Compare::Container); } struct XfbMultiShader: AbstractShaderProgram { @@ -445,19 +442,17 @@ void TransformFeedbackGLTest::attachBases() { MAGNUM_VERIFY_NO_GL_ERROR(); - #ifdef MAGNUM_TARGET_WEBGL - CORRADE_SKIP("Can't map buffers on WebGL."); - #else - auto data1 = Containers::arrayCast(output1.mapRead(0, 2*sizeof(Vector2))); - CORRADE_COMPARE(data1[0], Vector2(1.0f, -1.0f)); - CORRADE_COMPARE(data1[1], Vector2(0.0f, 0.0f)); - output1.unmap(); - - auto data2 = Containers::arrayCast(output2.mapRead(0, 2*sizeof(Float))); - CORRADE_COMPARE(data2[0], 0.0f); - CORRADE_COMPARE(data2[1], -2.0f); - output2.unmap(); - #endif + auto data1 = DebugTools::bufferData(output1); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(Containers::arrayCast(data1), + Containers::arrayView({{1.0f, -1.0f}, {0.0f, 0.0f}}), + TestSuite::Compare::Container); + + auto data2 = DebugTools::bufferData(output2); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(Containers::arrayCast(data2), + Containers::arrayView({0.0f, -2.0f}), + TestSuite::Compare::Container); } void TransformFeedbackGLTest::attachRanges() { @@ -502,19 +497,17 @@ void TransformFeedbackGLTest::attachRanges() { MAGNUM_VERIFY_NO_GL_ERROR(); - #ifdef MAGNUM_TARGET_WEBGL - CORRADE_SKIP("Can't map buffers on WebGL."); - #else - auto data1 = Containers::arrayCast(output1.mapRead(256, 2*sizeof(Vector2))); - CORRADE_COMPARE(data1[0], Vector2(1.0f, -1.0f)); - CORRADE_COMPARE(data1[1], Vector2(0.0f, 0.0f)); - output1.unmap(); - - auto data2 = Containers::arrayCast(output2.mapRead(512, 2*sizeof(Float))); - CORRADE_COMPARE(data2[0], 0.0f); - CORRADE_COMPARE(data2[1], -2.0f); - output2.unmap(); - #endif + auto data1 = DebugTools::bufferSubData(output1, 256, 2*sizeof(Vector2)); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(Containers::arrayCast(data1), + Containers::arrayView({{1.0f, -1.0f}, {0.0f, 0.0f}}), + TestSuite::Compare::Container); + + auto data2 = DebugTools::bufferSubData(output2, 512, 2*sizeof(Float)); + MAGNUM_VERIFY_NO_GL_ERROR(); + CORRADE_COMPARE_AS(Containers::arrayCast(data2), + Containers::arrayView({0.0f, -2.0f}), + TestSuite::Compare::Container); } #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Text/Test/CMakeLists.txt b/src/Magnum/Text/Test/CMakeLists.txt index 9aac7e3312..cdf641aa87 100644 --- a/src/Magnum/Text/Test/CMakeLists.txt +++ b/src/Magnum/Text/Test/CMakeLists.txt @@ -53,4 +53,7 @@ if(TARGET_GL AND BUILD_GL_TESTS) corrade_add_test(TextDistanceFieldGlyphCacheGLTest DistanceFieldGlyphCacheGLTest.cpp LIBRARIES MagnumText MagnumOpenGLTester) corrade_add_test(TextGlyphCacheGLTest GlyphCacheGLTest.cpp LIBRARIES MagnumText MagnumOpenGLTester) corrade_add_test(TextRendererGLTest RendererGLTest.cpp LIBRARIES MagnumText MagnumOpenGLTester) + if(NOT MAGNUM_TARGET_GLES2) + target_link_libraries(TextRendererGLTest PRIVATE MagnumDebugTools) + endif() endif() diff --git a/src/Magnum/Text/Test/RendererGLTest.cpp b/src/Magnum/Text/Test/RendererGLTest.cpp index 276f3fbc25..1907d8fcde 100644 --- a/src/Magnum/Text/Test/RendererGLTest.cpp +++ b/src/Magnum/Text/Test/RendererGLTest.cpp @@ -32,6 +32,10 @@ #include "Magnum/Text/AbstractFont.h" #include "Magnum/Text/Renderer.h" +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/DebugTools/BufferData.h" +#endif + namespace Magnum { namespace Text { namespace Test { namespace { struct RendererGLTest: GL::OpenGLTester { @@ -187,10 +191,9 @@ void RendererGLTest::renderMesh() { /* Bounds */ CORRADE_COMPARE(bounds, Range2D({0.0f, -0.5f}, {5.0f, 1.0f}).translated(offset)); - /** @todo How to verify this on ES? */ - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 /* Vertex buffer contents */ - Containers::Array vertices = vertexBuffer.data(); + Containers::Array vertices = DebugTools::bufferData(vertexBuffer); CORRADE_COMPARE_AS(Containers::arrayCast(vertices), Containers::arrayView({ 0.0f + offset.x(), 0.5f + offset.y(), 0.0f, 10.0f, @@ -208,8 +211,8 @@ void RendererGLTest::renderMesh() { 5.0f + offset.x(), 1.0f + offset.y(), 18.0f, 10.0f, 5.0f + offset.x(), -0.5f + offset.y(), 18.0f, 0.0f }), TestSuite::Compare::Container); - - Containers::Array indices = indexBuffer.data(); + /* Index buffer contents */ + Containers::Array indices = DebugTools::bufferData(indexBuffer); CORRADE_COMPARE_AS(Containers::arrayCast(indices), Containers::arrayView({ 0, 1, 2, 1, 3, 2, @@ -220,10 +223,11 @@ void RendererGLTest::renderMesh() { } void RendererGLTest::renderMeshIndexType() { - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_GLES2 TestFont font; GL::Mesh mesh{NoCreate}; - GL::Buffer vertexBuffer, indexBuffer; + GL::Buffer vertexBuffer{GL::Buffer::TargetHint::Array}; + GL::Buffer indexBuffer{GL::Buffer::TargetHint::ElementArray}; /* Sizes: four vertices per glyph, each vertex has 2D position and 2D texture coordinates, each float is four bytes; six indices per glyph. */ @@ -232,7 +236,7 @@ void RendererGLTest::renderMeshIndexType() { std::tie(mesh, std::ignore) = Text::Renderer3D::render(font, nullGlyphCache, 1.0f, std::string(64, 'a'), vertexBuffer, indexBuffer, GL::BufferUsage::StaticDraw); MAGNUM_VERIFY_NO_GL_ERROR(); - Containers::Array indicesByte = indexBuffer.data(); + Containers::Array indicesByte = DebugTools::bufferData(indexBuffer); CORRADE_COMPARE(vertexBuffer.size(), 256*(2 + 2)*4); CORRADE_COMPARE(indicesByte.size(), 64*6); CORRADE_COMPARE_AS(Containers::arrayCast(indicesByte).prefix(18), @@ -246,7 +250,7 @@ void RendererGLTest::renderMeshIndexType() { std::tie(mesh, std::ignore) = Text::Renderer3D::render(font, nullGlyphCache, 1.0f, std::string(65, 'a'), vertexBuffer, indexBuffer, GL::BufferUsage::StaticDraw); MAGNUM_VERIFY_NO_GL_ERROR(); - Containers::Array indicesShort = indexBuffer.data(); + Containers::Array indicesShort = DebugTools::bufferData(indexBuffer); CORRADE_COMPARE(vertexBuffer.size(), 260*(2 + 2)*4); CORRADE_COMPARE(indicesShort.size(), 65*6*2); CORRADE_COMPARE_AS(Containers::arrayCast(indicesShort).prefix(18), @@ -256,7 +260,7 @@ void RendererGLTest::renderMeshIndexType() { 8, 9, 10, 9, 11, 10 }), TestSuite::Compare::Container); #else - CORRADE_SKIP("Can't verify buffer contents on OpenGL ES."); + CORRADE_SKIP("Can't verify buffer contents on OpenGL ES 2.0."); #endif } @@ -280,9 +284,9 @@ void RendererGLTest::mutableText() { renderer.reserve(4, GL::BufferUsage::DynamicDraw, GL::BufferUsage::DynamicDraw); MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(renderer.capacity(), 4); - /** @todo How to verify this on ES? */ - #ifndef MAGNUM_TARGET_GLES - Containers::Array indices = renderer.indexBuffer().data(); + + #ifndef MAGNUM_TARGET_GLES2 + Containers::Array indices = DebugTools::bufferData(renderer.indexBuffer()); CORRADE_COMPARE_AS(Containers::arrayCast(indices).prefix(24), Containers::arrayView({ 0, 1, 2, 1, 3, 2, @@ -301,9 +305,8 @@ void RendererGLTest::mutableText() { /* Aligned to line/left, no offset needed */ - /** @todo How to verify this on ES? */ - #ifndef MAGNUM_TARGET_GLES - Containers::Array vertices = renderer.vertexBuffer().data(); + #ifndef MAGNUM_TARGET_GLES2 + Containers::Array vertices = DebugTools::bufferData(renderer.vertexBuffer()); CORRADE_COMPARE_AS(Containers::arrayCast(vertices).prefix(48), Containers::arrayView({ 0.0f, 0.5f, 0.0f, 10.0f,