From 86d78aba10aee204d2848af2bfdd3ce9c56b1f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Oct 2021 14:19:38 +0200 Subject: [PATCH] GL: fix MeshGLTest on WebGL. It doesn't allow anything except full RGBA and 32-bit types to be read from the framebuffer. Chromium browsers weren't complaining but Firefox did. I remember a similar restriction from GLES2 but all implementations I tested with including ANGLE and SwiftShader allow that already, so it's practically just a WebGL limitation. --- src/Magnum/GL/Test/MeshGLTest.cpp | 54 ++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/src/Magnum/GL/Test/MeshGLTest.cpp b/src/Magnum/GL/Test/MeshGLTest.cpp index 2b4f2b6ef..c882b38c1 100644 --- a/src/Magnum/GL/Test/MeshGLTest.cpp +++ b/src/Magnum/GL/Test/MeshGLTest.cpp @@ -932,8 +932,13 @@ void MeshGLTest::addVertexBufferUnsignedInt() { MAGNUM_VERIFY_NO_GL_ERROR(); - const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R32UI, mesh) - .get(PixelFormat::RedInteger, PixelType::UnsignedInt); + const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R32UI, mesh).get( + #ifndef MAGNUM_TARGET_WEBGL + PixelFormat::RedInteger, + #else + PixelFormat::RGBAInteger, + #endif + PixelType::UnsignedInt); MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(value, 35681); @@ -965,8 +970,13 @@ void MeshGLTest::addVertexBufferInt() { MAGNUM_VERIFY_NO_GL_ERROR(); - const auto value = Checker(IntegerShader("int"), RenderbufferFormat::R32I, mesh) - .get(PixelFormat::RedInteger, PixelType::Int); + const auto value = Checker(IntegerShader("int"), RenderbufferFormat::R32I, mesh).get( + #ifndef MAGNUM_TARGET_WEBGL + PixelFormat::RedInteger, + #else + PixelFormat::RGBAInteger, + #endif + PixelType::Int); MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(value, 27530); @@ -1112,8 +1122,13 @@ void MeshGLTest::addVertexBufferVectorNi() { MAGNUM_VERIFY_NO_GL_ERROR(); - const auto value = Checker(IntegerShader("ivec2"), RenderbufferFormat::RG32I, mesh) - .get(PixelFormat::RGInteger, PixelType::Int); + const auto value = Checker(IntegerShader("ivec2"), RenderbufferFormat::RG32I, mesh).get( + #ifndef MAGNUM_TARGET_WEBGL + PixelFormat::RGInteger + #else + PixelFormat::RGBAInteger + #endif + , PixelType::Int); MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(value, Vector2i(27592, -157)); @@ -1413,8 +1428,13 @@ void MeshGLTest::addVertexBufferUnsignedIntWithUnsignedShort() { MAGNUM_VERIFY_NO_GL_ERROR(); - const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R16UI, mesh) - .get(PixelFormat::RedInteger, PixelType::UnsignedShort); + const UnsignedShort value = Checker(IntegerShader("uint"), RenderbufferFormat::R16UI, mesh) + #ifndef MAGNUM_TARGET_WEBGL + .get(PixelFormat::RedInteger, PixelType::UnsignedShort) + #else + .get(PixelFormat::RGBAInteger, PixelType::UnsignedInt) + #endif + ; #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL) CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::SwiftShader, @@ -1527,8 +1547,13 @@ void MeshGLTest::addVertexBufferIntWithShort() { MAGNUM_VERIFY_NO_GL_ERROR(); - const auto value = Checker(IntegerShader("int"), RenderbufferFormat::R16I, mesh) - .get(PixelFormat::RedInteger, PixelType::Short); + const Short value = Checker(IntegerShader("int"), RenderbufferFormat::R16I, mesh) + #ifndef MAGNUM_TARGET_WEBGL + .get(PixelFormat::RedInteger, PixelType::Short) + #else + .get(PixelFormat::RGBAInteger, PixelType::Int) + #endif + ; #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL) CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::SwiftShader, @@ -3289,8 +3314,13 @@ void MeshGLTest::addVertexBufferInstancedInteger() { MAGNUM_VERIFY_NO_GL_ERROR(); - const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R32UI, mesh) - .get(PixelFormat::RedInteger, PixelType::UnsignedInt); + const auto value = Checker(IntegerShader("uint"), RenderbufferFormat::R32UI, mesh).get( + #ifndef MAGNUM_TARGET_WEBGL + PixelFormat::RedInteger, + #else + PixelFormat::RGBAInteger, + #endif + PixelType::UnsignedInt); MAGNUM_VERIFY_NO_GL_ERROR(); CORRADE_COMPARE(value, 35681);