Merge pull request #1890 from billhollings/fix-display-timing-race-condition

Fix race condition when updating values in VkPastPresentationTimingGOOGLE.
This commit is contained in:
Bill Hollings 2023-05-05 17:57:40 -04:00 committed by GitHub
commit dfc0af84aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 6 deletions

View File

@ -24,6 +24,7 @@ Released TBD
- Support separate depth and stencil attachments during dynamic rendering.
- Deprecate the obsolete and non-standard `VK_MVK_moltenvk` extension.
- Fix memory leak when waiting on timeline semaphores.
- Fix race condition when updating values in `VkPastPresentationTimingGOOGLE`.
- Ensure shaders that use `PhysicalStorageBufferAddresses` encode the use of the associated `MTLBuffer`.
- Disable pipeline cache compression prior to macOS 10.15 and iOS/tvOS 13.0.
- Add `MVK_ENABLE_EXPLICIT_LOD_WORKAROUND` environment variable to selectively

View File

@ -449,7 +449,7 @@ public:
#pragma mark Metal
/** Presents the contained drawable to the OS. */
void presentCAMetalDrawable(id<MTLCommandBuffer> mtlCmdBuff, MVKImagePresentInfo& presentInfo);
void presentCAMetalDrawable(id<MTLCommandBuffer> mtlCmdBuff, MVKImagePresentInfo presentInfo);
#pragma mark Construction
@ -463,7 +463,7 @@ protected:
friend MVKSwapchain;
id<CAMetalDrawable> getCAMetalDrawable() override;
void addPresentedHandler(id<CAMetalDrawable> mtlDrawable, MVKImagePresentInfo& presentInfo);
void addPresentedHandler(id<CAMetalDrawable> mtlDrawable, MVKImagePresentInfo presentInfo);
void releaseMetalDrawable();
MVKSwapchainImageAvailability getAvailability();
void makeAvailable(const MVKSwapchainSignaler& signaler);

View File

@ -1294,8 +1294,9 @@ id<CAMetalDrawable> MVKPresentableSwapchainImage::getCAMetalDrawable() {
}
// Present the drawable and make myself available only once the command buffer has completed.
// Pass MVKImagePresentInfo by value because it may not exist when the callback runs.
void MVKPresentableSwapchainImage::presentCAMetalDrawable(id<MTLCommandBuffer> mtlCmdBuff,
MVKImagePresentInfo& presentInfo) {
MVKImagePresentInfo presentInfo) {
lock_guard<mutex> lock(_availabilityLock);
_swapchain->willPresentSurface(getMTLTexture(0), mtlCmdBuff);
@ -1357,8 +1358,9 @@ void MVKPresentableSwapchainImage::presentCAMetalDrawable(id<MTLCommandBuffer> m
signalPresentationSemaphore(signaler, mtlCmdBuff);
}
// Pass MVKImagePresentInfo by value because it may not exist when the callback runs.
void MVKPresentableSwapchainImage::addPresentedHandler(id<CAMetalDrawable> mtlDrawable,
MVKImagePresentInfo& presentInfo) {
MVKImagePresentInfo presentInfo) {
#if !MVK_OS_SIMULATOR
if ([mtlDrawable respondsToSelector: @selector(addPresentedHandler:)]) {
retain(); // Ensure this image is not destroyed while awaiting presentation

View File

@ -121,7 +121,7 @@ protected:
void willPresentSurface(id<MTLTexture> mtlTexture, id<MTLCommandBuffer> mtlCmdBuff);
void renderWatermark(id<MTLTexture> mtlTexture, id<MTLCommandBuffer> mtlCmdBuff);
void markFrameInterval();
void recordPresentTime(MVKImagePresentInfo& presentInfo, uint64_t actualPresentTime = 0);
void recordPresentTime(const MVKImagePresentInfo& presentInfo, uint64_t actualPresentTime = 0);
CAMetalLayer* _mtlLayer = nil;
MVKWatermark* _licenseWatermark = nullptr;

View File

@ -557,7 +557,7 @@ VkResult MVKSwapchain::getPastPresentationTiming(uint32_t *pCount, VkPastPresent
return res;
}
void MVKSwapchain::recordPresentTime(MVKImagePresentInfo& presentInfo, uint64_t actualPresentTime) {
void MVKSwapchain::recordPresentTime(const MVKImagePresentInfo& presentInfo, uint64_t actualPresentTime) {
std::lock_guard<std::mutex> lock(_presentHistoryLock);
if (_presentHistoryCount < kMaxPresentationHistory) {
_presentHistoryCount++;