566 Commits

Author SHA1 Message Date
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
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
Bill Hollings
09aceaa981 runcts script also output a file containing a list of the failed CTS tests.
- Add get_failing_cts_tests.py script to extract failures
  from runcts output, and call automatically from runcts.
2024-01-30 14:47:22 -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
Bill Hollings
3e6b3a7809 Don't update currentExtent of headless surface when swapchain attached. 2024-01-26 18:05:05 -05:00
Bill Hollings
5992dda9ba Add optional support for VkPhysicalDeviceFeatures::wideLines.
- Add MVK_USE_METAL_PRIVATE_API build setting to allow MoltenVK
  to be built with access to Metal private API calls.
- Add support for VkPhysicalDeviceFeatures::wideLines feature
  when MVK_USE_METAL_PRIVATE_API is enabled in a MoltenVK build.
- Set lineWidthRange and lineWidthGranularity to reasonable arbitrary values.
2024-01-25 13:08:10 -05:00
Bill Hollings
7f75502440 Support libMoltenVK.dylib for iOS Simulator architecture.
- Xcode now supports building dylib for iOS Simulator
  (but unfortunately not yet tvOS Simulator).
- Restore support for iOS Simulator destination in recent update to
  Cube demo that uses dynamic-linking, by using script build phase
  to overwrite the iOS build of MoltenVK with the iOS Simulator build.
2024-01-23 12:29:38 -05:00
sean
151e940e13 Add: KHR_shader_integer_dot_product 2024-01-16 20:41:54 +01:00
Bill Hollings
ccf68f4aac Ensure buffers available for buffer addresses in push constants.
Fix issue where push constants contain a buffer address, but no descriptor
resources are encoded, resulting in addressed buffer not resident in GPU.

- Add MVKGPUAddressableBuffersCommandEncoderState to track when the
  GPU-addressable buffer usage needs to be encoded, and only encode
  them once per Metal renderpass.
- Set MVKGPUAddressableBuffersCommandEncoderState dirty whenever
  a buffer is bound for a descriptor or a push constant.

Unrelated changes:
- MVKCommandEncoder::finalizeDrawState() reorder encoding of encoder
  states to encode resource and push-constant encoder states together.
- Move getGraphicsPipeline() and getComputePipeline() to MVKCommandEncoder.
- MVKDevice Remove preallocation on _resources and _gpuAddressableBuffers.
- Align conditions for VkPhysicalDeviceVulkan12Features::bufferDeviceAddress
  to those for VK_KHR_buffer_device_address/VK_EXT_buffer_device_address.
2024-01-13 13:38:06 -05:00
Bill Hollings
94e86a32bd Fix potential crash when using multi-planar images.
- MVKImage add functions to consolidate mapping plane indexes to memory bindings
  to add safety in situation where one memory binding supports all planes.
- Update MoltenVK version to 1.2.8 (unrelated).
2024-01-11 11:37:50 -05:00
Bill Hollings
8a675aa3a8 Revert to disabling MVK_HIDE_VULKAN_SYMBOLS by default.
- Statically expose vkGetInstanceProcAddr(), even
  when MVK_HIDE_VULKAN_SYMBOLS is enabled.
- To support Volk, link Cube demo dynamically to libMoltenVK.dylib
  instead of statically to MoltenVK.xcframework.
2024-01-10 17:16:33 -05:00
Bill Hollings
cb460524d7 Update dependency libraries to match Vulkan SDK 1.3.275.
- Hide static Vulkan API symbols by default
  (build setting MVK_HIDE_VULKAN_SYMBOLS=1 by default).
