3099 Commits

Author SHA1 Message Date
Chip Davis
e09ca0186f MVKDevice: Expose VK_EXT_debug_utils device functions as device functions.
Despite being an instance extension, `VK_EXT_debug_utils` provides some
functions that belong to the device, not the instance. Therefore, when
checking device functions, we must also check if an enabled *instance*
extension provides the function.

Also, only enable two-extension functions if *both* extensions or the
requisite core version are enabled. In all cases, these functions require
both extensions or the first extension plus some core version.

Fixes two CTS tests:
`dEQP-VK.info.instance_extension_device_functions`
`dEQP-VK.api.version_check.entry_points`
2023-11-22 01:07:03 -08:00
Chip Davis
3836b00309 MVKDevice: Change maxDrawIndexedIndexValue back to UINT32_MAX.
If the `fullDrawIndexUint32` feature is supported, then
`maxDrawIndexedIndexValue` must be `UINT32_MAX`. I had originally done
this when I turned the feature on, but for a while now, we've been
setting it to one less, because primitive restart can't be disabled and
the value is defined to exclude primitive restart.

The wording in the spec is ambiguous. The description of
`maxDrawIndexedIndexValue` says:

> * `maxDrawIndexedIndexValue` is the maximum index value that **can**
>   be used for indexed draw calls when using 32-bit indices. *This
>   excludes the primitive restart index value of 0xFFFFFFFF.* [emphasis
>   added]

But the description of `fullDrawIndexUint32` says:

> * `fullDrawIndexUint32` specifies the full 32-bit range of indices is
>   supported for indexed draw calls when using a VkIndexType of
>   `VK_INDEX_TYPE_UINT32`. `maxDrawIndexedIndexValue` is the maximum
>   index value that **may** [sic] be used *(aside from the primitive
>   restart index, which is always 2<sup>32</sup>-1 when the VkIndexType
>   is `VK_INDEX_TYPE_UINT32`)*. If this feature is supported,
>   `maxDrawIndexedIndexValue` **must** be 2<sup>32</sup>-1; otherwise
>   it **must** be no smaller than 2<sup>24</sup>-1. [emphasis added]

It's unclear whether it means that the primitive restart index is to be
ignored, or the maximum draw index must account for it.

The alternative is to disable `fullDrawIndexUint32` because we cannot
set `maxDrawIndexedIndexValue` to `UINT32_MAX`; but that might mislead
programs into thinking that we only support 24-bit vertex indices.

Fixes the rest of the `dEQP-VK.info.device_properties` test.
2023-11-21 12:34:40 -08:00
Chip Davis
52ce6a2c6c MVKDevice: Correct lineWidthGranularity.
If the `wideLines` feature isn't supported, then `lineWidthGranularity`
must be zero.

Fixes one part of the `dEQP-VK.info.device_properties` CTS test.
2023-11-21 12:34:40 -08:00
Chip Davis
6b9371ff05 MVKBuffer, MVKImage: Also ignore no external handle types specified.
Previously, we were erroneously failing create calls that specified zero
external handle types (as opposed to omitting external memory info
entirely).

Fixes 6 tests under
`dEQP-VK.api.buffer_memory_requirements.create_no_flags.ext_mem_flags_included.*`
2023-11-21 12:32:39 -08:00
Bill Hollings
a7dc8daf62
Merge pull request #2066 from billhollings/EXT_extended_dynamic_state3
Add support for VK_EXT_extended_dynamic_state3 extension.
2023-11-17 10:11:43 -05:00
Bill Hollings
9f73e7752b
Merge pull request #2067 from billhollings/fix-rare-dlopen-deadlock
Fix rare deadlock during launch via dlopen().
2023-11-16 22:18:21 -05:00
Bill Hollings
13998affe8 Add support for VK_EXT_extended_dynamic_state3 extension.
- Move patch point tracking from pipeline state to render state, and
  remove MVKPipelineCommandEncoderState subclasses no longer needed.
- Move sample location tracking from renderpass input to pipeline
  static or dynamic state tracking.
