Add support for VK_PRESENT_MODE_IMMEDIATE_KHR swapchain presentation mode.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
index 9109dc1..6dd5139 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
@@ -229,12 +229,16 @@
CAMetalLayer* mtlLayer = surface->getCAMetalLayer();
if ( !mtlLayer ) { return surface->getConfigurationResult(); }
- // TODO: check which mode(s) are applicable to Metal
- const VkPresentModeKHR presentModes[] = {
-// VK_PRESENT_MODE_MAILBOX_KHR,
- VK_PRESENT_MODE_FIFO_KHR,
- };
- const uint presentModesCnt = sizeof(presentModes) / sizeof(VkPresentModeKHR);
+ vector<VkPresentModeKHR> presentModes;
+ presentModes.push_back(VK_PRESENT_MODE_FIFO_KHR);
+
+#if MVK_MACOS
+ if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) {
+ presentModes.push_back(VK_PRESENT_MODE_IMMEDIATE_KHR);
+ }
+#endif
+
+ uint32_t presentModesCnt = uint32_t(presentModes.size());
// If properties aren't actually being requested yet, simply update the returned count
if ( !pPresentModes ) {
@@ -947,9 +951,9 @@
#endif
#if MVK_MACOS
- if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) { fsMsg += "\n\t\tOSX GPU Family 1 v3"; }
- if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v2] ) { fsMsg += "\n\t\tOSX GPU Family 1 v2"; }
- if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v1] ) { fsMsg += "\n\t\tOSX GPU Family 1 v1"; }
+ if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) { fsMsg += "\n\t\tmacOS GPU Family 1 v3"; }
+ if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v2] ) { fsMsg += "\n\t\tmacOS GPU Family 1 v2"; }
+ if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v1] ) { fsMsg += "\n\t\tmacOS GPU Family 1 v1"; }
#endif
MVKLogInfo(fsMsg.c_str(), _properties.deviceName, devTypeStr.c_str(), _properties.vendorID, _properties.deviceID,
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm
index 3a87f1f..c491966 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm
@@ -189,9 +189,15 @@
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT |
VK_IMAGE_USAGE_STORAGE_BIT));
+#if MVK_MACOS
+ if ( pCreateInfo->presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) {
+ _mtlLayer.displaySyncEnabled = NO;
+ }
+#endif
// TODO: set additional CAMetalLayer properties before extracting drawables:
// - presentsWithTransaction
+ // - maximumDrawableCount (maybe for MAILBOX?)
// - drawsAsynchronously
// - colorspace (macOS only) Vulkan only supports sRGB colorspace for now.
// - wantsExtendedDynamicRangeContent (macOS only)