416 Commits

Author SHA1 Message Date
sean
9b1194afba
Note Metal requirement in UserGuide.md 2022-05-25 15:56:07 +02:00
sean
5e03632d69
Also support the NVIDIA specific extension 2022-05-25 15:17:21 +02:00
Bill Hollings
866c0dc8eb Fix vertex buffer binding counts when establishing implicit buffers binding indexes.
This patch fixes a regression caused by 1b6b8bc9 when the implicit buffers
were moved to top of Metal buffer index range.

Fix vertex buffer binding counts when binding indexes are not consecutive,
or when additional synthetic buffer bindings are required to accommodate
vertex attributes that are outside the vertex buffer stride values.
Take into consideration that the app may bind more vertex attribute buffers
than a pipeline may consume, and don't allow these to overwrite any implicit
buffers sent to the shader.

MVKResourcesCommandEncoderState::encodeBinding() clear binding dirty flag
before calling lambda function to allow function operation to possibly
override and leave binding marked dirty.

Set tessellation vertex buffer indexes based on platform maximum vertex stage
buffer count, instead of hardcoding them, to preemptively avoid conflict with
implicit buffers should the platform counts ever change.
2022-05-22 15:50:26 -04:00
Bill Hollings
695a54037b Add workaround for zombie memory bug in Intel Iris Plus Graphics
driver when repeatedly retrieving GPU counter sets.
2022-05-12 11:40:02 -04:00
Bill Hollings
e2168a33db Fix error on some Apple GPU's where a vkCmdTimestampQuery() after a
renderpass was writing timestamp before renderpass activity was complete.

MVKCommandBuffer tracks whether it contains a stage-based timestamp command,
and MVKCommandEncoder updates the timestamp command fence when ending any
Metal command encoder on such a MVKCommandBuffer.

MVKCommandEncoder reorder member variables to avoid layout gaps (unrelated).
MVKCommandBuffer update _commandCount even for single-use immediate command
encoding (unrelated).
2022-05-10 14:51:55 -04:00
Bill Hollings
1bad27cf26 Add support for VK_KHR_separate_depth_stencil_layouts extension.
Add VK_KHR_separate_depth_stencil_layouts and enable its features.
Metal generally ignores image layouts, so nothing further needed.
Update Whats_New.md and MoltenVK_Runtime_UserGuide.md documents
with recently-added extensions.

Passes almost all supported separate_layouts CTS tests, with the
few remaining tests failing due to issues with unrelated capabilities.

Unrelated cleanup:
- MVKDevice enable extensions before features.
- MVKDevice reorder ivar declarations to reduce
  memory layout gaps, and define default values.
- Rename VkSemaphoreStyle to MVKSemaphoreStyle to
  remove potential conflicts with Vulkan Vk name space.
2022-05-05 15:55:26 -04:00
Bill Hollings
cd5b336bec Add support for VK_EXT_separate_stencil_usage extension. 2022-04-29 22:14:05 -04:00
Bill Hollings
e00fef5b69 Update to latest SPIRV-Cross.
MSL: Emit interface block members of array length 1 as arrays instead of scalars.
2022-04-27 15:02:14 -04:00
Bill Hollings
751dac4391 Support attachment clearing when some clearing formats are not specified.
Exclude attachment from shader if clearing format is not specified.
2022-04-19 09:02:56 -04:00
Bill Hollings
e3f8ce4ebc Add support for VK_KHR_dynamic_rendering extension.
- MVKDevice track enabling VK_KHR_dynamic_rendering extension features.
- Add MVKCmdBeginRendering and MVKCmdEndRendering command objects
  and associated command pools.
- Add MVKCommandEncoder::beginRendering() which dynamically instantiates
  temporary MVKRenderpass and (imageless) MVKFramebuffer objects to handle
  equivalent renderpass operations.
- MVKCommandEncoder retain and release subpass and framebuffer objects
  to allow transient dynamic instances to be created and destroyed.
