1775 Commits

Author SHA1 Message Date
Bill Hollings
b6835f7298 Fixes to dynamic rendering and occlusion queries.
- Fix crash when VkCommandBufferInheritanceInfo::renderPass is VK_NULL_HANDLE.
- Do not clear attachments when dynamic rendering is resumed.
- Allow ending dynamic rendering to trigger next multiview pass if needed.
- Move deciding to begin next multiview pass to MVKCommandEncoder.
- Fix premature caching of occlusion query results during tessellation rendering.
  Tessellation ends Metal renderpass for compute control and eval stages.
  Wait until end of Metal renderpass after rasterization stage.
- vkCmdCopyQueryPoolResults(): Fix loss of queries when query
  count is not a multiple of GPU threadgroup execution width.
- Disable occlusion recording while clearing attachments or render area.
- MVKCmdClearAttachments improve labelling of MTLDebugGroup to better
  distinguish clearing renderpass render area from vkCmdClearAttachments()
  in an Xcode GPU capture (unrelated but helpful during debugging).
- MVKCmdClearAttachments re-order member variables to
  optimize memory requirements (unrelated).
- MVKCommandBuffer remove unused renderpass tracking functions (unrelated).
2023-02-21 21:54:10 -05:00
Bill Hollings
e897f49185 Fixes to recent update, to suit building on older Xcode versions.
- Revert mvkRoundHalfToEven() to static inline instead of constexpr,
  because internal use of std::remainder() is not constexpr until C++23.
- Replace non-template constexpr functions with static constexpr.
- Update Github CI to default to use Xcode 14.2,
  and macos-latest (which is now macos-12).
2023-02-14 15:36:43 -05:00
Bill Hollings
fbf5159ec2 Fix rounding error when checking if the drawableSize of a CAMetalLayer has changed.
- Add mvkGetNaturalExtent() to consolidate retrieving the natural rounded
  extent of the CAMetalDrawables that will be created by a CAMetalLayer,
  based on its drawableSize and contentsScale properties.
- Replace MVKSwapchain::_mtlLayerDrawableSize with _mtlLayerDrawableExtent.
- MVKSwapchain::hasOptimalSurface() compares last, actual,
  and natural rounded drawable extents of CAMetalLayer.
2023-02-13 23:17:00 -05:00
Bill Hollings
eabede8cdf Replace static inline with constexpr where possible. 2023-02-12 20:14:18 +00:00
Bill Hollings
2f87f85278 Fixes from PR review of VK_EXT_swapchain_maintenance1 and VK_EXT_surface_maintenance1.
- Pass MVKImagePresentInfo struct by reference instead of copy.
- Remove unused boolean to pass around
  VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT status.
2023-02-12 19:02:47 +00:00
sean
79ff67138e
Fix: Don't assume M1/M2 are only available for arm64 targets 2023-02-05 21:18:28 +01:00
Randall C. O'Reilly
160a327cbb enable availability of EXT_shader_atomic_float and add docs for how to replace Vulkan SDK .dylib while avoiding need to reboot. 2023-02-05 00:26:04 -08:00
Bill Hollings
e480e1570b Merge latest main into swapchain-mtce1 branch.
Update VK_MVK_MOLTENVK_SPEC_VERSION to version 37.
2023-02-04 14:37:08 -05:00
Bill Hollings
3250569260 Queue submissions retain wait semaphores until MTLCommandBuffer finishes.
Add additional Vulkan error strings (unrelated).
2023-02-04 11:27:16 -05:00
Chip Davis
2c01c8b7e0 Work around problems with explicit LoD with arrayed depth images on Apple Silicon.
Use an explicit gradient to make it sample the correct level.

Update SPIRV-Cross to pull in the change needed for this.
2023-02-03 14:48:25 -08:00
Bill Hollings
fabad21405 Add support for VK_EXT_swapchain_maintenance1 and VK_EXT_surface_maintenance1.
- Support querying scaling capabilities and present mode compatibilies
  when querying surface capabilities.
- Rename MVKPresentTimingInfo to MVKImagePresentInfo and add present mode
  and fence to support dynamic present mode changes and fence signaling.
- MVKPresentableSwapchainImage remove static functions from class declaration.
- MVKSwapchain support releasing swapchain images on command.
- MVKSwapchain support configuring with scaling and gravity info, apply it to
  CAMetalLayer.and do not return VK_SUBOPTIMAL_KHR if swapchain was configured
  with scaling info.
