From 210c5f0cf99c6ee3c8c5cc085fd0874a8ee0bd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo?= Date: Mon, 23 Dec 2024 23:26:36 -0300 Subject: [PATCH] Add option and behavior to create the Vulkan interface correctly. (#99) --- CMakeLists.txt | 6 ++++++ src/hle/rt64_application.cpp | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ffcaf3..8ebec16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ if (${RT64_BUILD_EXAMPLES}) set(RT64_STATIC ON) endif() +option(RT64_SDL_WINDOW_VULKAN "Build RT64 to expect an SDL Window outside of Windows" OFF) + if (NOT ${RT64_STATIC}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() @@ -235,6 +237,10 @@ add_compile_definitions( IMGUI_IMPL_VULKAN_NO_PROTOTYPES ) +if (RT64_SDL_WINDOW_VULKAN) + add_compile_definitions("RT64_SDL_WINDOW_VULKAN") +endif() + set (SOURCES "${PROJECT_SOURCE_DIR}/src/common/rt64_common.cpp" "${PROJECT_SOURCE_DIR}/src/common/rt64_dynamic_libraries.cpp" diff --git a/src/hle/rt64_application.cpp b/src/hle/rt64_application.cpp index 3ce6c33..59acab6 100644 --- a/src/hle/rt64_application.cpp +++ b/src/hle/rt64_application.cpp @@ -22,7 +22,20 @@ namespace RT64 { // External functions to create the backends. extern std::unique_ptr CreateD3D12Interface(); + +#ifdef RT64_SDL_WINDOW_VULKAN + extern std::unique_ptr CreateVulkanInterface(RenderWindow renderWindow); +#else extern std::unique_ptr CreateVulkanInterface(); +#endif + + static std::unique_ptr CreateVulkanInterfaceWrapper(RenderWindow renderWindow) { +#ifdef RT64_SDL_WINDOW_VULKAN + return CreateVulkanInterface(renderWindow); +#else + return CreateVulkanInterface(); +#endif + } // Application::Core @@ -135,7 +148,7 @@ namespace RT64 { return SetupResult::InvalidGraphicsAPI; # endif case UserConfiguration::GraphicsAPI::Vulkan: - renderInterface = CreateVulkanInterface(); + renderInterface = CreateVulkanInterfaceWrapper(appWindow->windowHandle); break; default: fprintf(stderr, "Unknown Graphics API specified in configuration.\n"); @@ -182,7 +195,7 @@ namespace RT64 { if (isRDNA3 && useHDRinD3D12) { device.reset(); renderInterface.reset(); - renderInterface = CreateVulkanInterface(); + renderInterface = CreateVulkanInterfaceWrapper(appWindow->windowHandle); if (renderInterface == nullptr) { fprintf(stderr, "Unable to initialize graphics API.\n"); return SetupResult::GraphicsAPINotFound;