1174 Commits

Author SHA1 Message Date
Bill Hollings
95f5b58145
Merge pull request #717 from billhollings/master
Fixes to vkCmdBlitImage() & vkCmdClearImage().
2019-08-12 17:50:44 -04:00
Bill Hollings
74e8af1525 vkCmdBlitImage() support format component swizzling. 2019-08-12 16:35:59 -04:00
Bill Hollings
f824c1a955 vkCmdClearImage() fix validation of depth attachment formats. 2019-08-12 14:45:53 -04:00
Bill Hollings
b6328641a4
Merge pull request #715 from billhollings/master
Add ability to automatically cause an Xcode GPU capture without developer intervention.
2019-08-11 20:16:23 -04:00
Bill Hollings
f93c572001 vkInvalidateMappedMemoryRanges() synchronizes managed device memory to CPU.
Add MVKDevice::invalidateMappedMemoryRanges().
Add MVKMTLBlitEncoder struct.
MVKDevice::getQueue() defaults to queue family zero and queue zero.
2019-08-11 19:59:40 -04:00
Bill Hollings
fdd1c85b50 Add ability to automatically cause an Xcode GPU capture without developer intervention.
Add MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE env var and build setting.
2019-08-10 15:23:18 -04:00
Bill Hollings
8db6177cf8
Merge pull request #714 from billhollings/master
Fix crash in vkDestroyPipelineLayout()
2019-08-10 00:02:04 -04:00
Bill Hollings
607941ebd7 vkCmdClearImage() set error if attempt made to clear 1D image.
VkPhysicalDevicePortabilitySubsetFeaturesEXTX::events set to true.
2019-08-09 23:10:04 -04:00
Bill Hollings
97a9e70b1e
Merge pull request #713 from cdavis5e/metal3-numa-heaps
MVKDevice: Report a second heap for non-UMA devices.
2019-08-09 15:23:35 -04:00
Bill Hollings
0fc3036983 Fix crash in vkDestroyPipelineLayout().
MVKPipelineLayout hold retained/released pointers to MVKDescriptorSetLayout,
instead of copies of MVKDescriptorSetLayout instances.
2019-08-09 14:48:24 -04:00
Bill Hollings
ce3757a56e Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-08-09 14:32:38 -04:00
Bill Hollings
1c02662afa
Merge pull request #712 from cdavis5e/device-group
Support the VK_KHR_device_group extension.
2019-08-09 14:31:10 -04:00
Chip Davis
92f0bec6e2 MVKDevice: Report a second heap for non-UMA devices.
This is the heap representing system memory. The memory type
corresponding to `MTLStorageModeShared` is reported as belonging to this
heap.

I've tried to correct the reported size of the heaps as well while I'm
at it. UMA GPUs and the system heap for NUMA GPUs use the system memory
size as the heap size, and the amount of available memory as the budget.
iOS 13 uses the new `os_proc_available_memory()` API for this purpose.
NUMA GPUs additionally use the memory used by the process as a crude
measure of system heap usage.
2019-08-09 11:53:39 -05:00
Bill Hollings
69b238f95e
Merge pull request #711 from cdavis5e/metal3-placement-heaps
Use placement heaps for VkDeviceMemory when possible.
2019-08-09 12:48:57 -04:00
Chip Davis
100d7aa543 Support the VK_KHR_device_group extension.
Largely minimal for now. Much of it, particularly most of the
interactions with `VK_KHR_swapchain`, was already implemented
previously. The only interesting bits are the `vkCmdDispatchBase()`
command, and the ability to create arbitrary swapchain images and bind
them to swapchain memory, which requires the use of the previously
implemented `VK_KHR_bind_memory2` extension. Most everything else can be
safely ignored for now.

Non-zero dispatch bases use the compute stage-input region to pass the
dispatch base group to the shader, which must manually adjust the
`WorkgroupId` and `GlobalInvocationId` builtins, since Metal does not do
this for us. I have tested that this approach works well--at least, well
enough to pass the CTS.

Because of the ability to bind arbitrary images to swapchain memory,
I've sucked the guts out of `MVKSwapchainImage` and into `MVKSwapchain`
itself. Availability and drawable management is now performed by the
swapchain object. `MVKSwapchainImage` is now just a specialized kind of
image, created when requested with a `VkImageCreateSwapchainInfoKHR`
structure.

Update SPIRV-Cross so we can support the `vkCmdDispatchBase()` command.

One more step towards Vulkan 1.1.
2019-08-09 11:41:10 -05:00
Chip Davis
17759a2b33 Use placement heaps for VkDeviceMemory when possible.
All Apple GPUs support this, as does Mac GPU family 2. With this, we can
avoid expensive copies between buffers and textures allocated from the
same memory, and reduce memory usage to boot.

