372 Commits

Author SHA1 Message Date
Bill Hollings
a5ee3ead35 Update library dependencies to match Vulkan SDK 1.2.189.
Update What's New document.
2021-08-30 13:54:37 -04:00
Bill Hollings
f5dd310c55
Merge pull request #1426 from billhollings/partial-clear-stencil
Several renderpass clearing and input fixes from CTS
2021-08-23 19:42:13 -04:00
Bill Hollings
43a133ff10 Update to latest version of SPIRV-Cross.
MSL: Support row-major transpose when storing matrix from constant RHS matrix.
MSL: Fix casting in constant expressions with different sizes.
MSL: Fix duplicate gl_Position outputs when gl_Position defined but unused.
2021-08-23 18:31:45 -04:00
Bill Hollings
8a7e20d348 Fix GPU race condition when clearing a renderpass input attachment on Apple GPUs.
Apple GPUs do not support rendering/writing to an attachment and then reading
from that attachment within a single Metal renderpass. On Apple Silicon, restart
the Metal renderpass if an input attachment is cleared inside renderpass.

Don't clear render area when restarting Metal renderpass, as it should not occur,
and itself causes a recursive loop restarting the renderpass as a result.

Add MVKCommandUse::kMVKCommandUseRestartSubpass.
MVKCommandEncoder::beginMetalRenderPass() pass MVKCommandUse to help determine
Metal renderpass attachment load and clearing options.
2021-08-23 14:28:20 -04:00
Bill Hollings
ce583f4f3d Support stencil-only partial attachment clearing.
Rename MVKRenderPassAttachment::shouldUseClearAttachment() to
shouldClearAttachment(), pass whether testing for stencil clearing,
and check stencil clearing distinct from depth clearing.
Refactor MVKRenderSubpass::populateClearAttachments() to work with this.
Remove MVKRenderPassAttachment::getAttachmentStencilLoadOp() as obsolete.
2021-08-19 17:22:29 -04:00
Bill Hollings
8c7db31cd7 Prefer MTLEvent for VkSemaphore, except on NVIDIA, prefer emulation.
Disable MVK_ALLOW_METAL_FENCES by default.
Disable use of MTLEvent on NVIDIA.
By default, use MTLEvent for VkSemaphore everywhere except NVIDIA.
By default, use CPU synchronization on NVIDIA.

These changes fix a large number of CTS synchronization test failures.
2021-08-10 11:32:21 -04:00
Bill Hollings
8e6731fd8e Revert to prefer MTLEvent over MTLFence for VkSemaphore, except on NVIDIA.
Prefer MTLEvent over MTLFence for VkSemaphore, because MTLEvent handles
sync across MTLCommandBuffers and MTLCommandQueues, except on NVIDIA GPUs,
which have demonstrated trouble with MTLEvents, prefer MTLFence.
Add MVKDevice::VkSemaphoreStyle enum.
2021-08-10 10:29:09 -04:00
Bill Hollings
12f0089d0c Support resolving attachments with formats that Metal does not natively resolve.
Metal does not support resolving all formats that support MSAA, whereas Vulkan
assumes any MSAA format can be resolved. We fix that by running an optional
post-renderpass compute shader that resolves such textures by simply taking the
first sample as the resolved sample. This works to fix all failing CTS tests,
because such formats are all integer formats, and Vulkan allows an arbitrary
single sample value to be selected.

If we need to resolve, but the Metal format doesn't support it,
cause the Metal renderpass to store the MSAA attachment results.

