1594 Commits

Author SHA1 Message Date
Bill Hollings
9542a5cc54 Several underlying non-functional changes towards Metal argument buffer support.
Move tracking descriptor index to MVKDescriptorSetLayoutBinding from MVKDescriptorSetLayout.
Refactor MVKDescriptorSet::write() to be more DRY.
Grow and shrink MVKDescriptorSet memory consumption during allocate and free.
MVKPhysicalDevice refactor layout of pipelineCacheUUID to remove redundancy in MoltenVK
revision and allow tracking of enabled features that affect pipeline cache content.
MVKBitArray support resizing and simplify setBit() functionality.
2021-03-17 19:21:35 -04:00
Bill Hollings
f8280bca89 Rename mvkGetMVKConfiguration() to mvkConfig() for brevity. 2021-03-17 09:45:13 -04:00
Bill Hollings
55e1b1b29b
Merge pull request #1319 from billhollings/texel-buff-align
Fix advertising single-texel alignment capability for texel buffers.
2021-03-15 18:54:35 -04:00
Bill Hollings
e276f1a261 Fix advertising single-texel alignment capability for texel buffers.
The test for single-texel capability used a mod calculation to compare the linear
alignment requirement reported by Metal to the texel size. Instead, it should use an
inequality comparison, to check if the alignment requirement is LTE the texel size.
2021-03-15 18:29:11 -04:00
Bill Hollings
2ef21c65bf Preallocate a pool of descriptors by default.
Enable MVKConfiguration::preallocateDescriptors and
MVK_CONFIG_PREALLOCATE_DESCRIPTORS by default.
Rename MVKDescriptorTypePreallocation to MVKDescriptorTypePool.
2021-03-15 16:27:39 -04:00
Bill Hollings
6cba6a851b MVKDescriptorPool optimize reseting descriptor pool.
Don't free individual pooled descriptors during a pool reset.
Don't mark availability of individual descriptor sets during a pool reset.
Add MVKDescriptorPool::_hasPooledDescriptors as SVOT to track if descriptors
are pooled, and is set from outside constructor to ensure all internal
descriptor pools are constructed with the same SVOT.
MVKDescriptorPool::allocateDescriptorSet() ensure correct result returned.
2021-03-15 15:52:40 -04:00
Bill Hollings
4371ef4d2b MVKDescriptorPool pools its descriptor sets. 2021-03-15 11:33:14 -04:00
Bill Hollings
88fcb30090 Revert to using MVKBufferDescriptor::_buffRange, and populating
MVKMTLBufferBinding::size to specify the length of shader runtime arrays.
2021-03-13 14:03:47 -05:00
Bill Hollings
a2be769e5f MVKDescriptor subclasses: Reduce unused content.
Don't populate MVKMTLBufferBinding::size unless using mtlBytes and isInline.
Remove MVKBufferDescriptor::_buffRange.
Remove MVKImageDescriptor::_imageLayout.
Remove MVKCmdBufferImageCopy::_imageLayout.
2021-03-12 22:12:22 -05:00
Bill Hollings
068ce2ee8e MVKDescriptor subclasses: Simplify interface and reduce redundant content.
Remove MVKDescriptor::setLayout() and pass MVKDescriptorSetLayoutBinding
to MVKDescriptor::bind(), write(), and read().
Remove MVKSamplerDescriptorMixin::_hasDynamicSampler.
Remove MVKInlineUniformBlockDescriptor::_length.
2021-03-12 20:10:51 -05:00
Bill Hollings
984a74fffd Refactor preallocated descriptor handling.
Add MVKBitArray class.
Consolidate MVKPreallocatedDescriptors into MVKDescriptorPool
and remove MVKPreallocatedDescriptors.
2021-03-12 09:11:58 -05:00
Bill Hollings
9c13e46c47 In a renderpass, don't load or store memoryless attachments.
For memoryless attachments, setting renderpass load and store
actions to "load" and "store" triggers Metal validation errors.
Refactor determination of renderpass MTLLoadAction and MTLStoreAction.
For memoryless attachments, replace load with don't care,
and store with resolve or don't care.
2021-03-11 12:22:47 -05:00
Bill Hollings
4d452fdca6 Always explicitly set CAMetalLayer colorspace and wantsExtendedDynamicRangeContent.
Don't assume the incoming CAMetalLayer has default (no-op) values for colorspace and
wantsExtendedDynamicRangeContent properties, since they could have been set externally.
Ensure the Vulkan app has control over both of these properties.
vkCreateSwapchainKHR() returns VK_ERROR_FORMAT_NOT_SUPPORTED for unsupported colorspaces.
2021-03-10 19:59:11 -05:00
Bill Hollings
cd8a0e149e Restore support for HDR10 colorspace.
Restore support for VK_COLOR_SPACE_HDR10_HLG_EXT and VK_COLOR_SPACE_HDR10_ST2084_EXT
under Xcode12 that was removed due to App Store conflicts using older enum values.
2021-03-10 19:05:01 -05:00
Bill Hollings
8112d85103 Fix MVKPhysicalDevice::getSurfaceFormats() returning VK_FORMAT_UNDEFINED.
Fix MVKPhysicalDevice::getSurfaceFormats() returning VK_FORMAT_UNDEFINED
in available surface formats when a Metal surface format is available that
doesn't map to a defined Vulkan format (eg. MTLPixelFormatBGRA10_XR).
2021-03-10 18:30:11 -05:00
Bill Hollings
cfc2556c31 Fix use of VkFlags in MVKConfiguration enumerated values.
MVKConfigLogLevel, MVKConfigTraceVulkanCalls, and MVKConfigAutoGPUCaptureScope
do not need to be VkFlags, since they aren't bitwise flags.

