443 Commits

Author SHA1 Message Date
Bill Hollings
6110c349ce
Merge pull request #1168 from billhollings/mac-catalyst
Support Mac Catalyst on macOS 11.0+
2020-12-02 19:51:52 -05:00
Chip Davis
e0e5d3ce28 Support the VK_EXT_subgroup_size_control extension.
This extension allows the subgroup size to vary between draw/dispatch
calls, and even allows clients to declare that full subgroups must
always be dispatched. It corresponds better to how Metal actually works.

No support for declaring a required subgroup size, unfortunately.
2020-12-02 09:38:58 -06:00
Bill Hollings
1ec58c9a92 Support building for Mac Catalyst on macOS 11.0+.
Define MVK_MACCAT build macro and use it to conditionally compile code to align
with build features and capabilities of Mac Catalyst platform on macOS 11.0+.
Treat Mac Catalyst as minor variation of macOS 11.0.
Update documentation.

Currently only support Mac Catalyst on macOS 11.0+, to avoid complexities of
deselecting iOS features and capabilities for Mac Catalyst on previous macOS versions.

Mac Catalyst (and Simulators) require use of XCFrameworks.
Currently unable to generate a dylib for Mac Catalyst.
2020-12-01 19:26:15 -05:00
Bill Hollings
163e8e5b20 Merge branch 'master' of https://github.com/billhollings/MoltenVK into desc-set-cleanups 2020-11-05 15:14:02 -05:00
Chip Davis
75129b849b Support the VK_EXT_texture_compression_astc_hdr extension.
Requires Apple family 6.

This adds one too many `MTLPixelFormats`, so I bumped the
`_mtlPixelFormatCount`.

Fixes #738.
2020-11-05 10:17:42 -06:00
Bill Hollings
cdd5b458da Fix Metal validation error when unused elements in
an array of sampler are not populated by descriptors.

Populate a default MTLSampler in unused sampler descriptors.
2020-11-04 22:16:04 -05:00
Chip Davis
8bb9db2dce Enable VK_EXT_post_depth_coverage for Apple Silicon on Mac. 2020-11-04 16:23:33 -06:00
Chip Davis
51afe4745e Enable VK_AMD_shader_image_load_store_lod for Apple Silicon on Mac. 2020-11-04 16:23:33 -06:00
Bill Hollings
6e5984832f Sync VK_EXT_descriptor_indexing branch with master. 2020-11-04 11:07:27 -05:00
Chip Davis
d635d19de4 Support Apple GPU pixel formats with Apple Silicon on Mac.
Also, enable rendering caps on linear textures. This is supported on
Apple GPUs.

Conversely, disable capabilities supported by desktop GPUs that are not
supported on Apple GPUs.

Sadly, no support for 16-bit packed pixel formats on non-Apple GPUs.
2020-11-03 16:23:36 -06:00
Bill Hollings
d3155bd811 VK_EXT_descriptor_indexing add support for update after binding.
MVKDevice track enabled VkPhysicalDeviceInlineUniformBlockFeaturesEXT features.
Disable prefilled MTLCommandBuffers if update after binding enabled.
Update to latest SPIRV-Cross that includes support for unsized arrays.
2020-11-03 11:40:10 -05:00
Bill Hollings
0098e94668 Set VK_EXT_descriptor_indexing features and properties.
Increase per-stage texture count to 96 for A11 SoC's and above.
Report VkPhysicalDeviceLimits::maxPerStageDescriptorStorageImages as Metal limit of 8.
Add MVKPhysicalDeviceMetalFeatures::maxPerStageStorageTextureCount and set to 8.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 29.
2020-10-28 19:36:33 -04:00
Bill Hollings
794edc5ec1 Initial support for handling VK_EXT_descriptor_indexing structures.
VK_EXT_descriptor_indexing adds no new functions, but does add six structures to
existing pNext chains. This initial commit processes these structs, but does not
yet perform any operational functionality for this extension.
2020-10-27 11:32:06 -04:00
Bill Hollings
cd9e2b0437 Allow binding descriptor set using layout different than it was created with.
Bind descriptors based on binding number within pipeline layout, not order within
layout, and descriptor set looks up descriptor using binding layout it was created with.
2020-10-20 17:24:17 -04:00
Bill Hollings
89e3f1447a Clarify documentation on mapping limitations for host-coherent image memory on macOS. 2020-10-14 10:47:02 -04:00
Bill Hollings
b71fe94558 Add support for VK_EXT_private_data extension.
Moved to a new model for creation: create and potentially destroy the object
within MVKDevice::create..., to hide it from vulkan.mm where all other object
creation errors are handled. We could move to this slowly over time.

