752 Commits

Author SHA1 Message Date
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
Chip Davis
dcd29975e6 Use the new memory barrier methods for pipeline barrier commands.
These two new methods introduced in Metal 2.1 (macOS 10.14) are more
granular, providing more control over what exactly must be sync'd. They
also work on buffer memory, meaning that buffer dependencies work
properly here.
2019-05-03 13:57:13 -05:00
Bill Hollings
acd8a6cb4d Resolve and merge conflicts. 2019-05-01 23:29:11 -04:00
Bill Hollings
173d8cc5f3 Add support for the VK_EXT_debug_report extension.
Add MVKDebugReportCallback class.
Add MVKVulkanAPIObject class as base class of classes exposed in Vulkan API.
Remove MVKRefCountedDeviceObject class and move ref-counting to MVKVulkanAPIObject.
Rename MVKDispatchableObject class to MVKDispatchableVulkanAPIObject.
Introduce multiple inheritance mixin classes into class hierarchy.
Add MVKBaseObject::getVulkanAPIObject() function to find Vulkan API object
controlling any subobject that needs to report something.
MVKCommandResourceFactory functions pass in calling object for reporting.
Add MVKBaseObject::reportMessage() & reportError() functions.
Replace mvkNotifyErrorWithText() static function with reportError()
instance function to allow access to debug reporting.
Redefine MVKLog*() functions to call reportError() instance method.
Delete MVKLogging.cpp.
Remove MVKLogging.h from MoltenVKShaderConverter project.
Add mvk_datatypes.hpp to redirect errors in mvk_datatypes.h functions to debug
reporting. Use mvk_datatypes.hpp internally for all references to these functions.
Convert several static methods to instance methods.
Refactor platform defines in MVKSurface.h.
Explicitly count MVKExtensionList extension count to avoid relying on struct size.
Remove MVKCommandBuffer::recordResult() and use setConfigurationResult().
Change log indication of error in logs from [***MoltenVK ERROR***] to [mvk-error],
for consistency with other log level indications.
Update MoltenVK version to 1.0.35.
2019-05-01 22:27:03 -04:00
Chip Davis
787086351f MVKBuffer: Force managed storage for linear textures on shared buffers.
Shared storage on textures is disallowed on macOS.

Fixes #573.
2019-05-01 09:37:27 -05:00
Bill Hollings
1b60679104
Merge pull request #571 from cdavis5e/fix-query-race
Fix a race condition between sync objects and queries.
2019-04-30 15:33:16 -04:00
Chip Davis
cd26de225b MVKPipeline: Account for tessellation shaders as well.
If we don't have them, it's not a tessellation pipeline.
2019-04-29 17:40:03 -05:00
Chip Davis
1188edca76 Get rid of the queue idle event, too.
Put the fence back on the last submission.

