1961 Commits

Author SHA1 Message Date
Bill Hollings
5649fb3fd3
Update MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h
Renamed _maxVertexInputBindingBufferCount to kMVKMaxVertexInputBindingBufferCount.
2024-05-04 15:33:44 -04:00
Aitor Camacho
bd24db8553 Allow vertex buffer binding when they are used disregarding implicit index
Due to how MoltenVK decides when a buffer can be bound based on
its requirements for the implicit buffer, if the application uses
all bindings, implicit buffer index will be uint max. This lead
to used buffers not being bound.
2024-05-01 16:26:23 +02:00
Bill Hollings
607aaff4c1 On macOS Apple Silicon, avoid managed-memory textures, and resource syncs.
Like their iOS/tvOS counterparts, macOS Apple Silicon GPUs support
using Shared memory for textures, and do not require resource
synchronization, even with Managed memory. This change treats
macOS Apple Silicon the same as iOS & tvOS.

- MVKPhysicalDevice add _hasUnifiedMemory & _isAppleGPU flags.
- MVKDeviceTrackingMixin add isUnifiedMemoryGPU() & isAppleGPU().
- Do not advertise host-visible-but-not-host-coherent
  Vulkan memory type on macOS Apple Silicon.
- Replace mvkMTLStorageModeFromVkMemoryPropertyFlags() with
  MVKPhysicalDevice::getMTLStorageModeFromVkMemoryPropertyFlags(),
  and return Shared instead of Managed for Apple Silicon,
  even if coherency is not requested.
- On unified memory devices, avoid needless calls to didModifyRange:,
  synchronizeResource:, and synchronizeTexture:slice:level:.
2024-04-29 17:13:17 -04:00
Bill Hollings
6c68ba1e0c
Merge pull request #2208 from billhollings/VK_EXT_host_image_copy
Add support for VK_EXT_host_image_copy extension.
2024-04-23 20:30:00 -04:00
Bill Hollings
dae20de48a
Update MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm
Make fallback screen names consistent.
2024-04-23 16:42:34 -04:00
Bill Hollings
b6735878f3 VK_EXT_host_image_copy: On discrete GPUs, sync managed-memory textures before copying.
Discrete GPUs use managed-memory textures, and these need to be synchronized
from GPU memory before being available for host-copying to memory using the CPU.
Metal automatically handles the reverse sync when copying from memory to a texture.
2024-04-23 14:51:31 -04:00
Pedro J. Estébanez
a97ba52dbf Prevent deadlock if working on non-main thread 2024-04-23 19:35:35 +02:00
Bill Hollings
6a6fa2cb7b
Update MoltenVK/MoltenVK/Utility/MVKEnvironment.h
Removing as obsolete.
2024-04-19 11:15:57 -04:00
Bill Hollings
3dac6ec8ca
Update MoltenVK/MoltenVK/Utility/MVKEnvironment.h
Aligning with syntax of other comments in this file.
2024-04-19 11:15:32 -04:00
Evan Tang
b420d58b59 Add option to dump shaders 2024-04-17 13:38:02 -05:00
Bill Hollings
8b46bd2e7a Simplify maintenance of build-time checking of MVKConfiguration members.
- Remove _unused_struct_padding from MVKConfiguration and MVKConfigMembers.def.
- Add kMVKConfigurationInternalPaddingByteCount to specify MVKConfiguration
  internal padding byte count, for use in build time assertion check.
2024-04-16 18:05:10 -04:00
Bill Hollings
2290e86cd9 Add support for VK_EXT_host_image_copy extension.
- MVKResource::getHostMemoryAddress() return nullptr if
  MVKDeviceMemory::getHostMemoryAddress() returns null pointer,
  regardless of local offset.
- Remove unnecessary  enum value kMVKVkFormatFeatureFlagsTexTransfer
  to reduce redundancy between read and transfer feature flag options.
- Fix spelling of mvkVkOffset3DFromMTLOrigin() (unrelated).
- MVKResource remove unnecessary inline qualifiers (unrelated).
- MVKDevice remove some obsolete commentary (unrelated).
2024-04-16 12:18:40 -04:00
Bill Hollings
7533974fda Fix issue where incremental dynamic builds do not link to static dependencies.
After the recent change to building dynamic frameworks and dylibs as targets
built by linking to a static library dependency, incremental builds do not
correctly link the dynamic frameworks and dylibs to the rebuilt static library.

