154 Commits

Author SHA1 Message Date
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
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
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
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
Bill Hollings
95def90d06 Remove error logging on VK_TIMEOUT of VkSemaphore and VkFence. 2019-08-08 17:10:35 -04: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
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
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
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
Bill Hollings
095dd3339b Update to latest version of SPIRV-Cross.
Update demos to latest dependency library versions.
Update to Xcode 10.3.
Update What's New document.
2019-07-24 14:39:38 -04:00
Bill Hollings
2f468db9a2 Updates for SDK 1.1.114 release.
Update to latest external dependency libraries.
Rename components of VK_INTEL_shader_integer_functions2 to match 1.1.114 Vulkan spec.
Update What's New document.
2019-07-23 14:29:32 -04:00
Bill Hollings
1a9b0cba51 Fix crash when binding descriptor set to layout that has been destroyed and recreated.
Remove the descriptor set pool associated with a MVKDescriptorSetLayout when the layout
is destroyed. MVKDescriptorPool and MVKDescriptorSetLayout track each other to tell the
other when it has been destroyed.
2019-07-22 15:53:59 -04:00
Bill Hollings
6cc4b484db Return error when MVKImage created as 1D attachment. 2019-07-19 19:25:54 -04:00
Bill Hollings
a1fb3b106e Fix issue with push constants used across multiple draw calls not being applied.
Ensure MVKPushConstantsCommandEncoderState stays dirty until it actually makes changes.
2019-07-19 13:32:50 -04:00
Bill Hollings
27a1c44f0a Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-07-17 17:38:11 -04:00
Chip Davis
4fbbb313f2 Support the VK_INTEL_shader_integer_functions2 extension. 2019-07-17 11:36:58 -05:00
Chip Davis
530d84ba42 Advertise the VK_AMD_shader_trinary_minmax extension. 2019-07-17 11:36:58 -05:00
Chip Davis
3f3810afbd Advertise the VK_EXT_post_depth_coverage extension.
iOS only, and only on A11/A12 devices (GPU Family 4/5).
2019-07-17 11:36:58 -05:00
Chip Davis
b2ae0f011c Support the VK_EXT_scalar_block_layout extension. 2019-07-17 11:36:58 -05:00
Bill Hollings
de29ba9318 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-07-16 22:48:46 -04:00
Chip Davis
7771b00bee Support the VK_EXT_texel_buffer_alignment extension.
This extension lets implementations report separate limits for uniform
and storage texel buffers, as well as whether or not the required
alignment is only a single texel of the buffer view's format.

This information is available in Metal, but only through an API query.
We must query the required alignment for every buffer view format we
support.

Update Vulkan-Headers to pull in support for this new extension.
2019-07-16 14:51:45 -05:00
Bill Hollings
fe3b2fbd5f
Merge pull request #666 from cdavis5e/swapchain-colorspace
Support the VK_EXT_swapchain_colorspace extension.
2019-07-16 15:37:06 -04:00
Chip Davis
8c3d30b12b Support the VK_EXT_swapchain_colorspace extension.
Only some of the color spaces provided by this extension are supported.
macOS 10.12 supports a few more. macOS 10.14 (at least, according to the
*10.15* SDK) supports even more. (But that needs a change to the
Metal-3.0 branch.)

I've chosen to group by color space. That way, programs will find the
all the supported formats early on. Programs that are interested in
the color space can keep looking.
2019-07-16 10:14:28 -05:00
Bill Hollings
ab643baa5b Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-07-16 11:09:05 -04:00
Chip Davis
a2533116b3 Support the VK_KHR_uniform_buffer_standard_layout extension.
This happens to fall out of the way structure layouts are handled in
SPIRV-Cross.
2019-07-16 00:01:48 -05:00
Bill Hollings
d1a6b5a40d Remove exposure to leakable instances of NSString, NSArray & NSDictionary.
Reduce creation of autoreleased instances of NSString, NSArray & NSDictionary.
Ensure remaining are covered by deliberate autorelease pools.
2019-07-15 18:59:52 -04:00
Chip Davis
fc13aec2af Advertise the VK_EXT_shader_stencil_export extension.
This is supported by Mac GPU Family 2 starting on macOS 10.14, and Apple
GPU Family 5 starting on iOS 12.

