Check MTLDevice for gpuAddress support.
Support by the MTLDevice for Metal Tier 2 argument buffers has an
impact on both descriptor indexing and buffer device address support.
Add MVKPhysicalDeviceMetalFeatures::argumentBuffersTier, to track
the MTLDevice argument buffers support tier, set it from
[MTLDevice argumentBuffersSupport], and subsequently enable support for
VK_KHR_buffer_device_address and VK_EXT_buffer_device_address extensions,
and set descriptor indexing resource counts, based on it.
Update documentation requirements.
diff --git a/Docs/MoltenVK_Runtime_UserGuide.md b/Docs/MoltenVK_Runtime_UserGuide.md
index b82aa34..155e1fd 100644
--- a/Docs/MoltenVK_Runtime_UserGuide.md
+++ b/Docs/MoltenVK_Runtime_UserGuide.md
@@ -263,7 +263,7 @@
- `VK_KHR_16bit_storage`
- `VK_KHR_8bit_storage`
- `VK_KHR_bind_memory2`
-- `VK_KHR_buffer_device_address` *(requires Metal 3.0)*
+- `VK_KHR_buffer_device_address` *(requires GPU Tier 2 argument buffers support)*
- `VK_KHR_create_renderpass2`
- `VK_KHR_dedicated_allocation`
- `VK_KHR_depth_stencil_resolve`
@@ -298,7 +298,7 @@
- `VK_KHR_timeline_semaphore`
- `VK_KHR_uniform_buffer_standard_layout`
- `VK_KHR_variable_pointers`
-- `VK_EXT_buffer_device_address` *(requires Metal 3.0)*
+- `VK_EXT_buffer_device_address` *(requires GPU Tier 2 argument buffers support)*
- `VK_EXT_debug_marker`
- `VK_EXT_debug_report`
- `VK_EXT_debug_utils`
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index 5c1622f..06a21d8 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -20,7 +20,7 @@
- Add support for extensions:
- `VK_EXT_metal_objects`
- - `VK_KHR_buffer_device_address` and `VK_EXT_buffer_device_address`.
+ - `VK_KHR_buffer_device_address` and `VK_EXT_buffer_device_address` *(requires GPU Tier 2 argument buffers support)*.
- Reducing redundant state changes to improve command encoding performance.
- Update minimum Xcode deployment targets to macOS 10.13, iOS 11, and tvOS 11,
to avoid Xcode build warnings in Xcode 14.
diff --git a/MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h b/MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
index 0d6c35a..ffd7838 100644
--- a/MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
+++ b/MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
@@ -33,6 +33,7 @@
#import <Metal/Metal.h>
#else
typedef unsigned long MTLLanguageVersion;
+typedef unsigned long MTLArgumentBuffersTier;
#endif
@@ -931,6 +932,7 @@
MVKCounterSamplingFlags counterSamplingPoints; /**< Identifies the points where pipeline GPU counter sampling may occur. */
VkBool32 programmableSamplePositions; /**< If true, programmable MSAA sample positions are supported. */
VkBool32 shaderBarycentricCoordinates; /**< If true, fragment shader barycentric coordinates are supported. */
+ MTLArgumentBuffersTier argumentBuffersTier; /**< The argument buffer tier available on this device, as a Metal enumeration. */
} MVKPhysicalDeviceMetalFeatures;
/** MoltenVK performance of a particular type of activity. */
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
index 4316cc6..e5f6860 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
@@ -415,7 +415,7 @@
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT: {
- bool isTier2 = isUsingMetalArgumentBuffers() && (_mtlDevice.argumentBuffersSupport >= MTLArgumentBuffersTier2);
+ bool isTier2 = isUsingMetalArgumentBuffers() && (_metalFeatures.argumentBuffersTier >= MTLArgumentBuffersTier2);
uint32_t maxSampCnt = getMaxSamplerCount();
auto* pDescIdxProps = (VkPhysicalDeviceDescriptorIndexingPropertiesEXT*)next;
@@ -1724,6 +1724,10 @@
// Currently, if we don't support descriptor set argument buffers, we can't support argument buffers.
_metalFeatures.argumentBuffers = _metalFeatures.descriptorSetArgumentBuffers;
+ if ([_mtlDevice respondsToSelector: @selector(argumentBuffersSupport)]) {
+ _metalFeatures.argumentBuffersTier = _mtlDevice.argumentBuffersSupport;
+ }
+
#define checkSupportsMTLCounterSamplingPoint(mtlSP, mvkSP) \
if ([_mtlDevice respondsToSelector: @selector(supportsCounterSampling:)] && \
[_mtlDevice supportsCounterSampling: MTLCounterSamplingPointAt ##mtlSP ##Boundary]) { \
@@ -2851,6 +2855,11 @@
pWritableExtns->vk_KHR_fragment_shader_barycentric.enabled = false;
pWritableExtns->vk_NV_fragment_shader_barycentric.enabled = false;
}
+ // gpuAddress requires Tier2 argument buffer support (per feedback from Apple engineers).
+ if (_metalFeatures.argumentBuffersTier < MTLArgumentBuffersTier2) {
+ pWritableExtns->vk_KHR_buffer_device_address.enabled = false;
+ pWritableExtns->vk_EXT_buffer_device_address.enabled = false;
+ }
#if MVK_MACOS
if (!supportsMTLGPUFamily(Apple5)) {
pWritableExtns->vk_AMD_shader_image_load_store_lod.enabled = false;