Introduce QuirkManager for runtime GPU quirk tracking

We require a way to track certain host GPU features that are optional such as Vulkan extensions, this is what the `QuirkManager` class does as it checks for all quirks and holds them allowing other components to branch based off these quirks.
This commit is contained in:
PixelyIon
2021-11-12 01:23:46 +05:30
parent 8803616673
commit 8ef225a37d
6 changed files with 65 additions and 9 deletions

View File

@ -68,7 +68,6 @@ namespace skyline::gpu::memory {
.vulkanApiVersion = GPU::VkApiVersion,
};
ThrowOnFail(vmaCreateAllocator(&allocatorCreateInfo, &vmaAllocator));
// TODO: Use VK_KHR_dedicated_allocation when available (Should be on Adreno GPUs)
}
MemoryManager::~MemoryManager() {

View File

@ -0,0 +1,31 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include "quirk_manager.h"
namespace skyline {
QuirkManager::QuirkManager(vk::PhysicalDeviceProperties properties, vk::PhysicalDeviceFeatures2 features, const std::vector<vk::ExtensionProperties> &extensions) {
for (auto &extension : extensions) {
#define EXT_SET(name, property) \
case util::Hash(name): \
if (name == extensionName) \
property = true; \
break
#define EXT_SET_V(name, property, version) \
case util::Hash(name): \
if (name == extensionName && extensionVersion >= version) \
property = true; \
break
std::string_view extensionName{extension.extensionName};
auto extensionVersion{extension.specVersion};
switch (util::Hash(extensionName)) {
EXT_SET("VK_EXT_provoking_vertex", supportsLastProvokingVertex);
}
#undef EXT_SET
#undef EXT_SET_V
}
}
}

View File

@ -0,0 +1,21 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2021 Skyline Team and Contributors (https://github.com/skyline-emu/)
#pragma once
#include <vulkan/vulkan.hpp>
#include <common.h>
namespace skyline {
/**
* @brief Checks and stores all the quirks of the host GPU discovered at runtime
*/
class QuirkManager {
public:
bool supportsLastProvokingVertex{}; //!< If the device supports setting the last vertex as the provoking vertex (with VK_EXT_provoking_vertex)
QuirkManager() = default;
QuirkManager(vk::PhysicalDeviceProperties properties, vk::PhysicalDeviceFeatures2 features, const std::vector<vk::ExtensionProperties>& extensions);
};
}