- Restart Metal render pass when sample locations change, and enable
  VkPhysicalDeviceSampleLocationsPropertiesEXT::variableSampleLocations.
- Fix regression that broke VK_POLYGON_MODE_LINE (unrelated).
- Fix regression in marking MVKRenderingCommandEncoderState
  dirty after vkCmdClearAttachments() (unrelated).
2023-11-16 22:04:37 -05:00
Bill Hollings
037ac4b76c Fix rare deadlock during launch via dlopen().
- Don't create global MVKPixelFormats instance during launch,
  as this triggers a call to MTLCopyAllDevices(), which can
  deadlock if app is also launching other services that use Metal.
2023-11-16 19:55:08 -05:00
Bill Hollings
abeed4e720
Merge pull request #2065 from js6i/bit-array-fix
Fix MVKBitArray::getIndexOfFirstSetBit() skipping over entries.
2023-11-15 13:29:41 -05:00
Jan Sikorski
36e57f4348 Fix MVKBitArray::getIndexOfFirstSetBit() skipping over entries.
Reset startIndex so that we only skip over bits in the section that contains it.
2023-11-14 16:09:13 +01:00
Bill Hollings
ab84de541d
Merge pull request #2060 from billhollings/fix-runtime-array-regression
Fix regression error in argument buffer runtime arrays.
2023-11-07 17:53:57 -05:00
Bill Hollings
40baeaa965 Fix regression error in argument buffer runtime arrays.
- Update to latest SPIRV-Cross contining the fix.
- Modify CTS options in runcts script to avoid outputting full CTS log,
  and use less file caching, all to reduce memory and filespace consumption,
  and possibly improve performance (unrelated).
- Update MoltenVKShaderConverter tool to include Metal 3.1 support
  and improved argument buffer settings (unrelated).
- Force Github CI to use Python 3.11, to avoid crash in
  glslang::update_glslang_sources.py due to use of distutils,
  removed in Python 3.12 (unrelated).
- Small unrelated non-functional edits.
2023-11-07 14:43:07 -05:00
Bill Hollings
bb914faa53
Merge pull request #2047 from billhollings/reduce-deps-disk-space
Reduce disk space consumed after running fetchDependencies.
2023-10-25 10:51:08 -04:00
Bill Hollings
e693a0a2be Reduce disk space consumed after running fetchDependencies.
- Add --keep-cache option to control whether or not to retain the
  External/build/Intermediates directory (default not retained).
- Export KEEP_CACHE & SKIP_PACKAGING to be available within scripts
  used by ExternalDependencies Xcode builds.
- Move BLD_SPECIFIED to build() instead of build_impl() to avoid
  updating it from background thread (which will fail).
- Update MoltenVK version to 1.2.7 (unrelated).
- Add CompilerMSL::Options::replace_recursive_inputs to pipeline cache (unrelated).
- Update GitHub CI to Xcode 15.0.
- Update Whats_new.md document.
2023-10-24 16:28:20 -04:00
Bill Hollings
9e4ee9e679
Merge pull request #2046 from billhollings/fix-prim-rsrt-warn
Emit primitiveRestartEnable disabled warning only for strip topology.
2023-10-18 13:45:32 -04:00
Bill Hollings
37e4fefe5f Emit primitiveRestartEnable disabled warning only for strip topology.
- Move check and warning to MVKRenderingCommandEncoderState.
- Pass primitiveRestartEnable to MVKRenderingCommandEncoderState.
- Warn only if primitiveRestartEnable disabled and strip topology is used.
2023-10-18 09:58:11 -04:00
Bill Hollings
37268cadba
Merge pull request #2044 from billhollings/vulkan-sdk-1.3.268
Update dependency libraries to match Vulkan SDK 1.3.268.
2023-10-17 16:55:43 -04:00
Bill Hollings
49c6e8bae3 Update dependency libraries to match Vulkan SDK 1.3.268. 2023-10-17 14:36:26 -04:00
Bill Hollings
b50ff83f94
Merge pull request #2043 from billhollings/fix-timestampPeriod
Fixes to determination of VkPhysicalDeviceLimits::timestampPeriod.
2023-10-17 07:58:42 -04:00
Bill Hollings
3a77f4ea97 Fixes to determination of VkPhysicalDeviceLimits::timestampPeriod.
- On Apple GPUs, set timestampPeriod to 1.0.
- On non-Apple GPUs, calculate timestampPeriod each time it is retrieved.
- On older devices that do not support GPU timestamps, use nanosecond
  CPU timestamps to be consistent with timestampPeriod of 1.0.
