Merge branch 'master' into combined-store-resolve

This commit is contained in:
Bill Hollings 2019-01-22 10:58:06 -08:00 committed by GitHub
commit a9420c2898
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 165 additions and 61 deletions

View File

@ -48,7 +48,7 @@ extern "C" {
*/ */
#define MVK_VERSION_MAJOR 1 #define MVK_VERSION_MAJOR 1
#define MVK_VERSION_MINOR 0 #define MVK_VERSION_MINOR 0
#define MVK_VERSION_PATCH 31 #define MVK_VERSION_PATCH 32
#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)
@ -133,7 +133,7 @@ typedef struct {
* will be dispatched to a GCD dispatch_queue whose priority is determined by * will be dispatched to a GCD dispatch_queue whose priority is determined by
* VkDeviceQueueCreateInfo::pQueuePriorities during vkCreateDevice(). * VkDeviceQueueCreateInfo::pQueuePriorities during vkCreateDevice().
* *
* The value of this parameter may be changed before creating a VkDevice, * 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
@ -193,7 +193,7 @@ typedef struct {
* is required per command buffer queue submission, which may be significantly less than the * is required per command buffer queue submission, which may be significantly less than the
* number of Vulkan command buffers. * number of Vulkan command buffers.
* *
* The value of this parameter may be changed before creating a VkDevice, * 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
@ -331,7 +331,7 @@ typedef struct {
* as having specialized graphics OR compute OR transfer functionality, to make it easier for some * as having specialized graphics OR compute OR transfer functionality, to make it easier for some
* apps to select a queue family with the appropriate requirements. * apps to select a queue family with the appropriate requirements.
* *
* The value of this parameter may be changed before creating a VkDevice, and before * The value of this parameter must be changed before creating a VkDevice, and before
* querying a VkPhysicalDevice for queue family properties, for the change to take effect. * querying a VkPhysicalDevice for queue family properties, 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
@ -364,7 +364,7 @@ typedef struct {
* system window compositor to determine how best to blend content with the windowing * system window compositor to determine how best to blend content with the windowing
* system, and as a result, may want to disable this parameter. * system, and as a result, may want to disable this parameter.
* *
* The value of this parameter may be changed before creating a VkDevice, * 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
@ -414,6 +414,35 @@ typedef struct {
*/ */
VkBool32 fullImageViewSwizzle; VkBool32 fullImageViewSwizzle;
/**
* The index of the queue family whose presentation submissions will
* be used as the default GPU Capture Scope during debugging in Xcode.
*
* The value of this parameter must be changed before creating a VkDevice,
* for the change to take effect.
*
* The initial value or this parameter is set by the
* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX
* runtime environment variable or MoltenVK compile-time build setting.
* If neither is set, the value of this parameter defaults to zero (the first queue family).
*/
uint32_t defaultGPUCaptureScopeQueueFamilyIndex;
/**
* The index of the queue, within the queue family identified by the
* defaultGPUCaptureScopeQueueFamilyIndex parameter, whose presentation submissions
* will be used as the default GPU Capture Scope during debugging in Xcode.
*
* The value of this parameter must be changed before creating a VkDevice,
* for the change to take effect.
*
* The initial value or this parameter is set by the
* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_INDEX
* runtime environment variable or MoltenVK compile-time build setting.
* If neither is set, the value of this parameter defaults to zero (the first queue).
*/
uint32_t defaultGPUCaptureScopeQueueIndex;
} MVKConfiguration; } MVKConfiguration;
/** /**
@ -454,8 +483,9 @@ typedef struct {
VkSampleCountFlags supportedSampleCounts; /**< A bitmask identifying the sample counts supported by the device. */ VkSampleCountFlags supportedSampleCounts; /**< A bitmask identifying the sample counts supported by the device. */
uint32_t minSwapchainImageCount; /**< The minimum number of swapchain images that can be supported by a surface. */ uint32_t minSwapchainImageCount; /**< The minimum number of swapchain images that can be supported by a surface. */
uint32_t maxSwapchainImageCount; /**< The maximum number of swapchain images that can be supported by a surface. */ uint32_t maxSwapchainImageCount; /**< The maximum number of swapchain images that can be supported by a surface. */
// v17
VkBool32 combinedStoreResolveAction; /**< If true, the device supports VK_ATTACHMENT_STORE_OP_STORE with a simultaneous resolve attachment. */ VkBool32 combinedStoreResolveAction; /**< If true, the device supports VK_ATTACHMENT_STORE_OP_STORE with a simultaneous resolve attachment. */
VkBool32 arrayOfTextures; /**< If true, arrays of textures is supported. */
VkBool32 arrayOfSamplers; /**< If true, arrays of texture samplers is supported. */
} MVKPhysicalDeviceMetalFeatures; } MVKPhysicalDeviceMetalFeatures;
/** /**

View File

@ -73,7 +73,7 @@ typedef struct MVKShaderResourceBinding {
#pragma mark MVKDescriptorSetLayoutBinding #pragma mark MVKDescriptorSetLayoutBinding
/** Represents a Vulkan descriptor set layout binding. */ /** Represents a Vulkan descriptor set layout binding. */
class MVKDescriptorSetLayoutBinding : public MVKConfigurableObject { class MVKDescriptorSetLayoutBinding : public MVKBaseDeviceObject {
public: public:
@ -100,7 +100,8 @@ public:
uint32_t dslIndex); uint32_t dslIndex);
/** Constructs an instance. */ /** Constructs an instance. */
MVKDescriptorSetLayoutBinding(MVKDescriptorSetLayout* layout, MVKDescriptorSetLayoutBinding(MVKDevice* device,
MVKDescriptorSetLayout* layout,
const VkDescriptorSetLayoutBinding* pBinding); const VkDescriptorSetLayoutBinding* pBinding);
MVKDescriptorSetLayoutBinding(const MVKDescriptorSetLayoutBinding& binding); MVKDescriptorSetLayoutBinding(const MVKDescriptorSetLayoutBinding& binding);
@ -112,9 +113,9 @@ protected:
friend class MVKDescriptorBinding; friend class MVKDescriptorBinding;
friend class MVKPipelineLayout; friend class MVKPipelineLayout;
VkResult initMetalResourceIndexOffsets(MVKShaderStageResourceBinding* pBindingIndexes, void initMetalResourceIndexOffsets(MVKShaderStageResourceBinding* pBindingIndexes,
MVKShaderStageResourceBinding* pDescSetCounts, MVKShaderStageResourceBinding* pDescSetCounts,
const VkDescriptorSetLayoutBinding* pBinding); const VkDescriptorSetLayoutBinding* pBinding);
VkDescriptorSetLayoutBinding _info; VkDescriptorSetLayoutBinding _info;
std::vector<MVKSampler*> _immutableSamplers; std::vector<MVKSampler*> _immutableSamplers;

View File

@ -405,30 +405,31 @@ void MVKDescriptorSetLayoutBinding::populateShaderConverterContext(SPIRVToMSLCon
} }
} }
MVKDescriptorSetLayoutBinding::MVKDescriptorSetLayoutBinding(MVKDescriptorSetLayout* layout, MVKDescriptorSetLayoutBinding::MVKDescriptorSetLayoutBinding(MVKDevice* device,
const VkDescriptorSetLayoutBinding* pBinding) : MVKConfigurableObject() { MVKDescriptorSetLayout* layout,
const VkDescriptorSetLayoutBinding* pBinding) : MVKBaseDeviceObject(device) {
// Determine the shader stages used by this binding // Determine the shader stages used by this binding
_applyToVertexStage = mvkAreFlagsEnabled(pBinding->stageFlags, VK_SHADER_STAGE_VERTEX_BIT); _applyToVertexStage = mvkAreFlagsEnabled(pBinding->stageFlags, VK_SHADER_STAGE_VERTEX_BIT);
_applyToFragmentStage = mvkAreFlagsEnabled(pBinding->stageFlags, VK_SHADER_STAGE_FRAGMENT_BIT); _applyToFragmentStage = mvkAreFlagsEnabled(pBinding->stageFlags, VK_SHADER_STAGE_FRAGMENT_BIT);
_applyToComputeStage = mvkAreFlagsEnabled(pBinding->stageFlags, VK_SHADER_STAGE_COMPUTE_BIT); _applyToComputeStage = mvkAreFlagsEnabled(pBinding->stageFlags, VK_SHADER_STAGE_COMPUTE_BIT);
// If this binding is used by the vertex shader, set the Metal resource index // If this binding is used by the vertex shader, set the Metal resource index
if (_applyToVertexStage) { if (_applyToVertexStage) {
setConfigurationResult(initMetalResourceIndexOffsets(&_mtlResourceIndexOffsets.vertexStage, initMetalResourceIndexOffsets(&_mtlResourceIndexOffsets.vertexStage,
&layout->_mtlResourceCounts.vertexStage, pBinding)); &layout->_mtlResourceCounts.vertexStage, pBinding);
} }
// If this binding is used by the fragment shader, set the Metal resource index // If this binding is used by the fragment shader, set the Metal resource index
if (_applyToFragmentStage) { if (_applyToFragmentStage) {
setConfigurationResult(initMetalResourceIndexOffsets(&_mtlResourceIndexOffsets.fragmentStage, initMetalResourceIndexOffsets(&_mtlResourceIndexOffsets.fragmentStage,
&layout->_mtlResourceCounts.fragmentStage, pBinding)); &layout->_mtlResourceCounts.fragmentStage, pBinding);
} }
// If this binding is used by a compute shader, set the Metal resource index // If this binding is used by a compute shader, set the Metal resource index
if (_applyToComputeStage) { if (_applyToComputeStage) {
setConfigurationResult(initMetalResourceIndexOffsets(&_mtlResourceIndexOffsets.computeStage, initMetalResourceIndexOffsets(&_mtlResourceIndexOffsets.computeStage,
&layout->_mtlResourceCounts.computeStage, pBinding)); &layout->_mtlResourceCounts.computeStage, pBinding);
} }
// If immutable samplers are defined, copy them in // If immutable samplers are defined, copy them in
if ( pBinding->pImmutableSamplers && if ( pBinding->pImmutableSamplers &&
@ -446,7 +447,7 @@ MVKDescriptorSetLayoutBinding::MVKDescriptorSetLayoutBinding(MVKDescriptorSetLay
} }
MVKDescriptorSetLayoutBinding::MVKDescriptorSetLayoutBinding(const MVKDescriptorSetLayoutBinding& binding) : MVKDescriptorSetLayoutBinding::MVKDescriptorSetLayoutBinding(const MVKDescriptorSetLayoutBinding& binding) :
MVKConfigurableObject(), _info(binding._info), _immutableSamplers(binding._immutableSamplers), MVKBaseDeviceObject(binding._device), _info(binding._info), _immutableSamplers(binding._immutableSamplers),
_mtlResourceIndexOffsets(binding._mtlResourceIndexOffsets), _mtlResourceIndexOffsets(binding._mtlResourceIndexOffsets),
_applyToVertexStage(binding._applyToVertexStage), _applyToFragmentStage(binding._applyToFragmentStage), _applyToVertexStage(binding._applyToVertexStage), _applyToFragmentStage(binding._applyToFragmentStage),
_applyToComputeStage(binding._applyToComputeStage) { _applyToComputeStage(binding._applyToComputeStage) {
@ -461,17 +462,19 @@ MVKDescriptorSetLayoutBinding::~MVKDescriptorSetLayoutBinding() {
} }
} }
/** // Sets the appropriate Metal resource indexes within this binding from the
* Sets the appropriate Metal resource indexes within this binding from the // specified descriptor set binding counts, and updates those counts accordingly.
* specified descriptor set binding counts, and updates those counts accordingly. void MVKDescriptorSetLayoutBinding::initMetalResourceIndexOffsets(MVKShaderStageResourceBinding* pBindingIndexes,
*/ MVKShaderStageResourceBinding* pDescSetCounts,
VkResult MVKDescriptorSetLayoutBinding::initMetalResourceIndexOffsets(MVKShaderStageResourceBinding* pBindingIndexes, const VkDescriptorSetLayoutBinding* pBinding) {
MVKShaderStageResourceBinding* pDescSetCounts,
const VkDescriptorSetLayoutBinding* pBinding) {
switch (pBinding->descriptorType) { switch (pBinding->descriptorType) {
case VK_DESCRIPTOR_TYPE_SAMPLER: case VK_DESCRIPTOR_TYPE_SAMPLER:
pBindingIndexes->samplerIndex = pDescSetCounts->samplerIndex; pBindingIndexes->samplerIndex = pDescSetCounts->samplerIndex;
pDescSetCounts->samplerIndex += pBinding->descriptorCount; pDescSetCounts->samplerIndex += pBinding->descriptorCount;
if (pBinding->descriptorCount > 1 && !_device->_pMetalFeatures->arrayOfSamplers) {
setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "Device %s does not support arrays of samplers.", _device->getName()));
}
break; break;
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
@ -479,6 +482,15 @@ VkResult MVKDescriptorSetLayoutBinding::initMetalResourceIndexOffsets(MVKShaderS
pDescSetCounts->textureIndex += pBinding->descriptorCount; pDescSetCounts->textureIndex += pBinding->descriptorCount;
pBindingIndexes->samplerIndex = pDescSetCounts->samplerIndex; pBindingIndexes->samplerIndex = pDescSetCounts->samplerIndex;
pDescSetCounts->samplerIndex += pBinding->descriptorCount; pDescSetCounts->samplerIndex += pBinding->descriptorCount;
if (pBinding->descriptorCount > 1) {
if ( !_device->_pMetalFeatures->arrayOfTextures ) {
setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "Device %s does not support arrays of textures.", _device->getName()));
}
if ( !_device->_pMetalFeatures->arrayOfSamplers ) {
setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "Device %s does not support arrays of samplers.", _device->getName()));
}
}
break; break;
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
@ -488,6 +500,10 @@ VkResult MVKDescriptorSetLayoutBinding::initMetalResourceIndexOffsets(MVKShaderS
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
pBindingIndexes->textureIndex = pDescSetCounts->textureIndex; pBindingIndexes->textureIndex = pDescSetCounts->textureIndex;
pDescSetCounts->textureIndex += pBinding->descriptorCount; pDescSetCounts->textureIndex += pBinding->descriptorCount;
if (pBinding->descriptorCount > 1 && !_device->_pMetalFeatures->arrayOfTextures) {
setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "Device %s does not support arrays of textures.", _device->getName()));
}
break; break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
@ -501,7 +517,6 @@ VkResult MVKDescriptorSetLayoutBinding::initMetalResourceIndexOffsets(MVKShaderS
default: default:
break; break;
} }
return VK_SUCCESS;
} }
@ -634,7 +649,7 @@ MVKDescriptorSetLayout::MVKDescriptorSetLayout(MVKDevice* device,
// Create the descriptor bindings // Create the descriptor bindings
_bindings.reserve(pCreateInfo->bindingCount); _bindings.reserve(pCreateInfo->bindingCount);
for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) { for (uint32_t i = 0; i < pCreateInfo->bindingCount; i++) {
_bindings.emplace_back(this, &pCreateInfo->pBindings[i]); _bindings.emplace_back(_device, this, &pCreateInfo->pBindings[i]);
_bindingToIndex[pCreateInfo->pBindings[i].binding] = i; _bindingToIndex[pCreateInfo->pBindings[i].binding] = i;
setConfigurationResult(_bindings.back().getConfigurationResult()); setConfigurationResult(_bindings.back().getConfigurationResult());
} }

