mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-15 22:32:50 +00:00
Merge pull request #11470 from GPUCode/bundle-vvl
android: Add option to bundle validation layer
This commit is contained in:
commit
b011ce023d
|
@ -49,6 +49,8 @@ option(YUZU_TESTS "Compile tests" "${BUILD_TESTING}")
|
||||||
|
|
||||||
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
|
||||||
|
|
||||||
|
option(YUZU_DOWNLOAD_ANDROID_VVL "Download validation layer binary for android" ON)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_ROOM "Compile LDN room server" ON "NOT ANDROID" OFF)
|
||||||
|
|
||||||
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
|
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
|
||||||
|
@ -77,6 +79,24 @@ if (ANDROID OR WIN32 OR APPLE)
|
||||||
endif()
|
endif()
|
||||||
option(ENABLE_OPENSSL "Enable OpenSSL backend for ISslConnection" ${DEFAULT_ENABLE_OPENSSL})
|
option(ENABLE_OPENSSL "Enable OpenSSL backend for ISslConnection" ${DEFAULT_ENABLE_OPENSSL})
|
||||||
|
|
||||||
|
if (ANDROID AND YUZU_DOWNLOAD_ANDROID_VVL)
|
||||||
|
set(vvl_version "sdk-1.3.261.1")
|
||||||
|
set(vvl_zip_file "${CMAKE_BINARY_DIR}/externals/vvl-android.zip")
|
||||||
|
if (NOT EXISTS "${vvl_zip_file}")
|
||||||
|
# Download and extract validation layer release to externals directory
|
||||||
|
set(vvl_base_url "https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases/download")
|
||||||
|
file(DOWNLOAD "${vvl_base_url}/${vvl_version}/android-binaries-${vvl_version}-android.zip"
|
||||||
|
"${vvl_zip_file}" SHOW_PROGRESS)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${vvl_zip_file}"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Copy the arm64 binary to src/android/app/main/jniLibs
|
||||||
|
set(vvl_lib_path "${CMAKE_CURRENT_SOURCE_DIR}/src/android/app/src/main/jniLibs/arm64-v8a/")
|
||||||
|
file(COPY "${CMAKE_BINARY_DIR}/externals/android-binaries-${vvl_version}/arm64-v8a/libVkLayer_khronos_validation.so"
|
||||||
|
DESTINATION "${vvl_lib_path}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# On Android, fetch and compile libcxx before doing anything else
|
# On Android, fetch and compile libcxx before doing anything else
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
set(CMAKE_SKIP_INSTALL_RULES ON)
|
set(CMAKE_SKIP_INSTALL_RULES ON)
|
||||||
|
|
|
@ -66,21 +66,6 @@ std::string BuildCommaSeparatedExtensions(
|
||||||
return fmt::format("{}", fmt::join(available_extensions, ","));
|
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
|
} // Anonymous namespace
|
||||||
|
|
||||||
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
||||||
|
@ -103,7 +88,8 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
||||||
cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary(context.get())),
|
cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary(context.get())),
|
||||||
instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type,
|
instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type,
|
||||||
Settings::values.renderer_debug.GetValue())),
|
Settings::values.renderer_debug.GetValue())),
|
||||||
debug_callback(MakeDebugCallback(instance, dld)),
|
debug_messenger(Settings::values.renderer_debug ? CreateDebugUtilsCallback(instance)
|
||||||
|
: vk::DebugUtilsMessenger{}),
|
||||||
surface(CreateSurface(instance, render_window.GetWindowInfo())),
|
surface(CreateSurface(instance, render_window.GetWindowInfo())),
|
||||||
device(CreateDevice(instance, dld, *surface)), memory_allocator(device), state_tracker(),
|
device(CreateDevice(instance, dld, *surface)), memory_allocator(device), state_tracker(),
|
||||||
scheduler(device, state_tracker),
|
scheduler(device, state_tracker),
|
||||||
|
|
|
@ -35,8 +35,6 @@ class GPU;
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
using DebugCallback = std::variant<vk::DebugUtilsMessenger, vk::DebugReportCallback>;
|
|
||||||
|
|
||||||
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
||||||
VkSurfaceKHR surface);
|
VkSurfaceKHR surface);
|
||||||
|
|
||||||
|
@ -75,7 +73,7 @@ private:
|
||||||
vk::InstanceDispatch dld;
|
vk::InstanceDispatch dld;
|
||||||
|
|
||||||
vk::Instance instance;
|
vk::Instance instance;
|
||||||
DebugCallback debug_callback;
|
vk::DebugUtilsMessenger debug_messenger;
|
||||||
vk::SurfaceKHR surface;
|
vk::SurfaceKHR surface;
|
||||||
|
|
||||||
ScreenInfo screen_info;
|
ScreenInfo screen_info;
|
||||||
|
|
|
@ -63,22 +63,6 @@ VkBool32 DebugUtilCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severity,
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkBool32 DebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType,
|
|
||||||
uint64_t object, size_t location, int32_t messageCode,
|
|
||||||
const char* pLayerPrefix, const char* pMessage, void* pUserData) {
|
|
||||||
const VkDebugReportFlagBitsEXT severity = static_cast<VkDebugReportFlagBitsEXT>(flags);
|
|
||||||
const std::string_view message{pMessage};
|
|
||||||
if (severity & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
|
|
||||||
LOG_CRITICAL(Render_Vulkan, "{}", message);
|
|
||||||
} else if (severity & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
|
|
||||||
LOG_WARNING(Render_Vulkan, "{}", message);
|
|
||||||
} else if (severity & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
|
|
||||||
LOG_INFO(Render_Vulkan, "{}", message);
|
|
||||||
} else if (severity & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
|
|
||||||
LOG_DEBUG(Render_Vulkan, "{}", message);
|
|
||||||
}
|
|
||||||
return VK_FALSE;
|
|
||||||
}
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
vk::DebugUtilsMessenger CreateDebugUtilsCallback(const vk::Instance& instance) {
|
vk::DebugUtilsMessenger CreateDebugUtilsCallback(const vk::Instance& instance) {
|
||||||
|
@ -98,15 +82,4 @@ vk::DebugUtilsMessenger CreateDebugUtilsCallback(const vk::Instance& instance) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::DebugReportCallback CreateDebugReportCallback(const vk::Instance& instance) {
|
|
||||||
return instance.CreateDebugReportCallback({
|
|
||||||
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.flags = VK_DEBUG_REPORT_DEBUG_BIT_EXT | VK_DEBUG_REPORT_INFORMATION_BIT_EXT |
|
|
||||||
VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT,
|
|
||||||
.pfnCallback = DebugReportCallback,
|
|
||||||
.pUserData = nullptr,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -9,6 +9,4 @@ namespace Vulkan {
|
||||||
|
|
||||||
vk::DebugUtilsMessenger CreateDebugUtilsCallback(const vk::Instance& instance);
|
vk::DebugUtilsMessenger CreateDebugUtilsCallback(const vk::Instance& instance);
|
||||||
|
|
||||||
vk::DebugReportCallback CreateDebugReportCallback(const vk::Instance& instance);
|
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -76,11 +76,9 @@ namespace {
|
||||||
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (enable_validation) {
|
if (enable_validation &&
|
||||||
const bool debug_utils =
|
AreExtensionsSupported(dld, std::array{VK_EXT_DEBUG_UTILS_EXTENSION_NAME})) {
|
||||||
AreExtensionsSupported(dld, std::array{VK_EXT_DEBUG_UTILS_EXTENSION_NAME});
|
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
extensions.push_back(debug_utils ? VK_EXT_DEBUG_UTILS_EXTENSION_NAME
|
|
||||||
: VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
|
|
||||||
}
|
}
|
||||||
return extensions;
|
return extensions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue