[vulkan] Add helpers for Skia to enable Vulkan features
As Graphite/Vk starts to use more extensions, it's onerous to ask every
user application to go and enable the extensions. Instead, if Skia is
given a chance to modify the extensions and features the application
intends to enable, it can modify its extension use any time and all
applications will automatically enable them.
In this change, a new class `VulkanPreferredFeatures` is introduced
which does three things:
* Adds instance extensions to enable: This is currently a no-op.
* Adds feature structs to query, based on available Vulkan extensions.
* Adds feature structs and extensions to enable, based on available
Vulkan extensions.
Since the application is free to use any instance version or enable any
extensions and features, this class adapts the extensions and features
to enable to the what the application has provided. In some cases, it
has to replace application's structs with
`VkPhysicalDeviceVulkan1*Features` with application's enabled features
from those separate structs aggregated in. The majority of the
complications handled by this class are due to the different ways
extensions were promoted (especially in earlier Vulkan versions), such
as a feature-less extension gaining a feature in a later Vulkan version,
as well as the various versions where a feature is marked as required.
See comments on the class on how to use it. Tests have been added to
make sure Vulkan rules are followed, which can also serve as example
usage.
Bug: skia:422204178
Change-Id: Iade59624f0378e699783e1192031d4aabb6c95e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1002796
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Shahbaz Youssefi <syoussefi@google.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Nicolette Prevost <nicolettep@google.com>
20 files changed