From f854ffd0158a3ed2946c18011b4f5f426fdabc07 Mon Sep 17 00:00:00 2001
From: Mike Lothian <mike@fireburn.co.uk>
Date: Thu, 28 Dec 2023 11:35:28 +0000
Subject: [PATCH] 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})