From 160a327cbb87a2561185a4d3c10117d40d58f974 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Sun, 5 Feb 2023 00:26:04 -0800 Subject: [PATCH 1/5] enable availability of EXT_shader_atomic_float and add docs for how to replace Vulkan SDK .dylib while avoiding need to reboot. --- Docs/MoltenVK_Runtime_UserGuide.md | 22 ++++++++++++++++++++++ MoltenVK/MoltenVK/Layers/MVKExtensions.def | 1 + 2 files changed, 23 insertions(+) diff --git a/Docs/MoltenVK_Runtime_UserGuide.md b/Docs/MoltenVK_Runtime_UserGuide.md index ae08b5da..7b89c572 100644 --- a/Docs/MoltenVK_Runtime_UserGuide.md +++ b/Docs/MoltenVK_Runtime_UserGuide.md @@ -22,6 +22,7 @@ Table of Contents - [Installing **MoltenVK** in Your *Vulkan* Application](#install) - [Install *MoltenVK* as a Universal `XCFramework`](#install_xcfwk) - [Install *MoltenVK* as a Dynamic Library](#install_dylib) + - [Install *MoltenVK* replacing the Vulkan SDK .dylib](#install_vksdk) - [Build and Runtime Requirements](#requirements) - [Interacting with the **MoltenVK** Runtime](#interaction) - [MoltenVK `VK_MVK_moltenvk` Extension](#moltenvk_extension) @@ -219,6 +220,27 @@ To link **MoltenVK** to your application as a dynamic library (`.dylib`), follow - `MoltenVK/dylib/tvOS/libMoltenVK.dylib` *(tvOS)* + +### Install *MoltenVK* replacing the Vulkan SDK .dylib + +There are a few potential issues when building **MoltenVK** to replace the version installed via the *[Vulkan SDK](https://vulkan.lunarg.com/sdk/home)* standard install process, which lives in `/usr/local/lib/libMoltenVK.dylib`. + +1. You must *remove* the existing `.dylib` file before copying the new one, because of the way that the gatekeeper system works to prevent malicious overwriting of files in standard locations such as `/usr/local`: + +```bash +$ sudo rm /usr/local/lib/libMoltenVK.dylib +$ sudo cp Package/Release/MoltenVK/dylib/macOS/libMoltenVK.dylib /usr/local/lib +``` + +If you do not do the remove first, your application will terminate immediately with a singularly unhelpful `Killed: 9` message. + +2. Do *not* copy the `MoltenVK_icd.json` file from the newly-built package to `/usr/local/share/vulkan/icd.d` -- it will not work and will result in errors about not being able to initialize the instance. The one installed by Vulkan SDK uses a relative path to specify the location of the `.dylib`, whereas the one in the package specifies it in the same directory. + +3. The default config for command-line build has verbose logging info turned on -- if you want it to be like the original, use this command for building: + +```bash +$ make macos MVK_CONFIG_LOG_LEVEL=1 +``` ### Build and Runtime Requirements diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.def b/MoltenVK/MoltenVK/Layers/MVKExtensions.def index 17ed1f25..ec57fbf4 100644 --- a/MoltenVK/MoltenVK/Layers/MVKExtensions.def +++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.def @@ -113,6 +113,7 @@ MVK_EXTENSION(EXT_scalar_block_layout, EXT_SCALAR_BLOCK_LAYOUT, MVK_EXTENSION(EXT_separate_stencil_usage, EXT_SEPARATE_STENCIL_USAGE, DEVICE, 10.11, 8.0) MVK_EXTENSION(EXT_shader_stencil_export, EXT_SHADER_STENCIL_EXPORT, DEVICE, 10.14, 12.0) MVK_EXTENSION(EXT_shader_viewport_index_layer, EXT_SHADER_VIEWPORT_INDEX_LAYER, DEVICE, 10.11, 8.0) +MVK_EXTENSION(EXT_shader_atomic_float, EXT_SHADER_ATOMIC_FLOAT, DEVICE, 13.0, 16.0) MVK_EXTENSION(EXT_subgroup_size_control, EXT_SUBGROUP_SIZE_CONTROL, DEVICE, 10.14, 13.0) MVK_EXTENSION(EXT_swapchain_colorspace, EXT_SWAPCHAIN_COLOR_SPACE, INSTANCE, 10.11, 9.0) MVK_EXTENSION(EXT_texel_buffer_alignment, EXT_TEXEL_BUFFER_ALIGNMENT, DEVICE, 10.13, 11.0) From 6c044acad6c65d8634254b00f973cd7d31d87772 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Wed, 22 Feb 2023 01:40:12 -0800 Subject: [PATCH 2/5] Update SPIRV-Cross and glslang repo revisions to include support for atomic float (glslang for HLSL support for InterlockedAdd on float) --- ExternalRevisions/SPIRV-Cross_repo_revision | 2 +- ExternalRevisions/glslang_repo_revision | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ExternalRevisions/SPIRV-Cross_repo_revision b/ExternalRevisions/SPIRV-Cross_repo_revision index 4ecdce5f..623b2093 100644 --- a/ExternalRevisions/SPIRV-Cross_repo_revision +++ b/ExternalRevisions/SPIRV-Cross_repo_revision @@ -1 +1 @@ -4e2fdb25671c742a9fbe93a6034eb1542244c7e1 +3550a54ae01b295c40ce972d951b420b388b9401 diff --git a/ExternalRevisions/glslang_repo_revision b/ExternalRevisions/glslang_repo_revision index fd739be9..cd6a5b28 100644 --- a/ExternalRevisions/glslang_repo_revision +++ b/ExternalRevisions/glslang_repo_revision @@ -1 +1 @@ -ca8d07d0bc1c6390b83915700439fa7719de6a2a +6d41bb9c557c5a0eec61ffba1f775dc5f717a8f7 From 19f19c9aae31ee9c4e6a18002d001d835e0f42b6 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Wed, 22 Feb 2023 02:13:17 -0800 Subject: [PATCH 3/5] add VkPhysicalDeviceShaderAtomicFloatFeaturesEXT in MVKDevice.mm, using mslVersion >= 030000 --- MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 5ec47c4c..815cb1d7 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -401,6 +401,11 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) { shaderIntFuncsFeatures->shaderIntegerFunctions2 = true; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT: { + auto* atomicFloatFeatures = (VkPhysicalDeviceShaderAtomicFloatFeaturesEXT*)next; + atomicFloatFeatures->shaderBufferFloat32AtomicAdd = _metalFeatures.mslVersion >= 030000; + break; + } default: break; } From 8046d82215005c4dbca5e8725055eefcde464cc1 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Tue, 7 Mar 2023 21:06:21 -0800 Subject: [PATCH 4/5] updates from latest PR comments from Hollings --- Docs/MoltenVK_Runtime_UserGuide.md | 23 +++++++++++++++++----- Docs/Whats_New.md | 2 +- MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm | 7 ++++++- MoltenVK/MoltenVK/Layers/MVKExtensions.def | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Docs/MoltenVK_Runtime_UserGuide.md b/Docs/MoltenVK_Runtime_UserGuide.md index 7b89c572..e80c6670 100644 --- a/Docs/MoltenVK_Runtime_UserGuide.md +++ b/Docs/MoltenVK_Runtime_UserGuide.md @@ -223,20 +223,32 @@ To link **MoltenVK** to your application as a dynamic library (`.dylib`), follow ### Install *MoltenVK* replacing the Vulkan SDK .dylib -There are a few potential issues when building **MoltenVK** to replace the version installed via the *[Vulkan SDK](https://vulkan.lunarg.com/sdk/home)* standard install process, which lives in `/usr/local/lib/libMoltenVK.dylib`. +There are a few potential issues when building **MoltenVK** to replace the version installed via +the *[Vulkan SDK](https://vulkan.lunarg.com/sdk/home)* standard install process, which lives in +`/usr/local/lib/libMoltenVK.dylib`. -1. You must *remove* the existing `.dylib` file before copying the new one, because of the way that the gatekeeper system works to prevent malicious overwriting of files in standard locations such as `/usr/local`: +1. You must *remove* the existing `.dylib` file before copying the new one, because of the way +that the gatekeeper system works to prevent malicious overwriting of files in standard locations +such as `/usr/local`: ```bash $ sudo rm /usr/local/lib/libMoltenVK.dylib $ sudo cp Package/Release/MoltenVK/dylib/macOS/libMoltenVK.dylib /usr/local/lib ``` -If you do not do the remove first, your application will terminate immediately with a singularly unhelpful `Killed: 9` message. +If you do not do the remove first, your application will terminate immediately with a +singularly unhelpful `Killed: 9` message. Alternatively, moving the existing `.dylib` to a +backup name and making a symbolic link to the Package location above is particularly useful +for repeated building and testing. -2. Do *not* copy the `MoltenVK_icd.json` file from the newly-built package to `/usr/local/share/vulkan/icd.d` -- it will not work and will result in errors about not being able to initialize the instance. The one installed by Vulkan SDK uses a relative path to specify the location of the `.dylib`, whereas the one in the package specifies it in the same directory. +2. Do *not* copy the `MoltenVK_icd.json` file from the newly-built package to +`/usr/local/share/vulkan/icd.d` -- it will not work and will result in errors about not being +able to initialize the instance. The one installed by Vulkan SDK uses a relative path to +specify the location of the `.dylib`, whereas the one in the package specifies it in the same +directory. -3. The default config for command-line build has verbose logging info turned on -- if you want it to be like the original, use this command for building: +3. The default config for command-line build has verbose logging info turned on -- if you want +it to be like the original, use this command for building: ```bash $ make macos MVK_CONFIG_LOG_LEVEL=1 @@ -325,6 +337,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll - `VK_KHR_sampler_mirror_clamp_to_edge` *(requires a Mac GPU or Apple family 7 GPU)* - `VK_KHR_sampler_ycbcr_conversion` - `VK_KHR_separate_depth_stencil_layouts` +- `VK_EXT_shader_atomic_float` *(requires Metal 3.0)* - `VK_KHR_shader_draw_parameters` - `VK_KHR_shader_float_controls` - `VK_KHR_shader_float16_int8` diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 634865ba..09286d7e 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -22,7 +22,7 @@ Released TBA was sometimes incorrectly disabled due to a Metal driver bug. - Work around problems with using explicit LoD with arrayed depth images on Apple Silicon. - +- Added support for `VK_EXT_shader_atomic_float` *(requires Metal 3.0)*. MoltenVK 1.2.2 diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 815cb1d7..3acd6bb2 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -403,7 +403,12 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) { } case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT: { auto* atomicFloatFeatures = (VkPhysicalDeviceShaderAtomicFloatFeaturesEXT*)next; - atomicFloatFeatures->shaderBufferFloat32AtomicAdd = _metalFeatures.mslVersion >= 030000; + mvkClear(atomicFloatFeatures); + bool atomicFloatEnabled = _metalFeatures.mslVersion >= 030000; + atomicFloatFeatures->shaderBufferFloat32Atomics = atomicFloatEnabled; + atomicFloatFeatures->shaderBufferFloat32AtomicAdd = atomicFloatEnabled; + atomicFloatFeatures->shaderSharedFloat32Atomics = atomicFloatEnabled; + atomicFloatFeatures->shaderSharedFloat32AtomicAdd = atomicFloatEnabled; break; } default: diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.def b/MoltenVK/MoltenVK/Layers/MVKExtensions.def index ec57fbf4..224cdbe0 100644 --- a/MoltenVK/MoltenVK/Layers/MVKExtensions.def +++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.def @@ -111,9 +111,9 @@ MVK_EXTENSION(EXT_sample_locations, EXT_SAMPLE_LOCATIONS, MVK_EXTENSION(EXT_sampler_filter_minmax, EXT_SAMPLER_FILTER_MINMAX, DEVICE, MVK_NA, MVK_NA) MVK_EXTENSION(EXT_scalar_block_layout, EXT_SCALAR_BLOCK_LAYOUT, DEVICE, 10.11, 8.0) MVK_EXTENSION(EXT_separate_stencil_usage, EXT_SEPARATE_STENCIL_USAGE, DEVICE, 10.11, 8.0) +MVK_EXTENSION(EXT_shader_atomic_float, EXT_SHADER_ATOMIC_FLOAT, DEVICE, 13.0, 16.0) MVK_EXTENSION(EXT_shader_stencil_export, EXT_SHADER_STENCIL_EXPORT, DEVICE, 10.14, 12.0) MVK_EXTENSION(EXT_shader_viewport_index_layer, EXT_SHADER_VIEWPORT_INDEX_LAYER, DEVICE, 10.11, 8.0) -MVK_EXTENSION(EXT_shader_atomic_float, EXT_SHADER_ATOMIC_FLOAT, DEVICE, 13.0, 16.0) MVK_EXTENSION(EXT_subgroup_size_control, EXT_SUBGROUP_SIZE_CONTROL, DEVICE, 10.14, 13.0) MVK_EXTENSION(EXT_swapchain_colorspace, EXT_SWAPCHAIN_COLOR_SPACE, INSTANCE, 10.11, 9.0) MVK_EXTENSION(EXT_texel_buffer_alignment, EXT_TEXEL_BUFFER_ALIGNMENT, DEVICE, 10.13, 11.0) From e2e412cf31a9f4878dd96fdb3236028be64c6e15 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Wed, 8 Mar 2023 12:21:50 -0800 Subject: [PATCH 5/5] undo WhatsNew --- Docs/Whats_New.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 09286d7e..634865ba 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -22,7 +22,7 @@ Released TBA was sometimes incorrectly disabled due to a Metal driver bug. - Work around problems with using explicit LoD with arrayed depth images on Apple Silicon. -- Added support for `VK_EXT_shader_atomic_float` *(requires Metal 3.0)*. + MoltenVK 1.2.2