560 Commits

Author SHA1 Message Date
Bill Hollings
c85507b996
Merge pull request #1960 from cdavis5e/shader-non-semantic-info
Advertise the `VK_KHR_shader_non_semantic_info` extension.
2023-06-26 17:20:41 -04:00
Chip Davis
b74feb7c77 Support VK_EXT_shader_subgroup_ballot and VK_EXT_shader_subgroup_vote.
Update SPIRV-Cross to pull in the needed support for these extensions.
2023-06-26 13:40:34 -07:00
Chip Davis
5253e6f9e0 Advertise the VK_KHR_shader_non_semantic_info extension.
This just provides support for the `SPV_KHR_non_semantic_info`
extension, which supports extended instruction sets that do not affect
the semantics of a SPIR-V shader (e.g. debug info). SPIRV-Cross already
handles these instruction sets, so no additional work is required on our
part to support this extension.
2023-06-24 16:48:30 -07:00
Chip Davis
4e3ac69305 Support the VK_EXT_calibrated_timestamps extension.
This extension has a direct Metal equivalent in the
`-[MTLDevice sampleTimestamps:gpuTimestamp:]` method. However, that
method returns CPU timestamps in the Mach absolute time domain, which is
*not* that of `CLOCK_MONOTONIC_RAW` but of `CLOCK_UPTIME_RAW`. The
function that corresponds to `CLOCK_MONOTONIC_RAW` is
`mach_continuous_time()`. Therefore, this implementation uses the
`mach_continuous_time()` function for the CPU timestamp. Perhaps we
should lobby the WG for `VK_TIME_DOMAIN_CLOCK_UPTIME_RAW_EXT`.
2023-06-23 12:08:56 -07:00
Chip Davis
5d173d0e09 Support the VK_EXT_4444_formats extension.
This turned out to be a little bit more involved than I had hoped. But,
with this, we can now use the `VK_FORMAT_A4R4G4B4_UNORM_PACK16` and
`VK_FORMAT_A4B4G4R4_UNORM_PACK16` formats from shaders, use them as blit
sources, and even clear them. Storage images and render targets of these
formats aren't supported, however. To support the latter would require
the insertion of a swizzle into the fragment shader before returning.
The former cannot be reasonably supported.
2023-06-22 15:14:50 -07:00
Bill Hollings
e69c249348 Log more info about SPIR-V to MSL conversion errors.
Remove unhelpful "Shader module does not contain
an entry point named 'main0'" error message.
2023-06-15 19:56:36 -04:00
Raafat Akkad
e7243572d7 Allows maximizing the concurrent executing compilation tasks.
https://developer.apple.com/videos/play/wwdc2023/10127/?time=540
On an M1 Pro Macbook Pro 16" maximumConcurrentCompilationTaskCount goes from 2 to 8
2023-06-14 20:17:53 +01:00
Bill Hollings
4949c34b4d
Merge pull request #1936 from billhollings/present-imm-mode-unless-present-time
Support VK_PRESENT_MODE_IMMEDIATE_KHR if VkPresentTimeGOOGLE::desiredPresentTime is zero.
2023-06-07 18:41:57 -04:00
Chip Davis
750adcaae2 Advertise the VK_EXT_shader_demote_to_helper_invocation extension.
As of macOS Big Sur and iOS/tvOS 14, the `discard_fragment()` function
in MSL is defined to have demote semantics; that is, fragment shader
output is discarded, but the fragment shader thread continues to run as
a helper invocation. This is very useful for Direct3D emulation, since
this is the semantic that HLSL `discard` has.

Signed-off-by: Chip Davis <chip@holochip.com>
2023-06-07 12:48:02 -07:00
Bill Hollings
6fb53471b1 Support VK_PRESENT_MODE_IMMEDIATE_KHR if VkPresentTimeGOOGLE::desiredPresentTime is zero.
- [MTLDrawable presentAtTime:] syncs to display vsync. To support
  VK_PRESENT_MODE_IMMEDIATE_KHR while using VkPresentTimeGOOGLE::presentID,
  only call presentAtTime: if VkPresentTimeGOOGLE::desiredPresentTime has
  been explicitly set to a non-zero value.