View File

@ -90,6 +90,9 @@ public:
/** Populates the specified structure with the properties of this device. */ /** Populates the specified structure with the properties of this device. */
void getProperties(VkPhysicalDeviceProperties2* properties); void getProperties(VkPhysicalDeviceProperties2* properties);
/** Returns the name of this device. */
inline const char* getName() { return _properties.deviceName; }
/** Returns whether the specified format is supported on this device. */ /** Returns whether the specified format is supported on this device. */
bool getFormatIsSupported(VkFormat format); bool getFormatIsSupported(VkFormat format);
@ -315,6 +318,9 @@ public:
/** Returns the physical device underlying this logical device. */ /** Returns the physical device underlying this logical device. */
inline MVKPhysicalDevice* getPhysicalDevice() { return _physicalDevice; } inline MVKPhysicalDevice* getPhysicalDevice() { return _physicalDevice; }
/** Returns the name of this device. */
inline const char* getName() { return _pProperties->deviceName; }
/** Returns the common resource factory for creating command resources. */ /** Returns the common resource factory for creating command resources. */
inline MVKCommandResourceFactory* getCommandResourceFactory() { return _commandResourceFactory; } inline MVKCommandResourceFactory* getCommandResourceFactory() { return _commandResourceFactory; }

View File

@ -619,6 +619,14 @@ void MVKPhysicalDevice::initMetalFeatures() {
_metalFeatures.mtlBufferAlignment = 16; // Min float4 alignment for typical vertex buffers. MTLBuffer may go down to 4 bytes for other data. _metalFeatures.mtlBufferAlignment = 16; // Min float4 alignment for typical vertex buffers. MTLBuffer may go down to 4 bytes for other data.
_metalFeatures.maxTextureDimension = (16 * KIBI); _metalFeatures.maxTextureDimension = (16 * KIBI);
} }
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily3_v2] ) {
_metalFeatures.arrayOfTextures = true;
}
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily3_v3] ) {
_metalFeatures.arrayOfSamplers = true;
}
#endif #endif
#if MVK_MACOS #if MVK_MACOS
@ -644,6 +652,8 @@ void MVKPhysicalDevice::initMetalFeatures() {
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) { if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) {
_metalFeatures.mslVersion = SPIRVToMSLConverterOptions::makeMSLVersion(2); _metalFeatures.mslVersion = SPIRVToMSLConverterOptions::makeMSLVersion(2);
_metalFeatures.texelBuffers = true; _metalFeatures.texelBuffers = true;
_metalFeatures.arrayOfTextures = true;
_metalFeatures.arrayOfSamplers = true;
_metalFeatures.presentModeImmediate = true; _metalFeatures.presentModeImmediate = true;
} }
@ -685,6 +695,9 @@ void MVKPhysicalDevice::initFeatures() {
_features.shaderInt16 = true; _features.shaderInt16 = true;
_features.multiDrawIndirect = true; _features.multiDrawIndirect = true;
_features.shaderSampledImageArrayDynamicIndexing = _metalFeatures.arrayOfTextures;
_features.shaderStorageImageArrayDynamicIndexing = _metalFeatures.arrayOfTextures;
if (_metalFeatures.indirectDrawing && _metalFeatures.baseVertexInstanceDrawing) { if (_metalFeatures.indirectDrawing && _metalFeatures.baseVertexInstanceDrawing) {
_features.drawIndirectFirstInstance = true; _features.drawIndirectFirstInstance = true;
} }
@ -698,10 +711,6 @@ void MVKPhysicalDevice::initFeatures() {
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily3_v1] ) { if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily3_v1] ) {
_features.occlusionQueryPrecise = true; _features.occlusionQueryPrecise = true;
}
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily3_v2] ) {
_features.shaderSampledImageArrayDynamicIndexing = true;
_features.shaderStorageImageArrayDynamicIndexing = true;
} }
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily2_v4] ) { if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily2_v4] ) {
_features.depthClamp = true; _features.depthClamp = true;
@ -722,8 +731,6 @@ void MVKPhysicalDevice::initFeatures() {
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) { if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v3] ) {
_features.multiViewport = true; _features.multiViewport = true;
_features.shaderSampledImageArrayDynamicIndexing = true;
_features.shaderStorageImageArrayDynamicIndexing = true;
} }
#endif #endif
@ -1874,9 +1881,13 @@ void MVKDevice::initQueues(const VkDeviceCreateInfo* pCreateInfo) {
const VkDeviceQueueCreateInfo* pQFInfo = &pCreateInfo->pQueueCreateInfos[qrIdx]; const VkDeviceQueueCreateInfo* pQFInfo = &pCreateInfo->pQueueCreateInfos[qrIdx];
uint32_t qfIdx = pQFInfo->queueFamilyIndex; uint32_t qfIdx = pQFInfo->queueFamilyIndex;
MVKQueueFamily* qFam = qFams[qfIdx]; MVKQueueFamily* qFam = qFams[qfIdx];
VkQueueFamilyProperties qfProps;
qFam->getProperties(&qfProps);
_queuesByQueueFamilyIndex.resize(qfIdx + 1); // Ensure an entry for this queue family exists _queuesByQueueFamilyIndex.resize(qfIdx + 1); // Ensure an entry for this queue family exists
auto& queues = _queuesByQueueFamilyIndex[qfIdx]; auto& queues = _queuesByQueueFamilyIndex[qfIdx];
for (uint32_t qIdx = 0; qIdx < pQFInfo->queueCount; qIdx++) { uint32_t qCnt = min(pQFInfo->queueCount, qfProps.queueCount);
for (uint32_t qIdx = 0; qIdx < qCnt; qIdx++) {
queues.push_back(new MVKQueue(this, qFam, qIdx, pQFInfo->pQueuePriorities[qIdx])); queues.push_back(new MVKQueue(this, qFam, qIdx, pQFInfo->pQueuePriorities[qIdx]));
} }
} }

