File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed
MoltenVK/MoltenVK/GPUObjects Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1629,8 +1629,9 @@ static void signalAndUntrack(const MVKSwapchainSignaler& signaler) {
1629
1629
// Ensure this image, the drawable, and the present fence are not destroyed while
1630
1630
// awaiting MTLCommandBuffer completion. We retain the drawable separately because
1631
1631
// a new drawable might be acquired by this image by then.
1632
- // Signal the fence from this callback, because the last one or two presentation
1633
- // completion callbacks can occasionally stall.
1632
+ // Signal the fence and notify the swapchain that the present has completed
1633
+ // from this callback, because the last one or two presentation completion
1634
+ // callbacks can occasionally stall.
1634
1635
retain ();
1635
1636
[mtlDrwbl retain ];
1636
1637
auto * fence = presentInfo.fence ;
@@ -1640,6 +1641,7 @@ static void signalAndUntrack(const MVKSwapchainSignaler& signaler) {
1640
1641
if (fence) { fence->release (); }
1641
1642
[mtlDrwbl release ];
1642
1643
release ();
1644
+ if (_swapchain) { _swapchain->notifyPresentComplete (presentInfo); }
1643
1645
}];
1644
1646
1645
1647
signal (signaler.semaphore , signaler.semaphoreSignalToken , mtlCmdBuff);
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ class MVKSwapchain : public MVKVulkanAPIDeviceObject {
123
123
void markFrameInterval ();
124
124
void beginPresentation (const MVKImagePresentInfo& presentInfo);
125
125
void endPresentation (const MVKImagePresentInfo& presentInfo, uint64_t beginPresentTime, uint64_t actualPresentTime = 0 );
126
+ void notifyPresentComplete (const MVKImagePresentInfo& presentInfo);
126
127
void forceUnpresentedImageCompletion ();
127
128
128
129
MVKSurface* _surface = nullptr ;
Original file line number Diff line number Diff line change 277
277
_presentTimingHistory[_presentHistoryIndex].earliestPresentTime = actualPresentTime;
278
278
_presentTimingHistory[_presentHistoryIndex].presentMargin = actualPresentTime > beginPresentTime ? actualPresentTime - beginPresentTime : 0 ;
279
279
_presentHistoryIndex = (_presentHistoryIndex + 1 ) % kMaxPresentationHistory ;
280
+ }
280
281
282
+ void MVKSwapchain::notifyPresentComplete (const MVKImagePresentInfo& presentInfo) {
281
283
if (presentInfo.presentId != 0 ) {
282
284
std::unique_lock pidLock (_currentPresentIdMutex);
283
285
_currentPresentId = std::max (_currentPresentId, presentInfo.presentId );
You can’t perform that action at this time.
0 commit comments