- Delete dynamic target outputs during static target builds.
- Run platform schemes sequentially in manual order.
- Build the dynamic framework before the dylib.
- Clean up Xcode Scheme organization.

It is not entirely obvious what the dependency problem is, and why
these particular changes work. A lot of trial-and-error was required.
It's possible that Xcode dependency analysis does not correctly analyze
the flow used in MoltenVK builds.
2024-03-30 17:47:36 -04:00
Bill Hollings
73f2b8c280
Merge pull request #2183 from SRSaunders/perf-tracker
Add "previous" member to MVKPerformanceTracker structure
2024-03-20 11:24:22 -04:00
SRSaunders
0cf9f7f24b Capture perf start times in MVKQueueSubmission constructors vs. arguments of execute() function 2024-03-20 00:03:35 -04:00
SRSaunders
1d3fe52db9 Update documentation for the new waitSubmitCommandBuffers and waitPresentSwapchains perf counters 2024-03-19 23:19:01 -04:00
SRSaunders
10810f41d0 Add two new counters in MVKQueuePerformance for async queue submit wait times 2024-03-19 00:09:11 -04:00
SRSaunders
08c1ad705a Increment MVK_PRIVATE_API_VERSION to 41 2024-03-17 11:35:08 -04:00
SRSaunders
3ec155a3b6 Fix mvkCopyGrowingStruct() to return success only if struct and buffer sizes match 2024-03-17 11:34:14 -04:00
Jeroen Bakker
f7ffecd9a7 Fix compilation issue due to new version 2024-03-14 11:19:15 +01:00
Bill Hollings
a9ebfc2c76 Update MoltenVK version to 1.2.9. 2024-03-13 13:10:03 -04:00
SRSaunders
11bd581c8d Add "previous" to MVKPerformanceTracker and save value before capturing "latest" 2024-03-13 09:55:08 -04:00
Bill Hollings
d61cefb530 Update dependency libraries to match Vulkan SDK 1.3.280.
- Remove support for deprecated -[MTLRenderCommandEncoder textureBarrier]
  and deprecate MVKPhysicalDeviceMetalFeatures::textureBarriers.
- Update minimum macOS deployment target to 10.15.
- Update minimum iOS/tvOS deployment target to 13.0.
- Update Whats_New.md document.
2024-03-12 11:49:11 -04:00
Bill Hollings
41f1808cea Suppress Xcode project build settings update warnings.
Xcode validates project build settings with each new Xcode release and
issues warnings to apply recommendations. We ignore these. This patch
sets the validated Xcode version to the maximum so that Xcode will
not longer issue these warnings.
2024-03-07 17:54:28 -05:00
Bill Hollings
802470b5a8 Create macOS libMoltenVK.dylib directly from Xcode.
Previously, libMoltenVK.dylib was created by copying and renaming
the binary from MoltenVK.framework, but this resulted in an unsigned
dylib that was not loadable.

- Create signed macOS libMoltenVK.dylib directly from Xcode.
- Refactor package_moltenvk.sh into package_dylibs.sh & package_headers.sh.
- Remove unused non-packaging Xcode schemes (unrelated).
2024-03-07 15:54:31 -05:00
Bill Hollings
5d21869b6d
Merge pull request #2173 from js6i/fixup-2
Don't set MTLTextureUsageShaderAtomic if the pixel format does not support it.
2024-03-07 10:19:28 -05:00
Bill Hollings
699e8d09e2
Update MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm
Restore original formatting.
2024-03-06 15:51:02 -05:00
Bill Hollings
4e89f2f802
Merge branch 'main' into fix/visionOS_build 2024-03-06 15:47:27 -05:00
Bill Hollings
eff7571446
Merge pull request #2170 from billhollings/xcode-built-dyn-xcfwk
Improve support for iOS App Store rules by using Xcode-built dynamic XCFramework.
2024-03-06 15:22:37 -05:00
Jan Sikorski
e388a0e3af MVKPixelFormats: Only set MTLTextureUsageShaderAtomic for supported pixel format. 2024-03-06 12:27:34 +01:00
Jan Sikorski
69446d122d MVKBuffer: Only set MTLTextureUsageShaderAtomic on views with supported pixel format. 2024-03-06 12:27:34 +01:00
Jan Sikorski
3056cae106 Fix uninitialized MVKImage member. 2024-03-06 11:14:24 +01:00
Bill Hollings
0d62ff8fb7 Improve support for iOS App Store rules by using dynamic XCFramework.
Apple's iOS App Store does not permit an app to link to naked dylibs.
Instead, these must be placed in frameworks, which are embedded in a
dynamic version of MoltenVK.xcframework.

