From 426779d02f4f6811af2895a97f56fc21f7998357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo?= Date: Tue, 24 Dec 2024 00:39:25 -0300 Subject: [PATCH 1/3] Use SDL Window as the WindowHandle (Enables wayland support). (#520) --- CMakeLists.txt | 3 +++ lib/N64ModernRuntime | 2 +- lib/rt64 | 2 +- src/main/main.cpp | 24 +++++++++++------------- src/main/rt64_render_context.cpp | 7 ++----- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b900bc..d737837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ if (WIN32) endif() set(RT64_STATIC TRUE) +set(RT64_SDL_WINDOW_VULKAN TRUE) add_subdirectory(${CMAKE_SOURCE_DIR}/lib/rt64 ${CMAKE_BINARY_DIR}/rt64) # set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}") @@ -247,6 +248,8 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux") find_package(SDL2 REQUIRED) find_package(X11 REQUIRED) + add_compile_definitions("RT64_SDL_WINDOW_VULKAN") + # Generate icon_bytes.c from the app icon PNG. add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icon_bytes.c ${CMAKE_CURRENT_BINARY_DIR}/icon_bytes.h COMMAND file_to_c ${CMAKE_SOURCE_DIR}/icons/512.png icon_bytes ${CMAKE_CURRENT_BINARY_DIR}/icon_bytes.c ${CMAKE_CURRENT_BINARY_DIR}/icon_bytes.h diff --git a/lib/N64ModernRuntime b/lib/N64ModernRuntime index d5c81d0..1361c48 160000 --- a/lib/N64ModernRuntime +++ b/lib/N64ModernRuntime @@ -1 +1 @@ -Subproject commit d5c81d0a6bf2e5f36747a095a7a060d7623bbf58 +Subproject commit 1361c48f59877f1bb8189a27bf38e1983fcbb738 diff --git a/lib/rt64 b/lib/rt64 index 67422c3..16f1708 160000 --- a/lib/rt64 +++ b/lib/rt64 @@ -1 +1 @@ -Subproject commit 67422c3b647058d3d38f2813a2abe79cf1638f13 +Subproject commit 16f1708da21048684838c22abb43b60b4ce19e2e diff --git a/src/main/main.cpp b/src/main/main.cpp index bf13a28..49cd8fa 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -55,14 +55,12 @@ ultramodern::gfx_callbacks_t::gfx_data_t create_gfx() { SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); -#if defined(__linux__) - SDL_SetHint(SDL_HINT_VIDEODRIVER, "x11"); -#endif - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) > 0) { exit_error("Failed to initialize SDL2: %s\n", SDL_GetError()); } + fprintf(stdout, "SDL Video Driver: %s\n", SDL_GetCurrentVideoDriver()); + return {}; } @@ -118,7 +116,13 @@ bool SetImageAsIcon(const char* filename, SDL_Window* window) SDL_Window* window; ultramodern::renderer::WindowHandle create_window(ultramodern::gfx_callbacks_t::gfx_data_t) { - window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, SDL_WINDOW_RESIZABLE ); + uint32_t flags = SDL_WINDOW_RESIZABLE; + +#if defined(RT64_SDL_WINDOW_VULKAN) + flags |= SDL_WINDOW_VULKAN; +#endif + + window = SDL_CreateWindow("Zelda 64: Recompiled", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 960, flags); #if defined(__linux__) SetImageAsIcon("icons/512.png",window); if (ultramodern::renderer::get_graphics_config().wm_option == ultramodern::renderer::WindowMode::Fullscreen) { // TODO: Remove once RT64 gets native fullscreen support on Linux @@ -138,14 +142,8 @@ ultramodern::renderer::WindowHandle create_window(ultramodern::gfx_callbacks_t:: #if defined(_WIN32) return ultramodern::renderer::WindowHandle{ wmInfo.info.win.window, GetCurrentThreadId() }; -#elif defined(__ANDROID__) - static_assert(false && "Unimplemented"); -#elif defined(__linux__) - if (wmInfo.subsystem != SDL_SYSWM_X11) { - exit_error("Unsupported SDL2 video driver \"%s\". Only X11 is supported on Linux.\n", SDL_GetCurrentVideoDriver()); - } - - return ultramodern::renderer::WindowHandle{ wmInfo.info.x11.display, wmInfo.info.x11.window }; +#elif defined(__linux__) || defined(__ANDROID__) + return ultramodern::renderer::WindowHandle{ window }; #else static_assert(false && "Unimplemented"); #endif diff --git a/src/main/rt64_render_context.cpp b/src/main/rt64_render_context.cpp index e800d99..126ab70 100644 --- a/src/main/rt64_render_context.cpp +++ b/src/main/rt64_render_context.cpp @@ -200,11 +200,8 @@ zelda64::renderer::RT64Context::RT64Context(uint8_t* rdram, ultramodern::rendere RT64::Application::Core appCore{}; #if defined(_WIN32) appCore.window = window_handle.window; -#elif defined(__ANDROID__) - assert(false && "Unimplemented"); -#elif defined(__linux__) - appCore.window.display = window_handle.display; - appCore.window.window = window_handle.window; +#elif defined(__linux__) || defined(__ANDROID__) + appCore.window = window_handle; #elif defined(__APPLE__) appCore.window.window = window_handle.window; appCore.window.view = window_handle.view; From 5e5515935eb6f7876836c78b686b51ee0629e729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo?= Date: Sun, 29 Dec 2024 01:18:18 -0300 Subject: [PATCH 2/3] Update RT64 to fix SDL2 Deadlock issues with ImGui. (#522) --- lib/rt64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rt64 b/lib/rt64 index 16f1708..0ca92ee 160000 --- a/lib/rt64 +++ b/lib/rt64 @@ -1 +1 @@ -Subproject commit 16f1708da21048684838c22abb43b60b4ce19e2e +Subproject commit 0ca92eeb6c2f58ce3581c65f87f7261b8ac0fea0 From d77f0909fd553b5dc6c66edb3deb022f3a79b7b7 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Wed, 1 Jan 2025 12:05:26 -0500 Subject: [PATCH 3/3] Integrate live recompiler and update N64Recomp commit in CI --- .github/workflows/validate.yml | 2 +- CMakeLists.txt | 9 ++++----- lib/N64ModernRuntime | 2 +- patches/patch_helpers.h | 2 +- src/game/input.cpp | 2 +- src/game/recomp_api.cpp | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b9f7c96..e2f5fd7 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -9,7 +9,7 @@ on: N64RECOMP_COMMIT: type: string required: false - default: 'd33d38161798167929b114c2b0fd445f9670e10a' + default: 'fc696046da3e703450559154d9370ca74c197f8b' DXC_CHECKSUM: type: string required: false diff --git a/CMakeLists.txt b/CMakeLists.txt index d737837..c660365 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,7 @@ target_include_directories(RecompiledFuncs PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/ultramodern/include ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/librecomp/include + ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/N64Recomp/include ) file(GLOB FUNC_C_SOURCES ${CMAKE_SOURCE_DIR}/RecompiledFuncs/*.c) @@ -79,6 +80,7 @@ target_include_directories(PatchesLib PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/ultramodern/include ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/librecomp/include + ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/N64Recomp/include ) target_sources(PatchesLib PRIVATE @@ -97,12 +99,8 @@ if(NOT DEFINED PATCHES_LD) set(PATCHES_LD ld.lld) endif() -if(NOT DEFINED PATCHES_OBJCOPY) - set(PATCHES_OBJCOPY llvm-objcopy) -endif() - add_custom_target(PatchesBin - COMMAND ${CMAKE_COMMAND} -E env CC=${PATCHES_C_COMPILER} LD=${PATCHES_LD} OBJCOPY=${PATCHES_OBJCOPY} make + COMMAND ${CMAKE_COMMAND} -E env CC=${PATCHES_C_COMPILER} LD=${PATCHES_LD} make WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/patches BYPRODUCTS ${CMAKE_SOURCE_DIR}/patches/patches.elf ) @@ -167,6 +165,7 @@ set (SOURCES target_include_directories(Zelda64Recompiled PRIVATE ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/lib/N64ModernRuntime/N64Recomp/include ${CMAKE_SOURCE_DIR}/lib/concurrentqueue ${CMAKE_SOURCE_DIR}/lib/GamepadMotionHelpers ${CMAKE_SOURCE_DIR}/lib/RmlUi/Include diff --git a/lib/N64ModernRuntime b/lib/N64ModernRuntime index 1361c48..43790db 160000 --- a/lib/N64ModernRuntime +++ b/lib/N64ModernRuntime @@ -1 +1 @@ -Subproject commit 1361c48f59877f1bb8189a27bf38e1983fcbb738 +Subproject commit 43790db072e0e599cc14860c215d79569387a3ed diff --git a/patches/patch_helpers.h b/patches/patch_helpers.h index 371e8b4..f6b88d3 100644 --- a/patches/patch_helpers.h +++ b/patches/patch_helpers.h @@ -4,7 +4,7 @@ #ifdef MIPS #include "ultra64.h" #else -#include "librecomp/recomp.h" +#include "recomp.h" #endif #ifdef __cplusplus diff --git a/src/game/input.cpp b/src/game/input.cpp index 4aff5e6..fc707ee 100644 --- a/src/game/input.cpp +++ b/src/game/input.cpp @@ -2,7 +2,7 @@ #include #include "ultramodern/ultramodern.hpp" -#include "librecomp/recomp.h" +#include "recomp.h" #include "recomp_input.h" #include "zelda_config.h" #include "recomp_ui.h" diff --git a/src/game/recomp_api.cpp b/src/game/recomp_api.cpp index 28b4779..00c8f34 100644 --- a/src/game/recomp_api.cpp +++ b/src/game/recomp_api.cpp @@ -1,6 +1,6 @@ #include -#include "librecomp/recomp.h" +#include "recomp.h" #include "librecomp/overlays.hpp" #include "zelda_config.h" #include "recomp_input.h"