- Rename MVKSwapchain::acquireNextImageKHR to acquireNextImage.
- CAMetalLayer naturalDrawableSizeMVK compute precise drawable size.
- CAMetalLayer remove obsolete and unused updatedDrawableSizeMVK method.
- Rename MVKConfiguration::swapchainMagFilterUseNearest to
  swapchainMinMagFilterUseNearest to apply CAMetalLayer size
  filtering to both magnification and minification, and rename
  corresponding  env var MVK_CONFIG_SWAPCHAIN_MAG_FILTER_USE_NEAREST
  to MVK_CONFIG_SWAPCHAIN_MIN_MAG_FILTER_USE_NEAREST.
- Detect when size of surface has changed under the covers.
- Change rounding of surface size provided by Metal from truncation to
  rounding-with-half-to-even.
- Remove MVKLogSizeOf() logging macro as redundant to mvkPrintSizeOf() macro.
2023-02-02 23:00:37 -05:00
Bill Hollings
007136f2f4 Remove a couple of large obsolete list content comments in MVKDevice.mm. 2023-01-30 17:15:44 -05:00
Bill Hollings
7e9b5b73de Fix issue where extension VK_KHR_fragment_shader_barycentric
was sometimes incorrectly disabled due to a Metal driver bug.

Update MoltenVK version to 1.2.3.
2023-01-30 15:22:33 -05:00
Bill Hollings
e0333509a1 Set more accurate values for some VkPhysicalDeviceLimits members.
- Update maxClipDistances and maxCombinedClipAndCullDistances to more accurate values.
- Update maxDrawIndexedIndexValue to acknowledge primitive restart.
2023-01-13 19:03:00 -05:00
Bill Hollings
12592abbc9 Update copyright notices to year 2023. 2023-01-13 12:19:37 -05:00
Bill Hollings
682906976d Fix linking issues with dynamic Vulkan functions.
- Ensure Vulkan public symbols are not stripped from the library when
  statically linked to an app that calls all Vulkan functions dynamically.
- Per Vulkan 1.2 spec, support calling vkGetInstanceProcAddr() with a
  null instance, when vkGetInstanceProcAddr itself is the function name.
- Replace uses of strcmp() with mvkStringsAreEqual() to protect against
  null pointers, and provide a direct bool output (unrelated cleanup).
2023-01-10 07:22:05 -05:00
Bill Hollings
b6b51aa1f3 Remove some old unused commented-out debug log calls. 2022-12-30 10:14:19 -05:00
Bill Hollings
be51089f25 Fix small memory issues with MVKPresentableSwapchainImage.
- Fix Metal validation error caused by CAMetalDrawable released before
  MTLCommandBuffer is finished using it.
- When presenting, MVKPresentableSwapchainImage retains in-flight
  CAMetalDrawable until MTLCommandBuffer completion.

- Fix memory leak of MVKFences and MVKSemaphores when a
  swapchain image is acquired more than it is presented.
- Force MVKPresentableSwapchainImage to untrack any tracked fences or
  semaphores when it is destroyed.

- Update MoltenVK version to 1.2.2.
2022-12-29 21:50:04 -05:00
Bill Hollings
b09ee9d370 Revert commit e102ce1102dcdfd4d59df3fd5f3f381cb9a4ab81.
The now-reverted commit had caused fragment shader not
to run at all when no render attachment was available.
2022-12-27 14:09:24 -05:00
Bill Hollings
e102ce1102 Fix excessive Metal tile memory preallocation when rendering without attachments.
Metal uses MTLRenderPassDescriptor properties renderTargetWidth,
renderTargetHeight, and renderTargetArrayLength to preallocate tile memory
storage on machines using tiled rendering. This memory preallocation is not
necessary if we are not rendering to attachments, and some apps actively
define extremely oversized framebuffers when they know they are not rendering
to actual attachments, making this internal tile memory allocation even more
wasteful, occasionally to the point of triggering OOM crashes.

Update MoltenVK version to 1.2.2.
2022-12-11 19:11:38 -05:00
Bill Hollings
8965c87e14 Fix crash when buffer binding updates only offset while it is overridden.
MVKMTLBufferBinding don't allow justOffset if binding was overridden.
2022-12-08 18:38:49 -05:00
Bill Hollings
985ec99832 Fix app performance regression triggered by the previous introduction
of VK_KHR_shader_float_controls.

The introduction of shaderSignedZeroInfNanPreserveFloat32 was causing Metal
fast math to be aggressively disabled by the use of SignedZeroInfNanPreserve
in shaders in some apps, causing a regression in shader performance in those apps.

- Change MVKConfiguration::fastMathEnabled from bool to enumeration to distinguish
  between always using fast math or allowing shaders to selectively disable it.
- Default value to fast math always.
2022-12-07 12:40:50 -05:00
Bill Hollings
8e45217fbd Fix Metal buffer index binding overrides for push constants and attachment clearing.
Push constants and attachment clearing can temporarily override Metal buffer
bindings for descriptor sets and vertex attributes. Mark the overridden buffer
bindings and ensure they are reinstated when the pipeline is updated.

