Skip to content

Commit

Permalink
Add support for VK_PRESENT_MODE_IMMEDIATE_KHR swapchain presentation …
Browse files Browse the repository at this point in the history
…mode.
  • Loading branch information
billhollings committed Apr 19, 2018
1 parent 9b871d0 commit bb2188c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
22 changes: 13 additions & 9 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bb2188c

Please sign in to comment.