MVK_SET_FROM_ENV_OR_BUILD_INT32 supports setting enumerated values.
2021-03-10 09:26:59 -05:00
Bill Hollings
21ee6bac95 Create enums for remaining MVKConfiguration enumerated values.
Introduce MVKConfigLogLevelBits enum to specify values of
MVKConfiguration::logLevel in a Vulkan-friendly manner,
while automatically documenting the same values for env vars.

Introduce MVKConfigTraceVulkanCallsBits enum to specify values of
MVKConfiguration::traceVulkanCalls in a Vulkan-friendly manner,
while automatically documenting the same values for env vars.
2021-03-09 18:45:16 -05:00
Bill Hollings
904edb8434 Only start automatic GPU capture on queue identified by
MVKConfiguration::defaultGPUCaptureScopeQueueFamilyIndex
and defaultGPUCaptureScopeQueueIndex.

Introduce MVKConfigAutoGPUCaptureScopeBits enum to specify values of
MVKConfiguration::autoGPUCaptureScope in a Vulkan-friendly manner,
while automatically documenting the same values for env vars.

Update some config documentation.
2021-03-09 15:51:01 -05:00
Bill Hollings
691dc8a9ed Redefine MVKConfigAdvertiseExtensionBits enum as extension families. 2021-03-08 21:20:51 -05:00
Bill Hollings
2ba0fb3267 Extend MVKConfiguration::advertiseExtensions to optionally specify a few extensions.
Introduce MVKConfigAdvertiseExtensionBits enum to specify multiple API config values in
a Vulkan-friendly manner, while automatically documenting the same values for env vars.
2021-03-08 15:15:24 -05:00
Bill Hollings
ff7269f26e Add NDEBUG macro to all Release builds to remove assert() calls.
External libraries in particular make liberal use of assert() calls, which bypass
error catching, sometimes causing crashes rather than catch errors and moving on.
2021-03-04 13:47:25 -05:00
Bill Hollings
64681832c1 Remove project qualifiers from references to SPIRV-Cross and glslang header files.
Remove SPIRV-Cross/ qualifier from include references to SPIRV-Cross header files.
Remove glslang/ qualifier from include references to glslang header files.
This change allows easier integration with app build scripts.
2021-02-28 18:22:52 -05:00
Bill Hollings
b9d9ab613d Permit extension functions when all extensions have been disabled via configuration.
When mvkGetMVKConfiguration()->advertiseExtensions is disabled, and MoltenVK
artificially advertises that all extensions are not supported, allow the functions
of those extensions to be called anyway.

Some CTS tests are structured to assume one or more basic extensions are supported,
and do not bother checking for those extensions and provide alternate code paths
based on the extension not being supported. Permitting the calls to be made anyway
allows those tests to proceed and avoid crashing.
2021-02-27 14:18:40 -05:00
Bill Hollings
68a0119f21 Fix typo. 2021-02-25 21:09:14 -05:00
Bill Hollings
a4d36cb757 Reduce debug log noise by only logging header msg for
shader debug logs if at least one shader log exists.
2021-02-25 17:19:53 -05:00
Bill Hollings
08d9fa8ea2 Ensure queue submission message logging occurs before submission object is destroyed.
Fixes to MVKQueueCommandBufferSubmission:
- Consolidate MTLCommandBuffer completion callbacks, and ensure all other activities,
  including logging, which references the object, occurs before finish() is called.
