diff options
author | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2024-03-13 15:46:05 +0100 |
---|---|---|
committer | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2024-03-22 13:51:33 +0100 |
commit | 043ceca40ffda0a87871e1800578c99273916e60 (patch) | |
tree | c42ed3480703445927c6cdecaf7e4d79fcde3677 /src/plugins/platforms/wasm/qwasmopenglcontext.cpp | |
parent | a5b9ba15e2be40e9d638628d84a7689783dc95a0 (diff) |
wasm: Document and test OpenGLContext limitations
There is a limit in WebGL that OpenGL context sharing is not supported.
There is a proposal from 2013
(https://www.khronos.org/webgl/wiki/SharedResouces), but it seems that
it never was implemented.
There is an additional limit in that there is exactly one WebGL context
for each canvas (i.e. window).
A part of the problem here is that the identifier for an OpenGL context
is essentially a surface-thread-context triplet. And the thread part
might be more difficult to handle in a javascript setting.
Regardless of why, we need to have an opinion about what the
consequences are, and what we support to what extent.
As such this commit:
1) Adds a comment on the QOpenGLContext describing the limitations
2) Adds a qWarning() on the first activation of a shared context.
The second item is not complete. We will have problems with multiple
individual contexts also, It is just not possible to warn for these
cases. The second item covers, maybe, the most common case.
Change-Id: I51550a6acb0a7f6f6fa5e9e2c3da080a1d2b498f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmopenglcontext.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 07ae1d1cf5..8a4664ec8c 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -152,7 +152,13 @@ GLuint QWasmOpenGLContext::defaultFramebufferObject(QPlatformSurface *surface) c bool QWasmOpenGLContext::makeCurrent(QPlatformSurface *surface) { - if (auto *shareContext = m_qGlContext->shareContext()) + static bool sentSharingWarning = false; + if (!sentSharingWarning && isSharing()) { + qWarning() << "The functionality for sharing OpenGL contexts is limited, see documentation"; + sentSharingWarning = true; + } + + if (auto *shareContext = m_qGlContext->shareContext()) return shareContext->makeCurrent(surface->surface()); const auto context = obtainEmscriptenContext(surface); |