- Add support functions to create MVKRenderpass and (imageless)
  MVKFramebuffer objects from VkRenderingInfo.
- MVKRenderpass track VkRenderingFlags.
- MVKRenderSubpass create and track an internal VkPipelineRenderingCreateInfo.
- MVKRenderPassAttachment support LoadOp and StoreOp behavior for
  dynamic rendering suspend and resume.
- Refactor viewMask processing to permit operations on viewMask outside of
  MVKGraphicsPipeline without requiring the presence of an MVKSubpass.
- MVKGraphicsPipeline extract VkPipelineRenderingCreateInfo from MVKRenderSubpass
  if available, or VkGraphicsPipelineCreateInfo::pNext if not.
- MVKCommandBuffer track VkCommandBufferInheritanceRenderingInfo (currently unused).
- (unrelated) vulkan.mm move location of VK_EXT_sample_locations functions
  for layout readability consistency.
2022-04-19 07:27:41 -04:00
Bill Hollings
be7a68153f Fix error where previously bound push constants can override a descriptor
buffer binding used by a subsequent pipeline that does not use push constants.

This error was previously introduced in 2a17f75, where a push constants
binding could override the Metal buffer binding 0 of a subsequent pipeline
that does not use push constants.

When pipeline binding is encoded, track which stages use push constants
and only encode push constants if the pipeline and stage uses them.

(unrelated) Make use of MVKResourcesCommandEncoderState::getPipeline() consistent.
2022-04-18 15:32:40 -04:00
Bill Hollings
9fa373ebbb MoltenVK_icd.json support VK_KHR_portability_enumeration extension.
Update README.md and MoltenVK_Runtime_UserGuide.md to document the impact
of the VK_KHR_portability_enumeration extension during runtime loading on macOS.
Update MoltenVK version to 1.1.10.
2022-04-15 13:57:10 -04:00
Bill Hollings
be6f7a5083 Update dependency libraries to match Vulkan SDK 1.3.211.
Update What's New document.
2022-04-09 16:28:41 -04:00
Bill Hollings
3c0644f36a Add support for VK_EXT_sample_locations extension.
Supports only setting custom sample locations in subpasses via
vkBeginRenderpass. Does not support setting custom sample locations via
vkCmdBindPipeline or vkCmdSetSampleLocationsEXT, although collects that
info for possible future enhancements.

- MVKPhysicalDevice track platform support and respond to property queries.
- MVKCmdBeginRenderPassBase collect subpass custom sample locations.
- MVKPipeline support dynamic state values beyond 31.
- MVKPipeline collect custom sample locations.
- Add MVKCmdSetSampleLocations to support vkCmdSetSampleLocations
  to collect dynamic custom sample locations.
- MVKCommandEncoder support collecting custom sample positions from subpass
  and dynamic, and set into MTLRenderPassDescriptor for each Metal render pass.
- MVKArrayRef add assignment operator.
- Add MVKPhysicalDeviceMetalFeatures::programmableSamplePositions.
- Update VK_MVK_MOLTENVK_SPEC_VERSION to version 34.
- MVKCommandBuffer.h remove obsolete comment documentation.
- Update Whats_New.md.
2022-04-08 18:50:32 -04:00
Bill Hollings
2a17f757e1 Fixes to pipeline layout compatibility.
For pipeline layout compatibility, consume the Metal resource indexes in this order:
- Consume a fixed number of Metal buffer indexes for Metal argument buffers,
  but only consume them if Metal argument buffers are not being used.
- Consume push constants  Metal buffer index before descriptor set resources,
  but only consume it if the stage uses push constants.
- Consume descriptor set bindings.

In MVKPipelineLayout, separate tracking resource counts from push constants
indexes, and move push constant indexes ahead of descriptor bindings.
In MVKPipeline, track which stages use push constants.
Remove unused and obsolete function declaration in MVKDescriptorSet.h.
2022-03-14 16:29:22 -04:00
Bill Hollings
9f4243ff91 Fixes to optimize resource objects retained by descriptors beyond their lifetimes.
For a resource object that can be retained by descriptors beyond its lifetime,
release memory resources when the object is destroyed by the app. This includes
objects of type MVKBuffer, MVKBufferView, MVKImageView, and MVKSampler.

