1809 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
sean
a0490cec0f
Use NSScreen maximumFramesPerSecond on macOS 12+ 2022-05-25 14:57:49 +02:00
sean
6cc5110290
Add: Support for KHR_fragment_shader_barycentric 2022-05-24 23:37:04 +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
spnda
b322ffc7eb
Use superlayer to find NSScreen 2022-05-22 20:49:46 +02:00
kleinerm
08252c1006
Implement vkGetRefreshCycleDurationGOOGLE() for macOS.
So far it always returned a 60 Hz refresh on macOS. Now we query the
actual refresh interval for the NSScreen on which our swapChain is likely
displaying.

Tested on a MacBookPro dual-display setup with builtin 60 Hz Retina panel
and external 100 Hz monitor, showing proper reporting depending on which
monitor the window was displaying on. Tested on macOS 10.15.7 only.
2022-05-22 20:27:53 +02: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
smanhaeve
409101788a
Fix vkSetMoltenVKConfigurationMVK function typedef
Fixes issue https://github.com/KhronosGroup/MoltenVK/issues/1577
2022-04-25 14:37:00 +02:00
Bill Hollings
abaafd09d7
Update MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
Co-authored-by: Chip Davis <cdavis@codeweavers.com>
2022-04-21 14:41:22 -04:00
Bill Hollings
a1f3508f8e Optimize reuse of transient renderbuffer and framebuffer for dynamic rendering.
- MVKRenderPass set rendering flags from outside instead of via constructor.
- MVKCommandEncodingContext tracks and manages lifespan of renderpass and
  framebuffer, potentially across multiple MVKCommandEncoders.
- When resuming a suspended dynamic renderpass, reuse the renderpass and
  framebuffer cached in MVKCommandEncodingContext, otherwise create them.
- MVKCommandBuffer::begin() creates local copy of dynamic rendering color formats.
2022-04-19 14:53:15 -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
370fead8b7 Actually update MoltenVK version to 1.1.10. 2022-04-15 17:52:11 -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
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
148823a841
Merge pull request #1564 from bangnoise/pr/IOSurface-CF-leaks
Fix leak of CoreFoundation objects during calls to vkUseIOSurfaceMVK()
2022-04-08 13:06:05 -04:00
Tom Butterworth
9f5bd82bef Fix leak of CoreFoundation objects during calls to vkUseIOSurfaceMVK()
A small leak occurs if no existing IOSurface is provided to vkUseIOSurfaceMVK() because CoreFoundation objects returned from functions with Create in their name must be released with CFRelease()
2022-04-08 10:44:13 +01:00
Tom Butterworth
41fabde757 Fix crash in vkGetMTLCommandQueueMVK()
MVKQueue* cannot be cast from VkQueue, use MVKQueue::getMVKQueue() instead
2022-04-08 10:12:21 +01:00
BeastLe9enD
1955c161a6
Added optimized support for VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT when MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS is used 2022-04-05 18:01:52 +02:00
Bill Hollings
d84f6b69cf Use MVKExtensions.def to check OS version support for all Vulkan extensions.
In the interests of Single Source of Truth, OS version support is now populated
in MVKExtensions.def, and that info is used to validate each Vulkan extension
against OS version support for the functionality required by the extension, with
the default being unsupported, unless otherwise indicated in MVKExtensions.def.

- Add OS version info for each extension in MVKExtensions.def.
- mvkIsSupportedOnPlatform() checks every extension for OS version support,
  not just a separately-populated list of OS version limitations (that defaulted
  to supported, instead of unsupported).
- Visually clean up MVKExtensions.def for easier reading.
2022-04-03 20:31:55 -04:00
Bill Hollings
0bb6917979 Remove use of C++17 deprecated feature: std::iterator.
std::iterator is deprecated in C++17, which triggers multiple compilation warnings.
Update MVKSmallVector::iterator to explicitly specify iterator traits,
instead of subclassing from std::iterator.
Qualify use of std::remove() in mvkRemoveAllOccurances(),
to eliminate resolution ambiguity.
2022-03-22 10:03:56 -04:00
Bill Hollings
6011bfe05d Update Xcode build settings validation, and GitHub CI settings.
Update to Xcode 13.3 build settings validation.
Update GitHub CI settings to latest macOS and Xcode 13.2.1.
2022-03-21 20:31:33 -04:00
Bill Hollings
1b6b8bc992 Move implicit buffers to top of Metal buffer index range.
To better support pipeline layout compatibility between pipelines with differing
quantities of descriptor sets, move the buffer indexes used by implicit buffers to
the top end of the Metal buffer index range, below vertex and tessellation buffers.

MVKPipeline calculates implicit buffer indexes based on vertex and tessellation
buffers required by pipeline, instead of based on descriptors in MVKPipelineLayout.

MVKPipeline track buffer index counts consumed by MVKPipelineLayout, to validate
room for implicit buffers.
2022-03-15 11:52:15 -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
c5ce77fff3
Merge pull request #1540 from billhollings/reinstate-gpu-memory-barriers
Reinstate memory barriers on non-Apple GPUs.
2022-03-08 20:58:26 -05:00
Bill Hollings
3114e16457 Fix build for Xcode 11.7. 2022-03-08 17:52:50 -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
Joshua Goins
b6c392541c
Check if metal device supports base vertex instance drawing
Co-authored-by: Bill Hollings <bill.hollings@brenwill.com>
2022-03-08 14:17:55 -05:00
Joshua Goins
d05537dbe5 Enable base vertex instance support in shader conversion 2022-03-06 17:07:54 -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
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
13a0f6abee Fix use of GPU counter sets on older versions of iOS running on the simulator.
Replace test for MVK_APPLE_SILICON with test for MVK_MACOS plus Apple1 GPU.
2022-02-05 12:23:05 -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
7740d4f43a
Change scale of OSMin value in deviceID to 100.
Co-authored-by: Chip Davis <cdavis@codeweavers.com>
2021-12-28 19:58:10 -05:00
Bill Hollings
cd7c7fdfae Support MTLTimestamp on Xcode 11.7. 2021-12-28 18:12:25 -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
3a8975c21d Support Xcode 13.2 build settings. 2021-12-27 17:50:29 -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