From f854ffd0158a3ed2946c18011b4f5f426fdabc07 Mon Sep 17 00:00:00 2001 From: Mike Lothian Date: Thu, 28 Dec 2023 11:35:28 +0000 Subject: Add Vulkan-Utility-Libraries dependency --- .gitmodules | 3 +++ CMakeLists.txt | 6 ++++++ externals/CMakeLists.txt | 5 +++++ externals/Vulkan-Utility-Libraries | 1 + src/video_core/CMakeLists.txt | 2 +- 5 files changed, 16 insertions(+), 1 deletion(-) create mode 160000 externals/Vulkan-Utility-Libraries diff --git a/.gitmodules b/.gitmodules index e65997afc..52256d86f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -64,3 +64,6 @@ [submodule "oaknut"] path = externals/oaknut url = https://github.com/merryhime/oaknut +[submodule "Vulkan-Utility-Libraries"] + path = externals/Vulkan-Utility-Libraries + url = https://github.com/KhronosGroup/Vulkan-Utility-Libraries.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd6b2108..eb26fbfd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,8 @@ option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") option(YUZU_USE_EXTERNAL_VULKAN_HEADERS "Use Vulkan-Headers from externals" ON) +option(YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES "Use Vulkan-Utility-Libraries from externals" ON) + option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) @@ -308,6 +310,10 @@ if (NOT YUZU_USE_EXTERNAL_VULKAN_HEADERS) find_package(Vulkan 1.3.274 REQUIRED) endif() +if (NOT YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES) + find_package(VulkanUtilityLibraries REQUIRED) +endif() + if (ENABLE_LIBUSB) find_package(libusb 1.0.24 MODULE) endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 407c5c640..c84bedb2d 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -154,6 +154,11 @@ if (YUZU_USE_EXTERNAL_VULKAN_HEADERS) add_subdirectory(Vulkan-Headers) endif() +# Vulkan-Utility-Libraries +if (YUZU_USE_EXTERNAL_VULKAN_UTILITY_LIBRARIES) + add_subdirectory(Vulkan-Utility-Libraries) +endif() + # TZDB (Time Zone Database) add_subdirectory(nx_tzdb) diff --git a/externals/Vulkan-Utility-Libraries b/externals/Vulkan-Utility-Libraries new file mode 160000 index 000000000..524f8910d --- /dev/null +++ b/externals/Vulkan-Utility-Libraries @@ -0,0 +1 @@ +Subproject commit 524f8910d0e4a5f2ec5961996b23e5b74b95cb1d diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index c22c7631c..3d7a59f87 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -303,7 +303,7 @@ target_link_options(video_core PRIVATE ${FFmpeg_LDFLAGS}) add_dependencies(video_core host_shaders) target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE}) -target_link_libraries(video_core PRIVATE sirit Vulkan::Headers GPUOpen::VulkanMemoryAllocator) +target_link_libraries(video_core PRIVATE sirit Vulkan::Headers Vulkan::UtilityHeaders GPUOpen::VulkanMemoryAllocator) if (ENABLE_NSIGHT_AFTERMATH) if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK}) -- cgit v1.2.3 From 23e074ff140de6aab84c6a14fcc30a469c64b089 Mon Sep 17 00:00:00 2001 From: Mike Lothian Date: Fri, 22 Dec 2023 13:28:17 +0000 Subject: Simplify VkResult lookup --- src/video_core/renderer_vulkan/vk_swapchain.cpp | 5 +- .../vulkan_common/vk_enum_string_helper.h | 8 ++ src/video_core/vulkan_common/vulkan_wrapper.cpp | 107 +-------------------- src/video_core/vulkan_common/vulkan_wrapper.h | 3 - 4 files changed, 14 insertions(+), 109 deletions(-) create mode 100644 src/video_core/vulkan_common/vk_enum_string_helper.h diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 86a30dcd1..4f1d3b4e3 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -12,6 +12,7 @@ #include "core/core.h" #include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_swapchain.h" +#include "video_core/vulkan_common/vk_enum_string_helper.h" #include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_wrapper.h" #include "vulkan/vulkan_core.h" @@ -151,7 +152,7 @@ bool Swapchain::AcquireNextImage() { vk::Check(result); break; default: - LOG_ERROR(Render_Vulkan, "vkAcquireNextImageKHR returned {}", vk::ToString(result)); + LOG_ERROR(Render_Vulkan, "vkAcquireNextImageKHR returned {}", string_VkResult(result)); break; } @@ -187,7 +188,7 @@ void Swapchain::Present(VkSemaphore render_semaphore) { vk::Check(result); break; default: - LOG_CRITICAL(Render_Vulkan, "Failed to present with error {}", vk::ToString(result)); + LOG_CRITICAL(Render_Vulkan, "Failed to present with error {}", string_VkResult(result)); break; } ++frame_index; diff --git a/src/video_core/vulkan_common/vk_enum_string_helper.h b/src/video_core/vulkan_common/vk_enum_string_helper.h new file mode 100644 index 000000000..a1515814c --- /dev/null +++ b/src/video_core/vulkan_common/vk_enum_string_helper.h @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "video_core/vulkan_common/vulkan.h" + +#include diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index 074aed964..91a98a0dd 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp @@ -9,6 +9,7 @@ #include "common/common_types.h" #include "common/logging/log.h" +#include "video_core/vulkan_common/vk_enum_string_helper.h" #include "video_core/vulkan_common/vma.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -288,109 +289,7 @@ bool Load(VkInstance instance, InstanceDispatch& dld) noexcept { } const char* Exception::what() const noexcept { - return ToString(result); -} - -const char* ToString(VkResult result) noexcept { - switch (result) { - case VkResult::VK_SUCCESS: - return "VK_SUCCESS"; - case VkResult::VK_NOT_READY: - return "VK_NOT_READY"; - case VkResult::VK_TIMEOUT: - return "VK_TIMEOUT"; - case VkResult::VK_EVENT_SET: - return "VK_EVENT_SET"; - case VkResult::VK_EVENT_RESET: - return "VK_EVENT_RESET"; - case VkResult::VK_INCOMPLETE: - return "VK_INCOMPLETE"; - case VkResult::VK_ERROR_OUT_OF_HOST_MEMORY: - return "VK_ERROR_OUT_OF_HOST_MEMORY"; - case VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY: - return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; - case VkResult::VK_ERROR_INITIALIZATION_FAILED: - return "VK_ERROR_INITIALIZATION_FAILED"; - case VkResult::VK_ERROR_DEVICE_LOST: - return "VK_ERROR_DEVICE_LOST"; - case VkResult::VK_ERROR_MEMORY_MAP_FAILED: - return "VK_ERROR_MEMORY_MAP_FAILED"; - case VkResult::VK_ERROR_LAYER_NOT_PRESENT: - return "VK_ERROR_LAYER_NOT_PRESENT"; - case VkResult::VK_ERROR_EXTENSION_NOT_PRESENT: - return "VK_ERROR_EXTENSION_NOT_PRESENT"; - case VkResult::VK_ERROR_FEATURE_NOT_PRESENT: - return "VK_ERROR_FEATURE_NOT_PRESENT"; - case VkResult::VK_ERROR_INCOMPATIBLE_DRIVER: - return "VK_ERROR_INCOMPATIBLE_DRIVER"; - case VkResult::VK_ERROR_TOO_MANY_OBJECTS: - return "VK_ERROR_TOO_MANY_OBJECTS"; - case VkResult::VK_ERROR_FORMAT_NOT_SUPPORTED: - return "VK_ERROR_FORMAT_NOT_SUPPORTED"; - case VkResult::VK_ERROR_FRAGMENTED_POOL: - return "VK_ERROR_FRAGMENTED_POOL"; - case VkResult::VK_ERROR_OUT_OF_POOL_MEMORY: - return "VK_ERROR_OUT_OF_POOL_MEMORY"; - case VkResult::VK_ERROR_INVALID_EXTERNAL_HANDLE: - return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; - case VkResult::VK_ERROR_SURFACE_LOST_KHR: - return "VK_ERROR_SURFACE_LOST_KHR"; - case VkResult::VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: - return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; - case VkResult::VK_SUBOPTIMAL_KHR: - return "VK_SUBOPTIMAL_KHR"; - case VkResult::VK_ERROR_OUT_OF_DATE_KHR: - return "VK_ERROR_OUT_OF_DATE_KHR"; - case VkResult::VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: - return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; - case VkResult::VK_ERROR_VALIDATION_FAILED_EXT: - return "VK_ERROR_VALIDATION_FAILED_EXT"; - case VkResult::VK_ERROR_INVALID_SHADER_NV: - return "VK_ERROR_INVALID_SHADER_NV"; - case VkResult::VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR: - return "VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR"; - case VkResult::VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR: - return "VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR"; - case VkResult::VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR: - return "VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR"; - case VkResult::VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR: - return "VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR"; - case VkResult::VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR: - return "VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR"; - case VkResult::VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR: - return "VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR"; - case VkResult::VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT: - return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; - case VkResult::VK_ERROR_FRAGMENTATION_EXT: - return "VK_ERROR_FRAGMENTATION_EXT"; - case VkResult::VK_ERROR_NOT_PERMITTED_EXT: - return "VK_ERROR_NOT_PERMITTED_EXT"; - case VkResult::VK_ERROR_INVALID_DEVICE_ADDRESS_EXT: - return "VK_ERROR_INVALID_DEVICE_ADDRESS_EXT"; - case VkResult::VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: - return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; - case VkResult::VK_ERROR_UNKNOWN: - return "VK_ERROR_UNKNOWN"; - case VkResult::VK_THREAD_IDLE_KHR: - return "VK_THREAD_IDLE_KHR"; - case VkResult::VK_THREAD_DONE_KHR: - return "VK_THREAD_DONE_KHR"; - case VkResult::VK_OPERATION_DEFERRED_KHR: - return "VK_OPERATION_DEFERRED_KHR"; - case VkResult::VK_OPERATION_NOT_DEFERRED_KHR: - return "VK_OPERATION_NOT_DEFERRED_KHR"; - case VkResult::VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR: - return "VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR"; - case VkResult::VK_PIPELINE_COMPILE_REQUIRED_EXT: - return "VK_PIPELINE_COMPILE_REQUIRED_EXT"; - case VkResult::VK_RESULT_MAX_ENUM: - return "VK_RESULT_MAX_ENUM"; - case VkResult::VK_ERROR_COMPRESSION_EXHAUSTED_EXT: - return "VK_ERROR_COMPRESSION_EXHAUSTED_EXT"; - case VkResult::VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT: - return "VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT"; - } - return "Unknown"; + return string_VkResult(result); } void Destroy(VkInstance instance, const InstanceDispatch& dld) noexcept { @@ -1057,7 +956,7 @@ u32 AvailableVersion(const InstanceDispatch& dld) noexcept { u32 version; if (const VkResult result = vkEnumerateInstanceVersion(&version); result != VK_SUCCESS) { LOG_ERROR(Render_Vulkan, "vkEnumerateInstanceVersion returned {}, assuming Vulkan 1.1", - ToString(result)); + string_VkResult(result)); return VK_API_VERSION_1_1; } return version; diff --git a/src/video_core/vulkan_common/vulkan_wrapper.h b/src/video_core/vulkan_common/vulkan_wrapper.h index a0c70797f..757f3c8af 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.h +++ b/src/video_core/vulkan_common/vulkan_wrapper.h @@ -125,9 +125,6 @@ private: VkResult result; }; -/// Converts a VkResult enum into a rodata string -const char* ToString(VkResult) noexcept; - /// Throws a Vulkan exception if result is not success. inline void Check(VkResult result) { if (result != VK_SUCCESS) { -- cgit v1.2.3