- Remove separate flag that indicates whether to track MTLCommandBuffer completion times.
- Localize Vulkan error reporting to the queue instead of the device.
2021-02-25 16:37:06 -05:00
Bill Hollings
bee482927a
Merge pull request #1281 from cdavis5e/enhanced-cmdbuf-errors
Log enhanced command buffer errors in debug mode.
2021-02-25 10:56:54 -05:00
Chip Davis
48aff9f45d Log enhanced command buffer errors in debug mode.
If we're on macOS 11 or iOS/tvOS 14, and debug mode (`MVK_DEBUG=1`) were
enabled, then we'll enable enhanced command buffer errors, which give us
more information about which encoder triggered the error. We'll also
print log messages from shader validation.
2021-02-24 19:53:10 -06:00
Bill Hollings
7ba625718a Support configuring whether to advertise extensions.
Always advertise VK_KHR_portability_subset. Advertise other extensions only if
MVKConfiguration::advertiseExtensions enabled and extension available on platform.
Reorganize and simplify checking extension platform availability.
2021-02-24 20:01:59 -05:00
Bill Hollings
8e610a43a8 Support configuring supported Vulkan API version.
Add MVKConfiguration::apiVersionToAdvertise and MVK_CONFIG_API_VERSION_TO_ADVERTISE
env var to configure MoltenVK to advertise a particular Vulkan version.

Advertise MVKConfiguration::apiVersionToAdvertise in:
  vkEnumerateInstanceVersion()
  vkGetPhysicalDeviceProperties()
  vkEnumerateInstanceLayerProperties()
  vkEnumerateDeviceLayerProperties()

Add MVKConfiguration::advertiseExtensions and MVK_CONFIG_ADVERTISE_EXTENSIONS
env var to configure MoltenVK to not advertise support for any Vulkan  extensions.
Refactor population of MVKConfiguration from environment variables to better
support validating and baking config values set by app.
Update MoltenVK version to 1.1.3.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 31.
2021-02-24 16:32:14 -05:00
Chip Davis
c225c423ba MVKMTLBufferAllocation: Support private temp buffers.
Some buffers, particularly those used by tessellation, indirect
multiview, or occlusion queries, are never written or read from the
host. Keeping the relevant data in VRAM should improve performance by
reducing the need for the GPU to make expensive accesses over the PCI
bus.

VRAM is a scarce resource on discrete GPUs, but this is part of why we
marked the buffers volatile.
2021-02-21 15:06:04 -06:00
Bill Hollings
3058a130d1
Merge pull request #1273 from billhollings/simulator-buffer-alignment
Set Metal buffer alignment to 256 on non-Apple Silicon iOS/tvOS simulators.
2021-02-21 13:03:22 -05:00
Bill Hollings
4675481a06 Redefine derivations of MVK_APPLE_SILICON, MVK_MACOS_APPLE_SILICON, and MVK_XCODE_12.
Derive MVK_APPLE_SILICON from target CPU.
Derive MVK_MACOS_APPLE_SILICON from target CPU and macOS platform.
Derive MVK_XCODE_12 from macOS and iOS SDK versions.
Test for simulator on non-Apple GPU using MVK_OS_SIMULATOR && !MVK_APPLE_SILICON.
2021-02-20 09:33:32 -05:00
Bill Hollings
0d1975907e Set Metal buffer alignment to 256 on non-Apple Silicon iOS/tvOS simulators. 2021-02-18 17:13:34 -05:00
Bill Hollings
c38f19dd20 Report accurate value for VkPhysicalDeviceLimits::maxBoundDescriptorSets.
This value is derived from limit expected by SPIRV-Cross.
The previous unbounded value was breaking CTS tests that used this value.
2021-02-18 13:47:45 -05:00
Bill Hollings
14dc8578ce Fix code formatting on completion handler blocks. 2021-02-17 14:09:05 -05:00
Bill Hollings
a1e33384c1 Remove @synchronized from MTLFunction specialization to avoid reentrant hang. 2021-02-17 13:56:37 -05:00
Bill Hollings
0b90a53d76 Fixes for CTS multithread tests.
MTLDevice retains an internal object web that is used during the creation of
new objects, such as pipeline states, libraries, functions, and samplers.
Simultaneously creating and destroying objects of these types can trigger
race conditions on the internal MTLDevice content.