When the app destroys an MVKBuffer, also detach from the MVKDeviceMemory,
to fix a potential race condition when the app updates the descriptor on
one thread while also freeing the MVKDeviceMemory on another thread.

MVKImageView guard against detached planes while in descriptor.

Add comment to clarify how destroy() is called from release().
2022-03-13 14:54:54 -04:00
Bill Hollings
cf3b5968ef Avoid adjusting SRGB clear color values by half-ULP.
For GPUs that round float clear colors down, a half-ULP adjustment is performed
on normalized formats. But this adjustment should not be performed on SRGB formats,
which Vulkan requires to be treated as linear, with the value managed by the app.
2022-03-11 11:24:05 -05:00
Bill Hollings
a91a3d000a Remove limit on VkPhysicalDeviceLimits::maxSamplerAllocationCount
when not using Metal argument buffers.
2022-03-10 18:12:54 -05:00
Bill Hollings
2aadca70ce Fix deletion of GPU counter MTLFence while it is being used by MTLCommandBuffer.
Move release of GPU counter MTLFence from MVKCommandEncoder destructor
to MTLCommandBuffer completion handler.
2022-03-10 13:25:09 -05:00
Bill Hollings
728182cf75 MoltenVKShaderConverter tool defaults to the
highest MSL version supported on runtime OS.

Update to latest SPIRV-Cross.
Update Docs/Whats_New.md document.
2022-03-08 21:22:25 -05:00
Bill Hollings
6327b767e0 Reinstate memory barriers on non-Apple GPUs.
Ensure non-Apple GPU's enable memory barriers.
A previous commit inadvertently disabled GPU memory barriers.

Change tests for memory barriers to runtime test for Apple GPU, instead of
build-time test for Apple Silicon, to accommodate running on Rosetta2, and
refactor tests for Apple Silicon and OS version on some macOS GPU feature settings.
2022-03-08 17:01:50 -05:00
Bill Hollings
e42b33e593 Don't attempt to store the depth component of a stencil-only renderpass attachment.
For a combined depth-stencil format in a MVKImageView attachment with
VK_IMAGE_ASPECT_STENCIL_BIT, the attachment format may have been swizzled
to a stencil-only format. In this case, we want to guard against an attempt
to store the non-existent depth component.

Pass MVKImageView attachment to MVKRenderPassAttachment::encodeStoreAction()
and MVKRenderPassAttachment::populateMTLRenderPassAttachmentDescriptor() to
check attachment depth format component.

Consolidate calls to MVKImageView::populateMTLRenderPassAttachmentDescriptor() by calling
it from within MVKRenderPassAttachment::populateMTLRenderPassAttachmentDescriptor().
2022-02-24 11:42:12 -05:00
Bill Hollings
e28a16d76b Update MoltenVK version number to 1.1.9.
Adjust Whats_New.md to accommodate earlier
trivial 1.1.8 patch release for SDK 1.3.204.1.
2022-02-22 14:18:55 -05:00
Bill Hollings
afd997ab31 Align flattened shader inputs to previous stage output structs.
When flattening shader inputs for stage_in, which are to be read from a buffer
that was populated as nested structs during an earlier stage, the structs will
be aligned according to C++ rules, which can affect the alignment of the first
member of the flattened input struct.

Add SPIRVShaderOutput::firstStructMemberAlignment to track the alignment
requirements of the first member of a nested structure, and recursively
determine the alignment of the first member of each nested output structure.

