225 Commits

Author SHA1 Message Date
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
Bill Hollings
abb8792843 fetchDependencies build external libraries in parallel by platform.
Log ext lib build steps to provide user feedback.
Add package_ext_libs_finish.sh script to separate packaging
libraries from building them, to avoid build database conflicts.
Travis only build macOS ext libs.
2020-06-22 00:00:00 -04:00
Chip Davis
75da0c694b Advertise the VK_EXT_robustness2 extension.
We only support the `robustImageAccess2` feature for now. Metal's
guarantees around out-of-bounds accesses to textures give us this for
free. `nullDescriptor` should also be possible to implement, but it
needs testing. Null image descriptors will probably just work, but null
buffer pointers probably not. We may need help, either from SPIRV-Cross
or a pass in SPIRV-Tools. `robustBufferAccess2` definitely needs an
assist from SPIRV-Tools. All three are useful for Direct3D compatibility
layers (DXVK, wined3d).
2020-06-16 12:06:38 -05:00
Bill Hollings
205b859580 Fix issue where mapped host-coherent device memory not updated from image contents on macOS.
Currently, when a mapping is initiated for host-coherent device memory, existing
image contents are copied from the MTLTexture to host memory. However, if
host-coherent device memory is already mapped in a long-standing memory mapping,
changes to MTLTexture content are not reflected to the host memory.

This change adds that capability to open memory mappings. When the image pipeline
barrier is applied to an image that is attached to a host-coherent device memory
that currently has an open memory mapping, the MTLTexture contents are copied to
the open host memory binding.

Add MVKMappedMemoryRange to retrieve the currently mapped range in an MVKDeviceMemory.

MVKImage cleanup use of isHostCoherent(). Let it be same as MVKDeviceMemory
and don't test for it from macOS because it is unnecessary.
2020-06-15 22:18:53 -04:00
Bill Hollings
c1c49def22 Move applyImageMemoryBarrier() logic to MVKImagePlane.
Mark MVKResource::bindDeviceMemory() as virtual.
Remove use of !! from mvkIsAnyFlagEnabled().
Update What's New document for VK_KHR_sampler_ycbcr_conversion.
2020-06-14 19:15:39 -04:00
Bill Hollings
89fce99ef1 Update What's New document. 2020-06-11 12:49:42 -04:00
Bill Hollings
752c1a908d Refactor Xcode build architectures
Set ARCHS build setting to $(ARCHS_STANDARD_64_BIT) in Xcode projects.
Remove ARCHS and VALID_ARCHS build settings in Xcode targets.
2020-06-09 16:39:23 -04:00
Bill Hollings
b408557c7e Set maxVertexInputBindingStride and maxVertexInputAttributeOffset to min Vulkan values.
Ensure kMVKUndefinedLarge... family of constant values are each a power-of-two.
Change several power-of-two math functions to template functions.
2020-06-09 14:44:50 -04:00
Bill Hollings
f39486666a Fix issue in reporting properties of substitutable VkFormats.
Report format properties only based on the primary MTLPixelFormat
of a VkFormat, not any possible substitution MTLPixelFormat.
Update MoltenVK version to 1.0.43 and VK_MVK_MOLTENVK_SPEC_VERSION to 26.
2020-06-09 12:01:55 -04:00
Bill Hollings
8d7468effb Update maximum number of framebuffer layers to 2048. 2020-06-01 23:41:36 -04:00
Bill Hollings
4840c97e94 Update dependency libraries to match Vulkan SDK 1.2.141. 2020-06-01 17:35:31 -04:00
Bill Hollings
1ef26259a7 Remove checking translated vertex bindings on inline buffers. 2020-05-31 21:38:05 -04:00
Bill Hollings
8671295570 Support vertex attribute offsets larger than the vertex buffer stride.
Add MVKTranslatedVertexBinding to describe a translated vertex binding, track these in
MVKGraphicsPipeline, and add a Metal vertex layout for each additional translated binding.
MVKGraphicsResourcesCommandEncoderState query MVKGraphicsPipeline for translated bindings
associated with existing bindings and binds the same MTLBuffer multiple times with
different offsets.
2020-05-31 14:16:12 -04:00
Bill Hollings
e302a6d023 Update to latest version of SPIRV-Cross.
Remove use of obsolete SPIRV-Cross API MSLVertexAttr content.
ExternalDependencies.xcodeproj updated to Xcode 11.5.
Update What's New document.
2020-05-30 16:07:47 -04:00
Bill Hollings
ea7303e8e6 Fix crash when more than two GPUs.
Crash happened because MVKPhysicalDevices created inline in MVKSmallVector<, 2>
using emplace_back(). Crash occurred when attempting to reallocate memory in
MVKSmallVector, and move inline MVKPhysicalDevice instances. Revert to tracking
MVKPhysicalDevice as pointers, which are easy to move after memory reallocation.

Review and optimize all uses of MVKSmallVector::emplace_back().
Set VkPhysicalDeviceLimits::maxSamplerLodBias to zero since it's unsupported.
Return error and use VK_POLYGON_MODE_LINE for unsupported VK_POLYGON_MODE_POINT.
2020-05-27 21:22:25 -04:00
Bill Hollings
9685f5d00a Support Xcode 11.5. 2020-05-22 18:48:29 -04:00
Bill Hollings
d343fed52e Add support for VK_KHR_external_memory extension.
Functions and functionality supported, but don't currently do anything
until Metal-friendly enumerations added to VkExternalMemoryHandleTypeFlagBits.
Updated What's New document.
2020-05-06 19:43:21 -04:00
Bill Hollings
efde388cbd Add support for VK_KHR_external_memory_capabilities extension.
Capability functions and functionality supported, but don't currently do anything
until Metal-friendly enumerations added to VkExternalMemoryHandleTypeFlagBits.
Rename MVKPhysicalDevice::getPhysicalDeviceMemoryProperties() to
getMemoryProperties() for consistency.
Updated What's New document.
2020-05-05 18:12:17 -04:00
Bill Hollings
e581266cc7 vkQueuePresentKHR() returns VkResult for each swapchain.
Add MVKSwapchain::getSurfaceStatus().
2020-04-15 15:31:29 -04:00