Support VkPhysicalDeviceFeatures2 Extensions

Implement the infrastructure to depend on `VkPhysicalDeviceFeatures2` extended feature structures which can be utilized to retrieve the specifics of features from extensions. It is implemented in the form of `vk::StructureChain` with `vk::PhysicalDeviceFeatures2` that can be extended with any extension feature structures.
This commit is contained in:
PixelyIon 2021-11-16 13:31:12 +05:30
parent ff5515d4d1
commit c3895a8197
3 changed files with 15 additions and 13 deletions

View File

@ -122,16 +122,16 @@ namespace skyline::gpu {
vk::raii::Device GPU::CreateDevice(const vk::raii::PhysicalDevice &physicalDevice, typeof(vk::DeviceQueueCreateInfo::queueCount) &vkQueueFamilyIndex, QuirkManager &quirks) {
auto properties{physicalDevice.getProperties()};
auto deviceFeatures2{physicalDevice.getFeatures2()};
vk::PhysicalDeviceFeatures2 enabledFeatures2{}; // We only want to enable features we required due to potential overhead from unused features
auto deviceFeatures2{physicalDevice.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVertexAttributeDivisorFeaturesEXT>()};
typeof(deviceFeatures2) enabledFeatures2{}; // We only want to enable features we required due to potential overhead from unused features
#define FEAT_REQ(feature) \
if (deviceFeatures2.features.feature) \
enabledFeatures2.features.feature = true; \
#define FEAT_REQ(structName, feature) \
if (deviceFeatures2.get<structName>().feature) \
enabledFeatures2.get<structName>().feature = true; \
else \
throw exception("Vulkan device doesn't support required feature: " #feature)
FEAT_REQ(independentBlend);
FEAT_REQ(vk::PhysicalDeviceFeatures2, features.independentBlend);
#undef FEAT_REQ

View File

@ -4,7 +4,7 @@
#include "quirk_manager.h"
namespace skyline {
QuirkManager::QuirkManager(const vk::PhysicalDeviceProperties &properties, const vk::PhysicalDeviceFeatures2 &deviceFeatures2, vk::PhysicalDeviceFeatures2 &enabledFeatures2, const std::vector<vk::ExtensionProperties> &deviceExtensions, std::vector<std::array<char, VK_MAX_EXTENSION_NAME_SIZE>> &enabledExtensions) {
QuirkManager::QuirkManager(const vk::PhysicalDeviceProperties &properties, const DeviceFeatures2 &deviceFeatures2, DeviceFeatures2 &enabledFeatures2, const std::vector<vk::ExtensionProperties> &deviceExtensions, std::vector<std::array<char, VK_MAX_EXTENSION_NAME_SIZE>> &enabledExtensions) {
for (auto &extension : deviceExtensions) {
#define EXT_SET(name, property) \
case util::Hash(name): \
@ -32,13 +32,13 @@ namespace skyline {
#undef EXT_SET_V
}
#define FEAT_SET(feature, property) \
if (deviceFeatures2.features.feature) { \
property = true; \
enabledFeatures2.features.feature = true; \
#define FEAT_SET(structName, feature, property) \
if (deviceFeatures2.get<structName>().feature) { \
property = true; \
enabledFeatures2.get<structName>().feature = true; \
}
FEAT_SET(logicOp, supportsLogicOp)
FEAT_SET(vk::PhysicalDeviceFeatures2, features.logicOp, supportsLogicOp)
#undef FEAT_SET
}

View File

@ -18,7 +18,9 @@ namespace skyline {
QuirkManager() = default;
QuirkManager(const vk::PhysicalDeviceProperties &properties, const vk::PhysicalDeviceFeatures2 &deviceFeatures2, vk::PhysicalDeviceFeatures2 &enabledFeatures2, const std::vector<vk::ExtensionProperties> &deviceExtensions, std::vector<std::array<char, VK_MAX_EXTENSION_NAME_SIZE>> &enabledExtensions);
using DeviceFeatures2 = vk::StructureChain<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVertexAttributeDivisorFeaturesEXT>;
QuirkManager(const vk::PhysicalDeviceProperties &properties, const DeviceFeatures2 &deviceFeatures2, DeviceFeatures2 &enabledFeatures2, const std::vector<vk::ExtensionProperties> &deviceExtensions, std::vector<std::array<char, VK_MAX_EXTENSION_NAME_SIZE>> &enabledExtensions);
/**
* @return A summary of all the GPU quirks as a human-readable string