KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.33k stars 647 forks source link

Fix profiles sample for Apple platforms #1119

Closed SRSaunders closed 3 months ago

SRSaunders commented 3 months ago

Description

This PR fixes the profiles sample on Apple platforms by doing the following:

  1. Enabling the VK_KHR_portability_enumeration extension and flag during instance creation.
  2. Enabling MoltenVK's Metal Argument Buffer feature on macOS. This uses the layer settings capability (note this does not depend on my pending layer settings framework PR), and falls back to an environment variable if layer settings is not available at runtime for older SDKs.
  3. Using the VP_LUNARG_desktop_portability_2021_subset profile on portability platforms. In addition to the standard desktop capabilities, this also checks the platform's portability subset features. UPDATE: Added an additional #ifdef guard to prevent build failures on iOS for current build configs (i.e. prior to merging my pending framework PR). This defensive check may become redundant in the future, but at least will be compatible and will not cause problems.
  4. UPDATE: Even though iOS will support Metal Argument Buffers staring with MoltenVK 1.2.10 and later (expected in the next Vulkan SDK following 1.3.290), that device platform does not support all features required for the selected Vulkan profile. For instance on iPhone 15, the following device features are missing: fragmentStoresAndAtomics, shaderStorageImageArrayDynamicIndexing, textureCompressionBC, and vertexPipelineStoresAndAtomics. In addition, some limits are lower than required: maxPerStageDescriptorSampledImages = 96, maxPerStageResources = 127, and maxPerStageDescriptorUpdateAfterBindInputAttachments = 96, and finally some image formats and/or tiling capabilities are not supported (e.g. all VK_FORMAT_<*>_BLOCK formats and some tiling features of VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32_SFLOAT).

Note that all code changes are guarded by VKB_ENABLE_PORTABILITY, so it will only affect portability platforms.

Fixes #1118

General Checklist:

Please ensure the following points are checked:

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: