Merge pull request #1638 from billhollings/SPV_KHR_physical_storage_buffer

Enhancements to recent extensions.
This commit is contained in:
Bill Hollings 2022-07-12 14:46:49 -04:00 committed by GitHub
commit 784b0dc28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 79 additions and 13 deletions

View File

@ -263,6 +263,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_16bit_storage` - `VK_KHR_16bit_storage`
- `VK_KHR_8bit_storage` - `VK_KHR_8bit_storage`
- `VK_KHR_bind_memory2` - `VK_KHR_bind_memory2`
- `VK_KHR_buffer_device_address` *(requires Metal 3.0)*
- `VK_KHR_create_renderpass2` - `VK_KHR_create_renderpass2`
- `VK_KHR_dedicated_allocation` - `VK_KHR_dedicated_allocation`
- `VK_KHR_depth_stencil_resolve` - `VK_KHR_depth_stencil_resolve`
@ -297,6 +298,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_timeline_semaphore` - `VK_KHR_timeline_semaphore`
- `VK_KHR_uniform_buffer_standard_layout` - `VK_KHR_uniform_buffer_standard_layout`
- `VK_KHR_variable_pointers` - `VK_KHR_variable_pointers`
- `VK_EXT_buffer_device_address` *(requires Metal 3.0)*
- `VK_EXT_debug_marker` - `VK_EXT_debug_marker`
- `VK_EXT_debug_report` - `VK_EXT_debug_report`
- `VK_EXT_debug_utils` - `VK_EXT_debug_utils`

View File

@ -20,11 +20,13 @@ Released TBD
- Add support for extensions: - Add support for extensions:
- `VK_EXT_metal_objects` - `VK_EXT_metal_objects`
- `VK_KHR_buffer_device_address` and `VK_EXT_buffer_device_address`.
- Reducing redundant state changes to improve command encoding performance. - Reducing redundant state changes to improve command encoding performance.
- Update minimum Xcode deployment targets to macOS 10.13, iOS 11, and tvOS 11, - Update minimum Xcode deployment targets to macOS 10.13, iOS 11, and tvOS 11,
to avoid Xcode build warnings in Xcode 14. to avoid Xcode build warnings in Xcode 14.
MoltenVK 1.1.10 MoltenVK 1.1.10
-------------- --------------

View File

@ -1 +1 @@
50b4d5389b6a06f86fb63a2848e1a7da6d9755ca d8d051381f65b9606fb8016c79b7c3bab872eec3

View File

@ -794,6 +794,9 @@ public:
const VkPhysicalDeviceImagelessFramebufferFeaturesKHR _enabledImagelessFramebufferFeatures; const VkPhysicalDeviceImagelessFramebufferFeaturesKHR _enabledImagelessFramebufferFeatures;
const VkPhysicalDeviceDynamicRenderingFeatures _enabledDynamicRenderingFeatures; const VkPhysicalDeviceDynamicRenderingFeatures _enabledDynamicRenderingFeatures;
const VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures _enabledSeparateDepthStencilLayoutsFeatures; const VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures _enabledSeparateDepthStencilLayoutsFeatures;
const VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR _enabledFragmentShaderBarycentricFeatures;
const VkPhysicalDeviceBufferDeviceAddressFeatures _enabledBufferDeviceAddressFeatures;
const VkPhysicalDeviceBufferDeviceAddressFeaturesEXT _enabledBufferDeviceAddressFeaturesEXT;
/** Pointer to the Metal-specific features of the underlying physical device. */ /** Pointer to the Metal-specific features of the underlying physical device. */
const MVKPhysicalDeviceMetalFeatures* _pMetalFeatures; const MVKPhysicalDeviceMetalFeatures* _pMetalFeatures;

View File

@ -288,16 +288,23 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR: {
auto* barycentricProperties = (VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR*)next; auto* barycentricFeatures = (VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR*)next;
barycentricProperties->fragmentShaderBarycentric = true; barycentricFeatures->fragmentShaderBarycentric = true;
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES: {
auto* bufferDeviceAddressFeatures = (VkPhysicalDeviceBufferDeviceAddressFeatures*)next; auto* bufferDeviceAddressFeatures = (VkPhysicalDeviceBufferDeviceAddressFeatures*)next;
bufferDeviceAddressFeatures->bufferDeviceAddress = true; bufferDeviceAddressFeatures->bufferDeviceAddress = mvkOSVersionIsAtLeast(12.05, 16.0);
bufferDeviceAddressFeatures->bufferDeviceAddressCaptureReplay = false; bufferDeviceAddressFeatures->bufferDeviceAddressCaptureReplay = false;
bufferDeviceAddressFeatures->bufferDeviceAddressMultiDevice = false; bufferDeviceAddressFeatures->bufferDeviceAddressMultiDevice = false;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT: {
auto* bufferDeviceAddressFeatures = (VkPhysicalDeviceBufferDeviceAddressFeaturesEXT*)next;
bufferDeviceAddressFeatures->bufferDeviceAddress = mvkOSVersionIsAtLeast(12.05, 16.0);
bufferDeviceAddressFeatures->bufferDeviceAddressCaptureReplay = false;
bufferDeviceAddressFeatures->bufferDeviceAddressMultiDevice = false;
break;
}
default: default:
break; break;
} }
@ -4115,7 +4122,10 @@ MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo
_enabledPortabilityFeatures(), _enabledPortabilityFeatures(),
_enabledImagelessFramebufferFeatures(), _enabledImagelessFramebufferFeatures(),
_enabledDynamicRenderingFeatures(), _enabledDynamicRenderingFeatures(),
_enabledSeparateDepthStencilLayoutsFeatures() { _enabledSeparateDepthStencilLayoutsFeatures(),
_enabledFragmentShaderBarycentricFeatures(),
_enabledBufferDeviceAddressFeatures(),
_enabledBufferDeviceAddressFeaturesEXT() {
// If the physical device is lost, bail. // If the physical device is lost, bail.
if (physicalDevice->getConfigurationResult() != VK_SUCCESS) { if (physicalDevice->getConfigurationResult() != VK_SUCCESS) {
@ -4244,10 +4254,25 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
mvkClear(&_enabledImagelessFramebufferFeatures); mvkClear(&_enabledImagelessFramebufferFeatures);
mvkClear(&_enabledDynamicRenderingFeatures); mvkClear(&_enabledDynamicRenderingFeatures);
mvkClear(&_enabledSeparateDepthStencilLayoutsFeatures); mvkClear(&_enabledSeparateDepthStencilLayoutsFeatures);
mvkClear(&_enabledFragmentShaderBarycentricFeatures);
mvkClear(&_enabledBufferDeviceAddressFeatures);
mvkClear(&_enabledBufferDeviceAddressFeaturesEXT);
VkPhysicalDeviceBufferDeviceAddressFeaturesEXT pdBufferDeviceAddressFeaturesEXT;
pdBufferDeviceAddressFeaturesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT;
pdBufferDeviceAddressFeaturesEXT.pNext = nullptr;
VkPhysicalDeviceBufferDeviceAddressFeatures pdBufferDeviceAddressFeatures;
pdBufferDeviceAddressFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES;
pdBufferDeviceAddressFeatures.pNext = &pdBufferDeviceAddressFeaturesEXT;
VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR pdFragmentShaderBarycentricFeatures;
pdFragmentShaderBarycentricFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR;
pdFragmentShaderBarycentricFeatures.pNext = &pdBufferDeviceAddressFeatures;
VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures pdSeparateDepthStencilLayoutsFeatures; VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures pdSeparateDepthStencilLayoutsFeatures;
pdSeparateDepthStencilLayoutsFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES; pdSeparateDepthStencilLayoutsFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES;
pdSeparateDepthStencilLayoutsFeatures.pNext = nullptr; pdSeparateDepthStencilLayoutsFeatures.pNext = &pdFragmentShaderBarycentricFeatures;
VkPhysicalDeviceDynamicRenderingFeatures pdDynamicRenderingFeatures; VkPhysicalDeviceDynamicRenderingFeatures pdDynamicRenderingFeatures;
pdDynamicRenderingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES; pdDynamicRenderingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES;
@ -4466,6 +4491,27 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
&pdSeparateDepthStencilLayoutsFeatures.separateDepthStencilLayouts, 1); &pdSeparateDepthStencilLayoutsFeatures.separateDepthStencilLayouts, 1);
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR: {
auto* requestedFeatures = (VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR*)next;
enableFeatures(&_enabledFragmentShaderBarycentricFeatures.fragmentShaderBarycentric,
&requestedFeatures->fragmentShaderBarycentric,
&pdFragmentShaderBarycentricFeatures.fragmentShaderBarycentric, 1);
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES: {
auto* requestedFeatures = (VkPhysicalDeviceBufferDeviceAddressFeatures*)next;
enableFeatures(&_enabledBufferDeviceAddressFeatures.bufferDeviceAddress,
&requestedFeatures->bufferDeviceAddress,
&pdBufferDeviceAddressFeatures.bufferDeviceAddress, 3);
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT: {
auto* requestedFeatures = (VkPhysicalDeviceBufferDeviceAddressFeaturesEXT*)next;
enableFeatures(&_enabledBufferDeviceAddressFeaturesEXT.bufferDeviceAddress,
&requestedFeatures->bufferDeviceAddress,
&pdBufferDeviceAddressFeaturesEXT.bufferDeviceAddress, 3);
break;
}
default: default:
break; break;
} }

View File

@ -165,7 +165,8 @@ protected:
id<MTLHeap> _mtlHeap = nil; id<MTLHeap> _mtlHeap = nil;
void* _pMemory = nullptr; void* _pMemory = nullptr;
void* _pHostMemory = nullptr; void* _pHostMemory = nullptr;
VkMemoryPropertyFlags _vkMemProps; VkMemoryPropertyFlags _vkMemPropFlags;
VkMemoryAllocateFlags _vkMemAllocFlags;
MTLStorageMode _mtlStorageMode; MTLStorageMode _mtlStorageMode;
MTLCPUCacheMode _mtlCPUCacheMode; MTLCPUCacheMode _mtlCPUCacheMode;
bool _isDedicated = false; bool _isDedicated = false;

View File

@ -57,7 +57,7 @@ VkResult MVKDeviceMemory::map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMa
// Coherent memory does not require flushing by app, so we must flush now // Coherent memory does not require flushing by app, so we must flush now
// to support Metal textures that actually reside in non-coherent memory. // to support Metal textures that actually reside in non-coherent memory.
if (mvkIsAnyFlagEnabled(_vkMemProps, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) { if (mvkIsAnyFlagEnabled(_vkMemPropFlags, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
pullFromDevice(offset, size); pullFromDevice(offset, size);
} }
@ -73,7 +73,7 @@ void MVKDeviceMemory::unmap() {
// Coherent memory does not require flushing by app, so we must flush now // Coherent memory does not require flushing by app, so we must flush now
// to support Metal textures that actually reside in non-coherent memory. // to support Metal textures that actually reside in non-coherent memory.
if (mvkIsAnyFlagEnabled(_vkMemProps, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) { if (mvkIsAnyFlagEnabled(_vkMemPropFlags, VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
flushToDevice(_mappedRange.offset, _mappedRange.size); flushToDevice(_mappedRange.offset, _mappedRange.size);
} }
@ -277,9 +277,9 @@ MVKDeviceMemory::MVKDeviceMemory(MVKDevice* device,
const VkMemoryAllocateInfo* pAllocateInfo, const VkMemoryAllocateInfo* pAllocateInfo,
const VkAllocationCallbacks* pAllocator) : MVKVulkanAPIDeviceObject(device) { const VkAllocationCallbacks* pAllocator) : MVKVulkanAPIDeviceObject(device) {
// Set Metal memory parameters // Set Metal memory parameters
_vkMemProps = _device->_pMemoryProperties->memoryTypes[pAllocateInfo->memoryTypeIndex].propertyFlags; _vkMemPropFlags = _device->_pMemoryProperties->memoryTypes[pAllocateInfo->memoryTypeIndex].propertyFlags;
_mtlStorageMode = mvkMTLStorageModeFromVkMemoryPropertyFlags(_vkMemProps); _mtlStorageMode = mvkMTLStorageModeFromVkMemoryPropertyFlags(_vkMemPropFlags);
_mtlCPUCacheMode = mvkMTLCPUCacheModeFromVkMemoryPropertyFlags(_vkMemProps); _mtlCPUCacheMode = mvkMTLCPUCacheModeFromVkMemoryPropertyFlags(_vkMemPropFlags);
_allocationSize = pAllocateInfo->allocationSize; _allocationSize = pAllocateInfo->allocationSize;
@ -315,6 +315,10 @@ MVKDeviceMemory::MVKDeviceMemory(MVKDevice* device,
case VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECT_CREATE_INFO_EXT: { case VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECT_CREATE_INFO_EXT: {
const auto* pExportInfo = (VkExportMetalObjectCreateInfoEXT*)next; const auto* pExportInfo = (VkExportMetalObjectCreateInfoEXT*)next;
willExportMTLBuffer = pExportInfo->exportObjectType == VK_EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXT; willExportMTLBuffer = pExportInfo->exportObjectType == VK_EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXT;
}
case VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO: {
auto* pMemAllocFlagsInfo = (VkMemoryAllocateFlagsInfo*)next;
_vkMemAllocFlags = pMemAllocFlagsInfo->flags;
break; break;
} }
default: default:

View File

@ -649,6 +649,7 @@ void MVKInstance::initProcAddrs() {
ADD_DVC_EXT_ENTRY_POINT(vkGetSemaphoreCounterValueKHR, KHR_TIMELINE_SEMAPHORE); ADD_DVC_EXT_ENTRY_POINT(vkGetSemaphoreCounterValueKHR, KHR_TIMELINE_SEMAPHORE);
ADD_DVC_EXT_ENTRY_POINT(vkSignalSemaphoreKHR, KHR_TIMELINE_SEMAPHORE); ADD_DVC_EXT_ENTRY_POINT(vkSignalSemaphoreKHR, KHR_TIMELINE_SEMAPHORE);
ADD_DVC_EXT_ENTRY_POINT(vkWaitSemaphoresKHR, KHR_TIMELINE_SEMAPHORE); ADD_DVC_EXT_ENTRY_POINT(vkWaitSemaphoresKHR, KHR_TIMELINE_SEMAPHORE);
ADD_DVC_EXT_ENTRY_POINT(vkGetBufferDeviceAddressEXT, EXT_BUFFER_DEVICE_ADDRESS);
ADD_DVC_EXT_ENTRY_POINT(vkDebugMarkerSetObjectTagEXT, EXT_DEBUG_MARKER); ADD_DVC_EXT_ENTRY_POINT(vkDebugMarkerSetObjectTagEXT, EXT_DEBUG_MARKER);
ADD_DVC_EXT_ENTRY_POINT(vkDebugMarkerSetObjectNameEXT, EXT_DEBUG_MARKER); ADD_DVC_EXT_ENTRY_POINT(vkDebugMarkerSetObjectNameEXT, EXT_DEBUG_MARKER);
ADD_DVC_EXT_ENTRY_POINT(vkCmdDebugMarkerBeginEXT, EXT_DEBUG_MARKER); ADD_DVC_EXT_ENTRY_POINT(vkCmdDebugMarkerBeginEXT, EXT_DEBUG_MARKER);

View File

@ -44,7 +44,7 @@
MVK_EXTENSION(KHR_16bit_storage, KHR_16BIT_STORAGE, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_16bit_storage, KHR_16BIT_STORAGE, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_8bit_storage, KHR_8BIT_STORAGE, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_8bit_storage, KHR_8BIT_STORAGE, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_bind_memory2, KHR_BIND_MEMORY_2, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_bind_memory2, KHR_BIND_MEMORY_2, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_buffer_device_address, KHR_BUFFER_DEVICE_ADDRESS, DEVICE, 13.0, 16.0) MVK_EXTENSION(KHR_buffer_device_address, KHR_BUFFER_DEVICE_ADDRESS, DEVICE, 12.05, 16.0)
MVK_EXTENSION(KHR_create_renderpass2, KHR_CREATE_RENDERPASS_2, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_create_renderpass2, KHR_CREATE_RENDERPASS_2, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_dedicated_allocation, KHR_DEDICATED_ALLOCATION, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_dedicated_allocation, KHR_DEDICATED_ALLOCATION, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_depth_stencil_resolve, KHR_DEPTH_STENCIL_RESOLVE, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_depth_stencil_resolve, KHR_DEPTH_STENCIL_RESOLVE, DEVICE, 10.11, 8.0)
@ -85,6 +85,7 @@ MVK_EXTENSION(KHR_swapchain_mutable_format, KHR_SWAPCHAIN_MUTABLE_FORMAT,
MVK_EXTENSION(KHR_timeline_semaphore, KHR_TIMELINE_SEMAPHORE, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_timeline_semaphore, KHR_TIMELINE_SEMAPHORE, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_uniform_buffer_standard_layout, KHR_UNIFORM_BUFFER_STANDARD_LAYOUT, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_uniform_buffer_standard_layout, KHR_UNIFORM_BUFFER_STANDARD_LAYOUT, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_variable_pointers, KHR_VARIABLE_POINTERS, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_variable_pointers, KHR_VARIABLE_POINTERS, DEVICE, 10.11, 8.0)
MVK_EXTENSION(EXT_buffer_device_address, EXT_BUFFER_DEVICE_ADDRESS, DEVICE, 12.05, 16.0)
MVK_EXTENSION(EXT_debug_marker, EXT_DEBUG_MARKER, DEVICE, 10.11, 8.0) MVK_EXTENSION(EXT_debug_marker, EXT_DEBUG_MARKER, DEVICE, 10.11, 8.0)
MVK_EXTENSION(EXT_debug_report, EXT_DEBUG_REPORT, INSTANCE, 10.11, 8.0) MVK_EXTENSION(EXT_debug_report, EXT_DEBUG_REPORT, INSTANCE, 10.11, 8.0)
MVK_EXTENSION(EXT_debug_utils, EXT_DEBUG_UTILS, INSTANCE, 10.11, 8.0) MVK_EXTENSION(EXT_debug_utils, EXT_DEBUG_UTILS, INSTANCE, 10.11, 8.0)

View File

@ -2801,6 +2801,12 @@ MVK_PUBLIC_VULKAN_SYMBOL VkResult vkWaitSemaphoresKHR(
} }
#pragma mark -
#pragma mark VK_EXT_buffer_device_address extension
MVK_PUBLIC_VULKAN_ALIAS(vkGetBufferDeviceAddressEXT, vkGetBufferDeviceAddressKHR);
#pragma mark - #pragma mark -
#pragma mark VK_EXT_debug_report extension #pragma mark VK_EXT_debug_report extension