diff options
author | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2024-03-11 12:42:47 +0100 |
---|---|---|
committer | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2024-03-16 14:26:18 +0100 |
commit | 3d46094b6835103293dae0e573c561a07048d7d1 (patch) | |
tree | 6d1aa5b97c28615b47fc62ed8c97f24482200bb3 /src/plugins/platforms | |
parent | 49329ae2272f488949653f5e06b3f2d82e924261 (diff) |
wasm: Lift restriction on offscreen for fake context sharing
We only activated our fake context sharing logic for offscreen
surfaces. This commit removed that restriction this allows the
rendercontrol example to run
Fixes: QTBUG-117410
Change-Id: Id86617f57c6a98a920f5dd82332dcd8277f103e4
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index aaea74f29b..07ae1d1cf5 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -58,27 +58,19 @@ QWasmOpenGLContext::obtainEmscriptenContext(QPlatformSurface *surface) return m_ownedWebGLContext.handle; if (surface->surface()->surfaceClass() == QSurface::Offscreen) { - if (const auto *shareContext = m_qGlContext->shareContext()) { - // Since there are no resource sharing capabilities with WebGL whatsoever, we use the - // same actual underlaying WebGL context. This is not perfect, but it works in most - // cases. - return static_cast<QWasmOpenGLContext *>(shareContext->handle()) - ->m_ownedWebGLContext.handle; - } else { - // Reuse the existing context for offscreen drawing, even if it happens to be a canvas - // context. This is because it is impossible to re-home an existing context to the - // new surface and works as an emulation measure. - if (m_ownedWebGLContext.handle) - return m_ownedWebGLContext.handle; - - // The non-shared offscreen context is heavily limited on WASM, but we provide it - // anyway for potential pixel readbacks. - m_ownedWebGLContext = - QOpenGLContextData{ .surface = surface, - .handle = createEmscriptenContext( - static_cast<QWasmOffscreenSurface *>(surface)->id(), - m_actualFormat) }; - } + // Reuse the existing context for offscreen drawing, even if it happens to be a canvas + // context. This is because it is impossible to re-home an existing context to the + // new surface and works as an emulation measure. + if (m_ownedWebGLContext.handle) + return m_ownedWebGLContext.handle; + + // The non-shared offscreen context is heavily limited on WASM, but we provide it + // anyway for potential pixel readbacks. + m_ownedWebGLContext = + QOpenGLContextData{ .surface = surface, + .handle = createEmscriptenContext( + static_cast<QWasmOffscreenSurface *>(surface)->id(), + m_actualFormat) }; } else { destroyWebGLContext(m_ownedWebGLContext.handle); @@ -160,6 +152,9 @@ GLuint QWasmOpenGLContext::defaultFramebufferObject(QPlatformSurface *surface) c bool QWasmOpenGLContext::makeCurrent(QPlatformSurface *surface) { + if (auto *shareContext = m_qGlContext->shareContext()) + return shareContext->makeCurrent(surface->surface()); + const auto context = obtainEmscriptenContext(surface); if (!context) return false; |