Add support for VK_KHR_separate_depth_stencil_layouts extension.

Add VK_KHR_separate_depth_stencil_layouts and enable its features.
Metal generally ignores image layouts, so nothing further needed.
Update Whats_New.md and MoltenVK_Runtime_UserGuide.md documents
with recently-added extensions.

Passes almost all supported separate_layouts CTS tests, with the
few remaining tests failing due to issues with unrelated capabilities.

Unrelated cleanup:
- MVKDevice enable extensions before features.
- MVKDevice reorder ivar declarations to reduce
  memory layout gaps, and define default values.
- Rename VkSemaphoreStyle to MVKSemaphoreStyle to
  remove potential conflicts with Vulkan Vk name space.
This commit is contained in:
Bill Hollings 2022-05-05 15:55:26 -04:00
parent 790b7aa594
commit 1bad27cf26
5 changed files with 54 additions and 31 deletions

View File

@ -270,6 +270,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_device_group` - `VK_KHR_device_group`
- `VK_KHR_device_group_creation` - `VK_KHR_device_group_creation`
- `VK_KHR_driver_properties` - `VK_KHR_driver_properties`
- `VK_KHR_dynamic_rendering`
- `VK_KHR_get_memory_requirements2` - `VK_KHR_get_memory_requirements2`
- `VK_KHR_get_physical_device_properties2` - `VK_KHR_get_physical_device_properties2`
- `VK_KHR_get_surface_capabilities2` - `VK_KHR_get_surface_capabilities2`
@ -284,6 +285,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_KHR_relaxed_block_layout` - `VK_KHR_relaxed_block_layout`
- `VK_KHR_sampler_mirror_clamp_to_edge` *(requires a Mac GPU or Apple family 7 GPU)* - `VK_KHR_sampler_mirror_clamp_to_edge` *(requires a Mac GPU or Apple family 7 GPU)*
- `VK_KHR_sampler_ycbcr_conversion` - `VK_KHR_sampler_ycbcr_conversion`
- `VK_KHR_separate_depth_stencil_layouts`
- `VK_KHR_shader_draw_parameters` - `VK_KHR_shader_draw_parameters`
- `VK_KHR_shader_float16_int8` - `VK_KHR_shader_float16_int8`
- `VK_KHR_shader_subgroup_extended_types` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)* - `VK_KHR_shader_subgroup_extended_types` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)*
@ -309,6 +311,7 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_EXT_robustness2` - `VK_EXT_robustness2`
- `VK_EXT_sample_locations` - `VK_EXT_sample_locations`
- `VK_EXT_scalar_block_layout` - `VK_EXT_scalar_block_layout`
- `VK_EXT_separate_stencil_usage`
- `VK_EXT_shader_stencil_export` *(requires Mac GPU family 2 or iOS GPU family 5)* - `VK_EXT_shader_stencil_export` *(requires Mac GPU family 2 or iOS GPU family 5)*
- `VK_EXT_shader_viewport_index_layer` - `VK_EXT_shader_viewport_index_layer`
- `VK_EXT_subgroup_size_control` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)* - `VK_EXT_subgroup_size_control` *(requires Metal 2.1 on Mac or Metal 2.2 and Apple family 4 on iOS)*

View File

@ -23,6 +23,7 @@ Released TBD
updated to indicate the impact of the `VK_KHR_portability_enumeration` extension during updated to indicate the impact of the `VK_KHR_portability_enumeration` extension during
runtime loading on *macOS* via the *Vulkan Loader*. runtime loading on *macOS* via the *Vulkan Loader*.
- `VK_KHR_dynamic_rendering` - `VK_KHR_dynamic_rendering`
- `VK_KHR_separate_depth_stencil_layouts`
- `VK_EXT_separate_stencil_usage` - `VK_EXT_separate_stencil_usage`
- Fix error where previously bound push constants can override a descriptor buffer binding - Fix error where previously bound push constants can override a descriptor buffer binding
used by a subsequent pipeline that does not use push constants. used by a subsequent pipeline that does not use push constants.

View File

@ -429,6 +429,12 @@ typedef struct MVKMTLBlitEncoder {
id<MTLCommandBuffer> mtlCmdBuffer = nil; id<MTLCommandBuffer> mtlCmdBuffer = nil;
} MVKMTLBlitEncoder; } MVKMTLBlitEncoder;
typedef enum {
MVKSemaphoreStyleUseMTLEvent,
MVKSemaphoreStyleUseMTLFence,
MVKSemaphoreStyleUseEmulation
} MVKSemaphoreStyle;
/** Represents a Vulkan logical GPU device, associated with a physical device. */ /** Represents a Vulkan logical GPU device, associated with a physical device. */
class MVKDevice : public MVKDispatchableVulkanAPIObject { class MVKDevice : public MVKDispatchableVulkanAPIObject {
@ -762,6 +768,9 @@ public:
#pragma mark Properties directly accessible #pragma mark Properties directly accessible
/** The list of Vulkan extensions, indicating whether each has been enabled by the app for this device. */
const MVKExtensionList _enabledExtensions;
/** Device features available and enabled. */ /** Device features available and enabled. */
const VkPhysicalDeviceFeatures _enabledFeatures; const VkPhysicalDeviceFeatures _enabledFeatures;
const VkPhysicalDevice16BitStorageFeatures _enabledStorage16Features; const VkPhysicalDevice16BitStorageFeatures _enabledStorage16Features;
@ -781,9 +790,7 @@ public:
const VkPhysicalDevicePortabilitySubsetFeaturesKHR _enabledPortabilityFeatures; const VkPhysicalDevicePortabilitySubsetFeaturesKHR _enabledPortabilityFeatures;
const VkPhysicalDeviceImagelessFramebufferFeaturesKHR _enabledImagelessFramebufferFeatures; const VkPhysicalDeviceImagelessFramebufferFeaturesKHR _enabledImagelessFramebufferFeatures;
const VkPhysicalDeviceDynamicRenderingFeatures _enabledDynamicRenderingFeatures; const VkPhysicalDeviceDynamicRenderingFeatures _enabledDynamicRenderingFeatures;
const VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures _enabledSeparateDepthStencilLayoutsFeatures;
/** The list of Vulkan extensions, indicating whether each has been enabled by the app for this device. */
const MVKExtensionList _enabledExtensions;
/** 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;
@ -858,21 +865,15 @@ protected:
std::mutex _rezLock; std::mutex _rezLock;
std::mutex _sem4Lock; std::mutex _sem4Lock;
std::mutex _perfLock; std::mutex _perfLock;
id<MTLBuffer> _globalVisibilityResultMTLBuffer; std::mutex _vizLock;
id<MTLSamplerState> _defaultMTLSamplerState; id<MTLBuffer> _globalVisibilityResultMTLBuffer = nil;
id<MTLBuffer> _dummyBlitMTLBuffer; id<MTLSamplerState> _defaultMTLSamplerState = nil;
uint32_t _globalVisibilityQueryCount; id<MTLBuffer> _dummyBlitMTLBuffer = nil;
std::mutex _vizLock; MVKSemaphoreStyle _vkSemaphoreStyle = MVKSemaphoreStyleUseEmulation;
bool _logActivityPerformanceInline; uint32_t _globalVisibilityQueryCount = 0;
bool _isPerformanceTracking; bool _logActivityPerformanceInline = false;
bool _isCurrentlyAutoGPUCapturing; bool _isPerformanceTracking = false;
bool _isCurrentlyAutoGPUCapturing = false;
typedef enum {
VkSemaphoreStyleUseMTLEvent,
VkSemaphoreStyleUseMTLFence,
VkSemaphoreStyleUseEmulation
} VkSemaphoreStyle;
VkSemaphoreStyle _vkSemaphoreStyle;
}; };

View File

@ -282,6 +282,11 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
dynamicRenderingFeatures->dynamicRendering = true; dynamicRenderingFeatures->dynamicRendering = true;
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES: {
auto* separateDepthStencilLayoutsFeatures = (VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures*)next;
separateDepthStencilLayoutsFeatures->separateDepthStencilLayouts = true;
break;
}
default: default:
break; break;
} }
@ -3327,9 +3332,9 @@ MVKSemaphore* MVKDevice::createSemaphore(const VkSemaphoreCreateInfo* pCreateInf
} }
} else { } else {
switch (_vkSemaphoreStyle) { switch (_vkSemaphoreStyle) {
case VkSemaphoreStyleUseMTLEvent: return new MVKSemaphoreMTLEvent(this, pCreateInfo); case MVKSemaphoreStyleUseMTLEvent: return new MVKSemaphoreMTLEvent(this, pCreateInfo);
case VkSemaphoreStyleUseMTLFence: return new MVKSemaphoreMTLFence(this, pCreateInfo); case MVKSemaphoreStyleUseMTLFence: return new MVKSemaphoreMTLFence(this, pCreateInfo);
case VkSemaphoreStyleUseEmulation: return new MVKSemaphoreEmulated(this, pCreateInfo); case MVKSemaphoreStyleUseEmulation: return new MVKSemaphoreEmulated(this, pCreateInfo);
} }
} }
} }
@ -3981,10 +3986,10 @@ MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo
_enabledPortabilityFeatures(), _enabledPortabilityFeatures(),
_enabledImagelessFramebufferFeatures(), _enabledImagelessFramebufferFeatures(),
_enabledDynamicRenderingFeatures(), _enabledDynamicRenderingFeatures(),
_enabledExtensions(this), _enabledSeparateDepthStencilLayoutsFeatures(),
_isCurrentlyAutoGPUCapturing(false) _enabledExtensions(this) {
{
// If the physical device is lost, bail. // If the physical device is lost, bail.
if (physicalDevice->getConfigurationResult() != VK_SUCCESS) { if (physicalDevice->getConfigurationResult() != VK_SUCCESS) {
setConfigurationResult(physicalDevice->getConfigurationResult()); setConfigurationResult(physicalDevice->getConfigurationResult());
return; return;
@ -3992,8 +3997,8 @@ MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo
initPerformanceTracking(); initPerformanceTracking();
initPhysicalDevice(physicalDevice, pCreateInfo); initPhysicalDevice(physicalDevice, pCreateInfo);
enableFeatures(pCreateInfo);
enableExtensions(pCreateInfo); enableExtensions(pCreateInfo);
enableFeatures(pCreateInfo);
initQueues(pCreateInfo); initQueues(pCreateInfo);
reservePrivateData(pCreateInfo); reservePrivateData(pCreateInfo);
@ -4075,15 +4080,15 @@ void MVKDevice::initPhysicalDevice(MVKPhysicalDevice* physicalDevice, const VkDe
bool isRosetta2 = _pProperties->vendorID == kAppleVendorId && !MVK_APPLE_SILICON; bool isRosetta2 = _pProperties->vendorID == kAppleVendorId && !MVK_APPLE_SILICON;
bool canUseMTLEventForSem4 = _pMetalFeatures->events && mvkConfig().semaphoreUseMTLEvent && !(isRosetta2 || isNVIDIA); bool canUseMTLEventForSem4 = _pMetalFeatures->events && mvkConfig().semaphoreUseMTLEvent && !(isRosetta2 || isNVIDIA);
bool canUseMTLFenceForSem4 = _pMetalFeatures->fences && mvkConfig().semaphoreUseMTLFence; bool canUseMTLFenceForSem4 = _pMetalFeatures->fences && mvkConfig().semaphoreUseMTLFence;
_vkSemaphoreStyle = canUseMTLEventForSem4 ? VkSemaphoreStyleUseMTLEvent : (canUseMTLFenceForSem4 ? VkSemaphoreStyleUseMTLFence : VkSemaphoreStyleUseEmulation); _vkSemaphoreStyle = canUseMTLEventForSem4 ? MVKSemaphoreStyleUseMTLEvent : (canUseMTLFenceForSem4 ? MVKSemaphoreStyleUseMTLFence : MVKSemaphoreStyleUseEmulation);
switch (_vkSemaphoreStyle) { switch (_vkSemaphoreStyle) {
case VkSemaphoreStyleUseMTLEvent: case MVKSemaphoreStyleUseMTLEvent:
MVKLogInfo("Using MTLEvent for Vulkan semaphores."); MVKLogInfo("Using MTLEvent for Vulkan semaphores.");
break; break;
case VkSemaphoreStyleUseMTLFence: case MVKSemaphoreStyleUseMTLFence:
MVKLogInfo("Using MTLFence for Vulkan semaphores."); MVKLogInfo("Using MTLFence for Vulkan semaphores.");
break; break;
case VkSemaphoreStyleUseEmulation: case MVKSemaphoreStyleUseEmulation:
MVKLogInfo("Using emulation for Vulkan semaphores."); MVKLogInfo("Using emulation for Vulkan semaphores.");
break; break;
} }
@ -4110,10 +4115,15 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
mvkClear(&_enabledPortabilityFeatures); mvkClear(&_enabledPortabilityFeatures);
mvkClear(&_enabledImagelessFramebufferFeatures); mvkClear(&_enabledImagelessFramebufferFeatures);
mvkClear(&_enabledDynamicRenderingFeatures); mvkClear(&_enabledDynamicRenderingFeatures);
mvkClear(&_enabledSeparateDepthStencilLayoutsFeatures);
VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures pdSeparateDepthStencilLayoutsFeatures;
pdSeparateDepthStencilLayoutsFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES;
pdSeparateDepthStencilLayoutsFeatures.pNext = nullptr;
VkPhysicalDeviceDynamicRenderingFeatures pdDynamicRenderingFeatures; VkPhysicalDeviceDynamicRenderingFeatures pdDynamicRenderingFeatures;
pdDynamicRenderingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES; pdDynamicRenderingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES;
pdDynamicRenderingFeatures.pNext = NULL; pdDynamicRenderingFeatures.pNext = &pdSeparateDepthStencilLayoutsFeatures;
VkPhysicalDeviceImagelessFramebufferFeaturesKHR pdImagelessFramebufferFeatures; VkPhysicalDeviceImagelessFramebufferFeaturesKHR pdImagelessFramebufferFeatures;
pdImagelessFramebufferFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES; pdImagelessFramebufferFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES;
@ -4321,6 +4331,13 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
&pdDynamicRenderingFeatures.dynamicRendering, 1); &pdDynamicRenderingFeatures.dynamicRendering, 1);
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES: {
auto* requestedFeatures = (VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures*)next;
enableFeatures(&_enabledSeparateDepthStencilLayoutsFeatures.separateDepthStencilLayouts,
&requestedFeatures->separateDepthStencilLayouts,
&pdSeparateDepthStencilLayoutsFeatures.separateDepthStencilLayouts, 1);
break;
}
default: default:
break; break;
} }

View File

@ -72,6 +72,7 @@ MVK_EXTENSION(KHR_push_descriptor, KHR_PUSH_DESCRIPTOR,
MVK_EXTENSION(KHR_relaxed_block_layout, KHR_RELAXED_BLOCK_LAYOUT, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_relaxed_block_layout, KHR_RELAXED_BLOCK_LAYOUT, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_sampler_mirror_clamp_to_edge, KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE, DEVICE, 10.11, 14.0) MVK_EXTENSION(KHR_sampler_mirror_clamp_to_edge, KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE, DEVICE, 10.11, 14.0)
MVK_EXTENSION(KHR_sampler_ycbcr_conversion, KHR_SAMPLER_YCBCR_CONVERSION, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_sampler_ycbcr_conversion, KHR_SAMPLER_YCBCR_CONVERSION, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_separate_depth_stencil_layouts, KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_shader_draw_parameters, KHR_SHADER_DRAW_PARAMETERS, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_shader_draw_parameters, KHR_SHADER_DRAW_PARAMETERS, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_shader_float16_int8, KHR_SHADER_FLOAT16_INT8, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_shader_float16_int8, KHR_SHADER_FLOAT16_INT8, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_shader_subgroup_extended_types, KHR_SHADER_SUBGROUP_EXTENDED_TYPES, DEVICE, 10.14, 13.0) MVK_EXTENSION(KHR_shader_subgroup_extended_types, KHR_SHADER_SUBGROUP_EXTENDED_TYPES, DEVICE, 10.14, 13.0)