MVKRenderSubpass don't establish Metal resolve attachment textures if format
is not natively resolvable, and encode Metal renderpass store actions accordingly.
MVKCommandEncodingPool add MTLComputePipelineStates to run simple resolve
compute shaders on attachments that cannot be resolved in Metal renderpass.
Add MVKRenderSubpass::resolveUnresolvableAttachments() and call from
MVKCommandEncoder::endMetalRenderEncoding(), before subpass index is updated.
Rename MVKCommandEncodingPool::getClearStateIndex() to
getRenderpassLoadStoreStateIndex() and remove MVK_MACOS restriction on
clearing shaders to allow compatibility with resolve shader handling.
MVKRenderPassAttachment remove validation of whether a format can be resolved.
MVKPixelFormats::getMTLTextureUsage() add read and write usage as appropriate
to allow compute shader to run to resolve formats not natively resolvable.
MVKPixelFormats remove obsolete unit test code.
MVKImageView clean up access functions and obsolete constructor
use of MVKConfiguration.
2021-08-03 18:47:13 -04:00
Bill Hollings
086c680436 Fix pipeline barriers not working inside self-dependent subpasses on Apple GPUs.
On Apple GPUs, MVKCmdPipelineBarrier restarts Metal renderpass when encountered
inside self-dependent Vulkan subpass where the same attachment acts as both
input attachment and render attachment.
2021-07-30 15:25:59 -04:00
Bill Hollings
665dbfd632 Fix issue with vkCmdBlitImage() from compressed textures. 2021-07-27 18:08:50 -04:00
Bill Hollings
b40dba904d Fix issue where swapchain images were acquired out of order under heavy load.
Move update of MVKSwapchainImageAvailability::acquisitionID to the acquisition
time instead of the become available again time, so other images will be preferred
if either all images are available or no images are available.
2021-07-27 15:42:43 -04:00
Bill Hollings
2adb24bde2 Merge master branch into timestamp-using-metal-gpu-counters branch. 2021-07-23 12:42:27 -04:00
Bill Hollings
386bde9c78 Update to latest SPIRV-Cross version.
MSL: Adjust gl_SampleMaskIn for sample-shading and/or fixed sample mask.
MSL: Fix setting SPIRVCrossDecorationInterpolantComponentExpr decoration.
MSL: Simplify spvSubgroupBallot().
2021-07-22 11:03:52 -04:00
Bill Hollings
6ae1745a9c Vulkan timestamp query pools use Metal GPU counters when available.
Add MVKPhysicalDeviceMetalFeatures::counterSamplingPoints
to track platform availability of GPU counters.
MVKPhysicalDevice creates and manages MTLCounterSets and checks for and enables
flags within MVKPhysicalDeviceMetalFeatures::counterSamplingPoints.
Add abstract MVKGPUCounterQueryPool class as parent of MVKTimestampQueryPool
and MVKPipelineStatisticsQueryPool concrete classes and refactor access to host
and command copy tracking data to allow extraction from MTLCounterSampleBuffer.
MVKTimestampQueryPool uses MTLCounterSampleBuffer if supported, otherwise reverts
to using host data for timestamps.
MVKCommandEncoder encodes Vulkan timestamp commands either as Metal staged or
command timestamps, depending on whether the GPU is tile-based or immediate-mode.
For Metal stage counters, we use a light-weight dummy BLIT encoder to mark
timestamp commands executed in the previous Metal encoding pass.
Add MVKDevice::getDummyBlitMTLBuffer() to supply a dummy single-byte buffer that
can be used by a stand-alone MTLBlitCommandEncoder as dummy work to mark timestamps.
2021-07-20 22:13:04 -04:00
Bill Hollings
b1a8b59f66 Support alpha-to-coverage without a color attachment.
If alpha-to-coverage is enabled, we must enable the fragment shader first color output,
even without a color attachment present or in use, so that coverage can be calculated.
2021-07-10 15:38:02 -04:00
Bill Hollings
b3cf74401f Disable VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT for
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 on macOS Apple Silicon.