This mostly reverts the last of the original change, save for a few
formatting changes and deletions of unused cruft.
2019-04-29 16:05:50 -05:00
Chip Davis
ba7c578827 Get rid of the 'command buffer done' event.
Since we no longer have a completion block which runs asynchronously,
the race condition it was meant to guard against can no longer happen.
2019-04-29 13:15:27 -05:00
Chip Davis
256ffc6d31 Try to capture only the work queued up to this point in a fence. 2019-04-25 23:11:24 -05:00
Chip Davis
4591cac69b MVKVector: Make this more amenable to the standard algorithms. 2019-04-24 15:00:46 -05:00
Chip Davis
43f97113b6 Perform query pool copies on the device side. 2019-04-24 14:20:13 -05:00
Michael Barriault
b24d2e35ef Fix inequality. 2019-04-23 19:44:04 +01:00
Michael Barriault
cbd772a9d7 Refactor again to simplify conditionals. 2019-04-23 19:39:04 +01:00
Michael Barriault
dec40811ae Refactor to reduce code duplication. 2019-04-23 17:23:49 +01:00
Michael Barriault
a336e64bea Fix case where viewport/scissor doesn't get set properly when mixing dynamic and static-configured pipelines in the same command buffer. 2019-04-22 19:26:00 +01:00
Michael Barriault
0670ea133d Tweak counting logic 2019-04-22 15:48:48 +01:00
Michael Barriault
17da3e4d00 Move color attachment array access back inside if block. 2019-04-22 14:49:18 +01:00
Michael Barriault
eb468b7014 Fix unused attachments terminating loop early. 2019-04-20 23:01:57 +01:00
Bill Hollings
e91d2f6b35 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2019-04-18 15:12:42 -04:00
Michael Barriault
231196092b Fix spaces->tabs for consistency. 2019-04-17 22:51:40 +01:00
Michael Barriault
ea5e38093a Work around potential Metal bug with stage in indirect buffers. Exact size isn't needed in our case anyway. 2019-04-17 21:31:38 +01:00
Michael Barriault
be54e748f0 Fix tessellated indirect draws using wrong kernels to map parameters. 2019-04-17 21:30:42 +01:00
Bill Hollings
eca03b8de1 MoltenVKShaderConverter tool add MSL version and platform command-line options.
Add SPIRVToMSLConverterOptions::platform to track platform. Default to build platform.
Update default SPIRVToMSLConverterOptions MSL version to 2.1.
MoltenVKShaderConverter test MSL compilation use same MSL version as conversion.
Default min perf tracking value to 0.0.
SPIRVToMSLConverter.h reference spirv.hpp via SPIRV-Cross framework.
Update What's New document.
2019-04-17 16:09:07 -04:00
Chip Davis
48d319432a MVKCountingEvent -> MVKSemaphoreImpl.
Remove the redundant class I added. Simplify a bit.
2019-04-17 10:42:25 -05:00
Michael Barriault
0aed9167c1 Tweak tabbing for consistency. 2019-04-16 18:12:10 +01:00
Michael Barriault
ef3e590617 Use empty depth state for tessellation vertex pre-pass. 2019-04-16 18:03:51 +01:00
Michael Barriault
2d627c6b8f Fix intermediate Metal renderpasses load and store actions maintaining attachments appropriately. 2019-04-16 18:03:15 +01:00
Michael Barriault
4c4332b848 Fix zero local threadgroup size in indirect rendering. 2019-04-15 17:58:26 +01:00
Chip Davis
5df1b1b7db Don't use setVertexBytes() for passing vertex counts.
In a tessellated draw, the vertex shader will take a `device` pointer to
the vertex count. It must be a `device` pointer, because the `constant`
AS on Mac requires 256-byte alignment, which we cannot guarantee,
particularly with an indirect draw. But, the `setVertexBytes:...` method
cannot be used with the `device` AS. So, we need yet another temporary
buffer to hold this value in the `device` AS.

Fixes #566.
2019-04-13 12:49:20 -05:00
Chip Davis
9a0c4f6cef Fix a race condition between sync objects and queries.
In the past, MoltenVK signaled fences and semaphores immediately when
Metal reported that the batch was finished executing. But, some commands
do work in completion handlers that run concurrently with this. In
particular, in #278 I shunted copying query pool results onto a
different dispatch queue. This caused a race between this block and the
block which signals fences and semaphores.

Since some commands do work in completion handlers, the handler which
signals semaphores and fences must wait until these handlers finish
running. Also because of this, it is not adequate to submit a fence-only
request to implement `vkQueueWaitIdle()`. So, that function must now
wait for all submissions to complete. To preserve the invariant that
fence-only submissions are equivalent to `vkQueueWaitIdle()`, this
change also makes fence signaling wait for all submissions.

If the queue is continually supplied with new work, this implementation
may delay signaling fences indefinitely. Ideally, fences would only wait
for all work up to that point to complete before signaling. But I'm not
sure how to accomplish that yet.

Fixes #454.
2019-04-12 00:17:46 -05:00