diff --git a/externals/MoltenVK/Resources/vulkan/icd.d/MoltenVK_icd.json b/externals/MoltenVK/Resources/vulkan/icd.d/MoltenVK_icd.json index a95edb05b4..51944f2a78 100644 --- a/externals/MoltenVK/Resources/vulkan/icd.d/MoltenVK_icd.json +++ b/externals/MoltenVK/Resources/vulkan/icd.d/MoltenVK_icd.json @@ -1,7 +1,7 @@ { - "file_format_version" : "1.0.0", + "file_format_version": "1.0.0", "ICD": { - "library_path": "../../../Frameworks/libMoltenVK.dylib", - "api_version" : "1.0.0" + "library_path": "../../../lib/libMoltenVK.dylib", + "api_version": "1.0.0" } } \ No newline at end of file diff --git a/externals/MoltenVK/include/MoltenVK/mvk_datatypes.h b/externals/MoltenVK/include/MoltenVK/mvk_datatypes.h index 55320a4ae2..4ecd650034 100644 --- a/externals/MoltenVK/include/MoltenVK/mvk_datatypes.h +++ b/externals/MoltenVK/include/MoltenVK/mvk_datatypes.h @@ -163,21 +163,8 @@ size_t mvkVkFormatBytesPerLayer(VkFormat vkFormat, size_t bytesPerRow, uint32_t */ size_t mvkMTLPixelFormatBytesPerLayer(MTLPixelFormat mtlFormat, size_t bytesPerRow, uint32_t texelRowsPerLayer); -/** - * Returns the default properties for the specified Vulkan format. - * - * Not all MTLPixelFormats returned by this function are supported by all GPU's, and, as a - * result, MoltenVK may return a different value from the vkGetPhysicalDeviceFormatProperties() - * function than is returned here. Use the vkGetPhysicalDeviceFormatProperties() function to - * return the properties for a particular GPU. - * - * Setting assumeGPUSupportsDefault to true allows the default format properties to be returned. - * The assumeGPUSupportsDefault flag can be set to false if it is already known that the format - * is not supported by a particular GPU for images, in which case all of the returned properties - * will be disabled, except possibly VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT, which may be supported - * for the format even without image support. - */ -VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat, bool assumeGPUSupportsDefault = true); +/** Returns the default properties for the specified Vulkan format. */ +VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat); /** Returns the name of the specified Vulkan format. */ const char* mvkVkFormatName(VkFormat vkFormat); @@ -218,8 +205,8 @@ VkImageType mvkVkImageTypeFromMTLTextureType(MTLTextureType mtlTextureType); /** Returns the Metal MTLTextureType corresponding to the Vulkan VkImageViewType. */ MTLTextureType mvkMTLTextureTypeFromVkImageViewType(VkImageViewType vkImageViewType, bool isMultisample); -/** Returns the Metal texture usage from the Vulkan image usage. */ -MTLTextureUsage mvkMTLTextureUsageFromVkImageUsageFlags(VkImageUsageFlags vkImageUsageFlags); +/** Returns the Metal texture usage from the Vulkan image usage taking into considertion usage limits for the pixel format. */ +MTLTextureUsage mvkMTLTextureUsageFromVkImageUsageFlags(VkImageUsageFlags vkImageUsageFlags, MTLPixelFormat mtlPixFmt); /** Returns the Vulkan image usage from the Metal texture usage and format. */ VkImageUsageFlags mvkVkImageUsageFlagsFromMTLTextureUsage(MTLTextureUsage mtlUsage, MTLPixelFormat mtlFormat); @@ -370,7 +357,7 @@ MTLTriangleFillMode mvkMTLTriangleFillModeFromVkPolygonMode(VkPolygonMode vkFill MTLLoadAction mvkMTLLoadActionFromVkAttachmentLoadOp(VkAttachmentLoadOp vkLoadOp); /** Returns the Metal MTLStoreAction corresponding to the specified Vulkan VkAttachmentStoreOp. */ -MTLStoreAction mvkMTLStoreActionFromVkAttachmentStoreOp(VkAttachmentStoreOp vkStoreOp, bool hasResolveAttachment = false); +MTLStoreAction mvkMTLStoreActionFromVkAttachmentStoreOp(VkAttachmentStoreOp vkStoreOp, bool hasResolveAttachment); /** Returns the Metal MTLViewport corresponding to the specified Vulkan VkViewport. */ MTLViewport mvkMTLViewportFromVkViewport(VkViewport vkViewport); diff --git a/externals/MoltenVK/include/MoltenVK/vk_mvk_moltenvk.h b/externals/MoltenVK/include/MoltenVK/vk_mvk_moltenvk.h index 078c134a4a..80be2fc233 100644 --- a/externals/MoltenVK/include/MoltenVK/vk_mvk_moltenvk.h +++ b/externals/MoltenVK/include/MoltenVK/vk_mvk_moltenvk.h @@ -50,12 +50,12 @@ typedef unsigned long MTLLanguageVersion; */ #define MVK_VERSION_MAJOR 1 #define MVK_VERSION_MINOR 0 -#define MVK_VERSION_PATCH 40 +#define MVK_VERSION_PATCH 43 #define MVK_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + (patch)) #define MVK_VERSION MVK_MAKE_VERSION(MVK_VERSION_MAJOR, MVK_VERSION_MINOR, MVK_VERSION_PATCH) -#define VK_MVK_MOLTENVK_SPEC_VERSION 24 +#define VK_MVK_MOLTENVK_SPEC_VERSION 26 #define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk" /** @@ -95,64 +95,101 @@ typedef unsigned long MTLLanguageVersion; * In addition to the configuration parmeters in this structure, there are several settings that * can be configured through runtime environment variables or MoltenVK compile-time build settings: * - * 1. The MVK_CONFIG_LOG_LEVEL runtime environment variable or MoltenVK compile-time build setting - * controls the level of logging performned by MoltenVK using the following numeric values: - * 0: No logging. - * 1: Log errors only. - * 2: Log errors and informational messages. - * If none of these is set, errors and informational messages are logged. + * 1. The MVK_CONFIG_LOG_LEVEL runtime environment variable or MoltenVK compile-time build setting + * controls the level of logging performned by MoltenVK using the following numeric values: + * 0: No logging. + * 1: Log errors only. + * 2: Log errors and informational messages. + * If none of these is set, errors and informational messages are logged. * - * 2. The MVK_CONFIG_TRACE_VULKAN_CALLS runtime environment variable or MoltenVK compile-time build - * setting causes MoltenVK to log the name of each Vulkan call made by the application. The logging - * format options can be controlled by setting the value of MVK_CONFIG_TRACE_VULKAN_CALLS as follows: - * 0: No Vulkan call logging. - * 1: Log the name of each Vulkan call when the call is entered. - * 2: Log the name of each Vulkan call when the call is entered and exited. This effectively - * brackets any other logging activity within the scope of the Vulkan call. - * 3: Same as option 2, plus logs the time spent inside the Vulkan function. - * If none of these is set, no Vulkan call logging will occur. + * 2. The MVK_CONFIG_TRACE_VULKAN_CALLS runtime environment variable or MoltenVK compile-time build + * setting causes MoltenVK to log the name of each Vulkan call made by the application, along with + * the Mach thread ID, global system thread ID, and thread name. The logging format options can be + * controlled by setting the value of MVK_CONFIG_TRACE_VULKAN_CALLS as follows: + * 0: No Vulkan call logging. + * 1: Log the name of each Vulkan call when the call is entered. + * 2: Log the name of each Vulkan call when the call is entered and exited. This effectively + * brackets any other logging activity within the scope of the Vulkan call. + * 3: Same as option 2, plus logs the time spent inside the Vulkan function. + * If none of these is set, no Vulkan call logging will occur. * - * 3. Setting the MVK_CONFIG_FORCE_LOW_POWER_GPU runtime environment variable or MoltenVK compile-time - * build setting to 1 will force MoltenVK to use a low-power GPU, if one is availble on the device. - * By default, this setting is disabled, allowing both low-power and high-power GPU's to be used. + * 3. Setting the MVK_CONFIG_FORCE_LOW_POWER_GPU runtime environment variable or MoltenVK compile-time + * build setting to 1 will force MoltenVK to use a low-power GPU, if one is availble on the device. + * By default, this setting is disabled, allowing both low-power and high-power GPU's to be used. * - * 4. Setting the MVK_ALLOW_METAL_FENCES or MVK_ALLOW_METAL_EVENTS runtime environment variable - * or MoltenVK compile-time build setting to 1 will cause MoltenVK to use MTLFence or MTLEvent, - * respectively, if it is available on the device, for VkSemaphore synchronization behaviour. - * If both variables are set, MVK_ALLOW_METAL_FENCES takes priority over MVK_ALLOW_METAL_EVENTS. - * If both are disabled, or if MTLFence or MTLEvent is not available on the device, MoltenVK - * will use CPU synchronization to control VkSemaphore synchronization behaviour. - * By default, MVK_ALLOW_METAL_FENCES is enabled and MVK_ALLOW_METAL_EVENTS is disabled, - * meaning MoltenVK will use MTLFences, if they are available, to control VkSemaphore - * synchronization behaviour, by default. + * 4. Setting the MVK_ALLOW_METAL_FENCES or MVK_ALLOW_METAL_EVENTS runtime environment variable + * or MoltenVK compile-time build setting to 1 will cause MoltenVK to use MTLFence or MTLEvent, + * respectively, if it is available on the device, for VkSemaphore synchronization behaviour. + * If both variables are set, MVK_ALLOW_METAL_FENCES takes priority over MVK_ALLOW_METAL_EVENTS. + * If both are disabled, or if MTLFence or MTLEvent is not available on the device, MoltenVK + * will use CPU synchronization to control VkSemaphore synchronization behaviour. + * By default, MVK_ALLOW_METAL_FENCES is enabled and MVK_ALLOW_METAL_EVENTS is disabled, + * meaning MoltenVK will use MTLFences, if they are available, to control VkSemaphore + * synchronization behaviour, by default. * - * 5. The MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE runtime environment variable or MoltenVK compile-time - * build setting controls whether Xcode should run an automatic GPU capture without the user - * having to trigger it manually via the Xcode user interface, and controls the scope under - * which that GPU capture will occur. This is useful when trying to capture a one-shot GPU - * trace, such as when running a Vulkan CTS test case. For the automatic GPU capture to occur, - * the Xcode scheme under which the app is run must have the Metal GPU capture option turned on. - * MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE should not be set to manually trigger a GPU capture via the - * Xcode user interface. - * 0: No automatic GPU capture. - * 1: Capture all GPU commands issued during the lifetime of the VkDevice. - * If none of these is set, no automatic GPU capture will occur. + * 5. The MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE runtime environment variable or MoltenVK compile-time + * build setting controls whether Metal should run an automatic GPU capture without the user + * having to trigger it manually via the Xcode user interface, and controls the scope under + * which that GPU capture will occur. This is useful when trying to capture a one-shot GPU + * trace, such as when running a Vulkan CTS test case. For the automatic GPU capture to occur, + * the Xcode scheme under which the app is run must have the Metal GPU capture option turned on. + * MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE should not be set to manually trigger a GPU capture via the + * Xcode user interface. + * 0: No automatic GPU capture. + * 1: Capture all GPU commands issued during the lifetime of the VkDevice. + * If MVK_CONFIG_AUTO_GPU_CAPTURE_OUTPUT_FILE is also set, it is a filename where the automatic + * GPU capture should be saved. In this case, the Xcode scheme need not have Metal GPU capture + * enabled, and in fact the app need not be run under Xcode's control at all. This is useful + * in case the app cannot be run under Xcode's control. A path starting with '~' can be used + * to place it in a user's home directory, as in the shell. This feature requires Metal 3.0 + * (macOS 10.15, iOS 13). + * If none of these is set, no automatic GPU capture will occur. * - * 6. The MVK_CONFIG_TEXTURE_1D_AS_2D runtime environment variable or MoltenVK compile-time build - * setting controls whether MoltenVK should use a Metal 2D texture with a height of 1 for a - * Vulkan 1D image, or use a native Metal 1D texture. Metal imposes significant restrictions - * on native 1D textures, including not being renderable, clearable, or permitting mipmaps. - * Using a Metal 2D texture allows Vulkan 1D textures to support this additional functionality. - * This setting is enabled by default, and MoltenVK will use a Metal 2D texture for each Vulkan 1D image. + * 6. The MVK_CONFIG_TEXTURE_1D_AS_2D runtime environment variable or MoltenVK compile-time build + * setting controls whether MoltenVK should use a Metal 2D texture with a height of 1 for a + * Vulkan 1D image, or use a native Metal 1D texture. Metal imposes significant restrictions + * on native 1D textures, including not being renderable, clearable, or permitting mipmaps. + * Using a Metal 2D texture allows Vulkan 1D textures to support this additional functionality. + * This setting is enabled by default, and MoltenVK will use a Metal 2D texture for each Vulkan 1D image. * - * 7. The MVK_CONFIG_PREALLOCATE_DESCRIPTORS runtime environment variable or MoltenVK compile-time - * build setting controls whether MoltenVK should preallocate memory in each VkDescriptorPool - * according to the values of the VkDescriptorPoolSize parameters. Doing so may improve - * descriptor set allocation performance at a cost of preallocated application memory. - * If this environment variable is disabled, the descriptors required for a descriptor set will - * be dynamically allocated in application memory when the descriptor set itself is allocated. - * This setting is disabled by default, and MoltenVK will dynamically allocate descriptors - * when the containing descriptor set is allocated. + * 7. The MVK_CONFIG_PREALLOCATE_DESCRIPTORS runtime environment variable or MoltenVK compile-time + * build setting controls whether MoltenVK should preallocate memory in each VkDescriptorPool + * according to the values of the VkDescriptorPoolSize parameters. Doing so may improve + * descriptor set allocation performance at a cost of preallocated application memory. + * If this setting is disabled, the descriptors required for a descriptor set will + * be dynamically allocated in application memory when the descriptor set itself is allocated. + * This setting is disabled by default, and MoltenVK will dynamically allocate descriptors + * when the containing descriptor set is allocated. + * + * 8. The MVK_CONFIG_USE_COMMAND_POOLING runtime environment variable or MoltenVK compile-time + * build setting controls whether MoltenVK should use pools to manage memory used when + * adding commands to command buffers. If this setting is enabled, MoltenVK + * will use a pool to hold command resources for reuse during command execution. If this + * setting is disabled, command memory is allocated and destroyed each time + * a command is executed. This is a classic time-space trade off. When command pooling is + * active, the memory in the pool can be cleared via a call to the vkTrimCommandPoolKHR() + * command. This setting is enabled by default, and MoltenVK will pool command memory. + * + * 9. The MVK_CONFIG_USE_MTLHEAP runtime environment variable or MoltenVK compile-time build + * setting controls whether MoltenVK should use MTLHeaps for allocating textures and buffers + * from device memory. If this setting is enabled, and placement MTLHeaps are + * available on the platform, MoltenVK will allocate a placement MTLHeap for each VkDeviceMemory + * instance, and allocate textures and buffers from that placement heap. If this environment + * variable is disabled, MoltenVK will allocate textures and buffers from general device memory. + * Apple recommends that MTLHeaps should only be used for specific requirements such as aliasing + * or hazard tracking, and MoltenVK testing has shown that allocating multiple textures of + * different types or usages from one MTLHeap can occassionally cause corruption issues under + * certain circumstances. Because of this, this setting is disabled by default, and MoltenVK + * will allocate texures and buffers from general device memory. + * + * 10. The MVK_CONFIG_PERFORMANCE_LOGGING_INLINE runtime environment variable or MoltenVK + * compile-time build setting controls whether MoltenVK should log the performance of + * individual activities as they happen. If this setting is enabled, activity performance + * will be logged when each activity happens. If this setting is disabled, activity + * performance will be logged when frame peformance is logged as determined by the + * MVK_CONFIG_PERFORMANCE_LOGGING_FRAME_COUNT environment variable or MoltenVK + * compile-time build setting. This setting is disabled by default, and activity + * performance will be logged only when frame activity is logged. */ typedef struct { @@ -331,8 +368,9 @@ typedef struct { * If enabled, performance statistics, as defined by the MVKPerformanceStatistics structure, * are collected, and can be retrieved via the vkGetPerformanceStatisticsMVK() function. * - * You can also use the performanceLoggingFrameCount parameter to automatically log the - * performance statistics collected by this parameter. + * You can also use the performanceLoggingFrameCount parameter or MVK_CONFIG_PERFORMANCE_LOGGING_INLINE + * environment variable or MoltenVK compile-time build setting to automatically log the performance + * statistics collected by this parameter. * * The value of this parameter may be changed at any time during application runtime, * and the changed value will immediately effect subsequent MoltenVK behaviour. @@ -345,12 +383,10 @@ typedef struct { VkBool32 performanceTracking; /** - * If non-zero, performance statistics, as defined by the MVKPerformanceStatistics structure, - * will be logged to the console. Frame-based statistics will be logged, on a repeating cycle, - * once per this many frames. Non-frame-based statistics will be logged as they occur. - * - * The performanceTracking parameter must also be enabled. If this parameter is zero, or - * the performanceTracking parameter is disabled, no performance statistics will be logged. + * If non-zero, performance statistics, frame-based statistics will be logged, on a + * repeating cycle, once per this many frames. The performanceTracking parameter must + * also be enabled. If this parameter is zero, or the performanceTracking parameter + * is disabled, no frame-based performance statistics will be logged. * * The value of this parameter may be changed at any time during application runtime, * and the changed value will immediately effect subsequent MoltenVK behaviour. @@ -573,32 +609,14 @@ typedef struct { VkBool32 native3DCompressedTextures; /**< If true, 3D compressed images are supported natively, without manual decompression. */ VkBool32 nativeTextureSwizzle; /**< If true, component swizzle is supported natively, without manual swizzling in shaders. */ VkBool32 placementHeaps; /**< If true, MTLHeap objects support placement of resources. */ - VkDeviceSize pushConstantSizeAlignment; /**< The alignment used internally when allocating memory for push constants. Must be PoT. */ + VkDeviceSize pushConstantSizeAlignment; /**< The alignment used internally when allocating memory for push constants. Must be PoT. */ + uint32_t maxTextureLayers; /**< The maximum number of layers in an array texture. */ } MVKPhysicalDeviceMetalFeatures; -/** - * MoltenVK swapchain performance statistics. You can retrieve a copy of this structure using - * the vkGetSwapchainPerformanceMVK() function. - * - * This structure may be extended as new features are added to MoltenVK. If you are linking to - * an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION - * than your app was, the size of this structure in your app may be larger or smaller than the - * struct in MoltenVK. See the description of the vkGetSwapchainPerformanceMVK() function for - * information about how to handle this. - * - * TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT - * BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER, - * SHOULD NOT BE CHANGED. - */ -typedef struct { - double lastFrameInterval; /**< The time interval between this frame and the immediately previous frame, in milliseconds. */ - double averageFrameInterval; /**< The rolling average time interval between frames, in miliseconds. This value has less volatility than the lastFrameInterval value. */ - double averageFramesPerSecond; /**< The rolling average number of frames per second. This is simply the 1000 divided by the averageFrameInterval value. */ -} MVKSwapchainPerformance; - /** MoltenVK performance of a particular type of activity. */ typedef struct { uint32_t count; /**< The number of activities of this type. */ + double latestDuration; /**< The latest (most recent) duration of the activity, in milliseconds. */ double averageDuration; /**< The average duration of the activity, in milliseconds. */ double minimumDuration; /**< The minimum duration of the activity, in milliseconds. */ double maximumDuration; /**< The maximum duration of the activity, in milliseconds. */ @@ -626,9 +644,10 @@ typedef struct { /** MoltenVK performance of queue activities. */ typedef struct { - MVKPerformanceTracker mtlQueueAccess; /** Create an MTLCommmandQueue or access an existing cached instance. */ + MVKPerformanceTracker mtlQueueAccess; /** Create an MTLCommandQueue or access an existing cached instance. */ MVKPerformanceTracker mtlCommandBufferCompletion; /** Completion of a MTLCommandBuffer on the GPU, from commit to completion callback. */ MVKPerformanceTracker nextCAMetalDrawable; /** Retrieve next CAMetalDrawable from CAMetalLayer during presentation. */ + MVKPerformanceTracker frameInterval; /** Frame presentation interval (1000/FPS). */ } MVKQueuePerformance; /** @@ -657,7 +676,6 @@ typedef struct { typedef VkResult (VKAPI_PTR *PFN_vkGetMoltenVKConfigurationMVK)(VkInstance instance, MVKConfiguration* pConfiguration, size_t* pConfigurationSize); typedef VkResult (VKAPI_PTR *PFN_vkSetMoltenVKConfigurationMVK)(VkInstance instance, MVKConfiguration* pConfiguration, size_t* pConfigurationSize); typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceMetalFeaturesMVK)(VkPhysicalDevice physicalDevice, MVKPhysicalDeviceMetalFeatures* pMetalFeatures, size_t* pMetalFeaturesSize); -typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainPerformanceMVK)(VkDevice device, VkSwapchainKHR swapchain, MVKSwapchainPerformance* pSwapchainPerf, size_t* pSwapchainPerfSize); typedef VkResult (VKAPI_PTR *PFN_vkGetPerformanceStatisticsMVK)(VkDevice device, MVKPerformanceStatistics* pPerf, size_t* pPerfSize); typedef void (VKAPI_PTR *PFN_vkGetVersionStringsMVK)(char* pMoltenVersionStringBuffer, uint32_t moltenVersionStringBufferLength, char* pVulkanVersionStringBuffer, uint32_t vulkanVersionStringBufferLength); @@ -790,40 +808,6 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceMetalFeaturesMVK( MVKPhysicalDeviceMetalFeatures* pMetalFeatures, size_t* pMetalFeaturesSize); -/** - * Populates the pSwapchainPerf structure with the current performance statistics for the swapchain. - * - * If you are linking to an implementation of MoltenVK that was compiled from a different - * VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKSwapchainPerformance - * structure in your app may be larger or smaller than the same struct as expected by MoltenVK. - * - * When calling this function, set the value of *pSwapchainPerfSize to sizeof(MVKSwapchainPerformance), - * to tell MoltenVK the limit of the size of your MVKSwapchainPerformance structure. Upon return from - * this function, the value of *pSwapchainPerfSize will hold the actual number of bytes copied into - * your passed MVKSwapchainPerformance structure, which will be the smaller of what your app thinks - * is the size of MVKSwapchainPerformance, and what MoltenVK thinks it is. This represents the safe - * access area within the structure for both MoltenVK and your app. - * - * If the size that MoltenVK expects for MVKSwapchainPerformance is different than the value passed in - * *pSwapchainPerfSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS. - * - * Although it is not necessary, you can use this function to determine in advance the value - * that MoltenVK expects the size of MVKSwapchainPerformance to be by setting the value of - * pSwapchainPerf to NULL. In that case, this function will set *pSwapchainPerfSize to the - * size that MoltenVK expects MVKSwapchainPerformance to be. - * - * This function is not supported by the Vulkan SDK Loader and Layers framework. - * The VkDevice and VkSwapchainKHR objects you provide here must have been retrieved directly - * from MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan - * objects are often changed by layers, and passing them from one layer to another, - * or from a layer directly to MoltenVK, will result in undefined behaviour. - */ -VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainPerformanceMVK( - VkDevice device, - VkSwapchainKHR swapchain, - MVKSwapchainPerformance* pSwapchainPerf, - size_t* pSwapchainPerfSize); - /** * Populates the pPerf structure with the current performance statistics for the device. * diff --git a/externals/MoltenVK/lib/libMoltenVK.dylib b/externals/MoltenVK/lib/libMoltenVK.dylib index 4860478731..1ca47c533e 100755 Binary files a/externals/MoltenVK/lib/libMoltenVK.dylib and b/externals/MoltenVK/lib/libMoltenVK.dylib differ diff --git a/externals/MoltenVK/lib/libVkLayer_khronos_validation.dylib b/externals/MoltenVK/lib/libVkLayer_khronos_validation.dylib index 3f7c74ba38..fea892b59c 100755 Binary files a/externals/MoltenVK/lib/libVkLayer_khronos_validation.dylib and b/externals/MoltenVK/lib/libVkLayer_khronos_validation.dylib differ diff --git a/externals/MoltenVK/lib/libvulkan.dylib b/externals/MoltenVK/lib/libvulkan.dylib index 3eb6e1d694..5e800ab8dd 100755 Binary files a/externals/MoltenVK/lib/libvulkan.dylib and b/externals/MoltenVK/lib/libvulkan.dylib differ diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp index fc85785424..8ddbd04078 100644 --- a/src/video_core/renderer_vulkan/vk_device.cpp +++ b/src/video_core/renderer_vulkan/vk_device.cpp @@ -38,8 +38,11 @@ constexpr std::array REQUIRED_EXTENSIONS = { VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME, #ifndef __APPLE__ VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, + // Subgroup ballot/vote will be supported by MoltenVK shortly VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME, VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME, + // Apparently shader draw params can be a missing feature + VK_KHR_SHADER_DRAW_PARAMETERS #endif }; @@ -242,7 +245,11 @@ bool VKDevice::Create() { bit16_storage.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR; bit16_storage.pNext = nullptr; bit16_storage.storageBuffer16BitAccess = false; +#ifdef __APPLE__ + bit16_storage.uniformAndStorageBuffer16BitAccess = false; +#else bit16_storage.uniformAndStorageBuffer16BitAccess = true; +#endif bit16_storage.storagePushConstant16 = false; bit16_storage.storageInputOutput16 = false; SetNext(next, bit16_storage); diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 97429cc59f..e20456915f 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -276,28 +276,38 @@ class SPIRVDecompiler final : public Sirit::Module { public: explicit SPIRVDecompiler(const VKDevice& device, const ShaderIR& ir, ShaderType stage, const Registry& registry, const Specialization& specialization) - : Module(0x00010300), device{device}, ir{ir}, stage{stage}, header{ir.GetHeader()}, + : +#ifdef __APPLE__ + Module(0x00010000), +#else + Module(0x00010300), +#endif + device{device}, ir{ir}, stage{stage}, header{ir.GetHeader()}, registry{registry}, specialization{specialization} { if (stage != ShaderType::Compute) { transform_feedback = BuildTransformFeedback(registry.GetGraphicsInfo()); } AddCapability(spv::Capability::Shader); - AddCapability(spv::Capability::UniformAndStorageBuffer16BitAccess); AddCapability(spv::Capability::ImageQuery); AddCapability(spv::Capability::Image1D); AddCapability(spv::Capability::ImageBuffer); AddCapability(spv::Capability::ImageGatherExtended); AddCapability(spv::Capability::SampledBuffer); AddCapability(spv::Capability::StorageImageWriteWithoutFormat); +#ifndef __APPLE__ + // Not sure why Draw Parameters not supported when it should be AddCapability(spv::Capability::DrawParameters); + // These can be added back when MoltenVK finally supports vk 1.1 AddCapability(spv::Capability::SubgroupBallotKHR); AddCapability(spv::Capability::SubgroupVoteKHR); + AddCapability(spv::Capability::UniformAndStorageBuffer16BitAccess); AddExtension("SPV_KHR_shader_ballot"); AddExtension("SPV_KHR_subgroup_vote"); + AddExtension("SPV_KHR_shader_draw_parameters"); +#endif AddExtension("SPV_KHR_storage_buffer_storage_class"); AddExtension("SPV_KHR_variable_pointers"); - AddExtension("SPV_KHR_shader_draw_parameters"); if (!transform_feedback.empty()) { if (device.IsExtTransformFeedbackSupported()) { @@ -514,6 +524,8 @@ private: } void DeclareCommon() { +#ifndef __APPLE__ +//subgrouplocalinvocationId requires VK_EXT_shader_subgroup_ballot - isn't in metal yet thread_id = DeclareInputBuiltIn(spv::BuiltIn::SubgroupLocalInvocationId, t_in_uint, "thread_id"); thread_masks[0] = @@ -526,6 +538,7 @@ private: DeclareInputBuiltIn(spv::BuiltIn::SubgroupLeMask, t_in_uint4, "thread_le_mask"); thread_masks[4] = DeclareInputBuiltIn(spv::BuiltIn::SubgroupLtMask, t_in_uint4, "thread_lt_mask"); +#endif } void DeclareVertex() { @@ -631,7 +644,11 @@ private: void DeclareRegisters() { for (const u32 gpr : ir.GetRegisters()) { +#ifdef __APPLE__ + const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private); +#else const Id id = OpVariable(t_prv_float, spv::StorageClass::Private, v_float_zero); +#endif Name(id, fmt::format("gpr_{}", gpr)); registers.emplace(gpr, AddGlobalVariable(id)); } @@ -640,7 +657,11 @@ private: void DeclareCustomVariables() { const u32 num_custom_variables = ir.GetNumCustomVariables(); for (u32 i = 0; i < num_custom_variables; ++i) { +#ifdef __APPLE__ + const Id id = OpVariable(t_prv_float, spv::StorageClass::Private); +#else const Id id = OpVariable(t_prv_float, spv::StorageClass::Private, v_float_zero); +#endif Name(id, fmt::format("custom_var_{}", i)); custom_variables.emplace(i, AddGlobalVariable(id)); } @@ -648,7 +669,11 @@ private: void DeclarePredicates() { for (const auto pred : ir.GetPredicates()) { +#ifdef __APPLE__ + const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private); +#else const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false); +#endif Name(id, fmt::format("pred_{}", static_cast(pred))); predicates.emplace(pred, AddGlobalVariable(id)); } @@ -656,7 +681,11 @@ private: void DeclareFlowVariables() { for (u32 i = 0; i < ir.GetASTNumVariables(); i++) { +#ifdef __APPLE__ + const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private); +#else const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false); +#endif Name(id, fmt::format("flow_var_{}", static_cast(i))); flow_variables.emplace(i, AddGlobalVariable(id)); } @@ -703,7 +732,11 @@ private: constexpr std::array names = {"zero", "sign", "carry", "overflow"}; for (std::size_t flag = 0; flag < INTERNAL_FLAGS_COUNT; ++flag) { const auto flag_code = static_cast(flag); +#ifdef __APPLE__ + const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private); +#else const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false); +#endif internal_flags[flag] = AddGlobalVariable(Name(id, names[flag])); } } @@ -1327,10 +1360,11 @@ private: } if (const auto comment = std::get_if(&*node)) { +#ifndef __APPLE__ // This doesn't work at all on moltenVK Name(OpUndef(t_void), comment->GetText()); +#endif return {}; } - UNREACHABLE(); return {}; } diff --git a/src/video_core/renderer_vulkan/wrapper.cpp b/src/video_core/renderer_vulkan/wrapper.cpp index 42eff85d3a..e6172450c7 100644 --- a/src/video_core/renderer_vulkan/wrapper.cpp +++ b/src/video_core/renderer_vulkan/wrapper.cpp @@ -373,7 +373,11 @@ Instance Instance::Create(Span layers, Span extensions application_info.applicationVersion = VK_MAKE_VERSION(0, 1, 0); application_info.pEngineName = "yuzu Emulator"; application_info.engineVersion = VK_MAKE_VERSION(0, 1, 0); +#ifdef __APPLE__ + application_info.apiVersion = VK_API_VERSION_1_0; +#else application_info.apiVersion = VK_API_VERSION_1_1; +#endif VkInstanceCreateInfo ci; ci.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;