diff --git a/Demos/Cube/macOS/DemoViewController.m b/Demos/Cube/macOS/DemoViewController.m index 9586fa67..d8468bdc 100644 --- a/Demos/Cube/macOS/DemoViewController.m +++ b/Demos/Cube/macOS/DemoViewController.m @@ -43,13 +43,29 @@ self.view.wantsLayer = YES; // Back the view with a layer created by the makeBackingLayer method. - const char* argv[] = { "cube" }; + // Enabling this will sync the rendering loop with the natural display link (60 fps). + // Disabling this will allow the rendering loop to run flat out, limited only by the rendering speed. + bool useDisplayLink = true; + + VkPresentModeKHR vkPresentMode = useDisplayLink ? VK_PRESENT_MODE_FIFO_KHR : VK_PRESENT_MODE_IMMEDIATE_KHR; + char vkPresentModeStr[64]; + sprintf(vkPresentModeStr, "%d", vkPresentMode); + + const char* argv[] = { "cube", "--present_mode", vkPresentModeStr }; int argc = sizeof(argv)/sizeof(char*); demo_main(&demo, self.view.layer, argc, argv); - CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink); - CVDisplayLinkSetOutputCallback(_displayLink, &DisplayLinkCallback, &demo); - CVDisplayLinkStart(_displayLink); + if (useDisplayLink) { + CVDisplayLinkCreateWithActiveCGDisplays(&_displayLink); + CVDisplayLinkSetOutputCallback(_displayLink, &DisplayLinkCallback, &demo); + CVDisplayLinkStart(_displayLink); + } else { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + while(true) { + demo_draw(&demo); + } + }); + } } diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 1ef0385a..514d270e 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -19,6 +19,7 @@ MoltenVK 1.2.5 Released TBD - Ensure non-dispatch compute commands don't interfere with compute encoding state used by dispatch commands. +- Add support for `VK_PRESENT_MODE_IMMEDIATE_KHR` to macOS Cube demo. diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 8f043f41..fa8fd1d8 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -4114,7 +4114,6 @@ void MVKDevice::logActivityPerformance(MVKPerformanceTracker& activity, MVKPerfo } void MVKDevice::logPerformanceSummary() { - if (_activityPerformanceLoggingStyle == MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_IMMEDIATE) { return; } // Get a copy to minimize time under lock MVKPerformanceStatistics perfStats; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm index 5ff5d0cf..c52896d0 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm @@ -175,7 +175,9 @@ void MVKSwapchain::markFrameInterval() { perfLogCntLimit, (1000.0 / _device->_performanceStatistics.queue.frameInterval.averageDuration), mvkGetElapsedMilliseconds() / 1000.0); - _device->logPerformanceSummary(); + if (mvkConfig().activityPerformanceLoggingStyle == MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_FRAME_COUNT) { + _device->logPerformanceSummary(); + } } }