- Clarify initially clearing MVKImagePresentInfo to all zeros.
2023-06-05 19:17:10 -04:00
Bill Hollings
107be116b7 Add support for VK_PRESENT_MODE_IMMEDIATE_KHR to macOS Cube demo.
- Only log performance stats on FPS logging if logging style is explicitly
  set to MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_FRAME_COUNT (unrelated).
2023-05-30 21:11:02 -04:00
Bill Hollings
83a1811230 Ensure compute encoding state is marked dirty for non-dispatch commands.
The same compute encoder is used across dispatches and other commands,
which may override compute state, and end up breaking subsequent dispatches.

- Mark compute encoding state dirty when following commands,
  which use Metal compute encoders, are issued:
  - vkCmdCopyBuffer()
  - vkCmdClearColorImage()
  - vkCmdClearDepthStencilImage()
  - vkCmdFillBuffer()
  - vkCmdCopyQueryPoolResults()

- MVKCommandEncoder move marking compute state dirty from
  endCurrentMetalEncoding() to getMTLComputeEncoder().
- For efficiency, don't prematurely force end of query copy compute encoder
  used on renderpass end, in case compute dispatches follow.

- Update MoltenVK to 1.2.5 (unrelated).
2023-05-26 00:06:40 -04:00
Bill Hollings
b26ce32a60 Advertise VK_KHR_depth_stencil_resolve extension on all devices.
Advertise VK_KHR_depth_stencil_resolve extension on early iOS devices,
since VK_RESOLVE_MODE_SAMPLE_ZERO_BIT is supported on all devices,
even if other resolve modes are not, and makes it consistent with
Vulkan 1.2 mandatory support for VK_RESOLVE_MODE_SAMPLE_ZERO_BIT.
2023-05-23 19:01:31 -04:00
Bill Hollings
b863ecef4d Accumulate render stages when a resource is used by multiple descriptor bindings. 2023-05-23 13:13:19 -04:00
Bill Hollings
c231c90dd4 Update dependency libraries to match Vulkan SDK 1.3.250.
- Update Whats New document.
2023-05-22 20:00:14 -04:00
Bill Hollings
ae0ee6a012
Merge pull request #1908 from billhollings/fix-deviceUUID
Populate deviceUUID from MTLDevice location and peer group info.
2023-05-17 15:09:46 -04:00
Bill Hollings
665ef6df13 Improve support for deviceUUID and deviceLUID.
- MTLDevice registryID is not constant across OS reboots,
  which is not conformant with deviceUUID requirements.
- Replace with combination of MTLDevice location, locationNumber,
  peerGroupID, and peerIndex, which should define uniqueness,
  and should be constant across OS reboots.
- Populate deviceLUID from MTLDevice registryID.
2023-05-17 14:50:48 -04:00
Bill Hollings
d29092ab78 Do not fail on request for timestamp query pool that is too large.
- Report error, but do not fail on request for timestamp query pool
  that is too large for MTLCounterSampleBuffer.
- Change reported error to VK_ERROR_OUT_OF_DEVICE_MEMORY and clarify
  text of error reported when timestamp query pool is too large.
- Clarify error reported for occlusion query pool errors (unrelated).
2023-05-16 17:26:26 -04:00
Bill Hollings
65ce195a6f Ensure swapchain image presented time is always populated when requested.
If Metal reports zero presentedTime, and desired presentation
time has not been set by app, use the current time.
2023-05-15 18:47:22 -04:00
Bill Hollings
4893f78b29 Identify each unsupported device feature flag that the app attempts to be enable.
- Make MVKDevice::enableFeatures() functions into templates to pass struct type.
- Add mvkGetAddressOfFirstMember() to retrieve the address of the first member of
  a struct, taking into consideration whether the struct has a Vulkan pNext member.
- Add mvk::getTypeName() and mvk::getOrdinalSuffix() string functions.
2023-05-15 15:14:30 -04:00
Bill Hollings
3247bd465d GitHub CI streamline uploaded artifact sizes.
- Reinstate per-platform upload artifacts.
- Don't upload shader converter binaries.
2023-05-10 17:27:08 -04:00
Bill Hollings
ab5429b18c GitHub CI improvements.
- Build one universal build, instead of per-platform.
- Upload this single build artifact to GitHub.
- Upgrade to v3 of action dependencies to remove Node.js deprecation warnings.
- Avoid use of deprecated set-output GitHub action command.
- Use macOS 13 and Xcode 14.3.
- README.md document access to binary artifacts.
2023-05-09 00:12:16 -04:00
Bill Hollings
9e466699e5 Fix race condition when updating values in VkPastPresentationTimingGOOGLE.
- MVKPresentableSwapchainImage::presentCAMetalDrawable() and
  addPresentedHandler() pass MVKImagePresentInfo by value instead
  of reference, to avoid callbacks colliding with tracked
  MVKImagePresentInfos being cleared when
  MVKQueuePresentSurfaceSubmission is destroyed after it is run.
