From 6db78765d38b8222bf228843f8903df7e3f1c1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 25 Jan 2023 22:56:15 +0100 Subject: [PATCH] Shaders: WebGL doesn't allow uploading an UBO shorter than hardcoded. Also fixes a WebGL error in the tests. I suspect it might fail elsewhere as well. Nevertheless, this still doesn't mean that it would be impossible to use dynamic joint count with UBOs -- simply pad the UBO in that case. --- src/Magnum/Shaders/Test/FlatGLTest.cpp | 10 ++++++++++ src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp | 10 ++++++++++ src/Magnum/Shaders/Test/PhongGLTest.cpp | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 6da19eb24..983a24872 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -3191,6 +3191,11 @@ template void FlatGLTest::renderSkinning2D() { Matrix3{Math::IdentityInit}, }; + #ifdef MAGNUM_TARGET_WEBGL + if(flag == FlatGL2D::Flag::UniformBuffers && data.jointCount > Containers::arraySize(jointMatrices)) + CORRADE_SKIP("Uploading an uniform buffer smaller than the size hardcoded in the shader is an error in WebGL."); + #endif + GL::Buffer buffer{vertices}; GL::Mesh mesh{MeshPrimitive::TriangleStrip}; @@ -3317,6 +3322,11 @@ template void FlatGLTest::renderSkinning3D() { Matrix4{Math::IdentityInit}, }; + #ifdef MAGNUM_TARGET_WEBGL + if(flag == FlatGL3D::Flag::UniformBuffers && data.jointCount > Containers::arraySize(jointMatrices)) + CORRADE_SKIP("Uploading an uniform buffer smaller than the size hardcoded in the shader is an error in WebGL."); + #endif + GL::Buffer buffer{vertices}; GL::Mesh mesh{MeshPrimitive::TriangleStrip}; diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index 73aea25aa..2d895ac7a 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -4804,6 +4804,11 @@ template void MeshVisualizerGLTest::renderSkinnin Matrix3{Math::IdentityInit}, }; + #ifdef MAGNUM_TARGET_WEBGL + if(flag == MeshVisualizerGL2D::Flag::UniformBuffers && data.jointCount > Containers::arraySize(jointMatrices)) + CORRADE_SKIP("Uploading an uniform buffer smaller than the size hardcoded in the shader is an error in WebGL."); + #endif + GL::Buffer buffer{vertices}; GL::Mesh mesh{MeshPrimitive::Triangles}; @@ -4937,6 +4942,11 @@ template void MeshVisualizerGLTest::renderSkinnin Matrix4{Math::IdentityInit}, }; + #ifdef MAGNUM_TARGET_WEBGL + if(flag == MeshVisualizerGL3D::Flag::UniformBuffers && data.jointCount > Containers::arraySize(jointMatrices)) + CORRADE_SKIP("Uploading an uniform buffer smaller than the size hardcoded in the shader is an error in WebGL."); + #endif + GL::Buffer buffer{vertices}; GL::Mesh mesh{MeshPrimitive::Triangles}; diff --git a/src/Magnum/Shaders/Test/PhongGLTest.cpp b/src/Magnum/Shaders/Test/PhongGLTest.cpp index b46f47eee..fd6b5bbec 100644 --- a/src/Magnum/Shaders/Test/PhongGLTest.cpp +++ b/src/Magnum/Shaders/Test/PhongGLTest.cpp @@ -4033,6 +4033,11 @@ template void PhongGLTest::renderSkinning() { Matrix4{Math::IdentityInit}, }; + #ifdef MAGNUM_TARGET_WEBGL + if(flag == PhongGL::Flag::UniformBuffers && data.jointCount > Containers::arraySize(jointMatrices)) + CORRADE_SKIP("Uploading an uniform buffer smaller than the size hardcoded in the shader is an error in WebGL."); + #endif + GL::Buffer buffer{vertices}; GL::Mesh mesh{MeshPrimitive::TriangleStrip};