Passes all 49 private data CTS tests.
2020-10-10 17:15:07 -04:00
Bill Hollings
1b4c045707 Move Metal drawable presentation from MTLCommandBuffer to MTLDrawable.
Update MVKPresentableSwapchainImage::presentCAMetalDrawable() to create a
MTLCommandBuffer scheduled-handler and present the MTLDrawable from there.

According to Apple, it is more performant to call MTLDrawable present from within a
MTLCommandBuffer scheduled-handler than it is to call MTLCommandBuffer presentDrawable:.

Pass presentation timing info as a struct to simplify calls.
2020-10-03 16:11:25 -04:00
Bill Hollings
4dee7c288d MVKImageView remove obsolete test for nil image.
Update What's New document.
2020-10-01 15:23:15 -04:00
Bill Hollings
9f2fc8f7d0 Update dependency libraries to match Vulkan SDK 1.2.154. 2020-09-28 19:03:00 -04:00
Bill Hollings
dea8fd4fd1
Merge pull request #1066 from billhollings/kill-opts
fetchDependencies builds serially by default.
2020-09-23 15:34:22 -04:00
Bill Hollings
eb706ea40c Update What's New document. 2020-09-23 15:04:52 -04:00
Bill Hollings
4097089f1c vkSetMTLTextureMVK() Fix crash if incoming MTLTexture does not have an IOSurface. 2020-09-23 13:06:25 -04:00
Bill Hollings
a23f99c3e5 Refactor MoltenVKShaderConverter frameworks.
Combine MoltenVKSPIRVToMSLConverter and MoltenVKGLSLToSPIRVConverter
frameworks into a single MoltenVKShaderConverter framework.

Update corresponding directory structures, symlinks, scripts, and build paths.
Update MoltenVK code to use new framework name for headers.
Add symlinks in API-Samples demo to support legacy
MoltenVKGLSLToSPIRVConverter header paths.

In addition to simplifying shader converter code and build management, the
use of only one shader converter framework fixes a race condition within Xcode,
prior to Xcode 12, when multiple targets use the same dependency XCFramework.
2020-09-23 11:09:46 -04:00
Bill Hollings
6fba50bba5 Update What's New document with new linking options. 2020-09-21 18:08:54 -04:00
Chip Davis
20217d0bf6 Support the VK_KHR_depth_stencil_resolve extension.
I've turned on the `Resolve` cap for stencil-only formats, even though
no version of the Metal Feature Set tables lists them as supporting
multisample resolve. Obviously, if they couldn't be resolve
destinations, the stencil-resolve filter that was introduced in Metal
2.1 wouldn't work. I don't know if the platforms and feature sets where
I've turned the bit on is accurate, though. Wider testing is needed.

Because Apple families 1 and 2 don't support depth/stencil resolve at
all, I've disabled the extension for those families. Since sample-zero
resolution is a required feature of Vulkan 1.2, this means we won't be
able to support 1.2 on those devices. If there's demand, we could
possibly have a compute pass which does sample-zero resolution.
2020-09-21 13:05:38 -05:00
Bill Hollings
76828818ce Add support for VK_KHR_portability_subset extension.
Remove support for VK_EXTX_portability_subset extension.
2020-09-21 11:33:29 -04:00
Bill Hollings
e9c4b4813b Cleanup Vulkan 1.1 info.
Update remaining documents to reference Vulkan 1.1 instead of 1.0.
Per Vulkan 1.1 spec, remove now-obsolete MVKInstance code
that emits error if app requests higher Vulkan version.
Upgrade MoltenVK version to 1.1.0.
2020-09-11 11:16:34 -04:00
Chip Davis
260f9393d7 Support the VK_KHR_create_renderpass2 extension.
This will be needed for two other Vulkan 1.2 extensions,
`VK_KHR_depth_stencil_resolve` and
`VK_KHR_separate_depth_stencil_layouts`.

