From fa98ea3211c66a705cb5f6a1b02c17cb958d7227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 25 Jan 2023 22:54:53 +0100 Subject: [PATCH] Shaders: bind an attribute even if not (dynamically) used on WebGL. Just alias it to some other attribute. Fixes another WebGL error. --- src/Magnum/Shaders/Test/FlatGLTest.cpp | 6 ++++++ src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp | 6 ++++++ src/Magnum/Shaders/Test/PhongGLTest.cpp | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 512cd994c..6da19eb24 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -586,6 +586,12 @@ const struct { }}, false, true, false, "skinning.tga"}, {"only secondary set, dynamic", 5, 4, 4, 0, 3, FlatGL2D::Flag::DynamicPerVertexJointCount, {InPlaceInit, { + #ifdef MAGNUM_TARGET_WEBGL + /* On WebGL the primary joint vertex attribute has to be bound to + something even if not (dynamically) used in the end, otherwise + it causes an error. So just alias it with the secondary one. */ + {0, FlatGL2D::JointIds{FlatGL2D::JointIds::Components::Three}}, + #endif {0, FlatGL2D::SecondaryJointIds{FlatGL2D::SecondaryJointIds::Components::Three}}, {3*4, FlatGL2D::SecondaryWeights{FlatGL2D::SecondaryWeights::Components::Three}}, }}, true, true, false, diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index 06bf095a7..73aea25aa 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -991,6 +991,12 @@ const struct { {"only secondary set, dynamic", 5, 4, 4, 0, 3, MeshVisualizerGL2D::Flag::DynamicPerVertexJointCount, MeshVisualizerGL3D::Flag::DynamicPerVertexJointCount, {InPlaceInit, { + #ifdef MAGNUM_TARGET_WEBGL + /* On WebGL the primary joint vertex attribute has to be bound to + something even if not (dynamically) used in the end, otherwise + it causes an error. So just alias it with the secondary one. */ + {0, MeshVisualizerGL2D::JointIds{MeshVisualizerGL2D::JointIds::Components::Three}}, + #endif {0, MeshVisualizerGL2D::SecondaryJointIds{MeshVisualizerGL2D::SecondaryJointIds::Components::Three}}, {3*4, MeshVisualizerGL2D::SecondaryWeights{MeshVisualizerGL2D::SecondaryWeights::Components::Three}}, }}, true, true, false, diff --git a/src/Magnum/Shaders/Test/PhongGLTest.cpp b/src/Magnum/Shaders/Test/PhongGLTest.cpp index 4f85d18e5..b46f47eee 100644 --- a/src/Magnum/Shaders/Test/PhongGLTest.cpp +++ b/src/Magnum/Shaders/Test/PhongGLTest.cpp @@ -901,6 +901,12 @@ const struct { }}, false, true, false, "skinning.tga"}, {"only secondary set, dynamic", 5, 4, 4, 0, 3, PhongGL::Flag::DynamicPerVertexJointCount, {InPlaceInit, { + #ifdef MAGNUM_TARGET_WEBGL + /* On WebGL the primary joint vertex attribute has to be bound to + something even if not (dynamically) used in the end, otherwise + it causes an error. So just alias it with the secondary one. */ + {0, PhongGL::JointIds{PhongGL::JointIds::Components::Three}}, + #endif {0, PhongGL::SecondaryJointIds{PhongGL::SecondaryJointIds::Components::Three}}, {3*4, PhongGL::SecondaryWeights{PhongGL::SecondaryWeights::Components::Three}}, }}, true, true, false,