diff options
| author | 2020-12-30 04:58:38 -0300 | |
|---|---|---|
| committer | 2020-12-31 02:07:34 -0300 | |
| commit | cdbee27692d73046cecf56fdea1c90f72ebbc0ce (patch) | |
| tree | e360cc51563b7bee53e67587a421a1d15be3221e /src/video_core/vulkan_common | |
| parent | vk_device: Use an array to report lacking device limits (diff) | |
| download | yuzu-cdbee27692d73046cecf56fdea1c90f72ebbc0ce.tar.gz yuzu-cdbee27692d73046cecf56fdea1c90f72ebbc0ce.tar.xz yuzu-cdbee27692d73046cecf56fdea1c90f72ebbc0ce.zip | |
vulkan_instance: Allow different Vulkan versions and enforce 1.1
For listing the available physical devices we can use Vulkan 1.0.
Now that MoltenVK supports 1.1 we can require it for running games.
Add missing documentation.
Diffstat (limited to 'src/video_core/vulkan_common')
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_instance.cpp | 21 | ||||
| -rw-r--r-- | src/video_core/vulkan_common/vulkan_instance.h | 19 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/video_core/vulkan_common/vulkan_instance.cpp b/src/video_core/vulkan_common/vulkan_instance.cpp index ee46fc6cc..889ecda0c 100644 --- a/src/video_core/vulkan_common/vulkan_instance.cpp +++ b/src/video_core/vulkan_common/vulkan_instance.cpp | |||
| @@ -111,10 +111,9 @@ void RemoveUnavailableLayers(const vk::InstanceDispatch& dld, std::vector<const | |||
| 111 | } | 111 | } |
| 112 | } // Anonymous namespace | 112 | } // Anonymous namespace |
| 113 | 113 | ||
| 114 | std::pair<vk::Instance, u32> CreateInstance(const Common::DynamicLibrary& library, | 114 | vk::Instance CreateInstance(const Common::DynamicLibrary& library, vk::InstanceDispatch& dld, |
| 115 | vk::InstanceDispatch& dld, | 115 | u32 required_version, Core::Frontend::WindowSystemType window_type, |
| 116 | Core::Frontend::WindowSystemType window_type, | 116 | bool enable_debug_utils, bool enable_layers) { |
| 117 | bool enable_debug_utils, bool enable_layers) { | ||
| 118 | if (!library.IsOpen()) { | 117 | if (!library.IsOpen()) { |
| 119 | LOG_ERROR(Render_Vulkan, "Vulkan library not available"); | 118 | LOG_ERROR(Render_Vulkan, "Vulkan library not available"); |
| 120 | throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED); | 119 | throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED); |
| @@ -134,15 +133,19 @@ std::pair<vk::Instance, u32> CreateInstance(const Common::DynamicLibrary& librar | |||
| 134 | std::vector<const char*> layers = Layers(enable_layers); | 133 | std::vector<const char*> layers = Layers(enable_layers); |
| 135 | RemoveUnavailableLayers(dld, layers); | 134 | RemoveUnavailableLayers(dld, layers); |
| 136 | 135 | ||
| 137 | // Limit the maximum version of Vulkan to avoid using untested version. | 136 | const u32 available_version = vk::AvailableVersion(dld); |
| 138 | const u32 version = std::min(vk::AvailableVersion(dld), VK_API_VERSION_1_1); | 137 | if (available_version < required_version) { |
| 139 | 138 | LOG_ERROR(Render_Vulkan, "Vulkan {}.{} is not supported, {}.{} is required", | |
| 140 | vk::Instance instance = vk::Instance::Create(version, layers, extensions, dld); | 139 | VK_VERSION_MAJOR(available_version), VK_VERSION_MINOR(available_version), |
| 140 | VK_VERSION_MAJOR(required_version), VK_VERSION_MINOR(required_version)); | ||
| 141 | throw vk::Exception(VK_ERROR_INCOMPATIBLE_DRIVER); | ||
| 142 | } | ||
| 143 | vk::Instance instance = vk::Instance::Create(required_version, layers, extensions, dld); | ||
| 141 | if (!vk::Load(*instance, dld)) { | 144 | if (!vk::Load(*instance, dld)) { |
| 142 | LOG_ERROR(Render_Vulkan, "Failed to load Vulkan instance function pointers"); | 145 | LOG_ERROR(Render_Vulkan, "Failed to load Vulkan instance function pointers"); |
| 143 | throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED); | 146 | throw vk::Exception(VK_ERROR_INITIALIZATION_FAILED); |
| 144 | } | 147 | } |
| 145 | return std::make_pair(std::move(instance), version); | 148 | return instance; |
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | } // namespace Vulkan | 151 | } // namespace Vulkan |
diff --git a/src/video_core/vulkan_common/vulkan_instance.h b/src/video_core/vulkan_common/vulkan_instance.h index 5acca9756..e5e3a7144 100644 --- a/src/video_core/vulkan_common/vulkan_instance.h +++ b/src/video_core/vulkan_common/vulkan_instance.h | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <utility> | ||
| 8 | |||
| 9 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 10 | #include "common/dynamic_library.h" | 8 | #include "common/dynamic_library.h" |
| 11 | #include "core/frontend/emu_window.h" | 9 | #include "core/frontend/emu_window.h" |
| @@ -13,8 +11,21 @@ | |||
| 13 | 11 | ||
| 14 | namespace Vulkan { | 12 | namespace Vulkan { |
| 15 | 13 | ||
| 16 | [[nodiscard]] std::pair<vk::Instance, u32> CreateInstance( | 14 | /** |
| 17 | const Common::DynamicLibrary& library, vk::InstanceDispatch& dld, | 15 | * Create a Vulkan instance |
| 16 | * | ||
| 17 | * @param library Dynamic library to load the Vulkan instance from | ||
| 18 | * @param dld Dispatch table to load function pointers into | ||
| 19 | * @param required_version Required Vulkan version (for example, VK_API_VERSION_1_1) | ||
| 20 | * @param window_type Window system type's enabled extension | ||
| 21 | * @param enable_debug_utils Whether to enable VK_EXT_debug_utils_extension_name or not | ||
| 22 | * @param enable_layers Whether to enable Vulkan validation layers or not | ||
| 23 | * | ||
| 24 | * @return A new Vulkan instance | ||
| 25 | * @throw vk::Exception on failure | ||
| 26 | */ | ||
| 27 | [[nodiscard]] vk::Instance CreateInstance( | ||
| 28 | const Common::DynamicLibrary& library, vk::InstanceDispatch& dld, u32 required_version, | ||
| 18 | Core::Frontend::WindowSystemType window_type = Core::Frontend::WindowSystemType::Headless, | 29 | Core::Frontend::WindowSystemType window_type = Core::Frontend::WindowSystemType::Headless, |
| 19 | bool enable_debug_utils = false, bool enable_layers = false); | 30 | bool enable_debug_utils = false, bool enable_layers = false); |
| 20 | 31 | ||