2023-05-05 14:45:43 -04:00
Bill Hollings
cde220a277 Remove vkGetMoltenVKConfiguration2MVK() and vkSetMoltenVKConfiguration2MVK().
Also undeprecate the original vkGet/SetMoltenVKConfigurationMVK().

In expectation of the upcoming VK_EXT_layer_settings extension, it is felt that
adding these additional functions at this time would be confusing to app devs.
2023-05-05 11:41:06 -04:00
Bill Hollings
3db62a1d7b Reinstate VK_MVK_moltenvk extension and add simplified config functions.
- Reinstate VK_MVK_moltenvk extension, but log warning message when it is enabled.
- Add vkGetMoltenVKConfiguration2MVK() and vkSetMoltenVKConfiguration2MVK()
  to set config without passing a dummy VkInstance, and deprecate
  vkGetMoltenVKConfigurationMVK() and vkSetMoltenVKConfigurationMVK().
2023-05-04 11:08:16 -04:00
Bill Hollings
937b0bf943 Deprecate the obsolete and non-standard VK_MVK_moltenvk extension.
The VK_MVK_moltenvk extension has never been brought inside Vulkan, and
the functions have never been supported by the Vulkan Loader and Layers.
Most of the functionality has long been replaced by the official
VK_metal_objects extension.

- Remove VK_MVK_moltenvk as an advertised extension.
- Refactor vk_mvk_moltenvk.h header file into separate headers files:
    - mvk_config.h - Valid public config functions
    - mvk_private_api.h - Valid development debugging functions used with care
    - mvk_deprecated_api.h - Formally deprecated functions.
- Retain skeleton vk_mvk_moltenvk.h header file for legacy compatibility only.
- Update documentation and header comments to explain changes.
2023-05-01 17:30:21 -04:00
Bill Hollings
e50cb32127
Merge pull request #1878 from billhollings/dyn-rend-separate-depth-stencil
Support separate depth and stencil attachments during dynamic rendering
2023-04-28 12:38:29 -04:00
Bill Hollings
4aa2b6dd9f Support separate depth and stencil attachments during dynamic rendering.
- MVKRenderSubpass add separate getDepthFormat() & getStencilFormat(),
  and isDepthAttachmentUsed() & isStencilAttachmentUsed() and use
  instead of testing pixel format for depth and stencil components.
- Add MVKRenderingAttachmentIterator class to consistently iterate,
  and take actions, on the attachments in VkRenderingInfo to create
  synthetic MVKRenderPass and extract image views and clear colors.
- Remove mvkCreateRenderPass() and mvkCreateFramebuffer() in favor
  of additional constructors, and remove mvkGetDepthStencilFormat() in
  favor of retrieving formats for separate depth and stencil attachments.
- MVKRenderpass constructors reorganize order of adding attachments and
  subpasses, and connecting the two.
- Renmame MVKRenderPassAttachment to MVKAttachmentDescription.
- MVKPipeline reorganize member variables to minimize gaps in content
  and remove unnecessary _isRasterizingDepthStencil member var (unrelated).
2023-04-24 15:23:46 -04:00
Bill Hollings
fc8e8182ee Disable pipeline cache compression prior to macOS 10.15 and iOS/tvOS 13.0. 2023-04-24 15:01:41 -04:00
Bill Hollings
13e8103651 Ensure shaders using PhysicalStorageBufferAddresses encode the associated MTLBuffer.
- MVKDevice track VkBuffers marked with VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT.
- Add SPIRVToMSLConversionResultInfo::usesPhysicalStorageBufferAddressesCapability
  to detect and track shaders that use PhysicalStorageBufferAddresses capability,
  and track such shader stages within pipeline.
- MVKResourcesCommandEncoderState encode usage of VkBuffers marked with
  VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT when pipeline uses
  PhysicalStorageBufferAddresses capability.
- Rename MVKResourcesCommandEncoderState::encodeArgumentBufferResourceUsage()
  to encodeResourceUsage().
- MVKDevice move some functions to public scope and remove friend classes.
- MVKDeviceMemory ensure _vkMemAllocFlags is always initialized (unrelated).
- Rename MVKFoundation template method contains() to mvkContains() (unrelated).
2023-04-14 17:30:32 -04:00
Bill Hollings
5092330273 Support BC compression on iOS/tvOS, where available.
- Add MVK_XCODE_14_3 macro to compile for iOS/tvOS 16.4 and above.
- Add support for BC compression on iOS/tvOS 16.4 and above where supported.
- Consolidate MVKPixelFormats::modifyMTLFormatCapabilities(mtlDev)
  and centralize querying MTLDevice format methods for all platforms.
2023-04-12 11:50:09 -04:00
Bill Hollings
518385696b Several simple maintenance fixes.
- Fix memory leak when waiting on timeline semaphores.
- For correctness, set VkPhysicalDeviceLimits::lineWidthGranularity to 1.
- Update MoltenVK to version 1.2.4.
- Update Whats_New.md document with recent changes.
2023-04-11 20:41:59 -04:00
sean
20e255b4e6
Add: VK_KHR_map_memory2 2023-03-23 22:05:58 +01:00
Bill Hollings
4e344a6921 Update dependency libraries to match Vulkan SDK 1.3.243.
Update Whats New document.
2023-03-22 14:27:25 -04:00
Bill Hollings
cd8d0c30bb Add support for VK_EXT_external_memory_host extension.
- To expose host memory page size, add mvkGetHostMemoryPageSize() and
  MVKPhysicalDeviceMetalFeatures::hostMemoryPageSize.
- MVKPhysicalDevice::getProperties() sort EXT property structs alphabetically (unrelated).
- MVKExtensions.def fix alignment in OS versions (unrelated).
2023-03-19 22:53:36 -04:00
Bill Hollings
f191b0a31a Various maintenance updates.
- Cleanup VkPhysicalDeviceShaderAtomicFloatFeaturesEXT enablement and documentation.
- Cleanup VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT enablement.
- Expand MVK_CONFIG_TRACE_VULKAN_CALLS to log thread ID only if requested.
2023-03-08 19:04:52 -05:00
Bill Hollings
6d2ccd4505
Merge pull request #1836 from goki/main
WIP: enable availability of EXT_shader_atomic_float
2023-03-08 18:13:07 -05:00
Randall C. O'Reilly
e2e412cf31 undo WhatsNew 2023-03-08 12:21:50 -08:00
Randall C. O'Reilly
8046d82215 updates from latest PR comments from Hollings 2023-03-07 21:06:21 -08:00
Bill Hollings
a46dfde1fc Add support extension VK_EXT_pipeline_creation_cache_control.
- Adjust locks and performance timing on shader cache lookups.
2023-03-06 12:12:29 -05:00
Bill Hollings
c205c53ad9 Reduce memory footprint of retained MSL source code.
- Add MVKCompressor template class, and mvkCompress() & mvkDecompress()
  functions to support general data compression.
- Add MVKConfiguration::shaderSourceCompressionAlgorithm and
  env var MVK_CONFIG_SHADER_COMPRESSION_ALGORITHM to support
  compressing MSL shader source code held in a pipeline cache.
- Add MVKShaderCompilationPerformance::mslCompress and mslDecompress
  to allow performance of MSL compression to be tracked and queried.
- Add support for logging performance stats accumulated in a VkDevice,
  when it is destroyed. Good for CTS testing.
- Change MVKConfiguration::logActivityPerformanceInline boolean to
  activityPerformanceLoggingStyle enumeration value.
- Add MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE environment variable and
  build setting to set MVKConfiguration::activityPerformanceLoggingStyle value.
2023-03-03 10:39:26 -05:00
Bill Hollings
46d46f5191 Reduce memory footprint of retained MSL source code.
- Don't retain converted MSL source code in MVKShaderModule.
- Add SPIRVToMSLConversionResult and GLSLToSPIRVConversionResult
  structures to capture all feedback from shader conversions.
2023-02-27 14:54:19 -05:00
Bill Hollings
7a80f0249b Use a different visibility buffer for each MTLCommandBuffer in a queue submit. 2023-02-23 11:44:41 -05:00
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
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
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