- Change MVKConfiguration::timestampPeriodLowPassAlpha and environment
  variable MVK_CONFIG_TIMESTAMP_PERIOD_LOWPASS_ALPHA to 1.0, to use
  only latest value by default.
- Add build-time verification that MVKConfigMembers.def
  includes all members of MVKConfiguration (unrelated).
2023-10-17 00:45:56 -04:00
Bill Hollings
107cf2c34e
Merge pull request #2042 from billhollings/VK_EXT_extended_dynamic_state-fixes
Fixes for VK_EXT_extended_dynamic_state.
2023-10-16 22:25:05 -04:00
Bill Hollings
d706ed0a63 Fixes for VK_EXT_extended_dynamic_state.
- MVKPipeline only work around zero stride if stride is static.
- Ensure dynamic vertex stride is not enabled on builds before Xcode 15.
- Add MVKRenderStateType::LineWidth for track all default options (unrelated).
2023-10-16 20:52:23 -04:00
Bill Hollings
61b8712178
Merge pull request #2036 from billhollings/VK_EXT_extended_dynamic_state
Add support for VK_EXT_extended_dynamic_state & VK_EXT_extended_dynamic_state2 extensions.
2023-10-11 17:37:11 -04:00
Bill Hollings
eb7cfa1006 Fixes based on VK_EXT_extended_dynamic_state code review.
- Fix runtime failure on Metal versions that don't support dynamic attribute stride.
- Add MVKCommandEncoder::encodeVertexAttributeBuffer() consolidation function.
- Remove unnecessary validations that will be caught by Vulkan validation layers.
- To reduce memory, remove command class and pools for rendering commands that
  are not supported, and perform no validation.
- Document extension conformance limitations in MoltenVK_Runtime_UserGuide.md.
2023-10-11 11:37:50 -04:00
Bill Hollings
ee271b34fc
Merge pull request #2037 from billhollings/fix-debug-msg-deadlock
Fix deadlock when reporting debug message on MVKInstance destruction.
2023-10-10 16:45:11 -04:00
Bill Hollings
659b1cecd7 VK_EXT_extended_dynamic_state fix build fail before Xcode 15. 2023-10-10 15:14:58 -04:00
Bill Hollings
0584aa0083 Fix deadlock when reporting debug message on MVKInstance destruction. 2023-10-10 15:02:06 -04:00
Bill Hollings
f4423428e3 Add support for VK_EXT_extended_dynamic_state2 extension.
- Add MVKPipelineCommandEncoderState subclasses
  MVKGraphicsPipelineCommandEncoderState & MVKComputePipelineCommandEncoderState,
  track patch control points in MVKGraphicsPipelineCommandEncoderState,
  and add getGraphicsPipeline() & getComputePipeline() to simplify casting.
- Rename MVKRasterizingCommandEncoderState to MVKRenderingCommandEncoderState,
  and MVKCommandEncoder::_rasterizingState to _renderingState.
- Rename MVKCmdRenderPass.h/mm to MVKCmdRendering.h/mm.
- Move MVKCmdExecuteCommands from MVKCmdRenderPass.h/mm to MVKCmdPipeline.h/mm.
- While working on vkCmdSetLogicOpEXT(), add support for
  vkCmdSetLogicOpEnableEXT() from VK_EXT_extended_dynamic_state3.
2023-10-10 12:19:15 -04:00
Bill Hollings
3c75e114dd Add support for VK_EXT_extended_dynamic_state extension.
- Add MVKRasterizingCommandEncoderState to consolidate handling
  of static and dynamic rasterizing states in a consistent manner.
- Rework MVKDepthStencilCommandEncoderState to consolidate handling
  of static and dynamic depth states in a consistent manner.
- MVKMTLDepthStencilDescriptorData clean up content setting, and struct layout.
- Add MVKRenderStateType to enumerate render state types.
- Add MVKRenderStateFlags to track binary info about states (enabled, dirty, etc).
- Add MVKMTLBufferBinding::stride.
- Add MVKPhysicalDeviceMetalFeatures::dynamicVertexStride.
- Set MVKPhysicalDeviceMetalFeatures::vertexStrideAlignment
  to 1 for Apple5+ GPUs (unrelated).
- Set VkPhysicalDeviceLimits::maxVertexInputBindingStride
  to unlimited for Apple2+ GPUs (unrelated).
- Add mvkVkRect2DFromMTLScissorRect() and simplify
  mvkMTLViewportFromVkViewport() and mvkMTLScissorRectFromVkRect2D().
- MVKFoundation:
  - Add mvkEnableAllFlags() and mvkDisableAllFlags().
  - Improve performance of mvkClear(), mvkCopy() & mvkAreEqual()
    when content is a single simple primitive type (unrelated).
  - Declare more functions as static constexpr (unrelated).
2023-10-05 17:33:01 -04:00
Bill Hollings
a06827c6fb Merge branch 'main' of https://github.com/billhollings/MoltenVK into VK_EXT_extended_dynamic_state 2023-10-03 13:00:28 -04:00
Bill Hollings
568cc3acc0
Merge pull request #2025 from etang-cw/MiscCleanup
Misc Cleanup
2023-09-28 16:44:29 -04:00
Evan Tang
27f4f6a6a0 Use MVKArrayRef<const T>, not const MVKArrayRef<T>
It's very easy to accidentally un-const a `const MVKArrayRef<T>`, since ArrayRefs are meant to be passed by value
2023-09-28 14:19:25 -05:00
Evan Tang
4ba3f335b4 MVKArrayRef cleanup
Make everything constexpr, remove direct access to members
2023-09-28 14:18:27 -05:00
Evan Tang
89195dc725 Remove count from mvkStringsAreEqual
It doesn't do anything, and we don't want anyone to think it does something
2023-09-26 23:48:16 -05:00
Evan Tang
aeae18d48b Remove getBaseObject
Nothing used it, and you should always be able to `static_cast<MVKBaseObject*>` for any object without a crazy inheritance tree
2023-09-26 23:48:15 -05:00
Evan Tang
5a216ab1f8 Refcounting cleanup
- Use relaxed atomics where possible
- Calling operator= on a refcounted object should not reinitialize the refcount
2023-09-26 23:47:44 -05:00
Bill Hollings
7f97fe2354 Merge branch 'KHR_extended_dynamic_state' of https://github.com/spnda/MoltenVK into VK_EXT_extended_dynamic_state 2023-09-19 17:36:05 -04:00
Bill Hollings
a7989c221f
Merge pull request #2023 from billhollings/promote-VK_EXT_private_data
Promote VK_EXT_private_data functions to Vulkan 1.3, and remove stubs.
2023-09-19 17:35:13 -04:00
Bill Hollings
2c3dc6415a Promote VK_EXT_private_data functions to Vulkan 1.3, and remove stubs. 2023-09-19 16:29:30 -04:00
Bill Hollings
6a4271c85f
Merge pull request #2021 from billhollings/VK_KHR_synchronization2
Add support for extension VK_KHR_synchronization2
2023-09-19 16:08:38 -04:00
Bill Hollings
6127918a32 Add support for extension VK_KHR_synchronization2.
- MVKPhysicalDevice add support for VkPhysicalDeviceSynchronization2Features.
- Pass sync2 structs to MVKPipelineBarrier, MVKCmdPipelineBarrier, MVKCmdSetEvent,
  MVKCmdResetEvent, MVKCmdWaitEvents, MVKRenderPass, MVKQueue & MVKQueueSubmission.
- Replace use of VkPipelineStageFlags & VkAccessFlags
  with VkPipelineStageFlags2 & VkAccessFlags2.