Move sizeOfOutput() from MVKPipeline.mm to SPIRVReflection.h,
rename to getShaderOutputSize(), and add getShaderOutputAlignment()
to extract member alignment.
2022-02-22 12:17:15 -05:00
Bill Hollings
f7ca132844 Update glslang version, to use python3 in glslang scripts,
to replace missing python on macOS 12.3.
2022-02-16 14:02:01 -05:00
Bill Hollings
16408fd6ae Remove logged warning if MoltenVK does not support VkApplicationInfo::apiVersion value.
Update MoltenVK version to 1.1.8.
Minor spelling fixes in comments.
2022-02-09 13:36:08 -05:00
Bill Hollings
24ff2106d9 Update dependency libraries to match Vulkan SDK 1.3.204.
Update What's New document.
2022-02-06 19:55:44 -05:00
Nikita Fediuchin
4efb90b3c1 Update license year 2022-02-04 13:33:27 +02:00
Bill Hollings
9986e92f35
Merge pull request #1497 from billhollings/apple-silicon-deviceID
On Apple Silicon, set VkPhysicalDeviceProperties::deviceID from GPU capabilities.
2021-12-28 22:08:44 -05:00
Bill Hollings
9633f4843d Improve accuracy of VkPhysicalDeviceLimits::timestampPeriod.
If using GPU counters, on all Apple GPUs lock timestampPeriod to 1.0,
since Apple GPUs use nanoseconds, and on non-Apple GPUs, dynamically
adapt value of timestampPeriod by correlating GPU ticks with GPU ticks.

If using CPU sync, set timestampPeriod to OS CPU timestamp tick period.
2021-12-28 17:19:11 -05:00
Bill Hollings
df043487e4 On Apple Silicon, set VkPhysicalDeviceProperties::deviceID from GPU capabilities.
Previously, on Apple Silicon (iOS, tvOS & macOS M1), we tried to guess
deviceID from GPU parameters, but this is becoming harder as the types
of Apple Silicon is growing, and the actual device SoC itself is less
relevant that the GPU capabilities. So we now set deviceID from the
combination of OS version and GPU type.

Rename MVKDevice::getHighestMTLFeatureSet() to getHighestGPUCapability().
2021-12-27 16:45:12 -05:00
Bill Hollings
5810772644 Fix merge conflicts and syntax build error in iOS build. 2021-12-26 18:30:31 -05:00
Bill Hollings
92712e240a Fix memory leak of dummy MTLTexture in render subpasses that use no attachments.
Older Metal does not support rendering without subpass attachments.
In this case, a dummy attachment with a dummy MTLTexture is created
whenever the subpass begins, but was not being correctly used.

Move the creation, retaining, and releasing of the dummy MTLTexture to
MVKFramebuffer, where the extent and layer count is known and can be reused.

Pass framebuffer to MVKCommandEncoder::beginRenderpass() and remember
current framebuffer in MVKCommandEncoder.
Add getFramebufferExtent() and getFramebufferLayerCount() to MVKCommandEncoder.
Pass framebuffer to MVKRenderSubpass:populateMTLRenderPassDescriptor() and
retrieve dummy MTLTexture from framebuffer.
2021-12-25 16:18:18 -05:00
Bill Hollings
355bfed457 Fix Metal object retain-release errors in assignment operators. 2021-12-25 12:58:55 -05:00
Bill Hollings
18642002ce Updates to better support Rosetta2 runtimes, and MSL 2.4 and 2.3 versions.
Do not use MTLEvent for VkSemaphore under Rosetta2.
Remove compile test for MVK_MACOS_APPLE_SILICON and MVK_APPLE_SILICON when testing
for Apple GPU families, to allow x86 builds to test for Apple GPU under Rosetta2.
Simplify identifying M1 GPU. All M1 SoCs currently support the A14 (Apple7) GPU.
Support compiling MSL 2.4 in runtime pipelines and MoltenVKShaderConverterTool.
Fix issue where MSL 2.3 only available on Apple Silicon, even on macOS.
Update to latest SPIRV-Cross (unrelated to Rosetta2).
2021-12-01 18:14:07 -05:00
Bill Hollings
5de7f5551c Support building MoltenVK with static Vulkan linkage symbols hidden.
Add build environment variable MVK_HIDE_VULKAN_SYMBOLS. to allow MoltenVK
to be built with static Vulkan API symbols hidden, to avoid library linking
conflicts when bound to a Vulkan Loader that also exports identical symbols.

