iOS: Share default-FBO for windows between contexts in a share-group
The current implementation of QOpenGLContext sharing assumes that the contexts form a tree and that leaf-nodes are destroyed before their parents. We build on this assumption and keep track of the default FBOs for windows in the root context of the tree. This allows two shared contexts to both makeCurrent() on the same window surface without resulting in two FBOs being set up (which doesn't work on iOS due to the CEAGLLayer already being tied to another render-buffer). Change-Id: Ib9f8c597effe488480fe99e10846be22c257f490 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
This commit is contained in:
parent
38b66bdcde
commit
e432787ad0
@ -140,17 +140,22 @@ void QIOSContext::swapBuffers(QPlatformSurface *surface)
|
|||||||
if (surface->surface()->surfaceClass() == QSurface::Offscreen)
|
if (surface->surface()->surfaceClass() == QSurface::Offscreen)
|
||||||
return; // Nothing to do
|
return; // Nothing to do
|
||||||
|
|
||||||
Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window);
|
FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface);
|
||||||
QIOSWindow *window = static_cast<QIOSWindow *>(surface);
|
|
||||||
Q_ASSERT(m_framebufferObjects.contains(window));
|
|
||||||
|
|
||||||
[EAGLContext setCurrentContext:m_eaglContext];
|
[EAGLContext setCurrentContext:m_eaglContext];
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_framebufferObjects[window].colorRenderbuffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, framebufferObject.colorRenderbuffer);
|
||||||
[m_eaglContext presentRenderbuffer:GL_RENDERBUFFER];
|
[m_eaglContext presentRenderbuffer:GL_RENDERBUFFER];
|
||||||
}
|
}
|
||||||
|
|
||||||
QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatformSurface *surface) const
|
QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatformSurface *surface) const
|
||||||
{
|
{
|
||||||
|
// We keep track of default-FBOs in the root context of a share-group. This assumes
|
||||||
|
// that the contexts form a tree, where leaf nodes are always destroyed before their
|
||||||
|
// parents. If that assumption (based on the current implementation) doesn't hold we
|
||||||
|
// should probably use QOpenGLMultiGroupSharedResource to track the shared default-FBOs.
|
||||||
|
if (m_sharedContext)
|
||||||
|
return m_sharedContext->backingFramebufferObjectFor(surface);
|
||||||
|
|
||||||
Q_ASSERT(surface && surface->surface()->surfaceClass() == QSurface::Window);
|
Q_ASSERT(surface && surface->surface()->surfaceClass() == QSurface::Window);
|
||||||
QIOSWindow *window = static_cast<QIOSWindow *>(surface);
|
QIOSWindow *window = static_cast<QIOSWindow *>(surface);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user