- Add stage masks to MVKPipelineBarrier, and redefine apply*MemoryBarrier()
  functions to remove separately passing stage masks.
- Add MVKSemaphoreSubmitInfo to track semaphores in MVKQueueSubmission.
- Add MVKCommandBufferSubmitInfo to track command buffers
  in MVKQueueCommandBufferSubmission.
- Add MVKSubpassDependency to combine VkSubpassDependency & VkMemoryBarrier2 in MVKRenderPass.
- Remove abstract MVKCmdSetResetEvent superclass.
- Streamline code in MVKMTLFunction::operator= (unrelated).
2023-09-19 14:20:55 -04:00
Bill Hollings
aed91cb563
Merge pull request #2020 from billhollings/incomplete-presentation-workaround-fix
Rework workaround to force incomplete CAMetalDrawable presentations to complete.
2023-09-15 19:23:31 -04:00
Bill Hollings
f0cb31a12b Rework workaround to force incomplete CAMetalDrawable presentations to complete.
- To force any incomplete CAMetalDrawable presentations to complete,
  don't force the creation of another transient drawable, as this can
  stall the creation of future drawables. Instead, when a swapchain
  is destroyed, or replaced by a new swapchain, set the CAMetalLayer
  drawableSize, which will force presentation completion.
- Add presentation completion handler in command buffer scheduling
  callback, move marking available to presentation completion handler,
  and minimize mutex locking.
- MVKQueue::waitIdle() remove wait for swapchain presentations,
  and remove callbacks to MVKQueue from drawable completions.
- MVKQueue::submit() don't bypass submitting a misconfigured submission,
  so that semaphores and fences will be signalled, and ensure misconfigured
  submissions are well behaved.
- Add MVKSwapchain::getCAMetalLayer() to streamline layer access (unrelated).
2023-09-15 09:54:48 -04:00
Bill Hollings
8f4619a788
Merge pull request #2018 from billhollings/depth-blit-msl
Fix MSL code used in vkCmdBlitImage() on depth-stencil formats.
2023-09-12 19:38:15 -04:00
Bill Hollings
9c206ecc79 Fix MSL code used in vkCmdBlitImage() on depth-stencil formats. 2023-09-12 16:44:33 -04:00
Bill Hollings
54dad691e0
Merge pull request #2017 from billhollings/config-timestampPeriod-lowpass
Add configurable lowpass filter for VkPhysicalDeviceLimits::timestampPeriod.
2023-09-12 16:21:56 -04:00
Bill Hollings
62e0368e21 Add configurable lowpass filter for VkPhysicalDeviceLimits::timestampPeriod.
- Add MVKConfiguration::timestampPeriodLowPassAlpha, along with matching
  MVK_CONFIG_TIMESTAMP_PERIOD_LOWPASS_ALPHA env var.
- Add MVKConfigMembers.def file to describe MVKConfiguration members,
  to support consistent batch handling of members.
- Add env var & build settings MVK_CONFIG_DEBUG, plus legacy
  MVK_CONFIG_ALLOW_METAL_EVENTS & MVK_CONFIG_ALLOW_METAL_FENCES.
- Simplify environment variable retrieval functions and macros.
- Rename MVKDevice::updateTimestampsAndPeriod() to updateTimestampPeriod().
2023-09-12 11:41:43 -04:00
Bill Hollings
a2d5b25a5c
Merge pull request #2015 from billhollings/mtlcmdbuff-retain-objs
Ensure objects retained for life of MTLCommandBuffer.
2023-09-11 11:56:41 -04:00
Bill Hollings
0ee15222c8 Ensure objects retained for life of MTLCommandBuffer.
- vkCmdBlitImage() ensure swizzle texture view is retained for life
  of MTLCommandBuffer.
- vkQueuePresentKHR() use MTLCommandBuffer that retains references.
- Update MoltenVK version to 1.2.6.
2023-09-08 20:46:28 -04:00
Bill Hollings
473ea0c2f1
Merge pull request #2008 from danginsburg/issue_2006_2
Fix crash in Dota 2 on macOS < 10.15 - closes #2006
2023-09-07 11:16:46 -04:00