From 4b146bf4f38b2d54b15475d538297e067daca422 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 28 Oct 2022 17:13:28 +0200 Subject: rhi: gl: Skip the prim.restart enable on WebGL2 Doing so generates an error as this value for glEnable is invalid with WebGL 2. The behavior is always as if this was enabled. (unlike in GLES 3) Task-number: QTBUG-107780 Change-Id: I3fc34329fc573a6fac8e4265d90ca93520e4e2ee Reviewed-by: Janne Koskinen (cherry picked from commit 062efb305e1866482c03717ed1cf9717f45e5abb) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhigles2.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 6b3207e05d..a12a0b551e 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -725,8 +725,15 @@ bool QRhiGles2::create(QRhi::Flags flags) else caps.fixedIndexPrimitiveRestart = caps.ctxMajor > 4 || (caps.ctxMajor == 4 && caps.ctxMinor >= 3); // 4.3 - if (caps.fixedIndexPrimitiveRestart) + if (caps.fixedIndexPrimitiveRestart) { +#ifdef Q_OS_WASM + // WebGL 2 behaves as if GL_PRIMITIVE_RESTART_FIXED_INDEX was always + // enabled (i.e. matching D3D/Metal), and the value cannot be passed to + // glEnable, so skip the call. +#else f->glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); +#endif + } caps.bgraExternalFormat = f->hasOpenGLExtension(QOpenGLExtensions::BGRATextureFormat); caps.bgraInternalFormat = caps.bgraExternalFormat && caps.gles; -- cgit v1.2.1