macOS is, unfortunately, constrained by the fact that `MTLHeap` objects
do not support any storage mode other than `MTLStorageModePrivate`--not
even `MTLStorageModeManaged`. This won't help for managed textures
there. Perhaps Apple will fix this in a later version.
2019-08-09 10:44:43 -05:00
Bill Hollings
75b4c27d14 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-08-09 10:59:08 -04:00
Bill Hollings
4abc4d45e7
Merge pull request #710 from cdavis5e/metal3-new-colorspaces-fix-name
Fix name of Display-P3 linear color space.
2019-08-09 10:56:36 -04:00
Bill Hollings
f43169e441
Merge pull request #709 from cdavis5e/buffer-no-prefer-dedicated
Don't prefer dedicated allocations for buffer memory.
2019-08-09 10:55:55 -04:00
Bill Hollings
a93595e743
Merge pull request #708 from billhollings/master
Add support for VkEvent.
2019-08-09 10:55:02 -04:00
Chip Davis
57bcfe64f4 Fix name of Display-P3 linear color space.
The old `DCI_P3_LINEAR` enum is deprecated. Use
`VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT` instead. This is a closer match
for the Core Graphics name anyhow.
2019-08-08 23:45:13 -05:00
Chip Davis
28fb7be085 MVKImage: Don't prefer dedicated allocations for buffer-backed images.
For the same reason we don't prefer them for buffers.
2019-08-08 23:42:12 -05:00
Bill Hollings
769e8877ad
Merge pull request #707 from cdavis5e/swapchain-composite-alpha
MVKSwapchain: Add handling for compositeAlpha.
2019-08-08 23:21:59 -04:00
Bill Hollings
0305557548
Merge pull request #706 from cdavis5e/metal3-texture-swizzle
Take advantage of native texture swizzling support.
2019-08-08 23:21:37 -04:00
Bill Hollings
95def90d06 Remove error logging on VK_TIMEOUT of VkSemaphore and VkFence. 2019-08-08 17:10:35 -04:00
Chip Davis
db1b5a464c MVKBuffer: Don't prefer dedicated allocations.
We always just use the underlying `MTLBuffer` in the `MVKDeviceMemory`
anyway. Dedicated allocations don't really buy us anything here.
2019-08-08 15:17:05 -05:00
Chip Davis
f601e923bd MVKSwapchain: Add handling for compositeAlpha.
Set the `opaque` property of the `CAMetalLayer` based on this. In the
past, we did nothing; this actually corresponds to
`VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR`.

Drop support for premultiplied alpha. In Core Animation, this is managed
by the `contents` of the layer. Most layers use a `CGImage` or an
`NSImage` for their contents; the `AlphaInfo` property of a `CGImage`
determines whether or not it uses premultiplied alpha. However,
`CAMetalLayer` doesn't use a `CGImage`, but a custom opaque Core
Foundation object which ostensibly vends images to be displayed by the
layer. I don't know which kind of alpha it uses, but since most
applications render postmultiplied colors I'm going to assume that
premultiplied alpha isn't supported yet.
2019-08-08 15:14:55 -05:00
Bill Hollings
7dc642196a Add support for VkEvent.
Add MVKEvent class. MVKEventNative subclass uses native MTLEvent. MVKEventEmulated
subclass uses emulation using CPU blocking and MTLCommandBuffer completion handling.
MVKConfiguration::synchronousQueueSubmits now disabled by default if MTLEvents are not supported.
Document updated use of MVK_ALLOW_METAL_EVENTS and MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS
environment variables and synchronousQueueSubmits config setting, in vk_mvk_moltenvk.h.
2019-08-08 16:13:47 -04:00
Chip Davis
2b4f29abd7 Take advantage of native texture swizzling support.
When available, use it instead of doing it manually in the shaders.
Unfortunately, it's only available on Apple GPU family 4 and up, and
desktop GPU family 2. Should still provide a nice boost.
2019-08-08 15:01:07 -05:00
Bill Hollings
35276531dc
Merge pull request #703 from cdavis5e/metal3-3d-compressed-texture
Take advantage of Metal 3.0's support for 3D compressed textures.
2019-08-08 11:27:40 -04:00
Chip Davis
df5c5655cf Take advantage of Metal 3.0's support for 3D compressed textures.
Mac-only for now. Mostly because I don't know which formats beyond DXTn
and ASTC support 3D textures. Also, the extension to support 3D ASTC
compression isn't ready yet.
2019-08-06 11:08:37 -05:00
Bill Hollings
dcd5225e56
Merge pull request #702 from cdavis5e/metal3-min-lod
Advertise the shaderResourceMinLod feature.
2019-08-06 12:03:43 -04:00
Chip Davis
f558cacd03 Advertise the shaderResourceMinLod feature.
This has now been implemented in SPIRV-Cross. It's supported on Mac as
of Metal 3.0 (10.15).
2019-08-06 10:09:39 -05:00
Bill Hollings
b2d787c1f9
Merge pull request #701 from cdavis5e/metal3-hdr-metadata
Support the VK_EXT_hdr_metadata extension.
2019-08-06 10:47:16 -04:00
Chip Davis
02f66bba3f Support the VK_EXT_hdr_metadata extension.
This extension requires macOS 10.15. For some reason, even though
Apple said that the new Apple TV supports HDR10 and DolbyVision, the
`CAEDRMetadata` type underlying this is not supported on either iOS or
tvOS.

