diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-06-01 13:29:24 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2016-06-17 13:18:24 +0000 |
commit | 655687d84d6a5914227f2580889e20b7e1b31095 (patch) | |
tree | 1c75a2dfb69f4b0085c7ec47fc99643cb7a447dd /src/plugins/platforms/ios/qioscontext.h | |
parent | 0b6adbcd234724edef747df4d17aa7a5bcf4381b (diff) |
UIKit: Don't reallocate renderbuffer on QIOSContext::swapBuffers()
During device rotation, the backing CEAGLLayer of our custom UIView is
resized by the system. Normally this is the time where we would then
reconfigure the corresponding renderbuffer that we render to, which
shares memory with the CEAGLLayer, but we chose a lazy approach where
we'd defer the reconfigure until client code actually called makeCurrent.
This caused problems because not only did we implement the lazy reconfig
in makeCurrent, but in every QIOSContext function that operated on the
default FBO, including swapBuffers(). When using threaded rendering,
such as in Qt Quick, the render thread may be half way in rendering a
new frame when the system resizes the CEAGLLayer, and we pick up that
resize on the swapBuffer call and allocate a new renderbuffer, before
flushing the queued up GL commands that were operating on another
renderbuffer of a different size. This resulted in the following crash:
0 - gpus_ReturnObjectErrorKillClient()
1 - gpusSubmitDataBuffers()
2 - glrFlushContextToken()
3 - flush(__GLIContextRec*)()
4 - QIOSContext::swapBuffers(QPlatformSurface*)
...
We solve this by still being lazy in how we reconfigure, but limit the
reconfigure to makeCurrent(). If the CEAGLLayer is resized in between
two frames, we skip the half-drawn frame. The old frame will then be
scaled to match the new size by the system, but this is preferable to
flushing a new frame that may have been drawn with two conflicting
window geometries.
Task-number: QTBUG-50017
Change-Id: Ie229f26d156dfbfc7ed8d9efd0eb5e992eee73f1
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/qioscontext.h')
-rw-r--r-- | src/plugins/platforms/ios/qioscontext.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/platforms/ios/qioscontext.h b/src/plugins/platforms/ios/qioscontext.h index ec678fee44..a95856aee1 100644 --- a/src/plugins/platforms/ios/qioscontext.h +++ b/src/plugins/platforms/ios/qioscontext.h @@ -34,6 +34,7 @@ #ifndef QIOSCONTEXT_H #define QIOSCONTEXT_H +#include <QtCore/qloggingcategory.h> #include <qpa/qplatformopenglcontext.h> @class EAGLContext; @@ -83,7 +84,9 @@ private: static void deleteBuffers(const FramebufferObject &framebufferObject); FramebufferObject &backingFramebufferObjectFor(QPlatformSurface *) const; - mutable QHash<QIOSWindow *, FramebufferObject> m_framebufferObjects; + mutable QHash<QPlatformSurface *, FramebufferObject> m_framebufferObjects; + + bool needsRenderbufferResize(QPlatformSurface *) const; }; QT_END_NAMESPACE |