- Use Xcode to directly generate a MoltenVK.framework for each platform,
  and remove create_dylib*.sh scripts.
- Move static XCFramework, containing libMoltenVK.a static libraries,
  to Package/Latest/MoltenVK/static/MoltenVK.xcframework.
- Generate dynamic XCFramework, containing MoltenVK.framework dynamic
  libraries, in Package/Latest/MoltenVK/dynamic/MoltenVK.xcframework.
- Add macro MVK_VERSION_STRING to create version string at compile time,
  use it to validate the CURRENT_PROJECT_VERSION build setting at compile time,
  and use it at runtime instead of mvkGetMoltenVKVersionString() function.
- Add -w to OTHER_LDFLAGS to dynamic framework builds to suppress
  spurious linker warnings of the type
  "ld: warning: no platform load command found in '...', assuming: iOS"
  issued from the new linker introduced in Xcode 15.
- Add MoltenVK-MacCat Xcode target and MoltenVK Package (MacCat only)
  Xcode scheme to avoid building dynamic MoltenVK.framework for the
  Mac Catalyst platform, because Xcode does not support doing so.
- Always run MoltenVK build scripts, to ensure all components are
  added to the XCFrameworks, and MoltenVK/Package is always refreshed,
  even if code compilation is not required.
- Cube demo link to dynamic MoltenVK.framework through
  dynamic/MoltenVK.xcframework, instead of to naked libMoltenVK.dylib.
- Update the version of Volk used by the Cube demo, to support
  loading MoltenVK from dynamic frameworks inside Volk.
- Update README.md and MoltenVK_Runtime_UserGuide.md documents.
- Update MVK_PRIVATE_API_VERSION to 40.
- Fix make install to install /usr/local/lib/libMoltenVK.dylib on macOS (unrelated).
- Remove unused MTLAttributeStrideStatic declaration prior to Xcode 15 (unrelated).
2024-03-05 20:38:35 -05:00
Mike Krus
9082ca839f Fix visionOS build
This adds a few macros to test which platform is currently being built.
Addresses some compile warnings such as missing return values.
2024-03-01 18:28:16 +00:00
Jan Sikorski
c03893b5ad Enable use of native texture atomics.
This commit conditionally skips the emulated image atomics paths if native
texture atomics are available and a configuration option is set.

Apart from unlocking some potential performance benefits from not having to
force some textures to be linear, it also makes texture atomics work with
argument buffers.
2024-02-27 12:41:39 +01:00
Bill Hollings
37361ccd55
Merge pull request #2159 from billhollings/no-headless-sub-optimal
Don't return VK_SUBOPTIMAL_KHR for headless surfaces.
2024-02-12 19:46:53 -05:00
Bill Hollings
a62cada021
Merge pull request #2157 from cdavis5e/smallvec-const-correct
MVKSmallVector: Make iterator const correct.
2024-02-12 16:39:47 -05:00
Bill Hollings
9c812da6a6 Don't return VK_SUBOPTIMAL_KHR for headless surfaces.
This fixes a regression caused by a recent change that keeps size
of headless surfaces at the special value {0xFFFFFFFF, 0xFFFFFFFF}.
2024-02-12 15:53:58 -05:00
Bill Hollings
efaae79d90 Consolidation and fixes for MVK_USE_METAL_PRIVATE_API functionality.
- Expose MTLRenderPipelineDescriptor.sampleMaskMVK and
  MTLSamplerDescriptor.lodBiasMVK properties when
  MVK_USE_METAL_PRIVATE_API build setting is disabled.
