582 Commits

Author SHA1 Message Date
Bill Hollings
423944d01e Rename mvkAreFlagsEnabled() & mvkAreOnlyAnyFlagsEnabled()
functions for consistency with similar functions.
2019-07-04 16:08:12 -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
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
e6afb1fedb Add MTLCommandBuffer completion timing performance tracking option.
Add MVKPerformanceStatistics::MVKQueuePerformance::mtlCommandBufferCompletion.
Increment VK_MVK_MOLTENVK_SPEC_VERSION to 21.
2019-06-20 17:31:19 -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
e755a17907 Report image layer limits for attachments in vkGetPhysicalDeviceImageFormatProperties(). 2019-06-13 14:30:16 -04:00
Bill Hollings
7ba7f1efef Fixes to clearning attachments.
vkCmdClearAttachments(): Return encoder to previous pipeline, depth-stencil & resource state after execution.
Fix issue clearing stencil attachment via renderpass when depth attachment is not being cleared.
2019-06-13 13:21:26 -04:00
Józef Kucia
f9399f70e1 Mark stencil reference value as dirty in MVKCmdClearAttachment command.
MVKCmdClearAttachment sets the stencil reference value to 0 and the stencil
reference value is not properly restored for subsequent draw calls.

I'm affraid there might be more similar bugs in MoltenVK.
2019-06-11 13:51:19 +02:00
bearishsun
4df8b92e9c Rename vkSetThreadgroupSizeMVK to vkSetWorkgroupSizeMVK to be consistent with Vulkan terminology 2019-06-07 09:59:27 +02: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
bearishsun
7f5a70d802 Added a way to set compute kernel threadgroup size when using MSL source code or MSL compiled code 2019-06-06 11:19:41 +02: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
70b78ac7fa Fix crash on pipeline cache merge after VkShaderModule destroyed.
Set MTLFunction label immediately after creation from MVKShaderModule.
Remove _shaderModule reference from MVKShaderLibrary & MVKShaderLibraryCache.
No-op propogateDebugName() function in MVKShaderModule & MVKPipelineCache.
2019-05-30 17:53:11 -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
7d37d5be16
Merge pull request #623 from cdavis5e/no-viewports-assertion
Don't assert if no viewports or scissor rects were given.
2019-05-29 13:00:43 -04:00
Bill Hollings
2e36a38524
Merge pull request #622 from cdavis5e/new-spirv-cross
Update SPIRV-Cross.
2019-05-29 12:59:45 -04:00
Chip Davis
edecd7e804 Don't assert if no viewports or scissor rects were given.
Instead, just avoid calling into Metal. It's perfectly valid to specify
no viewports--for example, if rasterization is disabled. Perhaps, then,
it'd be better to assert that rasterization is disabled when no
viewports are given.
2019-05-29 10:53:56 -05:00
Chip Davis
f075adc93f Update SPIRV-Cross.
This adds support for the `OpArrayLength` instruction.
2019-05-29 10:49:28 -05:00
Bill Hollings
f8a2707b21 Fixes to VK_EXT_debug_marker extension.
vkCmdDebugMarkerBegin() and vkCmdDebugMarkerEnd() attach debug
groups to render encoder if available, or command buffer if not.
Name MTLRenderCommandEncoder first after renderpass,
if named, then command buffer, if named, then usage name.
Add MVKCommandEncoder::endRenderpass() to clean up renderpass components.
MVKShaderLibrary and MVKShaderLibraryCache track shader module to
retrieve name for MTLLibrary and MTLFunction, even when cached offline.
2019-05-29 09:13:01 -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
c2706f3e6b Fix offset of buffer view relative to buffer offset within device memory. 2019-05-27 17:56:44 -04:00
Bill Hollings
8efebd6485 Guard against null _debugNames being used to build name strings. 2019-05-27 15:48:10 -04:00
Sergey Cherepanov
ce492f4f54 Added missing texelBufferTextureWidth setting in MVKComputePipeline::getMTLFunction.
Fixes #589.
2019-05-27 20:29:18 +03:00
Józef Kucia
1f8967a617 Use device address space when decompressing DXT image data.
Buffers in constant address space must be aligned to 256 bytes on macOS.

This fixes Metal validation errors:

Compute Function(cmdCopyBufferToImage3DDecompressDXTn): the offset into the buffer src that is bound at buffer index 0 must be a multiple of 256 but was set to 12928.
Compute Function(cmdCopyBufferToImage3DDecompressDXTn): the offset into the buffer src that is bound at buffer index 0 must be a multiple of 256 but was set to 78464.
2019-05-27 12:42:11 +02: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
Bill Hollings
2da855a6bc Clear attachments using layered rendering only if framebuffer is layered.
Consolidate testing of subpass layered rendering.
Add MVKCommandEncoder _isUsingLayeredRendering member variable.
Track layered rendering enabled in MVKRPSKeyClearAtt.
Rename MVKRPSKeyClearAtt::enable() and ::isEnabled() functions.
Add MVKRPSKeyClearAtt::reset() function.
Consolidate viewport, scissor & attachment limits.
MVKImage add validation for layered rendering when used as attachment.
2019-05-15 22:40:47 -04:00
Bill Hollings
a52b984a31 Fixes to Metal renderpass layered rendering settings.
Only set MTLRenderPassDescriptor layered rendering properties if layered rendering
is supported and the framebuffer really has multiple layers.
MVKCmdClearImage don't set renderTargetArrayLength, since layers are cleared individually.
Update highest available MTLFeatureSets for use in pipelineCacheUUID.
2019-05-15 15:08:17 -04:00
Bill Hollings
1da02b6d73 Fix crash with multisample layered rendering on older macOS devices.
Add MVKPhysicalDeviceMetalFeatures::multisampleLayeredRendering feature.
MVKCmdClearAttachments shader don't include [[render_target_array_index]] if multisample
and multisampleLayeredRendering is false.
Refactor validation of VkImageCreateInfo when creating an MVKImage.
Validate MVKImage multisample layered array attachments require multisampleLayeredRendering.
2019-05-14 14:22:14 -04:00
Bill Hollings
5dcc6d7501
Merge pull request #598 from mmaldacker/bugix/texture_coherent
texture don't have coherent memory on mac os
2019-05-13 20:59:28 -04:00
Maximilian Maldacker
05d2fcbede check if _deviceMemory is valid before getting storage mode in image. 2019-05-13 20:24:45 +02:00
Bill Hollings
67743ab423 Automatically update VkPhysicalDeviceProperties::pipelineCacheUUID when SPIRV-Cross revision changes.
Generate derived External/SPIRV-Cross/mvkSpirvCrossRevisionDerived.h
header file from SPIRV-Cross_repo_revision file from within fetchDependencies.
MoltenVK includes derived header file and extracts first part of revision hash
for inclusion in pipelineCacheUUID.
Update highest available MTLFeatureSets for use in pipelineCacheUUID.
Suppress echoing of script directory changes in fetchDependencies.
2019-05-10 18:24:19 -04:00
Bill Hollings
c3aaf976ae Add support for the VK_NV_glsl_shader extension.
Support runtime shader compilation from GLSL.
Return VK_ERROR_INVALID_SHADER_NV on shader and pipeline compilation errors.
Add MVKShaderCompilationPerformance::glslToSPRIV to track GLSL conversion performance.
Rename MoltenVKGLSLToSPIRVConverter MVKShaderStage enum to MVKGLSLConversionShaderStage
to avoid naming conflicts with MoltenVK MVKShaderStage enum.
Hologram demo load SPIR-V directly instead of using GLSL through either
MoltenVKGLSLToSPIRVConverter or VK_NV_glsl_shader extension.
Update to latest version of VulkanSamples that supports MVKGLSLConversionShaderStage.
2019-05-10 12:21:03 -04:00
Maximilian Maldacker
a615dabe85 texture don't have coherent memory on mac os 2019-05-10 12:27:40 +02:00
Bill Hollings
6b2e225d5c Update logic in mvkMTLRenderStagesFromVkPipelineStageFlags(), and test for renderpass. 2019-05-09 00:34:06 -04:00
Bill Hollings
f5999a8e76 Allow mvkMTLRenderStagesFromVkPipelineStageFlags() to map to all Vulkan stages,
by indicating whether the pipeline barrier should come before or after the stages.
2019-05-08 23:10:48 -04:00
Bill Hollings
224c3451f0 Resolve and merge conflicts. 2019-05-08 15:15:14 -04:00
Chip Davis
b491578c93 Actually use the correct device. 2019-05-07 14:00:36 -05:00
Chip Davis
be1a821a8c Use a Metal feature bit for memory barrier support. 2019-05-07 12:08:23 -05:00
Chip Davis
5c5f890039 Merge remote-tracking branch 'origin' into pipeline-barriers-2.1 2019-05-07 11:56:07 -05:00
Bill Hollings
cbb39a2f62
Merge pull request #591 from cdavis5e/gpu-semaphores
MVKSemaphore: Use MTLEvent for device-side synchronization.
2019-05-07 12:26:52 -04:00
Chip Davis
a3aec8db1a Don't use MTLBarrierScopeRenderTargets on iOS.
It's not available there.
2019-05-07 10:55:50 -05:00
Chip Davis
a42e77b101 MVKDevice: Don't unnecessarily iterate resources for global memory barriers.
All of the resources' `applyMemoryBarrier()` methods check if the second
scope contains host operations. If they don't, they have no effect. If
there are a lot of resources, iterating them for a method that will
ultimately do nothing is wasteful. Bail out if we can see that they will
do nothing.
2019-05-03 14:13:20 -05:00
Chip Davis
b02d354be5 MVKSemaphore: Use MTLEvent for device-side synchronization.
While `MTLFence` could be used for synchronization within a single
queue, it doesn't prevent execution across queues. For this, an
`MTLEvent` is required. Yes, this requires Metal 2.1 (macOS 10.14, iOS
12). Older versions will continue to use the old, CPU-based
implementation.

According to the Vulkan spec, semaphores must either be already signaled
or have a signal operation in progress before waiting for them. This
implementation increments the `MTLEvent`'s expected value after encoding
a wait operation, which requires this assumption to hold.

One thorny bit is acquiring a swapchain image when it is not already in
use. In this case, any semaphore provided must be signaled right away.
To accomplish this, a command buffer is executed which performs the
signal operation on the device. Alternatively, we could use an
`MTLSharedEvent`, which would allow us to signal the event on the host.
But, this could have performance implications that may not be
acceptable, just to handle this one case.

Fixes #438.
2019-05-03 14:01:55 -05:00