From d3748cad73f5a4bc11e6cd0ad178a8828676e45e Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jul 2021 21:02:00 -0400 Subject: [PATCH 1/3] emu_window_sdl2_vk: Use the generated SDL config On Linux, due to the way we include SDL2 as a submodule, it makes it difficult for us to specify which SDL_config.h we intended to include. Before, CMake would default to the dummy one included with SDL and ignore the generated one. This tells CMake to use the generated one. In addition, we define USING_GENERATED_CONFIG_H to throw an error in case the dummy config is used by accident. Fixes Vulkan not working on Linux yuzu-cmd. --- CMakeLists.txt | 30 ++++++++----------- externals/CMakeLists.txt | 2 +- src/yuzu_cmd/CMakeLists.txt | 5 ++++ .../emu_window/emu_window_sdl2_vk.cpp | 6 ++++ 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 716256cd5..214d5a4a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ project(yuzu) option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON "ENABLE_SDL2;MSVC" OFF) # On Linux system SDL2 is likely to be lacking HIDAPI support which have drawbacks but is needed for SDL motion -option(YUZU_ALLOW_SYSTEM_SDL2 "Try using system SDL2 before fallling back to one from externals" OFF) +CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) option(ENABLE_QT "Enable the Qt frontend" ON) option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) @@ -387,26 +387,20 @@ if (ENABLE_SDL2) add_library(SDL2 INTERFACE) target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") + elseif (YUZU_USE_EXTERNAL_SDL2) + message(STATUS "Using SDL2 from externals.") else() - if (YUZU_ALLOW_SYSTEM_SDL2) - find_package(SDL2 2.0.15 QUIET) + find_package(SDL2 2.0.15 REQUIRED) - if (SDL2_FOUND) - # Some installations don't set SDL2_LIBRARIES - if("${SDL2_LIBRARIES}" STREQUAL "") - message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2") - set(SDL2_LIBRARIES "SDL2::SDL2") - endif() - - include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) - add_library(SDL2 INTERFACE) - target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") - else() - message(STATUS "SDL2 2.0.15 or newer not found, falling back to externals.") - endif() - else() - message(STATUS "Using SDL2 from externals.") + # Some installations don't set SDL2_LIBRARIES + if("${SDL2_LIBRARIES}" STREQUAL "") + message(WARNING "SDL2_LIBRARIES wasn't set, manually setting to SDL2::SDL2") + set(SDL2_LIBRARIES "SDL2::SDL2") endif() + + include_directories(SYSTEM ${SDL2_INCLUDE_DIRS}) + add_library(SDL2 INTERFACE) + target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") endif() endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index fd427a912..4b8d35548 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -51,7 +51,7 @@ if (NOT LIBUSB_FOUND OR YUZU_USE_BUNDLED_LIBUSB) endif() # SDL2 -if (NOT SDL2_FOUND AND ENABLE_SDL2) +if (YUZU_USE_EXTERNAL_SDL2) if (NOT WIN32) # Yuzu itself needs: Events Joystick Haptic Sensor Timers Audio # Yuzu-cmd also needs: Video (depends on Loadso/Dlopen) diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 4bf25727b..e55a19649 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -38,6 +38,11 @@ target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR}) target_include_directories(yuzu-cmd PRIVATE ../../externals/Vulkan-Headers/include) +if (YUZU_USE_EXTERNAL_SDL2) + target_compile_definitions(yuzu-cmd PRIVATE -DYUZU_USE_EXTERNAL_SDL2) + target_include_directories(yuzu-cmd PRIVATE ${PROJECT_BINARY_DIR}/externals/SDL/include) +endif() + if(UNIX AND NOT APPLE) install(TARGETS yuzu-cmd RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") endif() diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index 3401ad4b4..b6049b032 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp @@ -15,6 +15,12 @@ #include "video_core/renderer_vulkan/renderer_vulkan.h" #include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" +#ifdef YUZU_USE_EXTERNAL_SDL2 +// Include this before SDL.h to prevent the external from including a dummy +#define USING_GENERATED_CONFIG_H +#include +#endif + // Include these late to avoid polluting everything with Xlib macros // Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 #ifdef __clang__ From 0e6ba0cd0db6f338696ffba9180e15ea4a092323 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jul 2021 21:02:38 -0400 Subject: [PATCH 2/3] emu_window_sdl2_vk: Specify the window manager if it should be supported The original language "not implemented" is wrong if the implementation exists but is not compiled. This causes a bit of a debugging headache when it goes wrong. Log it if the window manager is known before exiting. --- src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index b6049b032..7c870aea1 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp @@ -57,6 +57,11 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsyste window_info.type = Core::Frontend::WindowSystemType::Windows; window_info.render_surface = reinterpret_cast(wm.info.win.window); break; +#else + case SDL_SYSWM_TYPE::SDL_SYSWM_WINDOWS: + LOG_CRITICAL(Frontend, "Window manager subsystem Windows not compiled"); + std::exit(EXIT_FAILURE); + break; #endif #ifdef SDL_VIDEO_DRIVER_X11 case SDL_SYSWM_TYPE::SDL_SYSWM_X11: @@ -64,6 +69,11 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsyste window_info.display_connection = wm.info.x11.display; window_info.render_surface = reinterpret_cast(wm.info.x11.window); break; +#else + case SDL_SYSWM_TYPE::SDL_SYSWM_X11: + LOG_CRITICAL(Frontend, "Window manager subsystem X11 not compiled"); + std::exit(EXIT_FAILURE); + break; #endif #ifdef SDL_VIDEO_DRIVER_WAYLAND case SDL_SYSWM_TYPE::SDL_SYSWM_WAYLAND: @@ -71,6 +81,11 @@ EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsyste window_info.display_connection = wm.info.wl.display; window_info.render_surface = wm.info.wl.surface; break; +#else + case SDL_SYSWM_TYPE::SDL_SYSWM_WAYLAND: + LOG_CRITICAL(Frontend, "Window manager subsystem Wayland not compiled"); + std::exit(EXIT_FAILURE); + break; #endif default: LOG_CRITICAL(Frontend, "Window manager subsystem not implemented"); From f7859331252646748c00fbda6ad0b8765de5718b Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Thu, 15 Jul 2021 23:26:00 -0400 Subject: [PATCH 3/3] sdl_impl, emu_window: Remove clang ignore Fixed upstream by libsdl-org/SDL@25fc40b0bd44c484051064bc6b945ea9943f88dd --- src/input_common/sdl/sdl_impl.h | 8 -------- src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 8 -------- src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp | 8 -------- src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp | 9 --------- 4 files changed, 33 deletions(-) diff --git a/src/input_common/sdl/sdl_impl.h b/src/input_common/sdl/sdl_impl.h index b77afcbd8..7a9ad6346 100644 --- a/src/input_common/sdl/sdl_impl.h +++ b/src/input_common/sdl/sdl_impl.h @@ -10,15 +10,7 @@ #include #include -// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" -#endif #include -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif #include "common/common_types.h" #include "common/threadsafe_queue.h" diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 06b20c975..896181f0b 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -2,15 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wimplicit-fallthrough" -#endif #include -#ifdef __clang__ -#pragma clang diagnostic pop -#endif #include "common/logging/log.h" #include "common/scm_rev.h" diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp index 837a44be7..eadb41790 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_gl.cpp @@ -7,15 +7,7 @@ #include #define SDL_MAIN_HANDLED -// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wimplicit-fallthrough" -#endif #include -#ifdef __clang__ -#pragma clang diagnostic pop -#endif #include #include diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp index 7c870aea1..152e56db8 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2_vk.cpp @@ -21,16 +21,7 @@ #include #endif -// Include these late to avoid polluting everything with Xlib macros -// Ignore -Wimplicit-fallthrough due to https://github.com/libsdl-org/SDL/issues/4307 -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wimplicit-fallthrough" -#endif #include -#ifdef __clang__ -#pragma clang diagnostic pop -#endif #include EmuWindow_SDL2_VK::EmuWindow_SDL2_VK(InputCommon::InputSubsystem* input_subsystem)