On Apple Silicon (iOS/tvOs/macOS M1), format VK_FORMAT_E5B9G9R9_UFLOAT_PACK32
is fully supported as a color attachment except that format components cannot
be individually write-enabled. All components must either be write-enabled or
write-disabled together. This is causing several hundred Vulkan CTS blending
tests to fail on M1. The least intrusive behavioural change to allow the CTS
tests to report Not Supported instead, is to disable blending for this format.
2021-07-08 15:52:34 -04:00
Bill Hollings
53a2223abd Fix swizzle of depth and stencil values into RGBA (float4) variable in shaders.
MVKImageViewPlane track Vulkan component swizzle instead of just packed
swizzle, and modify swizzle when using depth or stencil sampling or reading.
2021-07-06 17:57:47 -04:00
Bill Hollings
2d30c0ae13 Fix incorrect translation of clear color values on Apple Silicon.
The same set of CTS tests either fails or passes on different GPUs
based on whether or not we adjust float clear colors by one ULP.
Add MVKFloatRounding enum.
Add MVKPhysicalDeviceMetalFeatures::clearColorFloatRounding.
Disable ULP adjustment for clear colors on Apple Silicon.
For consistency and to simplify bookkeepping, calculate
clear color ULP adjustment from bit width of format component.
Update MoltenVK version to 1.1.5.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 32.
2021-07-04 11:41:39 -04:00
Bill Hollings
4f7f0dc209
Merge pull request #1392 from billhollings/sdk-1.2.182
Update dependency libraries to match Vulkan SDK 1.2.182.
2021-06-28 08:11:38 -04:00
Bill Hollings
e3cf071ace
Merge pull request #1387 from billhollings/occlusion-query-fixes-for-M1
Occlusion query fixes for M1
2021-06-28 08:10:17 -04:00
Bill Hollings
55c5cee233 Update dependency libraries to match Vulkan SDK 1.2.182. 2021-06-25 15:32:34 -04:00
Bill Hollings
84e8e9ed73
Merge pull request #1389 from billhollings/add-cts-script
Add Scripts/runcts script as a convenience for running Vulkan CTS tests.
2021-06-24 13:14:16 -04:00
Bill Hollings
25d1349579 Add Scripts/runcts script as a convenience for running Vulkan CTS tests.
Update .gitignore to ignore CTS artifacts in Scripts directory.
2021-06-22 19:45:24 -04:00
Bill Hollings
664296abd0 Fix small memory leak during swapchain creation.
Add ability to profile Cube demo on macOS.
2021-06-22 11:50:58 -04:00
Bill Hollings
e72cd614e1 Fix issue where M1 GPU does not support reusing Metal visibility buffer offsets
across separate render encoders within a single Metal command buffer (Vulkan submit).

Add MVKCommandEncodingContext to track information across multiple
MVKCommandEncoders, and use it to track temporary visibility buffer and offset.
Add support for more than one temporary visibility buffer per MTLCommandBuffer
when current temporary visibility buffer is exhausted.
2021-06-21 11:17:40 -04:00
Bill Hollings
6b502bcb60 Upgrade projects to Xcode 13 SDK APIs.
Add MVK_XCODE_13 code macro.
Support MTLLanguageVersion2_4 enum value.
MoltenVKPackaging project add DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING
build setting to suppress build warnings about using manual build orders.
2021-06-14 16:24:32 -04:00
Bill Hollings
269fca63ba Upgrade project builds to use C++17. 2021-06-14 10:39:42 -04:00
Bill Hollings
51188ace2c Clear attachments in MVKCmdBeginRenderPass between invocations.
Fixes crash due to incorrect number of attachments.
Update What's New document with VK_KHR_imageless_framebuffer extension.
2021-05-31 21:31:30 -04:00
Bill Hollings
776719106c Fix crash using memoryless storage for input attachments on Apple Silicon.
Don't allow memoryless storage for VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT.
Memoryless storage for VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT descriptors
requires support for, and use of, shader framebuffer fetch.