Most of this is just changing MVKRenderPass to store everything
internally in `RenderPass2` format. I also added some basic handling for
a few things I left out from earlier changes, input attachment aspect
masks and dependency view offsets. The former won't become important
until Metal supports depth/stencil framebuffer fetch. The latter won't
be needed until we start using untracked resources, and therefore need
to insert explicit fences and/or barriers between subpasses. We don't
need either right now, but I've handled them regardless.
2020-09-10 19:09:05 -05:00
Bill Hollings
3fccd4bcbf Fix Metal validation error when occlusion query and
renderpass are in separate Vulkan command buffers.
2020-09-10 16:41:03 -04:00
Chip Davis
0cf2bfd1d2 Implement the vkEnumerateInstanceVersion() function.
We're Vulkan 1.1 now!
2020-09-08 13:22:17 -05:00
Chip Davis
09bcd534d9 Add basic support for VK_KHR_external_semaphore{,_capabilities}.
Also a non-functional base for future extensions. We can't implement it
anyway until all remaining bugs in `MTLEvent`-based semaphores are
fixed.

This is the last of the extensions that was promoted to core for Vulkan
1.1. We're almost there!
2020-09-05 21:05:54 -05:00
Chip Davis
e6424654e3 Add basic support for VK_KHR_external_fence{,_capabilities}.
Like with `VK_KHR_device_group` and `VK_KHR_external_memory`, this just
adds the groundwork needed to support future extensions; it provides no
actual support for external fences.

We should be able to easily support `VK_KHR_external_fence_fd`, by using
a POSIX semaphore. Since the fence FDs produced by that extension are
opaque, only supporting `close(2)` and `dup(2)`, we shouldn't have to
worry about portable programs poking the FD in weird ways. Hopefully.

Other types of external fences we might support include GCD semaphores
(`dispatch_semaphore_t`) and Mach semaphores (`semaphore_t`). I really
think we want support for GCD semaphores, because that's the most likely
object we're going to see passed between processes on Darwin given GCD's
built-in support for XPC.

I have deliberately omitted mention of these extensions from the user
guide. `VK_KHR_external_memory` was not mentioned in there, presumably
because no actual external memory types are actually supported.

Also, add missing `vkGetInstanceProcAddr()` entry for
`vkGetPhysicalDeviceExternalBufferPropertiesKHR()`. We have the
function, and we export the extension's name string. We might as well
make it available via `vkGetInstanceProcAddr()`.
2020-09-04 13:16:54 -05:00
Chip Davis
34930eaf5b Support the VK_KHR_multiview extension.
Originally, Metal did not support this directly, and still largely
doesn't on GPUs other than Apple family 6. Therefore, this
implementation uses vertex instancing to draw the needed views. To
support the Vulkan requirement that only the layers for the enabled
views are loaded and stored in a multiview render pass, this
implementation uses multiple Metal render passes for multiple "clumps"
of enabled views.

For indirect draws, as with tessellation, we must adjust the draw
parameters at execution time to account for the extra views, so we need
to use deferred store actions here. Without them, tracking the state
becomes too involved.

If the implementation doesn't support either layered rendering or
deferred store actions, multiview render passes are instead unrolled and
rendered one view at a time. This will enable us to support the
extension even on older devices and OSes, but at the cost of additional
command buffer memory and (possibly) worse performance.

Eventually, we should consider using vertex amplification to accelerate
this, particularly since indirect multiview draws are terrible and
currently require a compute pass to adjust the instance count. Also,
instanced drawing in itself is terrible due to its subpar performance.
But, since vertex amplification on family 6 only supports two views,
when `VK_KHR_multiview` mandates a minimum of 6, we'll still need to use
instancing to support more than two views.

I have tested this extensively against the CTS. I'm very confident in
its correctness. The only failing tests are
`dEQP-VK.multiview.queries.*`, due to our inadequate implementation of
timestamp queries; and `dEQP-VK.multiview.depth.*`, due to what I assume
is a bug in the way Metal handles arrayed packed depth/stencil textures,
and which may only be a problem on Mojave. I need to test this on
Catalina and Big Sur.

Update SPIRV-Cross to pull in some fixes necessary for this to work.

