From 4676418842faed412b190d691c6a5167543fd779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 11 Mar 2022 15:37:22 +0100 Subject: [PATCH] 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 Pick-to: 6.3 Change-Id: I68384a9f6954b6a1960ba6e8afd1fdbdfefe2335 Reviewed-by: Laszlo Agocs Reviewed-by: Lorn Potter --- src/gui/rhi/qrhigles2.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index e7a2382497..adb6614336 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -2753,6 +2753,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;