- MVKCmdSetDepthBias & MVKCmdSetDepthBounds subclass from MVKSingleValueCommand.
- MVKRenderingCommandEncoderState simplify calls to set depth bias
  and depth bounds, and make consistent with other settings.
- Refactor MVKRenderingCommandEncoderState::setContent() and
  setMTLContent() to remove need for intermediate value copies.
- MVKPipeline remove test for depth bounds support since
  it's checked before GPU encoding.
- MVKDepthBias member order same as in Vulkan calls.
- Whats_New.md consolidate notes about MVK_USE_METAL_PRIVATE_API.
2024-02-12 13:50:44 -05:00
Chip Davis
995a28808c MVKSmallVector: Make iterator const correct.
Or the newest libc++ in Xcode 15.3 won't build.

Fixes #2156.
2024-02-09 02:50:02 -07:00
Bill Hollings
224b14a080
Merge pull request #2142 from cdavis5e/metal-spis
Add more Metal SPI support
2024-01-29 19:49:12 -05:00
Bill Hollings
03d89dfb8a
Merge pull request #2139 from aitor-lunarg/depth-stencil-swizzle-sample
Handle depth/stencil swizzle sample correctly
2024-01-29 19:39:23 -05:00
Bill Hollings
361b161b8f
Update MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
Minor comment clarification.
2024-01-29 18:54:10 -05:00
Chip Davis
60a429f353 Support the depth bounds test.
This isn't even a regular SPI. It's not even present in the Metal
framework. It's exposed by the driver. Only AMD drivers support the
method we need for now.
2024-01-29 15:42:13 -07:00
Chip Davis
f8b974371b MVKPipeline: Support sample masks in the Metal SPI.
This is yet another "secret" property on the
`MTLRenderPipelineDescriptor`.
2024-01-29 15:39:01 -07:00
Chip Davis
f5d7190554 MVKSampler: Support LoD bias.
Metal actually supports this, but this is a hidden property of the
`MTLSamplerDescriptor`. It's not part of the public API. Guard our use
of it appropriately.
2024-01-29 15:38:52 -07:00
Chip Davis
8d1303a57a MVKPipeline: Support framebuffer logic operations.
This support was always there in Metal. It was just hidden from public
view--but not from prying eyes on the Objective-C metadata.

I had initially thought they were using OpenGL/Vulkan values for the
logic operation. When that didn't work, I then tried D3D11 values. I
guess D3D11 makes sense, because the Intel GPU drivers were the first to
support this in Metal.

Move the definition of `MVK_USE_METAL_PRIVATE_API` into
`"MVKCommonEnvironment.h"` so we can use it from non-C++ code.
2024-01-29 15:37:29 -07:00
Chip Davis
06d493dcc1 Add a configuration parameter to control the use of Metal SPIs.
With the new `MVK_CONFIG_USE_METAL_PRIVATE_API`, the user can prevent their
use at run time without recompiling MoltenVK. This may be useful for
troubleshooting purposes.

The extra member is because the compiler adds tail padding to make the
struct aligned on an 8-byte boundary, so the `static_assert()` fails
without it.
2024-01-29 15:26:23 -07:00
Aitor Camacho
33731ac34c Handle depth/stencil swizzle sample correctly
Fixes CTS tests:
dEQP-VK.pipeline.monolithic.sampler.border_swizzle.d*.opaque_white.*
2024-01-29 16:56:53 +01:00
Bill Hollings
1c24ec90d9 Simplify repetitive copy-paste declarations of single-value Vulkan commands.
There are many MVKCommand subclasses that simply encode a single value,
resulting in loads of repetitive copy-pasted code.
- Add abstract template superclass MVKSingleValueCommand
  for these concrete command classes.
- Modify MVKCmdSetBlendConstants to hold an MVKColor32 so it can
  subclass from MVKSingleValueCommand, and modify MVKGraphicsPipeline
  and MVKRenderingCommandEncoderState to use MVKColor32.
- Remove trivial comments for simple concrete Vulkan command classes.
2024-01-27 18:19:11 -05:00