diff --git a/Docs/MoltenVK_Runtime_UserGuide.md b/Docs/MoltenVK_Runtime_UserGuide.md index dfe7cdf9..d277828d 100644 --- a/Docs/MoltenVK_Runtime_UserGuide.md +++ b/Docs/MoltenVK_Runtime_UserGuide.md @@ -382,9 +382,10 @@ you can address the issue as follows: #include ... MVKConfiguration mvkConfig; - vkGetMoltenVKConfigurationMVK(vkInstance, &mvkConfig); + size_t appConfigSize = sizeof(mvkConfig); + vkGetMoltenVKConfigurationMVK(vkInstance, &mvkConfig, &appConfigSize); mvkConfig.debugMode = true; - vkSetMoltenVKConfigurationMVK(vkInstance, &mvkConfig); + vkSetMoltenVKConfigurationMVK(vkInstance, &mvkConfig, &appConfigSize); Performing these steps will enable debug mode in **MoltenVK**, which includes shader conversion logging, and causes both the incoming *SPIR-V* code and the converted *MSL* source code to be diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 1b80ce41..dc1cac4c 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -17,7 +17,13 @@ MoltenVK 1.0.24 Released TBD -- Allocate MVKDescriptorSets from a pool within MVKDescriptorPool, +- Include struct size parameter in VK_MVK_moltenvk extension functions that pass structs that + might change size across extension versions. +- Remove vkGetMoltenVKDeviceConfigurationMVK() & vkSetMoltenVKDeviceConfigurationMVK() functions. +- Allocate MVKDescriptorSets from a pool within MVKDescriptorPool +- Support copying between textures of compatible-sized formats +- Support VK_FORMAT_A2B10G10R10_UNORM_PACKED vertex format +- Build scripts support SRCROOT path containing spaces. MoltenVK 1.0.23 diff --git a/ExternalRevisions/VulkanSamples_repo_revision b/ExternalRevisions/VulkanSamples_repo_revision index 073ad43c..ee1ae7b3 100644 --- a/ExternalRevisions/VulkanSamples_repo_revision +++ b/ExternalRevisions/VulkanSamples_repo_revision @@ -1 +1 @@ -e268a7b7bf799b92410f35f6fea29cedb021bac1 +7cca1899215bbb043914cc5ef74924dc7f189b64 diff --git a/MoltenVK/MoltenVK.xcodeproj/xcshareddata/xcschemes/MoltenVK-iOS.xcscheme b/MoltenVK/MoltenVK.xcodeproj/xcshareddata/xcschemes/MoltenVK-iOS.xcscheme index afe58709..86fc06d1 100644 --- a/MoltenVK/MoltenVK.xcodeproj/xcshareddata/xcschemes/MoltenVK-iOS.xcscheme +++ b/MoltenVK/MoltenVK.xcodeproj/xcshareddata/xcschemes/MoltenVK-iOS.xcscheme @@ -1,7 +1,7 @@ + version = "2.0"> @@ -33,15 +33,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -33,15 +33,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> getMTLDevice() { return _mtlDevice; } diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index e8afc84d..2e67a6a2 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -80,10 +80,6 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) { } } -void MVKPhysicalDevice::getMetalFeatures(MVKPhysicalDeviceMetalFeatures* mtlFeatures) { - if (mtlFeatures) { *mtlFeatures = _metalFeatures; } -} - void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties* properties) { if (properties) { *properties = _properties; } } @@ -1626,7 +1622,7 @@ MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo _physicalDevice = physicalDevice; _pMVKConfig = _physicalDevice->_mvkInstance->getMoltenVKConfiguration(); _pFeatures = &_physicalDevice->_features; - _pMetalFeatures = &_physicalDevice->_metalFeatures; + _pMetalFeatures = _physicalDevice->getMetalFeatures(); _pProperties = &_physicalDevice->_properties; _pMemoryProperties = &_physicalDevice->_memoryProperties; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm index 7b6fb663..f899cd70 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm @@ -322,13 +322,6 @@ void MVKInstance::initProcAddrs() { ADD_PROC_ADDR(vkCreateMacOSSurfaceMVK); #endif -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - // Deprecated functions - ADD_PROC_ADDR(vkGetMoltenVKDeviceConfigurationMVK); - ADD_PROC_ADDR(vkSetMoltenVKDeviceConfigurationMVK); -#pragma clang diagnostic pop - } void MVKInstance::logVersions() { diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.h b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.h index 77604e94..a7bb266f 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.h @@ -62,8 +62,8 @@ public: /** Returns whether the surface size has changed since the last time this function was called. */ bool getHasSurfaceSizeChanged(); - /** Populates the specified performance stats structure. */ - void getPerformanceStatistics(MVKSwapchainPerformance* pSwapchainPerf); + /** Returns the specified performance stats structure. */ + const MVKSwapchainPerformance* getPerformanceStatistics() { return &_performanceStatistics; } #pragma mark Metal diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm index d82417ab..d26732ea 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm @@ -157,10 +157,6 @@ void MVKSwapchain::markFrameInterval() { } } -void MVKSwapchain::getPerformanceStatistics(MVKSwapchainPerformance* pSwapchainPerf) { - if (pSwapchainPerf) { *pSwapchainPerf = _performanceStatistics; } -} - #pragma mark Metal diff --git a/MoltenVK/MoltenVK/Utility/MVKFoundation.h b/MoltenVK/MoltenVK/Utility/MVKFoundation.h index 22539cf5..0aa05ae5 100644 --- a/MoltenVK/MoltenVK/Utility/MVKFoundation.h +++ b/MoltenVK/MoltenVK/Utility/MVKFoundation.h @@ -336,6 +336,21 @@ void mvkRemoveAllOccurances(C& container, T val) { container.erase(remove(container.begin(), container.end(), val), container.end()); } +/** + * If pSrc and pDst are not null, copies at most copySize bytes from the contents of the source + * struct to the destination struct, and returns the number of bytes copied, which is the smaller + * of copySize and the actual size of the struct. If either pSrc or pDst are null, returns zero. + */ +template +size_t mvkCopyStruct(S* pDst, const S* pSrc, size_t copySize = sizeof(S)) { + size_t bytesCopied = 0; + if (pSrc && pDst) { + bytesCopied = std::min(copySize, sizeof(S)); + memcpy(pDst, pSrc, bytesCopied); + } + return bytesCopied; +} + /** * Sets the value referenced by the destination pointer with the value referenced by * the source pointer, and returns whether the value was set. diff --git a/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm b/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm index cc6bbfb4..f756b4d2 100644 --- a/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm +++ b/MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm @@ -22,50 +22,73 @@ #include "MVKEnvironment.h" #include "MVKSwapchain.h" #include "MVKImage.h" +#include "MVKFoundation.h" #include using namespace std; +// If pSrc and pDst are not null, copies at most *pCopySize bytes from the contents of the source struct +// to the destination struct, and sets *pCopySize to the number of bytes copied, which is the smaller of +// the original value of *pCopySize and the actual size of the struct. Returns VK_SUCCESS if the original +// value of *pCopySize is the same as the actual size of the struct, or VK_INCOMPLETE otherwise. +// If either pSrc or pDst are null, sets the value of *pCopySize to the size of the struct and returns VK_SUCCESS. +template +VkResult mvkCopyStruct(S* pDst, const S* pSrc, size_t* pCopySize) { + if (pSrc && pDst) { + size_t origSize = *pCopySize; + *pCopySize = mvkCopyStruct(pDst, pSrc, origSize); + return (*pCopySize == origSize) ? VK_SUCCESS : VK_INCOMPLETE; + } else { + *pCopySize = sizeof(S); + return VK_SUCCESS; + } +} -MVK_PUBLIC_SYMBOL void vkGetMoltenVKConfigurationMVK( - VkInstance instance, - MVKConfiguration* pConfiguration) { +MVK_PUBLIC_SYMBOL VkResult vkGetMoltenVKConfigurationMVK( + VkInstance instance, + MVKConfiguration* pConfiguration, + size_t* pConfigurationSize) { MVKInstance* mvkInst = MVKInstance::getMVKInstance(instance); - if (pConfiguration) { *pConfiguration = *(MVKConfiguration*)mvkInst->getMoltenVKConfiguration(); } + return mvkCopyStruct(pConfiguration, mvkInst->getMoltenVKConfiguration(), pConfigurationSize); } MVK_PUBLIC_SYMBOL VkResult vkSetMoltenVKConfigurationMVK( - VkInstance instance, - MVKConfiguration* pConfiguration) { + VkInstance instance, + const MVKConfiguration* pConfiguration, + size_t* pConfigurationSize) { MVKInstance* mvkInst = MVKInstance::getMVKInstance(instance); - if (pConfiguration) { mvkInst->setMoltenVKConfiguration(pConfiguration); } - return VK_SUCCESS; + return mvkCopyStruct((MVKConfiguration*)mvkInst->getMoltenVKConfiguration(), pConfiguration, pConfigurationSize); } -MVK_PUBLIC_SYMBOL void vkGetPhysicalDeviceMetalFeaturesMVK( - VkPhysicalDevice physicalDevice, - MVKPhysicalDeviceMetalFeatures* pMetalFeatures) { - - MVKPhysicalDevice* mvkPD = MVKPhysicalDevice::getMVKPhysicalDevice(physicalDevice); - mvkPD->getMetalFeatures(pMetalFeatures); +MVK_PUBLIC_SYMBOL VkResult vkGetPhysicalDeviceMetalFeaturesMVK( + VkPhysicalDevice physicalDevice, + MVKPhysicalDeviceMetalFeatures* pMetalFeatures, + size_t* pMetalFeaturesSize) { + + MVKPhysicalDevice* mvkPD = MVKPhysicalDevice::getMVKPhysicalDevice(physicalDevice); + return mvkCopyStruct(pMetalFeatures, mvkPD->getMetalFeatures(), pMetalFeaturesSize); } -MVK_PUBLIC_SYMBOL void vkGetSwapchainPerformanceMVK( - VkDevice device, - VkSwapchainKHR swapchain, - MVKSwapchainPerformance* pSwapchainPerf) { +MVK_PUBLIC_SYMBOL VkResult vkGetSwapchainPerformanceMVK( + VkDevice device, + VkSwapchainKHR swapchain, + MVKSwapchainPerformance* pSwapchainPerf, + size_t* pSwapchainPerfSize) { - MVKSwapchain* mvkSwapchain = (MVKSwapchain*)swapchain; - mvkSwapchain->getPerformanceStatistics(pSwapchainPerf); + MVKSwapchain* mvkSC = (MVKSwapchain*)swapchain; + return mvkCopyStruct(pSwapchainPerf, mvkSC->getPerformanceStatistics(), pSwapchainPerfSize); } -MVK_PUBLIC_SYMBOL void vkGetPerformanceStatisticsMVK( - VkDevice device, - MVKPerformanceStatistics* pPerf) { +MVK_PUBLIC_SYMBOL VkResult vkGetPerformanceStatisticsMVK( + VkDevice device, + MVKPerformanceStatistics* pPerf, + size_t* pPerfSize) { - MVKDevice::getMVKDevice(device)->getPerformanceStatistics(pPerf); + MVKPerformanceStatistics mvkPerf; + MVKDevice::getMVKDevice(device)->getPerformanceStatistics(&mvkPerf); + return mvkCopyStruct(pPerf, &mvkPerf, pPerfSize); } MVK_PUBLIC_SYMBOL void vkGetVersionStringsMVK( @@ -134,24 +157,3 @@ MVK_PUBLIC_SYMBOL void vkGetIOSurfaceMVK( MVKImage* mvkImg = (MVKImage*)image; *pIOSurface = mvkImg->getIOSurface(); } - - -// Deprecated functions -MVK_PUBLIC_SYMBOL void vkGetMoltenVKDeviceConfigurationMVK( - VkDevice device, - MVKDeviceConfiguration* pConfiguration) { - - MVKDevice* mvkDev = MVKDevice::getMVKDevice(device); - if (pConfiguration) { *pConfiguration = *(MVKConfiguration*)mvkDev->getInstance()->getMoltenVKConfiguration(); } -} - -MVK_PUBLIC_SYMBOL VkResult vkSetMoltenVKDeviceConfigurationMVK( - VkDevice device, - MVKDeviceConfiguration* pConfiguration) { - - MVKDevice* mvkDev = MVKDevice::getMVKDevice(device); - if (pConfiguration) { mvkDev->getInstance()->setMoltenVKConfiguration(pConfiguration); } - return VK_SUCCESS; -} - - diff --git a/MoltenVKPackaging.xcodeproj/xcshareddata/xcschemes/MoltenVK Package (Debug) (iOS only).xcscheme b/MoltenVKPackaging.xcodeproj/xcshareddata/xcschemes/MoltenVK Package (Debug) (iOS only).xcscheme index e1fee980..fe1548ce 100644 --- a/MoltenVKPackaging.xcodeproj/xcshareddata/xcschemes/MoltenVK Package (Debug) (iOS only).xcscheme +++ b/MoltenVKPackaging.xcodeproj/xcshareddata/xcschemes/MoltenVK Package (Debug) (iOS only).xcscheme @@ -39,9 +39,10 @@ launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" - debugDocumentVersioning = "YES" + debugDocumentVersioning = "NO" debugServiceExtension = "internal" - allowLocationSimulation = "YES"> + enableGPUFrameCaptureMode = "1" + allowLocationSimulation = "NO"> + enableGPUFrameCaptureMode = "1" + allowLocationSimulation = "NO"> + version = "2.0"> @@ -36,12 +36,17 @@ buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + disableMainThreadChecker = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" - debugDocumentVersioning = "YES" + debugDocumentVersioning = "NO" + debugXPCServices = "NO" debugServiceExtension = "internal" - allowLocationSimulation = "YES"> + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -36,12 +36,17 @@ buildConfiguration = "Release" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + disableMainThreadChecker = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" - debugDocumentVersioning = "YES" + debugDocumentVersioning = "NO" + debugXPCServices = "NO" debugServiceExtension = "internal" - allowLocationSimulation = "YES"> + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -41,10 +41,12 @@ useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "NO" + debugXPCServices = "NO" debugServiceExtension = "internal" enableGPUFrameCaptureMode = "3" enableGPUValidationMode = "1" - allowLocationSimulation = "NO"> + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -33,15 +33,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "YES" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -33,15 +33,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -33,15 +33,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "YES" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -33,15 +33,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No"> + version = "2.0"> @@ -42,15 +42,20 @@ + enableGPUFrameCaptureMode = "3" + enableGPUValidationMode = "1" + allowLocationSimulation = "NO" + queueDebuggingEnabled = "No">