Merge branch 'master' into SingleQueueSemaphore

This commit is contained in:
Bill Hollings 2022-08-30 14:10:56 -04:00 committed by GitHub
commit 37f1988e34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 176 additions and 61 deletions

View File

@ -303,7 +303,9 @@ In addition to core *Vulkan* functionality, **MoltenVK** also supports the foll
- `VK_EXT_debug_marker` - `VK_EXT_debug_marker`
- `VK_EXT_debug_report` - `VK_EXT_debug_report`
- `VK_EXT_debug_utils` - `VK_EXT_debug_utils`
- `VK_EXT_descriptor_indexing` *(initial release limited to Metal Tier 1: 96/128 textures, 16 samplers)* - `VK_EXT_descriptor_indexing` *(initial release limited to Metal Tier 1: 96/128 textures,
16 samplers, except macOS 11.0 (Big Sur) or later, or on older versions of macOS using
an Intel GPU, and if Metal argument buffers enabled in config)*
- `VK_EXT_fragment_shader_interlock` *(requires Metal 2.0 and Raster Order Groups)* - `VK_EXT_fragment_shader_interlock` *(requires Metal 2.0 and Raster Order Groups)*
- `VK_EXT_host_query_reset` - `VK_EXT_host_query_reset`
- `VK_EXT_image_robustness` - `VK_EXT_image_robustness`

View File

@ -20,8 +20,12 @@ Released TBD
- Add support for extensions: - Add support for extensions:
- `VK_KHR_shader_float_controls` - `VK_KHR_shader_float_controls`
- Support config option to automatically use Metal argument buffers when `VK_EXT_descriptor_indexing`
extension is enabled. `MVKConfiguration::useMetalArgumentBuffers` (`MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS`)
is now an enum field. The use of Metal argument buffers is still disabled by default (`MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER`).
- Fix occassional crash from retention of `MVKSwapchain` for future drawable presentations. - Fix occassional crash from retention of `MVKSwapchain` for future drawable presentations.
- Add `MVK_USE_CEREAL` build setting to avoid use of Cereal external library (for pipeline caching). - Add `MVK_USE_CEREAL` build setting to avoid use of Cereal external library (for pipeline caching).
- Update `VK_MVK_MOLTENVK_SPEC_VERSION` to version `36`.

View File

@ -56,7 +56,7 @@ typedef unsigned long MTLArgumentBuffersTier;
#define MVK_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + (patch)) #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 MVK_VERSION MVK_MAKE_VERSION(MVK_VERSION_MAJOR, MVK_VERSION_MINOR, MVK_VERSION_PATCH)
#define VK_MVK_MOLTENVK_SPEC_VERSION 35 #define VK_MVK_MOLTENVK_SPEC_VERSION 36
#define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk" #define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
/** Identifies the level of logging MoltenVK should be limited to outputting. */ /** Identifies the level of logging MoltenVK should be limited to outputting. */
@ -96,6 +96,14 @@ typedef enum MVKConfigAdvertiseExtensionBits {
} MVKConfigAdvertiseExtensionBits; } MVKConfigAdvertiseExtensionBits;
typedef VkFlags MVKConfigAdvertiseExtensions; typedef VkFlags MVKConfigAdvertiseExtensions;
/** Identifies the use of Metal Argument Buffers. */
typedef enum MVKUseMetalArgumentBuffers {
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER = 0, /**< Don't use Metal Argument Buffers. */
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_ALWAYS = 1, /**< Use Metal Argument Buffers for all pipelines. */
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_DESCRIPTOR_INDEXING = 2, /**< Use Metal Argument Buffers only if VK_EXT_descriptor_indexing extension is enabled. */
MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_MAX_ENUM = 0x7FFFFFFF
} MVKUseMetalArgumentBuffers;
/** /**
* MoltenVK configuration settings. * MoltenVK configuration settings.
* *
@ -807,25 +815,26 @@ typedef struct {
* Controls whether MoltenVK should use Metal argument buffers for resources defined in * Controls whether MoltenVK should use Metal argument buffers for resources defined in
* descriptor sets, if Metal argument buffers are supported on the platform. Using Metal * descriptor sets, if Metal argument buffers are supported on the platform. Using Metal
* argument buffers dramatically increases the number of buffers, textures and samplers * argument buffers dramatically increases the number of buffers, textures and samplers
* that can be bound to a pipeline shader, and in most cases improves performance. If this * that can be bound to a pipeline shader, and in most cases improves performance.
* setting is enabled, MoltenVK will use Metal argument buffers to bind resources to the * This setting is an enumeration that specifies the conditions under which MoltenVK
* shaders. If this setting is disabled, MoltenVK will bind resources to shaders discretely. * will use Metal argument buffers.
* *
* NOTE: Currently, Metal argument buffer support is in beta stage, and is only supported * NOTE: Currently, Metal argument buffer support is in beta stage, and is only supported
* on macOS 11.0 (Big Sur) or later, or on older versions of macOS using an Intel GPU. * on macOS 11.0 (Big Sur) or later, or on older versions of macOS using an Intel GPU.
* Metal argument buffers support is not available on iOS. Development to support iOS * Metal argument buffers support is not available on iOS. Development to support iOS
* and a wider combination of GPU's on older macOS versions is under way. * and a wider combination of GPU's on older macOS versions is under way.
* *
* The value of this parameter must be changed before creating a VkInstance, * The value of this parameter must be changed before creating a VkDevice,
* for the change to take effect. * for the change to take effect.
* *
* The initial value or this parameter is set by the * The initial value or this parameter is set by the
* MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS * MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS
* runtime environment variable or MoltenVK compile-time build setting. * runtime environment variable or MoltenVK compile-time build setting.
* If neither is set, this setting is enabled by default, and MoltenVK will not * If neither is set, this setting is set to
* use Metal argument buffers, and will bind resources to shaders discretely. * MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER by default,
* and MoltenVK will not use Metal argument buffers.
*/ */
VkBool32 useMetalArgumentBuffers; MVKUseMetalArgumentBuffers useMetalArgumentBuffers;
} MVKConfiguration; } MVKConfiguration;

View File

@ -96,6 +96,17 @@ typedef enum {
MVKSemaphoreStyleSingleQueue, MVKSemaphoreStyleSingleQueue,
} MVKSemaphoreStyle; } MVKSemaphoreStyle;
/** VkPhysicalDeviceVulkan12Features entries that did not originate in a prior extension. */
typedef struct MVKPhysicalDeviceVulkan12FeaturesNoExt {
VkBool32 samplerMirrorClampToEdge;
VkBool32 drawIndirectCount;
VkBool32 descriptorIndexing;
VkBool32 samplerFilterMinmax;
VkBool32 shaderOutputViewportIndex;
VkBool32 shaderOutputLayer;
VkBool32 subgroupBroadcastDynamicId;
} MVKPhysicalDeviceVulkan12FeaturesNoExt;
/** Represents a Vulkan physical GPU device. */ /** Represents a Vulkan physical GPU device. */
class MVKPhysicalDevice : public MVKDispatchableVulkanAPIObject { class MVKPhysicalDevice : public MVKDispatchableVulkanAPIObject {
@ -339,8 +350,10 @@ public:
/** Returns whether the MSL version is supported on this device. */ /** Returns whether the MSL version is supported on this device. */
bool mslVersionIsAtLeast(MTLLanguageVersion minVer) { return _metalFeatures.mslVersionEnum >= minVer; } bool mslVersionIsAtLeast(MTLLanguageVersion minVer) { return _metalFeatures.mslVersionEnum >= minVer; }
/** Returns whether this device is using Metal argument buffers. */ /** Returns whether this physical device supports Metal argument buffers. */
bool isUsingMetalArgumentBuffers() const { return _metalFeatures.argumentBuffers && mvkConfig().useMetalArgumentBuffers; }; bool supportsMetalArgumentBuffers() const {
return _metalFeatures.argumentBuffers && mvkConfig().useMetalArgumentBuffers != MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER;
};
/** /**
* Returns the start timestamps of a timestamp correlation. * Returns the start timestamps of a timestamp correlation.
@ -413,6 +426,7 @@ protected:
MVKInstance* _mvkInstance; MVKInstance* _mvkInstance;
const MVKExtensionList _supportedExtensions; const MVKExtensionList _supportedExtensions;
VkPhysicalDeviceFeatures _features; VkPhysicalDeviceFeatures _features;
MVKPhysicalDeviceVulkan12FeaturesNoExt _vulkan12FeaturesNoExt;
MVKPhysicalDeviceMetalFeatures _metalFeatures; MVKPhysicalDeviceMetalFeatures _metalFeatures;
VkPhysicalDeviceProperties _properties; VkPhysicalDeviceProperties _properties;
VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT _texelBuffAlignProperties; VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT _texelBuffAlignProperties;
@ -695,6 +709,9 @@ public:
/** Returns the underlying Metal device. */ /** Returns the underlying Metal device. */
inline id<MTLDevice> getMTLDevice() { return _physicalDevice->getMTLDevice(); } inline id<MTLDevice> getMTLDevice() { return _physicalDevice->getMTLDevice(); }
/** Returns whether this device is using Metal argument buffers. */
bool isUsingMetalArgumentBuffers() { return _isUsingMetalArgumentBuffers; };
/** /**
* Returns an autoreleased options object to be used when compiling MSL shaders. * Returns an autoreleased options object to be used when compiling MSL shaders.
* The useFastMath parameter is and-combined with MVKConfiguration::fastMathEnabled * The useFastMath parameter is and-combined with MVKConfiguration::fastMathEnabled
@ -787,6 +804,9 @@ public:
VkPhysicalDevice##structName##Features##extnSfx _enabled##structName##Features; VkPhysicalDevice##structName##Features##extnSfx _enabled##structName##Features;
#include "MVKDeviceFeatureStructs.def" #include "MVKDeviceFeatureStructs.def"
/** VkPhysicalDeviceVulkan12Features entries that did not originate in a prior extension available and enabled. */
MVKPhysicalDeviceVulkan12FeaturesNoExt _enabledVulkan12FeaturesNoExt;
/** 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;
@ -850,8 +870,8 @@ protected:
VkDescriptorSetLayoutSupport* pSupport, VkDescriptorSetLayoutSupport* pSupport,
VkDescriptorSetVariableDescriptorCountLayoutSupportEXT* pVarDescSetCountSupport); VkDescriptorSetVariableDescriptorCountLayoutSupportEXT* pVarDescSetCountSupport);
MVKPhysicalDevice* _physicalDevice; MVKPhysicalDevice* _physicalDevice = nullptr;
MVKCommandResourceFactory* _commandResourceFactory; MVKCommandResourceFactory* _commandResourceFactory = nullptr;
MVKSmallVector<MVKSmallVector<MVKQueue*, kMVKQueueCountPerQueueFamily>, kMVKQueueFamilyCount> _queuesByQueueFamilyIndex; MVKSmallVector<MVKSmallVector<MVKQueue*, kMVKQueueCountPerQueueFamily>, kMVKQueueFamilyCount> _queuesByQueueFamilyIndex;
MVKSmallVector<MVKResource*, 256> _resources; MVKSmallVector<MVKResource*, 256> _resources;
MVKSmallVector<MVKPrivateDataSlot*> _privateDataSlots; MVKSmallVector<MVKPrivateDataSlot*> _privateDataSlots;
@ -870,6 +890,7 @@ protected:
bool _logActivityPerformanceInline = false; bool _logActivityPerformanceInline = false;
bool _isPerformanceTracking = false; bool _isPerformanceTracking = false;
bool _isCurrentlyAutoGPUCapturing = false; bool _isCurrentlyAutoGPUCapturing = false;
bool _isUsingMetalArgumentBuffers = false;
}; };
@ -889,25 +910,25 @@ class MVKDeviceTrackingMixin {
public: public:
/** Returns the device for which this object was created. */ /** Returns the device for which this object was created. */
inline MVKDevice* getDevice() { return _device; } MVKDevice* getDevice() { return _device; }
/** Returns the physical device underlying this logical device. */ /** Returns the physical device underlying this logical device. */
inline MVKPhysicalDevice* getPhysicalDevice() { return _device->getPhysicalDevice(); } MVKPhysicalDevice* getPhysicalDevice() { return _device->getPhysicalDevice(); }
/** Returns the underlying Metal device. */ /** Returns the underlying Metal device. */
inline id<MTLDevice> getMTLDevice() { return _device->getMTLDevice(); } id<MTLDevice> getMTLDevice() { return _device->getMTLDevice(); }
/** Returns info about the pixel format supported by the physical device. */ /** Returns info about the pixel format supported by the physical device. */
inline MVKPixelFormats* getPixelFormats() { return _device->getPixelFormats(); } MVKPixelFormats* getPixelFormats() { return _device->getPixelFormats(); }
/** Returns whether this device is using Metal argument buffers. */ /** Returns whether this device is using Metal argument buffers. */
inline bool isUsingMetalArgumentBuffers() { return getPhysicalDevice()->isUsingMetalArgumentBuffers(); }; bool isUsingMetalArgumentBuffers() { return _device->isUsingMetalArgumentBuffers(); };
/** Returns whether this device is using one Metal argument buffer for each descriptor set, on multiple pipeline and pipeline stages. */ /** Returns whether this device is using one Metal argument buffer for each descriptor set, on multiple pipeline and pipeline stages. */
inline bool isUsingDescriptorSetMetalArgumentBuffers() { return isUsingMetalArgumentBuffers() && _device->_pMetalFeatures->descriptorSetArgumentBuffers; }; bool isUsingDescriptorSetMetalArgumentBuffers() { return isUsingMetalArgumentBuffers() && _device->_pMetalFeatures->descriptorSetArgumentBuffers; };
/** Returns whether this device is using one Metal argument buffer for each descriptor set-pipeline-stage combination. */ /** Returns whether this device is using one Metal argument buffer for each descriptor set-pipeline-stage combination. */
inline bool isUsingPipelineStageMetalArgumentBuffers() { return isUsingMetalArgumentBuffers() && !_device->_pMetalFeatures->descriptorSetArgumentBuffers; }; bool isUsingPipelineStageMetalArgumentBuffers() { return isUsingMetalArgumentBuffers() && !_device->_pMetalFeatures->descriptorSetArgumentBuffers; };
/** Constructs an instance for the specified device. */ /** Constructs an instance for the specified device. */
MVKDeviceTrackingMixin(MVKDevice* device) : _device(device) { assert(_device); } MVKDeviceTrackingMixin(MVKDevice* device) : _device(device) { assert(_device); }

View File

@ -116,16 +116,16 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
VkPhysicalDeviceVulkan12Features supportedFeats12 = { VkPhysicalDeviceVulkan12Features supportedFeats12 = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
.pNext = nullptr, .pNext = nullptr,
.samplerMirrorClampToEdge = _metalFeatures.samplerMirrorClampToEdge, .samplerMirrorClampToEdge = _vulkan12FeaturesNoExt.samplerMirrorClampToEdge,
.drawIndirectCount = false, // VK_KHR_draw_indirect_count .drawIndirectCount = _vulkan12FeaturesNoExt.drawIndirectCount,
.storageBuffer8BitAccess = true, .storageBuffer8BitAccess = true,
.uniformAndStorageBuffer8BitAccess = true, .uniformAndStorageBuffer8BitAccess = true,
.storagePushConstant8 = true, .storagePushConstant8 = true,
.shaderBufferInt64Atomics = false, // VK_KHR_shader_atomic_int64 .shaderBufferInt64Atomics = false,
.shaderSharedInt64Atomics = false, // VK_KHR_shader_atomic_int64 .shaderSharedInt64Atomics = false,
.shaderFloat16 = true, .shaderFloat16 = true,
.shaderInt8 = true, .shaderInt8 = true,
.descriptorIndexing = false, // Requires _metalFeatures.arrayOfTextures && _metalFeatures.arrayOfSamplers && shaderStorageBufferArrayNonUniformIndexing .descriptorIndexing = _vulkan12FeaturesNoExt.descriptorIndexing,
.shaderInputAttachmentArrayDynamicIndexing = _metalFeatures.arrayOfTextures, .shaderInputAttachmentArrayDynamicIndexing = _metalFeatures.arrayOfTextures,
.shaderUniformTexelBufferArrayDynamicIndexing = _metalFeatures.arrayOfTextures, .shaderUniformTexelBufferArrayDynamicIndexing = _metalFeatures.arrayOfTextures,
.shaderStorageTexelBufferArrayDynamicIndexing = _metalFeatures.arrayOfTextures, .shaderStorageTexelBufferArrayDynamicIndexing = _metalFeatures.arrayOfTextures,
@ -146,7 +146,7 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
.descriptorBindingPartiallyBound = true, .descriptorBindingPartiallyBound = true,
.descriptorBindingVariableDescriptorCount = true, .descriptorBindingVariableDescriptorCount = true,
.runtimeDescriptorArray = true, .runtimeDescriptorArray = true,
.samplerFilterMinmax = false, // VK_EXT_sampler_filter_minmax .samplerFilterMinmax = _vulkan12FeaturesNoExt.samplerFilterMinmax,
.scalarBlockLayout = true, .scalarBlockLayout = true,
.imagelessFramebuffer = true, .imagelessFramebuffer = true,
.uniformBufferStandardLayout = true, .uniformBufferStandardLayout = true,
@ -157,12 +157,12 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
.bufferDeviceAddress = mvkOSVersionIsAtLeast(12.05, 16.0), .bufferDeviceAddress = mvkOSVersionIsAtLeast(12.05, 16.0),
.bufferDeviceAddressCaptureReplay = false, .bufferDeviceAddressCaptureReplay = false,
.bufferDeviceAddressMultiDevice = false, .bufferDeviceAddressMultiDevice = false,
.vulkanMemoryModel = false, // VK_KHR_vulkan_memory_model .vulkanMemoryModel = false,
.vulkanMemoryModelDeviceScope = false, // VK_KHR_vulkan_memory_model .vulkanMemoryModelDeviceScope = false,
.vulkanMemoryModelAvailabilityVisibilityChains = false, // VK_KHR_vulkan_memory_model .vulkanMemoryModelAvailabilityVisibilityChains = false,
.shaderOutputViewportIndex = true, .shaderOutputViewportIndex = _vulkan12FeaturesNoExt.shaderOutputViewportIndex,
.shaderOutputLayer = true, .shaderOutputLayer = _vulkan12FeaturesNoExt.shaderOutputLayer,
.subgroupBroadcastDynamicId = true, .subgroupBroadcastDynamicId = _vulkan12FeaturesNoExt.subgroupBroadcastDynamicId,
}; };
features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; features->sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
@ -295,6 +295,12 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
shaderDrawParamsFeatures->shaderDrawParameters = supportedFeats11.shaderDrawParameters; shaderDrawParamsFeatures->shaderDrawParameters = supportedFeats11.shaderDrawParameters;
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES: {
auto* i64Features = (VkPhysicalDeviceShaderAtomicInt64Features*)next;
i64Features->shaderBufferInt64Atomics = supportedFeats12.shaderBufferInt64Atomics;
i64Features->shaderSharedInt64Atomics = supportedFeats12.shaderSharedInt64Atomics;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES: {
auto* f16Features = (VkPhysicalDeviceShaderFloat16Int8Features*)next; auto* f16Features = (VkPhysicalDeviceShaderFloat16Int8Features*)next;
f16Features->shaderFloat16 = supportedFeats12.shaderFloat16; f16Features->shaderFloat16 = supportedFeats12.shaderFloat16;
@ -333,6 +339,13 @@ void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures2* features) {
varPtrFeatures->variablePointers = supportedFeats11.variablePointers; varPtrFeatures->variablePointers = supportedFeats11.variablePointers;
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES: {
auto* vmmFeatures = (VkPhysicalDeviceVulkanMemoryModelFeatures*)next;
vmmFeatures->vulkanMemoryModel = supportedFeats12.vulkanMemoryModel;
vmmFeatures->vulkanMemoryModelDeviceScope = supportedFeats12.vulkanMemoryModelDeviceScope;
vmmFeatures->vulkanMemoryModelAvailabilityVisibilityChains = supportedFeats12.vulkanMemoryModelAvailabilityVisibilityChains;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR: {
auto* barycentricFeatures = (VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR*)next; auto* barycentricFeatures = (VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR*)next;
barycentricFeatures->fragmentShaderBarycentric = true; barycentricFeatures->fragmentShaderBarycentric = true;
@ -401,7 +414,7 @@ void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties* properties) {
void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) { void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) {
uint32_t uintMax = std::numeric_limits<uint32_t>::max(); uint32_t uintMax = std::numeric_limits<uint32_t>::max();
uint32_t maxSamplerCnt = getMaxSamplerCount(); uint32_t maxSamplerCnt = getMaxSamplerCount();
bool isTier2 = isUsingMetalArgumentBuffers() && (_metalFeatures.argumentBuffersTier >= MTLArgumentBuffersTier2); bool isTier2 = supportsMetalArgumentBuffers() && (_metalFeatures.argumentBuffersTier >= MTLArgumentBuffersTier2);
// Create a SSOT for these Vulkan 1.1 properties, which can be queried via two mechanisms here. // Create a SSOT for these Vulkan 1.1 properties, which can be queried via two mechanisms here.
VkPhysicalDeviceVulkan11Properties supportedProps11; VkPhysicalDeviceVulkan11Properties supportedProps11;
@ -475,8 +488,8 @@ void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) {
supportedProps12.supportedStencilResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // Metal allows you to set the stencil resolve filter to either Sample0 or the same sample used for depth resolve. This is impossible to express in Vulkan. supportedProps12.supportedStencilResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT; // Metal allows you to set the stencil resolve filter to either Sample0 or the same sample used for depth resolve. This is impossible to express in Vulkan.
supportedProps12.independentResolveNone = true; supportedProps12.independentResolveNone = true;
supportedProps12.independentResolve = true; supportedProps12.independentResolve = true;
supportedProps12.filterMinmaxSingleComponentFormats = false; // VK_EXT_sampler_filter_minmax; supportedProps12.filterMinmaxSingleComponentFormats = false;
supportedProps12.filterMinmaxImageComponentMapping = false; // VK_EXT_sampler_filter_minmax; supportedProps12.filterMinmaxImageComponentMapping = false;
supportedProps12.maxTimelineSemaphoreValueDifference = std::numeric_limits<uint64_t>::max(); supportedProps12.maxTimelineSemaphoreValueDifference = std::numeric_limits<uint64_t>::max();
supportedProps12.framebufferIntegerColorSampleCounts = _metalFeatures.supportedSampleCounts; supportedProps12.framebufferIntegerColorSampleCounts = _metalFeatures.supportedSampleCounts;
@ -554,6 +567,12 @@ void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) {
physicalDeviceDriverProps->conformanceVersion = supportedProps12.conformanceVersion; physicalDeviceDriverProps->conformanceVersion = supportedProps12.conformanceVersion;
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES: {
auto* sfmmProps = (VkPhysicalDeviceSamplerFilterMinmaxProperties*)next;
sfmmProps->filterMinmaxSingleComponentFormats = supportedProps12.filterMinmaxSingleComponentFormats;
sfmmProps->filterMinmaxImageComponentMapping = supportedProps12.filterMinmaxImageComponentMapping;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES: {
auto* timelineSem4Props = (VkPhysicalDeviceTimelineSemaphoreProperties*)next; auto* timelineSem4Props = (VkPhysicalDeviceTimelineSemaphoreProperties*)next;
timelineSem4Props->maxTimelineSemaphoreValueDifference = supportedProps12.maxTimelineSemaphoreValueDifference; timelineSem4Props->maxTimelineSemaphoreValueDifference = supportedProps12.maxTimelineSemaphoreValueDifference;
@ -1972,9 +1991,7 @@ void MVKPhysicalDevice::initFeatures() {
_features.shaderSampledImageArrayDynamicIndexing = _metalFeatures.arrayOfTextures; _features.shaderSampledImageArrayDynamicIndexing = _metalFeatures.arrayOfTextures;
_features.textureCompressionBC = mvkSupportsBCTextureCompression(_mtlDevice); _features.textureCompressionBC = mvkSupportsBCTextureCompression(_mtlDevice);
if (_metalFeatures.indirectDrawing && _metalFeatures.baseVertexInstanceDrawing) { _features.drawIndirectFirstInstance = _metalFeatures.indirectDrawing && _metalFeatures.baseVertexInstanceDrawing;
_features.drawIndirectFirstInstance = true;
}
#if MVK_TVOS #if MVK_TVOS
_features.textureCompressionETC2 = true; _features.textureCompressionETC2 = true;
@ -2073,6 +2090,17 @@ void MVKPhysicalDevice::initFeatures() {
_features.textureCompressionASTC_LDR = true; _features.textureCompressionASTC_LDR = true;
} }
#endif #endif
// Additional non-extension Vulkan 1.2 features.
mvkClear(&_vulkan12FeaturesNoExt); // Start with everything cleared
_vulkan12FeaturesNoExt.samplerMirrorClampToEdge = _metalFeatures.samplerMirrorClampToEdge;
_vulkan12FeaturesNoExt.drawIndirectCount = false;
_vulkan12FeaturesNoExt.descriptorIndexing = true;
_vulkan12FeaturesNoExt.samplerFilterMinmax = false;
_vulkan12FeaturesNoExt.shaderOutputViewportIndex = _features.multiViewport;
_vulkan12FeaturesNoExt.shaderOutputLayer = _metalFeatures.layeredRendering;
_vulkan12FeaturesNoExt.subgroupBroadcastDynamicId = _metalFeatures.simdPermute || _metalFeatures.quadPermute;
} }
@ -2737,7 +2765,7 @@ void MVKPhysicalDevice::initPipelineCacheUUID() {
// Next 4 bytes contains flags based on enabled Metal features that // Next 4 bytes contains flags based on enabled Metal features that
// might affect the contents of the pipeline cache (mostly MSL content). // might affect the contents of the pipeline cache (mostly MSL content).
uint32_t mtlFeatures = 0; uint32_t mtlFeatures = 0;
mtlFeatures |= isUsingMetalArgumentBuffers() << 0; mtlFeatures |= supportsMetalArgumentBuffers() << 0;
*(uint32_t*)&_properties.pipelineCacheUUID[uuidComponentOffset] = NSSwapHostIntToBig(mtlFeatures); *(uint32_t*)&_properties.pipelineCacheUUID[uuidComponentOffset] = NSSwapHostIntToBig(mtlFeatures);
uuidComponentOffset += sizeof(mtlFeatures); uuidComponentOffset += sizeof(mtlFeatures);
} }
@ -2991,7 +3019,7 @@ uint64_t MVKPhysicalDevice::getCurrentAllocatedSize() {
// objects that can be created within the app. When not using argument buffers, no such // objects that can be created within the app. When not using argument buffers, no such
// limit is imposed. This has been verified with testing up to 1M MTLSamplerStates. // limit is imposed. This has been verified with testing up to 1M MTLSamplerStates.
uint32_t MVKPhysicalDevice::getMaxSamplerCount() { uint32_t MVKPhysicalDevice::getMaxSamplerCount() {
if (isUsingMetalArgumentBuffers()) { if (supportsMetalArgumentBuffers()) {
return ([_mtlDevice respondsToSelector: @selector(maxArgumentBufferSamplerCount)] return ([_mtlDevice respondsToSelector: @selector(maxArgumentBufferSamplerCount)]
? (uint32_t)_mtlDevice.maxArgumentBufferSamplerCount : 1024); ? (uint32_t)_mtlDevice.maxArgumentBufferSamplerCount : 1024);
} else { } else {
@ -4182,7 +4210,7 @@ id<MTLSamplerState> MVKDevice::getDefaultMTLSamplerState() {
if ( !_defaultMTLSamplerState ) { if ( !_defaultMTLSamplerState ) {
@autoreleasepool { @autoreleasepool {
MTLSamplerDescriptor* mtlSampDesc = [[MTLSamplerDescriptor new] autorelease]; MTLSamplerDescriptor* mtlSampDesc = [[MTLSamplerDescriptor new] autorelease];
mtlSampDesc.supportArgumentBuffers = _physicalDevice->isUsingMetalArgumentBuffers(); mtlSampDesc.supportArgumentBuffers = isUsingMetalArgumentBuffers();
_defaultMTLSamplerState = [getMTLDevice() newSamplerStateWithDescriptor: mtlSampDesc]; // retained _defaultMTLSamplerState = [getMTLDevice() newSamplerStateWithDescriptor: mtlSampDesc]; // retained
} }
} }
@ -4347,7 +4375,8 @@ void MVKDevice::getMetalObjects(VkExportMetalObjectsInfoEXT* pMetalObjectsInfo)
MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo* pCreateInfo) : _enabledExtensions(this) { MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo* pCreateInfo) : _enabledExtensions(this) {
// If the physical device is lost, bail. // If the physical device is lost, bail.
// Must have initialized everything accessed in destructor to null.
if (physicalDevice->getConfigurationResult() != VK_SUCCESS) { if (physicalDevice->getConfigurationResult() != VK_SUCCESS) {
setConfigurationResult(physicalDevice->getConfigurationResult()); setConfigurationResult(physicalDevice->getConfigurationResult());
return; return;
@ -4360,11 +4389,13 @@ MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo
initQueues(pCreateInfo); initQueues(pCreateInfo);
reservePrivateData(pCreateInfo); reservePrivateData(pCreateInfo);
_globalVisibilityResultMTLBuffer = nil; // After enableExtensions && enableFeatures
_globalVisibilityQueryCount = 0; // Use Metal arg buffs if available, and either config wants them always,
// or config wants them with descriptor indexing and descriptor indexing has been enabled.
_defaultMTLSamplerState = nil; _isUsingMetalArgumentBuffers = (_physicalDevice->supportsMetalArgumentBuffers() &&
_dummyBlitMTLBuffer = nil; (mvkConfig().useMetalArgumentBuffers == MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_ALWAYS ||
(mvkConfig().useMetalArgumentBuffers == MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_DESCRIPTOR_INDEXING &&
(_enabledVulkan12FeaturesNoExt.descriptorIndexing || _enabledExtensions.vk_EXT_descriptor_indexing.enabled))));
_commandResourceFactory = new MVKCommandResourceFactory(this); _commandResourceFactory = new MVKCommandResourceFactory(this);
@ -4470,6 +4501,8 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
#include "MVKDeviceFeatureStructs.def" #include "MVKDeviceFeatureStructs.def"
mvkClear(&_enabledVulkan12FeaturesNoExt);
sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
mvkClear(&_enabledFeatures); mvkClear(&_enabledFeatures);
VkPhysicalDeviceFeatures2 pdFeats2; VkPhysicalDeviceFeatures2 pdFeats2;
@ -4518,19 +4551,29 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES: {
auto& pdvulkan12FeaturesNoExt = _physicalDevice->_vulkan12FeaturesNoExt;
auto* requestedFeatures = (VkPhysicalDeviceVulkan12Features*)next; auto* requestedFeatures = (VkPhysicalDeviceVulkan12Features*)next;
enableFeatures(&_enabledVulkan12FeaturesNoExt.samplerMirrorClampToEdge,
&requestedFeatures->samplerMirrorClampToEdge,
&pdvulkan12FeaturesNoExt.samplerMirrorClampToEdge, 2);
enableFeatures(&_enabled8BitStorageFeatures.storageBuffer8BitAccess, enableFeatures(&_enabled8BitStorageFeatures.storageBuffer8BitAccess,
&requestedFeatures->storageBuffer8BitAccess, &requestedFeatures->storageBuffer8BitAccess,
&pd8BitStorageFeatures.storageBuffer8BitAccess, 3); &pd8BitStorageFeatures.storageBuffer8BitAccess, 3);
// enableFeatures(&_enabledShaderAtomicInt64Features.shaderBufferInt64Atomics, //VK_KHR_shader_atomic_int64 enableFeatures(&_enabledShaderAtomicInt64Features.shaderBufferInt64Atomics,
// &requestedFeatures->shaderBufferInt64Atomics, &requestedFeatures->shaderBufferInt64Atomics,
// &pdShaderAtomicInt64Features.shaderBufferInt64Atomics, 2); &pdShaderAtomicInt64Features.shaderBufferInt64Atomics, 2);
enableFeatures(&_enabledShaderFloat16Int8Features.shaderFloat16, enableFeatures(&_enabledShaderFloat16Int8Features.shaderFloat16,
&requestedFeatures->shaderFloat16, &requestedFeatures->shaderFloat16,
&pdShaderFloat16Int8Features.shaderFloat16, 2); &pdShaderFloat16Int8Features.shaderFloat16, 2);
enableFeatures(&_enabledVulkan12FeaturesNoExt.descriptorIndexing,
&requestedFeatures->descriptorIndexing,
&pdvulkan12FeaturesNoExt.descriptorIndexing, 1);
enableFeatures(&_enabledDescriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing, enableFeatures(&_enabledDescriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing,
&requestedFeatures->shaderInputAttachmentArrayDynamicIndexing, &requestedFeatures->shaderInputAttachmentArrayDynamicIndexing,
&pdDescriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing, 20); &pdDescriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing, 20);
enableFeatures(&_enabledVulkan12FeaturesNoExt.samplerFilterMinmax,
&requestedFeatures->samplerFilterMinmax,
&pdvulkan12FeaturesNoExt.samplerFilterMinmax, 1);
enableFeatures(&_enabledScalarBlockLayoutFeatures.scalarBlockLayout, enableFeatures(&_enabledScalarBlockLayoutFeatures.scalarBlockLayout,
&requestedFeatures->scalarBlockLayout, &requestedFeatures->scalarBlockLayout,
&pdScalarBlockLayoutFeatures.scalarBlockLayout, 1); &pdScalarBlockLayoutFeatures.scalarBlockLayout, 1);
@ -4555,9 +4598,12 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
enableFeatures(&_enabledBufferDeviceAddressFeatures.bufferDeviceAddress, enableFeatures(&_enabledBufferDeviceAddressFeatures.bufferDeviceAddress,
&requestedFeatures->bufferDeviceAddress, &requestedFeatures->bufferDeviceAddress,
&pdBufferDeviceAddressFeatures.bufferDeviceAddress, 3); &pdBufferDeviceAddressFeatures.bufferDeviceAddress, 3);
// enableFeatures(&_enabledVulkanMemoryModelFeatures.vulkanMemoryModel, // VK_KHR_vulkan_memory_model enableFeatures(&_enabledVulkanMemoryModelFeatures.vulkanMemoryModel,
// &requestedFeatures->vulkanMemoryModel, &requestedFeatures->vulkanMemoryModel,
// &pdVulkanMemoryModelFeatures.vulkanMemoryModel, 3); &pdVulkanMemoryModelFeatures.vulkanMemoryModel, 3);
enableFeatures(&_enabledVulkan12FeaturesNoExt.shaderOutputViewportIndex,
&requestedFeatures->shaderOutputViewportIndex,
&pdvulkan12FeaturesNoExt.shaderOutputViewportIndex, 3);
break; break;
} }
@ -4657,7 +4703,7 @@ MVKDevice::~MVKDevice() {
for (auto& queues : _queuesByQueueFamilyIndex) { for (auto& queues : _queuesByQueueFamilyIndex) {
mvkDestroyContainerContents(queues); mvkDestroyContainerContents(queues);
} }
_commandResourceFactory->destroy(); if (_commandResourceFactory) { _commandResourceFactory->destroy(); }
[_globalVisibilityResultMTLBuffer release]; [_globalVisibilityResultMTLBuffer release];
[_defaultMTLSamplerState release]; [_defaultMTLSamplerState release];

View File

@ -51,6 +51,7 @@ MVK_DEVICE_FEATURE(SamplerYcbcrConversion, SAMPLER_YCBCR_CONVERSION,
MVK_DEVICE_FEATURE(ScalarBlockLayout, SCALAR_BLOCK_LAYOUT, 1) MVK_DEVICE_FEATURE(ScalarBlockLayout, SCALAR_BLOCK_LAYOUT, 1)
MVK_DEVICE_FEATURE(SeparateDepthStencilLayouts, SEPARATE_DEPTH_STENCIL_LAYOUTS, 1) MVK_DEVICE_FEATURE(SeparateDepthStencilLayouts, SEPARATE_DEPTH_STENCIL_LAYOUTS, 1)
MVK_DEVICE_FEATURE(ShaderDrawParameters, SHADER_DRAW_PARAMETERS, 1) MVK_DEVICE_FEATURE(ShaderDrawParameters, SHADER_DRAW_PARAMETERS, 1)
MVK_DEVICE_FEATURE(ShaderAtomicInt64, SHADER_ATOMIC_INT64, 2)
MVK_DEVICE_FEATURE(ShaderFloat16Int8, SHADER_FLOAT16_INT8, 2) MVK_DEVICE_FEATURE(ShaderFloat16Int8, SHADER_FLOAT16_INT8, 2)
MVK_DEVICE_FEATURE(ShaderSubgroupExtendedTypes, SHADER_SUBGROUP_EXTENDED_TYPES, 1) MVK_DEVICE_FEATURE(ShaderSubgroupExtendedTypes, SHADER_SUBGROUP_EXTENDED_TYPES, 1)
MVK_DEVICE_FEATURE(SubgroupSizeControl, SUBGROUP_SIZE_CONTROL, 2) MVK_DEVICE_FEATURE(SubgroupSizeControl, SUBGROUP_SIZE_CONTROL, 2)
@ -58,6 +59,7 @@ MVK_DEVICE_FEATURE(TextureCompressionASTCHDR, TEXTURE_COMPRESSION_ASTC_HDR,
MVK_DEVICE_FEATURE(TimelineSemaphore, TIMELINE_SEMAPHORE, 1) MVK_DEVICE_FEATURE(TimelineSemaphore, TIMELINE_SEMAPHORE, 1)
MVK_DEVICE_FEATURE(UniformBufferStandardLayout, UNIFORM_BUFFER_STANDARD_LAYOUT, 1) MVK_DEVICE_FEATURE(UniformBufferStandardLayout, UNIFORM_BUFFER_STANDARD_LAYOUT, 1)
MVK_DEVICE_FEATURE(VariablePointer, VARIABLE_POINTER, 2) MVK_DEVICE_FEATURE(VariablePointer, VARIABLE_POINTER, 2)
MVK_DEVICE_FEATURE(VulkanMemoryModel, VULKAN_MEMORY_MODEL, 3)
MVK_DEVICE_FEATURE_EXTN(FragmentShaderBarycentric, FRAGMENT_SHADER_BARYCENTRIC, KHR, 1) MVK_DEVICE_FEATURE_EXTN(FragmentShaderBarycentric, FRAGMENT_SHADER_BARYCENTRIC, KHR, 1)
MVK_DEVICE_FEATURE_EXTN(PortabilitySubset, PORTABILITY_SUBSET, KHR, 15) MVK_DEVICE_FEATURE_EXTN(PortabilitySubset, PORTABILITY_SUBSET, KHR, 15)
MVK_DEVICE_FEATURE_EXTN(FragmentShaderInterlock, FRAGMENT_SHADER_INTERLOCK, EXT, 3) MVK_DEVICE_FEATURE_EXTN(FragmentShaderInterlock, FRAGMENT_SHADER_INTERLOCK, EXT, 3)

View File

@ -2076,6 +2076,7 @@ MTLSamplerDescriptor* MVKSampler::newMTLSamplerDescriptor(const VkSamplerCreateI
MVKSampler::MVKSampler(MVKDevice* device, const VkSamplerCreateInfo* pCreateInfo) : MVKVulkanAPIDeviceObject(device) { MVKSampler::MVKSampler(MVKDevice* device, const VkSamplerCreateInfo* pCreateInfo) : MVKVulkanAPIDeviceObject(device) {
_ycbcrConversion = NULL; _ycbcrConversion = NULL;
const VkSamplerReductionModeCreateInfo* pSampReductInfo = nullptr;
for (const auto* next = (const VkBaseInStructure*)pCreateInfo->pNext; next; next = next->pNext) { for (const auto* next = (const VkBaseInStructure*)pCreateInfo->pNext; next; next = next->pNext) {
switch (next->sType) { switch (next->sType) {
case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR: { case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR: {
@ -2083,6 +2084,10 @@ MVKSampler::MVKSampler(MVKDevice* device, const VkSamplerCreateInfo* pCreateInfo
_ycbcrConversion = (MVKSamplerYcbcrConversion*)(sampConvInfo->conversion); _ycbcrConversion = (MVKSamplerYcbcrConversion*)(sampConvInfo->conversion);
break; break;
} }
case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO: {
pSampReductInfo = (const VkSamplerReductionModeCreateInfo*)next;
break;
}
default: default:
break; break;
} }

View File

@ -51,6 +51,7 @@ MVK_EXTENSION(KHR_depth_stencil_resolve, KHR_DEPTH_STENCIL_RESOLVE,
MVK_EXTENSION(KHR_descriptor_update_template, KHR_DESCRIPTOR_UPDATE_TEMPLATE, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_descriptor_update_template, KHR_DESCRIPTOR_UPDATE_TEMPLATE, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_device_group, KHR_DEVICE_GROUP, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_device_group, KHR_DEVICE_GROUP, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_device_group_creation, KHR_DEVICE_GROUP_CREATION, INSTANCE, 10.11, 8.0) MVK_EXTENSION(KHR_device_group_creation, KHR_DEVICE_GROUP_CREATION, INSTANCE, 10.11, 8.0)
MVK_EXTENSION(KHR_draw_indirect_count, KHR_DRAW_INDIRECT_COUNT, DEVICE, MVK_NA, MVK_NA)
MVK_EXTENSION(KHR_driver_properties, KHR_DRIVER_PROPERTIES, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_driver_properties, KHR_DRIVER_PROPERTIES, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_dynamic_rendering, KHR_DYNAMIC_RENDERING, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_dynamic_rendering, KHR_DYNAMIC_RENDERING, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_external_fence, KHR_EXTERNAL_FENCE, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_external_fence, KHR_EXTERNAL_FENCE, DEVICE, 10.11, 8.0)
@ -75,6 +76,7 @@ MVK_EXTENSION(KHR_relaxed_block_layout, KHR_RELAXED_BLOCK_LAYOUT,
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_separate_depth_stencil_layouts, KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS, DEVICE, 10.11, 8.0)
MVK_EXTENSION(KHR_shader_atomic_int64, KHR_SHADER_ATOMIC_INT64, DEVICE, MVK_NA, MVK_NA)
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_float_controls, KHR_SHADER_FLOAT_CONTROLS, DEVICE, 10.11, 8.0) MVK_EXTENSION(KHR_shader_float_controls, KHR_SHADER_FLOAT_CONTROLS, 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)
@ -86,6 +88,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(KHR_vulkan_memory_model, KHR_VULKAN_MEMORY_MODEL, DEVICE, MVK_NA, MVK_NA)
MVK_EXTENSION(EXT_buffer_device_address, EXT_BUFFER_DEVICE_ADDRESS, DEVICE, 12.05, 16.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)
@ -103,6 +106,7 @@ MVK_EXTENSION(EXT_post_depth_coverage, EXT_POST_DEPTH_COVERAGE,
MVK_EXTENSION(EXT_private_data, EXT_PRIVATE_DATA, DEVICE, 10.11, 8.0) MVK_EXTENSION(EXT_private_data, EXT_PRIVATE_DATA, DEVICE, 10.11, 8.0)
MVK_EXTENSION(EXT_robustness2, EXT_ROBUSTNESS_2, DEVICE, 10.11, 8.0) MVK_EXTENSION(EXT_robustness2, EXT_ROBUSTNESS_2, DEVICE, 10.11, 8.0)
MVK_EXTENSION(EXT_sample_locations, EXT_SAMPLE_LOCATIONS, DEVICE, 10.13, 11.0) MVK_EXTENSION(EXT_sample_locations, EXT_SAMPLE_LOCATIONS, DEVICE, 10.13, 11.0)
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_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_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_stencil_export, EXT_SHADER_STENCIL_EXPORT, DEVICE, 10.14, 12.0)
@ -112,6 +116,7 @@ MVK_EXTENSION(EXT_swapchain_colorspace, EXT_SWAPCHAIN_COLOR_SPACE,
MVK_EXTENSION(EXT_texel_buffer_alignment, EXT_TEXEL_BUFFER_ALIGNMENT, DEVICE, 10.13, 11.0) MVK_EXTENSION(EXT_texel_buffer_alignment, EXT_TEXEL_BUFFER_ALIGNMENT, DEVICE, 10.13, 11.0)
MVK_EXTENSION(EXT_texture_compression_astc_hdr, EXT_TEXTURE_COMPRESSION_ASTC_HDR, DEVICE, 11.0, 13.0) MVK_EXTENSION(EXT_texture_compression_astc_hdr, EXT_TEXTURE_COMPRESSION_ASTC_HDR, DEVICE, 11.0, 13.0)
MVK_EXTENSION(EXT_vertex_attribute_divisor, EXT_VERTEX_ATTRIBUTE_DIVISOR, DEVICE, 10.11, 8.0) MVK_EXTENSION(EXT_vertex_attribute_divisor, EXT_VERTEX_ATTRIBUTE_DIVISOR, DEVICE, 10.11, 8.0)
MVK_EXTENSION(AMD_draw_indirect_count, AMD_DRAW_INDIRECT_COUNT, DEVICE, MVK_NA, MVK_NA)
MVK_EXTENSION(AMD_gpu_shader_half_float, AMD_GPU_SHADER_HALF_FLOAT, DEVICE, 10.11, 8.0) MVK_EXTENSION(AMD_gpu_shader_half_float, AMD_GPU_SHADER_HALF_FLOAT, DEVICE, 10.11, 8.0)
MVK_EXTENSION(AMD_negative_viewport_height, AMD_NEGATIVE_VIEWPORT_HEIGHT, DEVICE, 10.11, 8.0) MVK_EXTENSION(AMD_negative_viewport_height, AMD_NEGATIVE_VIEWPORT_HEIGHT, DEVICE, 10.11, 8.0)
MVK_EXTENSION(AMD_shader_image_load_store_lod, AMD_SHADER_IMAGE_LOAD_STORE_LOD, DEVICE, 11.0, 8.0) MVK_EXTENSION(AMD_shader_image_load_store_lod, AMD_SHADER_IMAGE_LOAD_STORE_LOD, DEVICE, 11.0, 8.0)

View File

@ -61,7 +61,7 @@ static void mvkInitConfigFromEnvVars() {
MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.apiVersionToAdvertise, MVK_CONFIG_API_VERSION_TO_ADVERTISE); MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.apiVersionToAdvertise, MVK_CONFIG_API_VERSION_TO_ADVERTISE);
MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.advertiseExtensions, MVK_CONFIG_ADVERTISE_EXTENSIONS); MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.advertiseExtensions, MVK_CONFIG_ADVERTISE_EXTENSIONS);
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.resumeLostDevice, MVK_CONFIG_RESUME_LOST_DEVICE); MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.resumeLostDevice, MVK_CONFIG_RESUME_LOST_DEVICE);
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.useMetalArgumentBuffers, MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS); MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.useMetalArgumentBuffers, MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS);
mvkSetConfig(evCfg); mvkSetConfig(evCfg);
} }

View File

@ -280,5 +280,5 @@ void mvkSetConfig(const MVKConfiguration& mvkConfig);
/** Support Metal argument buffers. Disabled by default. */ /** Support Metal argument buffers. Disabled by default. */
#ifndef MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS #ifndef MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS
# define MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS 0 # define MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS_NEVER
#endif #endif

View File

@ -109,13 +109,17 @@
isEnabled = "NO"> isEnabled = "NO">
</CommandLineArgument> </CommandLineArgument>
<CommandLineArgument <CommandLineArgument
argument = "-XS" argument = "-mab"
isEnabled = "NO"> isEnabled = "NO">
</CommandLineArgument> </CommandLineArgument>
<CommandLineArgument <CommandLineArgument
argument = "-l" argument = "-l"
isEnabled = "YES"> isEnabled = "YES">
</CommandLineArgument> </CommandLineArgument>
<CommandLineArgument
argument = "-XS"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument <CommandLineArgument
argument = "-p" argument = "-p"
isEnabled = "NO"> isEnabled = "NO">

View File

@ -219,6 +219,9 @@ bool MoltenVKShaderConverterTool::convertSPIRV(const vector<uint32_t>& spv,
mslContext.options.mslOptions.platform = _mslPlatform; mslContext.options.mslOptions.platform = _mslPlatform;
mslContext.options.mslOptions.set_msl_version(_mslVersionMajor, _mslVersionMinor, _mslVersionPatch); mslContext.options.mslOptions.set_msl_version(_mslVersionMajor, _mslVersionMinor, _mslVersionPatch);
mslContext.options.shouldFlipVertexY = _shouldFlipVertexY; mslContext.options.shouldFlipVertexY = _shouldFlipVertexY;
mslContext.options.mslOptions.argument_buffers = _useMetalArgumentBuffers;
mslContext.options.mslOptions.force_active_argument_buffer_resources = _useMetalArgumentBuffers;
mslContext.options.mslOptions.pad_argument_buffer_resources = _useMetalArgumentBuffers;
SPIRVToMSLConverter spvConverter; SPIRVToMSLConverter spvConverter;
spvConverter.setSPIRV(spv); spvConverter.setSPIRV(spv);
@ -364,6 +367,7 @@ void MoltenVKShaderConverterTool::showUsage() {
log(" May be omitted for defaults (\"cp cmp comp compute kn kl krn kern kernel\")."); log(" May be omitted for defaults (\"cp cmp comp compute kn kl krn kern kernel\").");
log(" -sx \"fileExtns\" - List of SPIR-V shader file extensions."); log(" -sx \"fileExtns\" - List of SPIR-V shader file extensions.");
log(" May be omitted for defaults (\"spv spirv\")."); log(" May be omitted for defaults (\"spv spirv\").");
log(" -mab - Use Metal Argument Buffers to hold resources in the shaders.");
log(" -l - Log the conversion results to the console (to aid debugging)."); log(" -l - Log the conversion results to the console (to aid debugging).");
log(" -p - Log the performance of the shader conversions."); log(" -p - Log the performance of the shader conversions.");
log(" -q - Quiet mode. Stops logging of informational messages."); log(" -q - Quiet mode. Stops logging of informational messages.");
@ -419,18 +423,25 @@ MoltenVKShaderConverterTool::MoltenVKShaderConverterTool(int argc, const char* a
_shouldReportPerformance = false; _shouldReportPerformance = false;
_shouldOutputAsHeaders = false; _shouldOutputAsHeaders = false;
_quietMode = false; _quietMode = false;
_useMetalArgumentBuffers = false;
_mslVersionMajor = 2; if (mvkOSVersionIsAtLeast(13.0)) {
_mslVersionMajor = 3;
if (mvkOSVersionIsAtLeast(12.0)) { _mslVersionMinor = 0;
} else if (mvkOSVersionIsAtLeast(12.0)) {
_mslVersionMajor = 2;
_mslVersionMinor = 4; _mslVersionMinor = 4;
} else if (mvkOSVersionIsAtLeast(11.0)) { } else if (mvkOSVersionIsAtLeast(11.0)) {
_mslVersionMajor = 2;
_mslVersionMinor = 3; _mslVersionMinor = 3;
} else if (mvkOSVersionIsAtLeast(10.15)) { } else if (mvkOSVersionIsAtLeast(10.15)) {
_mslVersionMajor = 2;
_mslVersionMinor = 2; _mslVersionMinor = 2;
} else if (mvkOSVersionIsAtLeast(10.14)) { } else if (mvkOSVersionIsAtLeast(10.14)) {
_mslVersionMajor = 2;
_mslVersionMinor = 1; _mslVersionMinor = 1;
} else if (mvkOSVersionIsAtLeast(10.13)) { } else if (mvkOSVersionIsAtLeast(10.13)) {
_mslVersionMajor = 2;
_mslVersionMinor = 0; _mslVersionMinor = 0;
} else if (mvkOSVersionIsAtLeast(10.12)) { } else if (mvkOSVersionIsAtLeast(10.12)) {
_mslVersionMajor = 1; _mslVersionMajor = 1;
@ -633,6 +644,11 @@ bool MoltenVKShaderConverterTool::parseArgs(int argc, const char* argv[]) {
continue; continue;
} }
if(equal(arg, "-mab", true)) {
_useMetalArgumentBuffers = true;
continue;
}
if(equal(arg, "-l", true)) { if(equal(arg, "-l", true)) {
_shouldLogConversions = true; _shouldLogConversions = true;
continue; continue;

View File

@ -123,6 +123,7 @@ namespace mvk {
bool _shouldReportPerformance; bool _shouldReportPerformance;
bool _shouldOutputAsHeaders; bool _shouldOutputAsHeaders;
bool _quietMode; bool _quietMode;
bool _useMetalArgumentBuffers;
}; };

View File

@ -106,7 +106,7 @@ export MVK_DEBUG=0
# editing below, or can be set before calling this script. # editing below, or can be set before calling this script.
export MVK_CONFIG_RESUME_LOST_DEVICE=1 export MVK_CONFIG_RESUME_LOST_DEVICE=1
export MVK_CONFIG_FAST_MATH_ENABLED=1 export MVK_CONFIG_FAST_MATH_ENABLED=1
export MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0 export MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=0 #(2 = VK_EXT_descriptor_indexing enabled)
export MVK_CONFIG_FORCE_LOW_POWER_GPU=0 export MVK_CONFIG_FORCE_LOW_POWER_GPU=0