From 062efb305e1866482c03717ed1cf9717f45e5abb Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 28 Oct 2022 17:13:28 +0200 Subject: [PATCH] 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 Pick-to: 6.4 Change-Id: I3fc34329fc573a6fac8e4265d90ca93520e4e2ee Reviewed-by: Janne Koskinen --- 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 4cb37a4cd6a..1a7be9eb49e 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -741,8 +741,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;