- Add MVKMTLBufferBinding::isOverridden to track if buffer binding is
  temporarily overridden.
- Rename MVKResourcesCommandEncoderState::markIndexDirty()
  to markBufferIndexOverridden() to mark buffer bindings as overridden.
- Rename MVKGraphicsResourcesCommandEncoderState::markBufferIndexDirty()
  to markBufferIndexOverridden().
- Rename MVKComputeResourcesCommandEncoderState::markBufferIndexDirty()
  to markBufferIndexOverridden().
- Add MVKResourcesCommandEncoderState::markOverriddenBufferIndexesDirty()
  to mark overridden buffer bindings as dirty.
- Add MVKGraphicsResourcesCommandEncoderState::markOverriddenBufferIndexesDirty()
  and call when render pipeline change is encoded
- Add MVKComputeResourcesCommandEncoderState::markOverriddenBufferIndexesDirty()
  and call when compute pipeline change is encoded.
2022-11-30 00:01:07 -05:00
Chip Davis
03ce25da20 MVKPipeline: Force extra checks for stores after fragment discard.
Update SPIRV-Cross to pull in multiple CTS fixes. Handle the new
`check_discarded_frag_stores` and `manual_helper_invocation_updates`
options.
2022-11-21 11:04:29 -08:00
Bill Hollings
bd497fe713 Fix mistaken YCBCR format support indication.
MVKVkFormatDesc::chromaSubsamplingPlaneCount must be > 1 to be considered supported.
2022-11-18 23:35:46 -05:00
Bill Hollings
0dd329398a
Merge pull request #1769 from MennoVink/#1764_emulated_semaphores_freeze_fix
Only wait on emulated semaphores once...
2022-11-17 18:13:27 -05:00
Bill Hollings
7c0143c37b Support Xcode 14.1 build settings. 2022-11-15 20:49:17 -05:00
Bill Hollings
6d7f4330c7 Work around MTLCounterSet crash on additional Intel Iris Plus Graphics devices.
Add 0x8a5a and 0x8a5c to list of Intel Iris Plus Graphics
device IDs requiring workaround.
2022-11-15 17:44:55 -05:00
Bill Hollings
c8f581088f
Merge pull request #1767 from cdavis5e/optimal-tiling-atomics
MVKImage: Always use a texel buffer for atomic storage images.
2022-11-13 17:01:53 -05:00
Chip Davis
b871d8f603 MVKDevice: Fix backwards attribution of storage/uniform texel buffer alignments.
A drive-by fix for something I noticed while investigating a problem
with linear-for-atomics textures.
2022-11-12 14:27:39 -08:00
Chip Davis
94b1ea3c95 MVKImage: Always use a texel buffer for atomic storage images.
Do this even if `OPTIMAL` tiling were requested. Vulkan mandates support
for image atomics on `OPTIMAL`-tiled `R32_UINT` and `R32_SINT` images.
In a way, this is "optimal"; image atomics won't work without this.

Advertise support for atomics on `OPTIMAL` tiled images now.

Fixes at least two CTS tests under
`dEQP-VK.compute.basic.image_atomic_op_*`.
2022-11-12 14:27:32 -08:00
sean
0b62f647d5
Fix: Invalid blit offsets 2022-11-11 18:33:54 +01:00
Menno Vink
05c757c8b7 Only wait on emulated semaphores once to prevent freezing when using prefilled command buffers. 2022-11-11 14:18:32 +01:00
Bill Hollings
5ebeac741d
Merge pull request #1755 from cdavis5e/raw-buffer-tese-input
MVKPipeline: Stop using vertex-style input for tessellation evaluatio…
2022-11-10 20:46:24 -05:00
Chip Davis
2cb33c09b6 MVKPipeline: Stop using vertex-style input for tessellation evaluation shaders.
This has caused us nothing but trouble. The code to build up the vertex
descriptor is fragile; we can rip that out now.

Also, make sure to positively identify per-patch blocks as per-patch.
For those, the individual members have the `Patch` decoration.

Update SPIRV-Cross to pull in the changes needed for this.

