diff options
author | GPUCode <geoster3d@gmail.com> | 2023-06-03 08:21:52 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2023-06-28 03:00:09 +0200 |
commit | 72e7f5b4dd08e9ea46ee049d8f2564a8808273d4 (patch) | |
tree | d8719c04fc2f795317797319ce503bf4222eefe2 /src/video_core/renderer_vulkan | |
parent | Merge pull request #10933 from merryhime/dunno (diff) | |
download | yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.tar yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.tar.gz yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.tar.bz2 yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.tar.lz yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.tar.xz yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.tar.zst yuzu-72e7f5b4dd08e9ea46ee049d8f2564a8808273d4.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.cpp | 18 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.h | 5 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index ddf28ca28..454bb66a4 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -12,6 +12,7 @@ #include <fmt/format.h> #include "common/logging/log.h" +#include "common/polyfill_ranges.h" #include "common/scope_exit.h" #include "common/settings.h" #include "common/telemetry.h" @@ -65,6 +66,21 @@ std::string BuildCommaSeparatedExtensions( return fmt::format("{}", fmt::join(available_extensions, ",")); } +DebugCallback MakeDebugCallback(const vk::Instance& instance, const vk::InstanceDispatch& dld) { + if (!Settings::values.renderer_debug) { + return DebugCallback{}; + } + const std::optional properties = vk::EnumerateInstanceExtensionProperties(dld); + const auto it = std::ranges::find_if(*properties, [](const auto& prop) { + return std::strcmp(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, prop.extensionName) == 0; + }); + if (it != properties->end()) { + return CreateDebugUtilsCallback(instance); + } else { + return CreateDebugReportCallback(instance); + } +} + } // Anonymous namespace Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld, @@ -87,7 +103,7 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary(context.get())), instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, Settings::values.renderer_debug.GetValue())), - debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), + debug_callback(MakeDebugCallback(instance, dld)), surface(CreateSurface(instance, render_window.GetWindowInfo())), device(CreateDevice(instance, dld, *surface)), memory_allocator(device), state_tracker(), scheduler(device, state_tracker), diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index b2e8cbd1b..ca22c0baa 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h @@ -5,6 +5,7 @@ #include <memory> #include <string> +#include <variant> #include "common/dynamic_library.h" #include "video_core/renderer_base.h" @@ -33,6 +34,8 @@ class GPU; namespace Vulkan { +using DebugCallback = std::variant<vk::DebugUtilsMessenger, vk::DebugReportCallback>; + Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld, VkSurfaceKHR surface); @@ -71,7 +74,7 @@ private: vk::InstanceDispatch dld; vk::Instance instance; - vk::DebugUtilsMessenger debug_callback; + DebugCallback debug_callback; vk::SurfaceKHR surface; ScreenInfo screen_info; |