- Update documentation.
2024-01-09 08:17:16 -05:00
Bill Hollings
f7e32e0f33 Update dependency libraries to match Vulkan SDK 1.3.273.
- Update Whats_New.md.
2024-01-05 07:13:54 -05:00
Bill Hollings
d9f75ed812 Update copyright notices to year 2024. 2024-01-04 14:51:53 -05:00
Bill Hollings
d20d13fe27
Merge pull request #2108 from spnda/format_feature_flags2
Add: KHR_format_feature_flags2
2024-01-03 10:58:16 -05:00
sean
e49a69e617 Add: KHR_format_feature_flags2 2024-01-03 08:03:27 +01:00
sean
6e94ff0bcc Add: KHR_calibrated_timestamp 2024-01-03 07:58:13 +01:00
sean
3ea2ab7412 Add: KHR_vertex_attribute_divisor 2024-01-01 03:49:04 +01:00
Bill Hollings
1ce40f63a4 Fixes from dev review feedback for adding VK_EXT_layer_settings extension.
- Document the name of the MoltenVK driver layer.
- Support future multiple string members in MVKConfiguration.
- Add static assert on number of string members in MVKConfigruation.
- Rename global mvkConfig() to getGlobalMVKConfig().
- Rename global mvkSetConfig() to mvkSetGlobalConfig().
- Remove unused mvkPrintSizeOf() macro. (unrelated).
- Trim trailing spaces from Markdown documents because
  it causes double-spaces in some Markdown readers (unrelated).
2023-12-19 11:17:39 -05:00
Bill Hollings
0fc9657bbd Update documentation for the VK_EXT_layer_settings extension.
- Add MoltenVK_Configuration_Parameters.md to
  document the MoltenVK configuration parameters.
- Deprecate vkSetMoltenVKConfigurationMVK().
- Deprecate mvk_config.h and move content to mvk_private_api.h and mvk_deprecated_api.h.
- Streamline lock on retrieval of MVKLayerManager singleton (unrelated).
2023-12-14 16:44:40 -05:00
Bill Hollings
ac46188bba Merge main branch into VK_EXT_layer_settings branch. 2023-12-09 13:31:53 -05:00
Bill Hollings
e6a3886313
Merge pull request #2086 from billhollings/VK_EXT_headless_surface
Add support for extension VK_EXT_headless_surface.
2023-12-05 09:11:50 -05:00
Bill Hollings
90eb1af19f Add support for extension VK_EXT_headless_surface.
- Consolidate info about CAMetalLayer and headless in MVKSurface.
- MVKSwapchainImage remove getCAMetalDrawable()
  and focus on abstracting getMTLTexture().
- MVKPresentableSwapchainImage::getCAMetalDrawable() return nil if headless.
- Add MVKPresentableSwapchainImage::_mtlTextureHeadless to support
  a fixed MTLTexture that is not retrieved from a CAMetalDrawable.
- MVKPresentableSwapchainImage refactor signalling semaphores and fences.
- MVKPresentableSwapchainImage don't lock when signalling semaphores and fences.
- If no present occurs, actualPresentTime will be zero. Set it to current
  time, instead of to desiredPresentTime, since it's more accurate.
- Rework timestamps:
  - Remove _mvkTimestampBase so mvkGetTimestamp() is equal to
    mach_absolute_time(), which is used in presentation timing.
  - Add mvkGetRuntimeNanoseconds().
  - Rename mvkGetAbsoluteTime() to mvkGetContinuousNanoseconds().
  - Remove mvkGetTimestampPeriod() as unused.
- MVKSemaphoreMTLEvent::encodeDeferredSignal remove redundant nil test (unrelated).
- Fix swapchain and surface bugs when windowing system
  is accessed from off the main thread (unrelated).
- Log warning when deprecated functions vkCreateMacOSSurfaceMVK()
  or vkCreateIOSSurfaceMVK() are used (unrelated).
- Remove documentation for visionos, as support is not ready (unrelated).
2023-12-04 11:56:22 -05:00
Chip Davis
d0dba760e7 MVKPipeline: Enable the cube texture gradient workaround for Apple Silicon.
Update SPIRV-Cross to pull in the code for the workaround.

Fixes 8 tests under `dEQP-VK.glsl.texture_functions.texturegrad.*`.
2023-11-28 14:08:49 -08:00
Bill Hollings
a7372edafe Fix initial value of VkPhysicalDeviceLimits::timestampPeriod on non-Apple Silicon GPUs.
- Don't update value of timestampPeriod on first measurement.
- Force that first measurement upon creation of MVKPhysicalDevice, so an
  accurate value for timestampPeriod will be calculated when next queried.
2023-11-22 17:24:09 -05: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
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
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
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
49c6e8bae3 Update dependency libraries to match Vulkan SDK 1.3.268. 2023-10-17 14:36:26 -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
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
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
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
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
9c206ecc79 Fix MSL code used in vkCmdBlitImage() on depth-stencil formats. 2023-09-12 16:44:33 -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
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
7fe4963985 Guard against CAMetalDrawable with invalid pixel format.
- Calling nextDrawable may result in a nil drawable, or a drawable with no
  pixel format. Attempt several times to retrieve a drawable with a valid
  pixel format, and if unsuccessful, return an error from vkQueuePresentKHR()
  and vkAcquireNextImageKHR(), to force swapchain to be re-created.
- Reorganize MVKQueuePresentSurfaceSubmission::execute() to detect drawable
  with invalid format, attach MTLCommandBuffer completion handler just before
  commit, and delay enqueuing MTLCommandBuffer until commit.
- Refactor mvkOSVersionIsAtLeast() for clarity (unrelated).
2023-09-06 16:16:11 -04:00
Bill Hollings
10625a8638 Add support for VK_EXT_layer_settings extension. 2023-09-04 21:45:42 -04:00
Bill Hollings
9f64faadbc Improve behavior of swapchain image presentation stalls caused by Metal regression.
In a recent Metal regression, Metal sometimes does not trigger the
[CAMetalDrawable addPresentedHandler:] callback on the final few (1-3)
CAMetalDrawable presentations, and retains internal memory associated
with these CAMetalDrawables. This does not occur for any CAMetalDrawable
presentations prior to those final few.

Most apps typically don't care much what happens after the last few
CAMetalDrawables are presented, and typically end shortly after that.

However, for some apps, such as Vulkan CTS WSI tests, which serially create
potentially hundreds, or thousands, of CAMetalLayers and MTLDevices,these
retained device memory allocations can pile up and cause the CTS WSI tests
to stall, block, or crash.

This issue has proven very difficult to debug, or replicate in incrementally
controlled environments. It appears consistently in some scenarios, and never
in other, almost identical scenarios.

For example, the MoltenVK Cube demo consistently runs without encountering
this issue, but CTS WSI test dEQP-VK.wsi.macos.swapchain.render.basic
consistently triggers the issue. Both apps run almost identical Vulkan
command paths, and identical swapchain image presentation paths, and
result in GPU captures that have identical swapchain image presentations.

We may ultimately have to wait for Apple to fix the core issue, but this
update includes workarounds that helps in some cases. During vkQueueWaitIdle()
and vkDeviceWaitIdle(), wait a short while for any in-flight swapchain image
presentations to finish, and attempt to force completion by calling
MVKPresentableSwapchainImage::forcePresentationCompletion(), which releases
the current CAMetalDrawable, and attempts to retrieve a new one, to trigger
the callback on the current CAMetalDrawable.

In exploring possible work-arounds for this issue, this update adds significant
structural improvements in the handling of swapchains, and quite a bit of new
performance and logging functionality that is useful for debugging purposes.

- Add several additional performance trackers, available via logging,
  or the mvk_private_api.h API.
- Rename MVKPerformanceTracker members, and refactor performance result
  collection, to support tracking and logging memory use, or other measurements,
  in addition to just durations.
- Redefine MVKQueuePerformance to add tracking separate performance metrics for
  MTLCommandBuffer retrieval, encoding, and execution, plus swapchain presentation.
- Add MVKDevicePerformance as part of MVKPerformanceStatistics to track device
  information, including GPU device memory allocated, and update device memory
  results whenever performance content is requested.
- Add MVKConfigActivityPerformanceLoggingStyle::
  MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_DEVICE_LIFETIME_ACCUMULATE
  to accumulate performance and memory results across multiple serial
  invocations of VkDevices, during the lifetime of the app process. This
  is useful for accumulating performance results across multiple CTS tests.
- Log destruction of VkDevice, VkPhysicalDevice, and VkInstance, to bookend
  the corresponding logs performed upon their creation.
- Include consumed GPU memory in log when VkPhysicalDevice is destroyed.
- Add mvkGetAvailableMTLDevicesArray() to support consistency when retrieving
  MTLDevices available on the system.
- Add mvkVkCommandName() to generically map command use to a command name.
- MVKDevice:
    - Support MTLPhysicalDevice.recommendedMaxWorkingSetSize on iOS & tvOS.
    - Include available and consumed GPU memory in log of GPU device at
      VkInstance creation time.
- MVKQueue:
    - Add handleMTLCommandBufferError() to handle errors for all
      MTLCommandBuffer executions.
    - Track time to retrieve a MTLCommandBuffer.
    - If MTLCommandBuffer could not be retrieved during queue submission,
      report error, signal queue submission completion, and return
      VK_ERROR_OUT_OF_POOL_MEMORY.
    - waitIdle() simplify to use [MTLCommandBuffer waitUntilCompleted],
      plus also wait for in-flight presentations to complete, and attempt
      to force them to complete if they are stuck.
- MVKPresentableSwapchainImage:
    - Don't track presenting MTLCommandBuffer.
    - Add limit on number of attempts to retrieve a drawable, and report
      VK_ERROR_OUT_OF_POOL_MEMORY if drawable cannot be retrieved.
    - Return VkResult from acquireAndSignalWhenAvailable() to notify upstream
      if MTLCommandBuffer could not be created.
    - Track presentation time.
	- Notify MVKQueue when presentation has completed.
	- Add forcePresentationCompletion(), which releases the current
	  CAMetalDrawable, and attempts to retrieve a new one, to trigger the
	  callback on the current CAMetalDrawable. Called when a swapchain is
	  destroyed, or by queue if waiting for presentation to complete stalls,
	- If destroyed while in flight, stop tracking swapchain and
	  don't notify when presentation completes.
- MVKSwapchain:
    - Track active swapchain in MVKSurface to check oldSwapchain
    - Track MVKSurface to access layer and detect lost surface.
    - Don't track layer and layer observer, since MVKSurface handles these.
    - On destruction, wait until all in-flight presentable images have returned.
    - Remove empty and unused releaseUndisplayedSurfaces() function.
- MVKSurface:
	- Consolidate constructors into initLayer() function.
    - Update logic to test for valid layer and to set up layer observer.
- MVKSemaphoreImpl:
    - Add getReservationCount()
- MVKBaseObject:
    - Add reportResult() and reportWarning() functions to support logging
      and reporting Vulkan results that are not actual errors.
- Rename MVKCommandUse::kMVKCommandUseEndCommandBuffer to
  kMVKCommandUseBeginCommandBuffer, since that's where it is used.
- Update MVK_CONFIGURATION_API_VERSION and MVK_PRIVATE_API_VERSION to 38.
- Cube Demo support running a maximum number of frames.
2023-09-02 08:51:36 -04:00
Bill Hollings
7910083ffa Fix rare case where vertex attribute buffers are not bound to Metal.
In the rare case where vertex attribute buffers are bound to MVKCommandEncoder,
are not used by first pipeline, but are used by a subsequent pipeline, and no
other bindings are changed, the MVKResourcesCommandEncoderState will not appear
to be dirty to the second pipeline, and the buffer will not be bound to Metal.

When reverting a binding to dirty if it is not used by a pipeline, also revert
the enclosing MVKResourcesCommandEncoderState to dirty state.

Update MoltenVK to version 1.2.6 (unrelated).
2023-08-23 14:14:15 -04:00
Bill Hollings
4fe8811665 Update dependency libraries to match Vulkan SDK 1.3.261.
- In MoltenVK Xcode projects, set iOS & tvOS deployment targets to 12.0,
  to avoid warnings while building MoltenVK.
- Add DYLD_LIBRARY_PATH to runcts script, to ensure Vulkan and MoltenVK
  libraries are found during CTS runs.
- Update Whats_New.md and MoltenVK_Runtime_UserGuide.md documents.
2023-08-15 16:03:31 -04:00
Bill Hollings
47840b9beb
Merge pull request #1993 from billhollings/fix-sim-buff-align
Ensure Xcode simulator always uses 256B buffer alignment.
2023-08-14 10:11:34 -04:00