Also set the `wantsExtendedDynamicRangeContent` property on macOS to
enable HDR output. It's not only set if HDR metadata is attached, but
also if an HDR color space is selected.
2019-08-06 09:13:55 -05:00
Bill Hollings
9f2a18376e
Merge pull request #700 from cdavis5e/metal3-new-colorspaces
Add more supported color spaces as of the latest OS versions.
2019-08-06 08:14:28 -04:00
Chip Davis
321af99cad Link to CoreGraphics.framework.
This is needed for color space support. I guess AppKit reexports this
framework on macOS, but UIKit on iOS doesn't.
2019-08-05 23:18:58 -05:00
Bill Hollings
e38b7e7d90
Merge pull request #699 from billhollings/master
Fix crash when VkDeviceCreateInfo specifies queue families out of numerical order.
2019-08-05 16:47:09 -04:00
Chip Davis
d2f1b59c4c Add more supported color spaces as of the latest OS versions.
Support `VK_EXT_swapchain_colorspace` on iOS as well. The 13.0 headers
add the `colorspace` property needed for this.
2019-08-05 14:51:16 -05:00
Bill Hollings
1745bfee98 Fix crash when VkDeviceCreateInfo specifies queue families out of numerical order.
MVKDevice check highest queue family index before expanding queue family collection.
MVKVector add bounds check to at(), [], front() & back() functions.
2019-08-05 15:49:08 -04:00
Bill Hollings
30f83f5ab0
Merge pull request #698 from cdavis5e/metal3-fix-build
MVKDevice: Remove usage of MTLSoftwareVersion.
2019-08-05 15:47:53 -04:00
Chip Davis
5cc70bf6f0 MVKDevice: Remove usage of MTLSoftwareVersion.
Apple removed this from all SDKs as of Xcode 11 beta 5.
2019-08-05 11:57:48 -05:00
Bill Hollings
ff671179a3
Merge pull request #696 from billhollings/master
Two code structural design improvements: MVKVector & MVKLinkableMixin
2019-08-02 10:30:42 -04:00
Bill Hollings
e904d63138 Use MVKVector whenever possible in MoltenVK, especially within render loop.
Minor fixes and extensions to MVKVector implementations.
2019-08-01 15:05:01 -04:00
Bill Hollings
da7a4420f5 Consolidate the various linkable objects into a MVKLinkableMixin template base class.
Update MoltenVK version number to 1.0.37.
2019-07-30 00:54:27 -04:00
Bill Hollings
4f008101d8
Merge pull request #691 from billhollings/Metal-3.0
Merge master 1.0.36 into Metal-3.0 branch.
2019-07-29 23:56:16 -04:00
Bill Hollings
4d32b6620a Merge master 1.0.36 into Metal-3.0 branch. 2019-07-29 23:15:35 -04:00
Bill Hollings
ef14a14faa
Merge pull request #690 from billhollings/master
Host-coherent memory for linear images again, plus Vulkan loader magic number fix.
2019-07-29 22:29:43 -04:00
Bill Hollings
c857014bb3 Ensure Vulkan loader magic number persists in objects pooled by MoltenVK.
MVKDispatchableVulkanAPIObject::getVkHandle() re-establishes the loader magic number
before returning, in case the loader overwrote it before returning the object.
2019-07-29 17:50:42 -04:00
Bill Hollings
355e200a29 Revert to supporting host-coherent memory for linear images on macOS.
MVKImage::getMemoryRequirements() include host-coherent for linear images.
Cube demo on macOS not use staging buffers for loading images.
2019-07-29 15:52:24 -04:00