The default value of MVK_HIDE_VULKAN_SYMBOLS is 0,
meaning Vulkan static symbols are exposed by default.

Add MVK_PUBLIC_VULKAN_SYMBOL directive to mark each Vulkan call symbols
for exporting or hiding.

Update the MoltenVK Xcode project to add the MVK_HIDE_VULKAN_SYMBOLS build
setting, and set the ENABLE_TESTABILITY build setting to NO, because it
conflicts with stripping symbols.

Update MoltenVK version to 1.1.7.
2021-11-17 18:22:33 -05:00
Bill Hollings
a0ed3345b6 Update library dependencies to match Vulkan SDK 1.2.198.
Update What's New.md document.
2021-11-13 19:57:41 -05:00
Bill Hollings
6e054ad5db Restore support for BC1_RGB compressed format.
For Vulkan BC1_RGB formats, swizzle alpha of substituted
Metal BC1_RGBA to 1.0, to return value expected by Vulkan.
2021-11-09 12:13:51 -05:00
Bill Hollings
bab17a52b7 Remove advertised support for BC1_RGB texel formats.
Metal does not provide direct support for BC1_RGB formats
(VK_FORMAT_BC1_RGB_UNORM_BLOCK & VK_FORMAT_BC1_RGB_SRGB_BLOCK).
We have been faking it by mapping these Vulkan formats to Metal
formats containing alpha (MTLPixelFormatBC7_RGBAUnorm &
MTLPixelFormatBC7_RGBAUnorm_sRGB, respectively),
and advertising support for BC1_RGB formats.

However, this triggers CTS failures, because the BC1_RGBA formats can return
an alpha value of 0.0 when constructed that way, whereas the BC1_RGB formats
always expect 1.0 (opaque) to be returned.

This change moves to indirect support for BC1_RGB formats. They will still
be covered by MTLPixelFormatBC7_RGBAUnorm & MTLPixelFormatBC7_RGBAUnorm_sRGB,
and will effectively work (except transparency), but are no longer advertised
through physical device format and image format queries.
2021-10-31 19:00:25 -04:00
Bill Hollings
cc10af04c9 Ensure dynamic pipeline state always respects pipeline dynamic flags.
Dynamic pipeline state set before the pipeline is set was reading
dynamic flags from previous pipeline. This is fixed here by accepting
the dynamic state, but deferring the decision to use either dynamic
or static state until the pipeline is encoded.
2021-09-30 21:09:07 -04:00
Bill Hollings
36fae88ee2 Move multilayer-rendering validation from MVKImage to MVKImageView.
An MVKImageView that renders to only one layer of a multilayer MVKImage
is not performing multilayer-rendering. Only validate multilayer-rendering
when it is definitely requested in an MVKImageView, instead of presuming
when a multilayer MVKImage is marked for rendering.
2021-09-30 15:30:23 -04:00
Bill Hollings
ba9623cad5 Update to latest version of SPIRV-Cross.
Add additional SPIRV-Cross header files to ExternalDependencies.xcodeproj
to allow browsing these files in Xcode.
2021-09-30 13:45:54 -04:00
Bill Hollings
4ad5930263 Improved checks for timestamp GPU counter support on older devices.
Check that appropriate GPU counter set is supported on
the device before creating GPU counter sample buffer.
Don't attempt to timestamp using GPU counters unless
a GPU sample counter buffer has been created.
2021-09-13 17:20:00 -04:00
Bill Hollings
333084f739 Several updates for CTS test fixes.
Support maximum point primitive size of 511.
Update to latest SPIRV-Cross version to add support
for OpSpecConstantOp ops OpQuantizeToF16 and OpSRem.
Update MoltenVK version to 1.1.6.
2021-09-08 12:05:08 -04:00
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