Fixes 66 tests in the CTS.
2022-11-10 14:12:02 -08:00
sean
237e538bd0
Fix: Proper requirements for enabling BDA extensions 2022-11-09 20:41:42 +01:00
sean
8a7979d3d0
Cleanup MVKCmdBufferImageCopy::setContent 2022-11-09 16:33:08 +01:00
sean
331d8e1d0b
Deduplicate code 2022-11-09 16:11:02 +01:00
sean
270a0198e0
Add: KHR_copy_commands2 2022-11-06 00:58:19 +01:00
Bill Hollings
0287a3242c Fix crash on descriptor update with out-of-bounds descriptor count data.
Update MoltenVK version to 1.2.1.
2022-10-31 14:41:08 -04:00
Richard S. Wright Jr
9987bca0d2 fix for wrong version number in icd json 2022-10-20 15:29:24 -04:00
Bill Hollings
608342b528 Update documentation for prefilling Metal command buffers options. 2022-10-18 12:41:13 -04:00
Bill Hollings
00b2184c23 Fix crash and memory leaks when configured for prefilling Metal command buffers.
- Redefine enumeration values of MVKPrefillMetalCommandBuffersStyle.
- Add option to defer encoding prefilled MTLCommandBuffer to queue submission.
- Remove option to create an autorelease pool in the MVKCommandEncoder
  to span immediate command encodings, because it causes crashes when
  multiple command buffers were overlapping prefilling on the same thread.
- Replace MTLCommandEncoder retain/release macros with template member functions.
- Rename MVKCommandPool::newMTLCommandBuffer() to getMTLCommandBuffer()
  and do not retain the returned MTLCommandBuffer (unrelated).
- Revert MoltenVK logging to use stderr instead of stdout (unrelated).
- Merge branch from master.
2022-10-18 03:28:12 -04:00
Bill Hollings
b751c07eb3 Fix memory leaks when configured for prefilling Metal command buffers.
- Add MVKPrefillMetalCommandBuffersStyle enumeration to enable prefilling,
  and configure memory recovery options.
- Redefine MVKConfiguration::prefillMetalCommandBuffers as a value from
  MVKPrefillMetalCommandBuffersStyle instead of a simple boolean. Set the
  values of MVKPrefillMetalCommandBuffersStyle and the default value of
  MVKConfiguration::prefillMetalCommandBuffers to be compatible with
  legacy use of this setting as a simple enable/disable boolean value.
- MVKCommandEncoder track prefill style, and support option to maintain
  a Metal autorelease pool that is created on vkBeginCommandBuffer()
  and drained on vkEndCommandBuffer(), when prefiling a command buffer
  from a single thread, and an option to wrap each command addition in
  a separate @autoreleasepool{} scope to create and drain an autorelease
  pool at every command addition to the Vulkan command buffer, when
  prefilling a single command buffer from multiple threads.
- MVKCommandEncoder retain Metal encoders when prefilling, because
  prefilling may span multiple autorelease pools.
- MVKCommandEncoder clean up memory leak of MTLBlitPassDescriptor
  during prefilling.
- MVKCommandEncoder rearrange declarations of MVKCommandUse member
  variables to tighten up class memory use (unrelated).
- MVKCommandBuffer remove unnecessary inline declarations (unrelated).
- Change MoltenVK logging to use stdout instead of stderr (unrelated).
2022-10-16 17:03:55 -04:00
Bill Hollings
ceb298965e Vulkan semaphore fallback to using single queue if MTLEvents unusable.
- If MTLEvents are unusable, fallback to single queue.
- Adjust values of MVKVkSemaphoreSupportStyle enumeration.
- For legacy compatibility, if legacy semaphoreUseMTLEvent and
  semaphoreUseMTLFence are both disabled, use CPU callback emulation.
- Update and expand related documentation in vk_mvk_moltenvk.h.
2022-10-09 21:17:18 -04:00
Bill Hollings
0cc6e1d3a4 Fix support for MVK_HIDE_VULKAN_SYMBOLS build setting.
- Remove separate extension entry points for 1.3 promoted
  vkCmdBeginRenderingKHR() and vkCmdEndRenderingKHR() functions,
  which caused build breaks when MVK_HIDE_VULKAN_SYMBOLS=1.
- For consistency, hide vkGetMoltenVKConfigurationMVK(),
  vkSetMoltenVKConfigurationMVK(), and vkGetVersionStringsMVK()
  when MVK_HIDE_VULKAN_SYMBOLS=1, which was an oversight in original
  implementation of hiding Vulkan functions.
- Update build `README.md` for generic command line build settings
  and MVK_HIDE_VULKAN_SYMBOLS in particular.
2022-10-09 16:32:26 -04:00
Giovanni Bajo
d32c60a901
Makefile: fix environment variable definitions 2022-10-04 22:58:55 +02:00
sean
e8b32dec92 Final 1.2 fixes 2022-09-26 12:38:03 -04:00
Bill Hollings
ac39eb24e1 Add support for Vulkan 1.2.
- Set MVK_VULKAN_API_VERSION from VK_API_VERSION_1_2.
- Update MoltenVK version to 1.2.0.
- Remove several previously overlooked extension suffixes
  in use of promoted Vulkan struct and enum values.
- Update documentation.
2022-09-26 11:25:49 -04:00
sean
6eaa0351fa
Add Vulkan 1.3 command stubs 2022-09-24 23:54:41 +02:00