Remove compile-time checking for MVK_APPLE_SILICON before disabling memoryless storage
for buffers and images, since the requirement exists for all platforms, and memoryless
storage will already otherwise be disabled on other platforms anyway.
2021-05-31 17:20:35 -04:00
Bill Hollings
e06eb3a892
Merge pull request #1370 from f32by/imageless_framebuffer
Support the VK_KHR_imageless_framebuffer extension.
2021-05-31 13:20:24 -04:00
UnsafeBy
a723dc1f21 Support the VK_KHR_imageless_framebuffer extension.
I'm not sure this is the elegant way but it works in my own
project:)
2021-05-28 23:28:20 +08:00
Philip Cheang
c70790bf0f
Fix minor typos in What's New 2021-05-28 02:18:48 +08:00
Philip Cheang
76abba6199
Fix minor typos in User Guide. 2021-05-28 02:02:15 +08:00
Bill Hollings
9e5ff3a614 Changes to MVKConfiguration::resumeLostDevice behavior.
On command buffer submission failure, if MVKConfiguration::resumeLostDevice enabled,
do not release waits on VkDevice, and do not return VK_ERROR_DEVICE_LOST, unless
VkPhysicalDevice is also lost.
2021-05-25 12:14:14 -04:00
Bill Hollings
4d2448db3f Fix inconsistent handling of linear attachment decisions on Apple Silicon. 2021-05-20 16:07:34 -04:00
Bill Hollings
378b5d5bc9 Fix synchronization issue with locking MTLArgumentEncoder.
Move mutex lock for using MTLArgumentEncoder to MVKMTLArgumentEncoder
to be tracked along with the MTLArgumentEncoder it guards.
2021-05-14 22:17:08 -04:00
Bill Hollings
8420988c73 Fixes for CTS dEQP-VK.info.device_properties failures.
Adjust VkPhysicalDeviceLimits values:
- minMemoryMapAlignment raised to MIN of 64 per Vulkan spec.
- pointSizeRange upper limit to 511 per Metal.
- lineWidthGranularity to 0 per Vulkan spec when wideLines disabled.
- maxSamplerLodBias set to 4 to cover setting in shader.
2021-05-07 21:28:56 -04:00
Bill Hollings
19f02fac3d Merge from master and fix PR conflicts. 2021-05-05 16:46:45 -04:00
Bill Hollings
f781ee720a MVKImagePlane::getMTLTexture() protect against
crash when image has no device memory bound.
2021-05-05 16:37:16 -04:00
Bill Hollings
523342dd2f Fix crash when requesting MTLCommandBuffer logs in runtime debug mode on older OS versions. 2021-05-05 14:46:36 -04:00
Bill Hollings
650e8f3a46 To improve cache hits when matching SPIRVToMSLConversionConfiguration structs
to each other to find cached shader, only consider current shader stage resources.

Rename more references to ShaderConverterContext to ShaderConversionConfig.
2021-05-04 20:06:34 -04:00
Bill Hollings
5b1f38fbb9 Miscellaneous non-functional maintainability updates.
Rename kMVKShaderStageMax to kMVKShaderStageCount
to clarify it's common use in array sizing and for loops.
Change mvkConfig() to return reference instead of pointer
to improve syntactic sugar to use . instead of ->.
Update MoltenVK version to 1.1.4.
Update What's New document.
2021-05-03 18:56:30 -04:00
Bill Hollings
8f94b820a8 Change documentation references to macOS 10.16 to macOS 11.0. 2021-04-27 12:53:02 -04:00
Bill Hollings
8969e4d4a4 Update dependency libraries to match Vulkan SDK 1.2.176, and update What's New document. 2021-04-26 16:38:23 -04:00
Bill Hollings
d4844490f4 Fix memory leak where swapchains and images were not destroyed due to a retention loop.
Add Cube app iOS device rotation support, to test swapchain destruction on iOS.
2021-03-26 17:45:16 -04:00
Bill Hollings
2ef21c65bf Preallocate a pool of descriptors by default.
Enable MVKConfiguration::preallocateDescriptors and
MVK_CONFIG_PREALLOCATE_DESCRIPTORS by default.
Rename MVKDescriptorTypePreallocation to MVKDescriptorTypePool.
2021-03-15 16:27:39 -04:00
Bill Hollings
4371ef4d2b MVKDescriptorPool pools its descriptor sets. 2021-03-15 11:33:14 -04:00
Bill Hollings
9c13e46c47 In a renderpass, don't load or store memoryless attachments.
For memoryless attachments, setting renderpass load and store
actions to "load" and "store" triggers Metal validation errors.
Refactor determination of renderpass MTLLoadAction and MTLStoreAction.
For memoryless attachments, replace load with don't care,
and store with resolve or don't care.
2021-03-11 12:22:47 -05:00
Bill Hollings
4d452fdca6 Always explicitly set CAMetalLayer colorspace and wantsExtendedDynamicRangeContent.
Don't assume the incoming CAMetalLayer has default (no-op) values for colorspace and
wantsExtendedDynamicRangeContent properties, since they could have been set externally.
Ensure the Vulkan app has control over both of these properties.
vkCreateSwapchainKHR() returns VK_ERROR_FORMAT_NOT_SUPPORTED for unsupported colorspaces.
2021-03-10 19:59:11 -05:00
Bill Hollings
cd8a0e149e Restore support for HDR10 colorspace.
Restore support for VK_COLOR_SPACE_HDR10_HLG_EXT and VK_COLOR_SPACE_HDR10_ST2084_EXT
under Xcode12 that was removed due to App Store conflicts using older enum values.
2021-03-10 19:05:01 -05:00