Supporting this is a bit tricky. Because only some devices support this
extension, we now have to keep track of supported device extensions per
device.
2019-07-15 12:12:39 -05:00
Bill Hollings
35d40a83b0 vkCmdCopyImage() support copying between compressed and uncompressed formats. 2019-07-05 19:39:52 -04:00
Bill Hollings
5e0214d3e1 MVKCmdBufferImageCopy don't supply bytes per image if not array texture.
MVKRPSKeyBlitImg::isArrayType() include multisample array type.
Clean up formatting in texture type functions in mvk_datatypes.mm.
2019-07-05 11:21:23 -04:00
Bill Hollings
c593cebce5 MVKCmdCopyImage validate that formats are compatible for copying.
MVKCmdBlitImage use same validation to use direct copy when possible.
2019-07-04 19:19:11 -04:00
Bill Hollings
74e38659aa Set Metal texture usage to allow texture copy via view.
MVKCmdCopyImage uses texture view if formats different. Enable
MTLTextureUsagePixelFormatView for VK_IMAGE_USAGE_TRANSFER_SRC_BIT.
Refactor mvkMTLTextureUsageFromVkImageUsageFlags() to clarify Metal usages
and enable views on depth-stencil attachments by default.
2019-07-04 15:50:12 -04:00
Bill Hollings
aa6a10570a Support VK_EXT_metal_surface extension.
Modify demo apps to pass OS layer instead of view.
2019-07-03 20:23:43 -04:00
Bill Hollings
8df685a9dc Fix race condition between swapchain image destruction and presentation completion callback.
Retain MVKSwapchainImage before passing to MTLCommandBuffer completion handler.
Redesign MVKVulkanAPIObject retain/release functionality using atomic ref count
instead of mutex locks, to simplify design and improve performance.
2019-06-30 17:28:52 -04:00
Bill Hollings
fb4dd158d0 Document each function in vk_mvk_moltenvk.h to indicate they cannot be used
with objects retrieved through the Vulkan SDK Loader and Layers framework.
2019-06-30 11:16:08 -04:00
Bill Hollings
7c71263f98 Add note in MoltenVK_Runtime_UserGuide.md that the functions in vk_mvk_moltenvk.h cannot
be used with objects retrieved through the Vulkan SDK Loader and Layers framework.
2019-06-29 19:55:07 -04:00
Bill Hollings
1b4124d4aa For shaders created directly from MSL, set function name from
VkPipelineShaderStageCreateInfo::pName.
2019-06-29 19:18:32 -04:00
Bill Hollings
84ea825ea3 Separate SPIRVToMSLConverterContext into input config and output results.
Refactor SPIRVToMSLConverterContext into distinct SPIRVToMSLConversionConfiguration
and SPIRVToMSLConversionResults for conversion input and output, respectively.
Update to latest SPIRV-Cross version.
Update What's New document.
2019-06-29 18:01:07 -04:00
Bill Hollings
a0f0c78b34 Expand MVK_CONFIG_TRACE_VULKAN_CALLS to optionally log Vulkan call timings.
Update What's New document.
2019-06-21 22:56:13 -04:00
Bill Hollings
ef8de08ff1 Skip SPIRV-Tools build in Travis.
Add fetchDependencies option to skip building SPIRV-Tools and use a template of pre-generated headers.
Modify .travis.yml to use this.
2019-06-16 12:00:22 -04:00
Bill Hollings
64d7e07243 Support immutable depth compare samplers as constexpr samplers hardcoded in MSL.
On iOS GPU family 2 and earlier:
  - Allow immutable samplers to be passed to SPIRV-Cross in a format
    they can be output as hardcoded constexpr samplers in MSL.
  - Validate depth compare samplers are only used as immutable.

MVKMVKPipelineLayout & MVKDescriptorSetLayout can take null MVKCommandEncoder
to perform a validation pass when binding or pushing.
Reduce redundancy by combining SPIRVToMSLConverterContext structs
with compatible SPIRV-Cross structs.
Update MoltenVK version to 1.0.36.
2019-06-15 01:47:13 -04:00
Bill Hollings
bf8c7f8bb8 Updates for SDK 1.1.108 release.
Update to latest external dependency libraries.
MVKDescriptorSetLayoutBinding allow binding of null MVKBuffer.
Update What's New document.
2019-06-13 17:11:44 -04:00
Bill Hollings
907c85a54c Guard against missing Metal pipeline states when pipeline compilation fails.
MVKPipeline records whether Metal pipelines are successfully compiled.
Pipeline and draw commands check for valid Metal pipeline state before encoding.
Compute compilation operations can have custom names.
Name Tessellation control stage compute compiler for logging.
2019-06-06 18:27:43 -04:00
Bill Hollings
673788cba8 VkSemaphore optionally uses MTLEvent, if available and
MVK_ALLOW_METAL_EVENTS environment variable is enabled.
2019-06-05 11:23:46 -04:00
Bill Hollings
3e069c4a78 Add support for the VK_EXT_debug_utils extension.
Dispatch messenger callbacks on any reported message or error.
Add MVKDebugUtilsMessenger class.
Add MVKVulkanAPIObject::getVkObjectType() function and override in all Vulkan API objects.
MVKDevice::getMTLPixelFormatFromVkFormat() take base object for reporting.
2019-05-29 17:26:50 -04:00
Bill Hollings
fbf2af58a0 Fixes and consolidation of external library header references.
All external library header references consistently include framework references.
Cleanup references to external library headers that are no longer required.
Simplify and consolidate external library header paths in Xcode projects.
Add MVK_EXCLUDE_SPIRV_TOOLS build option to avoid use of SPIRV-Tools library.
Remove all other references to headers within SPIRV-Tools library.
2019-05-28 17:19:43 -04:00
Bill Hollings
8d9fa6bbd5 Add support for VK_EXT_debug_marker extension.
Move MVKVulkanAPIObject to its own .h/mm files.
Add MVKCmdDebug.h/mm files.
Change extension on MVKExtensions.cpp and MVKBaseObject.cpp to .mm.
Remove unused command use in MVKQueue submit() and waitIdle() functions.
MVKCommandPool constructor use default isPooling value in MVKCommandTypePool constructors.
MVKSwapchainImage pass image index in constructor.
2019-05-25 16:23:05 -04:00
Bill Hollings
b773e7aaab Fix sporadic crash on vkDestroySwapchainKHR().
MVKSwapchain & MVKSurface init _layerObserver to nil.
2019-05-20 16:13:52 -04:00