Wrap the following in @synchronized (mtlDevice) {...}:
- MTLRenderPipelineState creation and destruction
- MTLComputePipelineState creation and destruction
- MTLLibrary creation
- MTLFunction creation and specialization
- MTLSampler creation and destruction
2021-02-17 09:33:04 -05:00
Bill Hollings
4a0a5cd0b4
Merge pull request #1267 from billhollings/rmv-cmd-enc-state-reset
Remove MVKCommandEncoderState::reset().
2021-02-12 19:28:02 -05:00
Bill Hollings
acf2a80535 Remove MVKCommandEncoderState::reset().
MVKCommandEncoderState has numerous subclasses, and the polymorphic
MVKCommandEncoderState::resetImpl() requires significant maintenance
across these subclasses. It's only use was in disabling depth-stencil state.

Remove MVKCommandEncoderState::reset() and all implementations of resetImpl()
across all MVKCommandEncoderState subclasses.
Remove MVKPipeline::__hasDepthStencilInfo and disable depth-stencil state
automatically via cleared Vulkan struct in MVKPipeline.
2021-02-12 19:04:17 -05:00
Bill Hollings
612c84d79e Remove official support for direct MSL shader loading from documentation. 2021-02-12 18:33:28 -05:00
Bill Hollings
4d60058efb Remove ONLY_ACTIVE_ARCH from Debug builds.
Debug builds now build for all platform architectures.
2021-02-12 09:50:17 -05:00
Bill Hollings
54e5723ff7
Merge pull request #1255 from billhollings/vizbuff-index
Fix Metal validation error of duplicate visibility offsets.
2021-02-10 19:37:59 -05:00
Bill Hollings
bbe87fe2fc Fix Metal validation error of duplicate visibility offsets.
Don't reset MVKOcclusionQueryCommandEncoderState::_mtlVisibilityResultOffset
when ending occlusion query, as subsequent queries need different offsets.

Also, remove MVKOcclusionQueryCommandEncoderState::_needsVisibilityResultMTLBuffer,
as it is always set once from MVKCommandBuffer::_needsVisibilityResultMTLBuffer.

When app setting MVKConfiguration it with a partial copy, start with existing.
2021-02-10 18:51:42 -05:00
Chip Davis
0ac65c87b8 MVKPhysicalDevice: Disable SIMD-group permutation for Mac family 1.
Our testing shows that none of the SIMD-group functions work on family
1, including `simd_is_first()`, which is needed for even `BASIC`
support.
2021-02-10 13:25:41 -06:00
Bill Hollings
84c6095fbf
Merge pull request #1243 from billhollings/config-strings
Test for null string on MVKConfiguration copy.
2021-02-08 07:14:08 -05:00
Bill Hollings
bbea8dabc9 Test for null string on MVKConfiguration copy.
When app sets MVKConfig not fully populated by app, or if app sets strings to null,
copy can fail. Test for this before copying.
2021-02-06 21:42:30 -05:00
Chip Davis
515a2cbcfe MVKPhysicalDevice: Clamp maximum buffer range to 4 GiB - 1.
It is possible for the maximum buffer size to be 4 binary gigabytes or
greater. In that case, the upper 32 bits will be lost, and the value of
the `maxUniformBufferRange` and `maxStorageBufferRange` limits would be
too small or even zero. Clamp it to 4 GiB - 1 in that case, since that
is the maximum value of a 32-bit integer.

For #1240.
2021-02-06 15:42:40 -06:00
Bill Hollings
efba5968a0
Merge pull request #1239 from billhollings/gpucapture
Add ability to automatically capture first GPU frame.
2021-02-04 13:47:48 -05:00
Bill Hollings
95cf144ccf Add ability to automatically capture first GPU frame.
Refactor auto GPU capture code to support both device and frame capture.
Add ability to automatically capture first GPU frame by setting
`MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE` to `2`.
Wrap GPU capture in autorelease pool to handle both cases of capture call
being made in run loop as in an app GUI, or in one-shot app like CTS.
2021-02-04 11:56:28 -05:00