Add support for VK_PRESENT_MODE_IMMEDIATE_KHR to macOS Cube demo.

- Only log performance stats on FPS logging if logging style is explicitly
  set to MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_FRAME_COUNT (unrelated).
This commit is contained in:
Bill Hollings 2023-05-30 21:11:02 -04:00
parent 2a4e415665
commit 107be116b7
4 changed files with 24 additions and 6 deletions

View File

@ -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);
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);
}
});
}
}

View File

@ -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.

View File

@ -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;

View File

@ -175,9 +175,11 @@ void MVKSwapchain::markFrameInterval() {
perfLogCntLimit,
(1000.0 / _device->_performanceStatistics.queue.frameInterval.averageDuration),
mvkGetElapsedMilliseconds() / 1000.0);
if (mvkConfig().activityPerformanceLoggingStyle == MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_FRAME_COUNT) {
_device->logPerformanceSummary();
}
}
}
#if MVK_MACOS
struct CIE1931XY {