renderer_vulkan: Use no more than target supported version. (#7439)

This commit is contained in:
Steveice10 2024-02-15 19:38:32 -08:00 committed by GitHub
parent 5e02be75a3
commit aa6809e2a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 9 deletions

View File

@ -4,6 +4,7 @@
#include <span>
#include <boost/container/static_vector.hpp>
#include <fmt/format.h>
#include "common/assert.h"
#include "common/settings.h"
@ -153,6 +154,12 @@ Instance::Instance(Core::TelemetrySession& telemetry, Frontend::EmuWindow& windo
physical_device = physical_devices[physical_device_index];
available_extensions = GetSupportedExtensions(physical_device);
properties = physical_device.getProperties();
if (properties.apiVersion < TargetVulkanApiVersion) {
throw std::runtime_error(fmt::format(
"Vulkan {}.{} is required, but only {}.{} is supported by device!",
VK_VERSION_MAJOR(TargetVulkanApiVersion), VK_VERSION_MINOR(TargetVulkanApiVersion),
VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion)));
}
CollectTelemetryParameters(telemetry);
CreateDevice();
@ -629,7 +636,7 @@ void Instance::CreateAllocator() {
.device = *device,
.pVulkanFunctions = &functions,
.instance = *instance,
.vulkanApiVersion = properties.apiVersion,
.vulkanApiVersion = TargetVulkanApiVersion,
};
const VkResult result = vmaCreateAllocator(&allocator_info, &allocator);

View File

@ -17,6 +17,7 @@
#include <memory>
#include <vector>
#include <boost/container/static_vector.hpp>
#include <fmt/format.h>
#include "common/assert.h"
#include "common/logging/log.h"
@ -290,13 +291,14 @@ vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
}
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
if (!VULKAN_HPP_DEFAULT_DISPATCHER.vkEnumerateInstanceVersion) {
throw std::runtime_error("Vulkan 1.0 is not supported, 1.1 is required!");
}
const u32 available_version = vk::enumerateInstanceVersion();
if (available_version < VK_API_VERSION_1_1) {
throw std::runtime_error("Vulkan 1.0 is not supported, 1.1 is required!");
const u32 available_version = VULKAN_HPP_DEFAULT_DISPATCHER.vkEnumerateInstanceVersion
? vk::enumerateInstanceVersion()
: VK_API_VERSION_1_0;
if (available_version < TargetVulkanApiVersion) {
throw std::runtime_error(fmt::format(
"Vulkan {}.{} is required, but only {}.{} is supported by instance!",
VK_VERSION_MAJOR(TargetVulkanApiVersion), VK_VERSION_MINOR(TargetVulkanApiVersion),
VK_VERSION_MAJOR(available_version), VK_VERSION_MINOR(available_version)));
}
const auto extensions = GetInstanceExtensions(window_type, enable_validation);
@ -306,7 +308,7 @@ vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
.applicationVersion = VK_MAKE_VERSION(1, 0, 0),
.pEngineName = "Citra Vulkan",
.engineVersion = VK_MAKE_VERSION(1, 0, 0),
.apiVersion = VK_API_VERSION_1_3,
.apiVersion = TargetVulkanApiVersion,
};
boost::container::static_vector<const char*, 2> layers;

View File

@ -19,6 +19,8 @@ enum class WindowSystemType : u8;
namespace Vulkan {
constexpr u32 TargetVulkanApiVersion = VK_API_VERSION_1_1;
using DebugCallback =
std::variant<vk::UniqueDebugUtilsMessengerEXT, vk::UniqueDebugReportCallbackEXT>;