View File

@ -353,21 +353,23 @@ void MVKInstance::logVersions() {
// Init config. // Init config.
void MVKInstance::initConfig() { void MVKInstance::initConfig() {
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.debugMode, MVK_DEBUG); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.debugMode, MVK_DEBUG);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.shaderConversionFlipVertexY, MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.shaderConversionFlipVertexY, MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.synchronousQueueSubmits, MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.synchronousQueueSubmits, MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.prefillMetalCommandBuffers, MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.prefillMetalCommandBuffers, MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS);
MVK_SET_FROM_ENV_OR_BUILD_INT32(_mvkConfig.maxActiveMetalCommandBuffersPerQueue, MVK_CONFIG_MAX_ACTIVE_METAL_COMMAND_BUFFERS_PER_QUEUE); MVK_SET_FROM_ENV_OR_BUILD_INT32(_mvkConfig.maxActiveMetalCommandBuffersPerQueue, MVK_CONFIG_MAX_ACTIVE_METAL_COMMAND_BUFFERS_PER_QUEUE);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.supportLargeQueryPools, MVK_CONFIG_SUPPORT_LARGE_QUERY_POOLS); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.supportLargeQueryPools, MVK_CONFIG_SUPPORT_LARGE_QUERY_POOLS);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.presentWithCommandBuffer, MVK_CONFIG_PRESENT_WITH_COMMAND_BUFFER); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.presentWithCommandBuffer, MVK_CONFIG_PRESENT_WITH_COMMAND_BUFFER);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.swapchainMagFilterUseNearest, MVK_CONFIG_SWAPCHAIN_MAG_FILTER_USE_NEAREST); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.swapchainMagFilterUseNearest, MVK_CONFIG_SWAPCHAIN_MAG_FILTER_USE_NEAREST);
MVK_SET_FROM_ENV_OR_BUILD_INT64(_mvkConfig.metalCompileTimeout, MVK_CONFIG_METAL_COMPILE_TIMEOUT); MVK_SET_FROM_ENV_OR_BUILD_INT64(_mvkConfig.metalCompileTimeout, MVK_CONFIG_METAL_COMPILE_TIMEOUT);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.performanceTracking, MVK_CONFIG_PERFORMANCE_TRACKING); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.performanceTracking, MVK_CONFIG_PERFORMANCE_TRACKING);
MVK_SET_FROM_ENV_OR_BUILD_INT32(_mvkConfig.performanceLoggingFrameCount, MVK_CONFIG_PERFORMANCE_LOGGING_FRAME_COUNT); MVK_SET_FROM_ENV_OR_BUILD_INT32(_mvkConfig.performanceLoggingFrameCount, MVK_CONFIG_PERFORMANCE_LOGGING_FRAME_COUNT);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.displayWatermark, MVK_CONFIG_DISPLAY_WATERMARK); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.displayWatermark, MVK_CONFIG_DISPLAY_WATERMARK);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.specializedQueueFamilies, MVK_CONFIG_SPECIALIZED_QUEUE_FAMILIES); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.specializedQueueFamilies, MVK_CONFIG_SPECIALIZED_QUEUE_FAMILIES);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.switchSystemGPU, MVK_CONFIG_SWITCH_SYSTEM_GPU); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.switchSystemGPU, MVK_CONFIG_SWITCH_SYSTEM_GPU);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.fullImageViewSwizzle, MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE); MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.fullImageViewSwizzle, MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.defaultGPUCaptureScopeQueueFamilyIndex, MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX);
MVK_SET_FROM_ENV_OR_BUILD_BOOL( _mvkConfig.defaultGPUCaptureScopeQueueIndex, MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_INDEX);
} }
VkResult MVKInstance::verifyLayers(uint32_t count, const char* const* names) { VkResult MVKInstance::verifyLayers(uint32_t count, const char* const* names) {

View File

@ -174,9 +174,15 @@ void MVKQueue::initMTLCommandQueue() {
// Initializes Xcode GPU capture scopes // Initializes Xcode GPU capture scopes
void MVKQueue::initGPUCaptureScopes() { void MVKQueue::initGPUCaptureScopes() {
const MVKConfiguration* pMVKConfig = _device->getInstance()->getMoltenVKConfiguration();
_submissionCaptureScope = new MVKGPUCaptureScope(this, "CommandBuffer-Submission"); _submissionCaptureScope = new MVKGPUCaptureScope(this, "CommandBuffer-Submission");
_presentationCaptureScope = new MVKGPUCaptureScope(this, "Surface-Presentation"); _presentationCaptureScope = new MVKGPUCaptureScope(this, "Surface-Presentation");
_presentationCaptureScope->makeDefault(); if (_queueFamily->getIndex() == pMVKConfig->defaultGPUCaptureScopeQueueFamilyIndex &&
_index == pMVKConfig->defaultGPUCaptureScopeQueueIndex) {
_presentationCaptureScope->makeDefault();
}
_presentationCaptureScope->beginScope(); // Allow Xcode to capture the first frame if desired. _presentationCaptureScope->beginScope(); // Allow Xcode to capture the first frame if desired.
} }

View File

@ -224,6 +224,7 @@ MVKMTLFunction MVKShaderModule::getMTLFunction(SPIRVToMSLConverterContext* pCont
const VkSpecializationInfo* pSpecializationInfo, const VkSpecializationInfo* pSpecializationInfo,
MVKPipelineCache* pipelineCache) { MVKPipelineCache* pipelineCache) {
lock_guard<mutex> lock(_accessLock); lock_guard<mutex> lock(_accessLock);
MVKShaderLibrary* mvkLib = _defaultLibrary; MVKShaderLibrary* mvkLib = _defaultLibrary;
if ( !mvkLib ) { if ( !mvkLib ) {
uint64_t startTime = _device->getPerformanceTimestamp(); uint64_t startTime = _device->getPerformanceTimestamp();
@ -233,7 +234,10 @@ MVKMTLFunction MVKShaderModule::getMTLFunction(SPIRVToMSLConverterContext* pCont
mvkLib = _shaderLibraryCache.getShaderLibrary(pContext, this); mvkLib = _shaderLibraryCache.getShaderLibrary(pContext, this);
} }
_device->addActivityPerformance(_device->_performanceStatistics.shaderCompilation.shaderLibraryFromCache, startTime); _device->addActivityPerformance(_device->_performanceStatistics.shaderCompilation.shaderLibraryFromCache, startTime);
} else {
pContext->markAllAttributesAndResourcesUsed();
} }
return mvkLib ? mvkLib->getMTLFunction(pSpecializationInfo) : MVKMTLFunctionNull; return mvkLib ? mvkLib->getMTLFunction(pSpecializationInfo) : MVKMTLFunctionNull;
} }

View File

@ -112,6 +112,23 @@
# define MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE 0 # define MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE 0
#endif #endif
/**
* The index of the queue family whose presentation submissions will
* be used as the default GPU Capture Scope during debugging in Xcode.
*/
#ifndef MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX
# define MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX 0
#endif
/**
* The index of the queue, within the queue family identified by the
* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX setting, whose presentation
* submissions will be used as the default GPU Capture Scope during debugging in Xcode.
*/
#ifndef MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_INDEX
# define MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_INDEX 0
#endif
/** /**
* IOSurfaces are supported on macOS, and on iOS starting with iOS 11. * IOSurfaces are supported on macOS, and on iOS starting with iOS 11.

View File

@ -105,6 +105,15 @@ MVK_PUBLIC_SYMBOL bool SPIRVToMSLConverterContext::isVertexBufferUsed(uint32_t m
return false; return false;
} }
MVK_PUBLIC_SYMBOL void SPIRVToMSLConverterContext::markAllAttributesAndResourcesUsed() {
if (options.entryPointStage == spv::ExecutionModelVertex) {
for (auto& va : vertexAttributes) { va.isUsedByShader = true; }
}
for (auto& rb : resourceBindings) { rb.isUsedByShader = true; }
}
MVK_PUBLIC_SYMBOL bool SPIRVToMSLConverterContext::matches(const SPIRVToMSLConverterContext& other) const { MVK_PUBLIC_SYMBOL bool SPIRVToMSLConverterContext::matches(const SPIRVToMSLConverterContext& other) const {
if ( !options.matches(other.options) ) { return false; } if ( !options.matches(other.options) ) { return false; }

View File

@ -143,6 +143,9 @@ namespace mvk {
/** Returns whether the vertex buffer at the specified Metal binding index is used by the shader. */ /** Returns whether the vertex buffer at the specified Metal binding index is used by the shader. */
bool isVertexBufferUsed(uint32_t mslBuffer) const; bool isVertexBufferUsed(uint32_t mslBuffer) const;
/** Marks all vertex attributes and resources as being used by the shader. */
void markAllAttributesAndResourcesUsed();
/** /**
* Returns whether this context matches the other context. It does if the respective * Returns whether this context matches the other context. It does if the respective
* options match and any vertex attributes and resource bindings used by this context * options match and any vertex attributes and resource bindings used by this context