From 995538fa3e0f18040258a3b0de1a404fdceb9c9b Mon Sep 17 00:00:00 2001 From: PabloMK7 Date: Sun, 8 Jun 2025 17:23:17 +0200 Subject: [PATCH] vulkan: Report error code on Vulkan::CreateSurface (#1130) --- .../renderer_vulkan/vk_platform.cpp | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_platform.cpp b/src/video_core/renderer_vulkan/vk_platform.cpp index cd628f03e..cbec2612e 100644 --- a/src/video_core/renderer_vulkan/vk_platform.cpp +++ b/src/video_core/renderer_vulkan/vk_platform.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Citra Emulator Project +// Copyright Citra Emulator Project / Azahar Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -128,6 +128,7 @@ std::shared_ptr OpenLibrary( vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::EmuWindow& emu_window) { const auto& window_info = emu_window.GetWindowInfo(); vk::SurfaceKHR surface{}; + vk::Result res; #if defined(VK_USE_PLATFORM_WIN32_KHR) if (window_info.type == Frontend::WindowSystemType::Windows) { @@ -136,8 +137,10 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::EmuWindow& e .hwnd = static_cast(window_info.render_surface), }; - if (instance.createWin32SurfaceKHR(&win32_ci, nullptr, &surface) != vk::Result::eSuccess) { - LOG_CRITICAL(Render_Vulkan, "Failed to initialize Win32 surface"); + if ((res = instance.createWin32SurfaceKHR(&win32_ci, nullptr, &surface)) != + vk::Result::eSuccess) { + LOG_CRITICAL(Render_Vulkan, "Failed to initialize Win32 surface: {}", + vk::to_string(res)); UNREACHABLE(); } } @@ -148,8 +151,9 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::EmuWindow& e .window = reinterpret_cast(window_info.render_surface), }; - if (instance.createXlibSurfaceKHR(&xlib_ci, nullptr, &surface) != vk::Result::eSuccess) { - LOG_ERROR(Render_Vulkan, "Failed to initialize Xlib surface"); + if ((res = instance.createXlibSurfaceKHR(&xlib_ci, nullptr, &surface)) != + vk::Result::eSuccess) { + LOG_ERROR(Render_Vulkan, "Failed to initialize Xlib surface: {}", vk::to_string(res)); UNREACHABLE(); } } else if (window_info.type == Frontend::WindowSystemType::Wayland) { @@ -158,9 +162,10 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::EmuWindow& e .surface = static_cast(window_info.render_surface), }; - if (instance.createWaylandSurfaceKHR(&wayland_ci, nullptr, &surface) != + if ((res = instance.createWaylandSurfaceKHR(&wayland_ci, nullptr, &surface)) != vk::Result::eSuccess) { - LOG_ERROR(Render_Vulkan, "Failed to initialize Wayland surface"); + LOG_ERROR(Render_Vulkan, "Failed to initialize Wayland surface: {}", + vk::to_string(res)); UNREACHABLE(); } } @@ -170,8 +175,10 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::EmuWindow& e .pLayer = static_cast(window_info.render_surface), }; - if (instance.createMetalSurfaceEXT(&macos_ci, nullptr, &surface) != vk::Result::eSuccess) { - LOG_CRITICAL(Render_Vulkan, "Failed to initialize MacOS surface"); + if ((res = instance.createMetalSurfaceEXT(&macos_ci, nullptr, &surface)) != + vk::Result::eSuccess) { + LOG_CRITICAL(Render_Vulkan, "Failed to initialize MacOS surface: {}", + vk::to_string(res)); UNREACHABLE(); } } @@ -181,9 +188,10 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::EmuWindow& e .window = reinterpret_cast(window_info.render_surface), }; - if (instance.createAndroidSurfaceKHR(&android_ci, nullptr, &surface) != + if ((res = instance.createAndroidSurfaceKHR(&android_ci, nullptr, &surface)) != vk::Result::eSuccess) { - LOG_CRITICAL(Render_Vulkan, "Failed to initialize Android surface"); + LOG_CRITICAL(Render_Vulkan, "Failed to initialize Android surface: {}", + vk::to_string(res)); UNREACHABLE(); } }