diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-02-02 17:12:57 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-02-05 11:50:09 +0100 |
commit | 98b60450f7ce6b16464392747ab8721f30add15e (patch) | |
tree | bddb9236e3636857b857415dbbe5d573bbc69289 /src/gui/rhi/qrhimetal.mm | |
parent | 0cba6a27e27b160e2805c5cc29b108bf6e7fde20 (diff) |
rhi: metal: Present drawables via addScheduledHandler instead of presentDrawable
The former API is the recommended way to present drawables -- avoiding
WindowServer submission throttling and potential issues with lock-ups
when window are not serviced, are being moved to other screens, or users
mistakenly call waitUntilCompleted.
The scheduled block captures the drawable and retains it until the block
is done executing.
Change-Id: I99dca2db3bcfbea67c686dd5d97ba5011598997e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhimetal.mm')
-rw-r--r-- | src/gui/rhi/qrhimetal.mm | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 7151741f2e..76d16b3e50 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -1453,10 +1453,14 @@ QRhi::FrameOpResult QRhiMetal::endFrame(QRhiSwapChain *swapChain, QRhi::EndFrame Q_ASSERT(currentSwapChain == swapChainD); const bool needsPresent = !flags.testFlag(QRhi::SkipPresent); - if (needsPresent) - [swapChainD->cbWrapper.d->cb presentDrawable: swapChainD->d->curDrawable]; + if (needsPresent) { + auto drawable = swapChainD->d->curDrawable; + [swapChainD->cbWrapper.d->cb addScheduledHandler:^(id<MTLCommandBuffer>) { + [drawable present]; + }]; + } - // Must not hold on to the drawable, regardless of needsPresent. + // Must not hold on to the drawable, regardless of needsPresent [swapChainD->d->curDrawable release]; swapChainD->d->curDrawable = nil; |