summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2022-03-11 15:37:22 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-14 16:16:44 +0000
commitab943cdda0988a88d50cc2beb0655f647a96439b (patch)
tree5add3d5fe044a13f028f5598503e847caa171edd
parent8dd6bd14cf9e98cf7bb5e9f0dacb3639de0c53e2 (diff)
wasm: prevent WebGL vertex attribute errors
WebGL is stricter than OpenGL ES and require that unused vertex attribute arrays are disabled. This prevents errors such as: WebGL: INVALID_OPERATION: drawElements: no buffer is bound to enabled attribute Change-Id: I68384a9f6954b6a1960ba6e8afd1fdbdfefe2335 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit 4676418842faed412b190d691c6a5167543fd779) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/gui/rhi/qrhigles2.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index 72eeeb88a5..2091300be9 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -2649,6 +2649,14 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
f->glVertexAttribDivisor(GLuint(i), 0);
state.instancedAttributesUsed = false;
}
+#ifdef Q_OS_WASM
+ for (int i = 0; i < CommandBufferExecTrackedState::TRACKED_ATTRIB_COUNT; ++i) {
+ if (state.enabledAttribArrays[i]) {
+ f->glDisableVertexAttribArray(GLuint(i));
+ state.enabledAttribArrays[i] = false;
+ }
+ }
+#endif
if (vao)
f->glBindVertexArray(0);
break;