Fixes #347.
2020-09-03 17:14:46 -05:00
Bill Hollings
d4b5df532e Re-add support for bitcode generation on iOS and tvOS.
Set BITCODE_GENERATION_MODE build setting in all Xcode projects.
create_dylib.sh support BITCODE_GENERATION_MODE.
2020-08-11 20:18:50 -04:00
Bill Hollings
5126aaed3e Update MoltenVK version to 1.0.45.
Update What's New document.
2020-08-05 19:58:59 -04:00
Bill Hollings
2c7734eda8 Fix issue where expected buffer-sizes buffer not bound to Metal compute encoder.
MVKComputeResourcesCommandEncoderState update buffer-size value before buffer
bindings are encoded into Metal and are no longer marked as dirty.
2020-07-28 15:38:39 -04:00
Bill Hollings
834d391aec Update dependency libraries to match Vulkan SDK 1.2.148.
fetchDependencies support option to skip all library builds.
fetchDependencies avoid sync locks if not building in parallel.
fetchDependencies build glslang headers.
Update ExternalRevisions/README.md glslang build integration section.
Update What's New.
2020-07-27 22:25:44 -04:00
Bill Hollings
f7a1c87c71 Update pipeline cache to latest CompilerMSL::Options struct content.
SPIRVToMSLConversionOptions compare instances using memcmp(CompilerMSL::Options).
Update What's New document.
2020-07-27 15:02:56 -04:00
Bill Hollings
6b25c816b5
Merge pull request #976 from cdavis5e/pipeline-sample-mask
MVKPipeline: Pass the pipeline sample mask, if present, to SPIRV-Cross.
2020-07-27 10:31:44 -04:00
Chip Davis
cda8a2cf44 MVKPipeline: Pass the pipeline sample mask, if present, to SPIRV-Cross.
SPIRV-Cross can now AND the `gl_SampleMask` output with an additional
fixed mask, presumably from the pipeline. Use this new functionality to
implement pipeline sample mask handling.

Special thanks to Tomek Pontika and Corentin Wallez of Google for
graciously contributing their implementation to SPIRV-Cross.

Update SPIRV-Cross to pull in the change necessary for this.
2020-07-24 15:15:11 -05:00
Chip Davis
b1803ea5d7 MVKDevice: Support the VK_EXT_image_robustness extension.
This extension provides weaker guarantees than `VK_EXT_robustness2` and
its `robustImageAccess2` feature. Metal easily meets those guarantees,
with no action on our part necessary.
2020-07-24 15:13:58 -05:00
Bill Hollings
1f68d5fc2a Fix intermittent concurrent shader specialization race condition.
MVKShaderLibrary::getMTLFunction() synchronize and refactor release of Metal objects.
Make use of existing autorelease pool instead of discrete retain/release.
Wrap entire specialization operation in @synchronized() to guard against
Metal internals not coping with multiple simultaneous specializations.
2020-07-22 17:48:19 -04:00
Bill Hollings
81ec314787 Track if indirect tessellation drawing is supported.
Add MVKPhysicalDeviceMetalFeatures::indirectTessellationDrawing.
Return error if indirect tessellated draw command is used when not supported.
2020-07-21 14:10:20 -04:00
Bill Hollings
fc0750d67c Set VkPhysicalDeviceDriverPropertiesKHR::driverID to VK_DRIVER_ID_MOLTENVK.
Update to latest version of Vulkan-Headers.
2020-07-20 14:51:40 -04:00
Bill Hollings
f5b937c7f9 Add native support for VK_FORMAT_D16_UNORM on iOS 13.0+ and tvOS 13.0+. 2020-07-18 00:06:51 -04:00
Bill Hollings
5ff8531bba Include vertex attribute size when testing whether attribute offset exceeds stride.
Track Metal vertex binding stride alignment.
Add MVKPhysicalDeviceMetalFeatures::vertexStrideAlignment.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 27.
Update pipeline cache archive description for CompilerMSL::Options.
2020-07-11 15:36:44 -04:00
Bill Hollings
e39dde02ec Fix new and unexpected App Store failure on newly deprecated color space values. 2020-07-08 14:58:29 -04:00
Bill Hollings
cd18cec727 Fix small memory leak when setting swapchain color space.
Add CAMetalLayer::colorspaceNameMVK property to handle retain/release automatically.
2020-07-06 17:36:05 -04:00
Bill Hollings
e40153abae Update to latest SPIRV-Cross version,
MSL: Workaround broken scalar access chain behavior in LLVM IR / AIR
2020-07-06 13:05:55 -04:00
Bill Hollings
5e5d6439da Update documentation to cover tvOS, iOS Simulator, and tvOS Simulator. 2020-06-23 23:06:08 -04:00