diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index 71dbf6a7..c94550f0 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -265,8 +265,7 @@ static ImageHandle create_message_image(Vulkan::Device &device, int width, } void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, - size_t font_size, uint32_t save_state_slot, - bool netplay_enabled) { + size_t font_size, uint32_t save_state_slot) { memset(&rdp_device, 0, sizeof(RDP_DEVICE)); window = (SDL_Window *)_window; @@ -291,12 +290,12 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, wsi_platform = new SDL_WSIPlatform; wsi_platform->set_window(window); wsi->set_platform(wsi_platform); - if (netplay_enabled) { - // VK_PRESENT_MODE_MAILBOX_KHR, fallback to VK_PRESENT_MODE_IMMEDIATE_KHR - wsi->set_present_mode(PresentMode::UnlockedMaybeTear); - } else { + if (gfx_info.vsync) { // VK_PRESENT_MODE_MAILBOX_KHR, fallback to VK_PRESENT_MODE_FIFO_KHR wsi->set_present_mode(PresentMode::UnlockedNoTearing); + } else { + // VK_PRESENT_MODE_MAILBOX_KHR, fallback to VK_PRESENT_MODE_IMMEDIATE_KHR + wsi->set_present_mode(PresentMode::UnlockedMaybeTear); } wsi->set_backbuffer_srgb(false); Context::SystemHandles handles = {}; diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index 28bcb228..2fb70a61 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -18,6 +18,7 @@ typedef struct { bool PAL; bool widescreen; bool fullscreen; + bool vsync; bool integer_scaling; uint32_t upscale; bool crt; @@ -37,7 +38,7 @@ typedef struct { } CALL_BACK; void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, - size_t font_size, uint32_t save_state_slot, bool netplay_enabled); + size_t font_size, uint32_t save_state_slot); void rdp_close(); void rdp_set_vi_register(uint32_t reg, uint32_t value); void rdp_update_screen(); diff --git a/src/ui/config.rs b/src/ui/config.rs index 64a819a3..1338d4c1 100644 --- a/src/ui/config.rs +++ b/src/ui/config.rs @@ -50,6 +50,7 @@ pub struct Video { pub integer_scaling: bool, pub fullscreen: bool, pub widescreen: bool, + pub vsync: bool, pub crt: bool, } @@ -151,6 +152,7 @@ impl Config { integer_scaling: false, fullscreen: false, widescreen: false, + vsync: true, crt: false, }, emulation: Emulation { diff --git a/src/ui/gui.rs b/src/ui/gui.rs index e7e53259..54769238 100644 --- a/src/ui/gui.rs +++ b/src/ui/gui.rs @@ -92,6 +92,7 @@ fn settings_window(app: &AppWindow, config: &ui::config::Config) { app.set_integer_scaling(config.video.integer_scaling); app.set_fullscreen(config.video.fullscreen); app.set_widescreen(config.video.widescreen); + app.set_vsync(config.video.vsync); app.set_apply_crt_shader(config.video.crt); app.set_overclock_n64_cpu(config.emulation.overclock); app.set_disable_expansion_pak(config.emulation.disable_expansion_pak); @@ -296,6 +297,7 @@ pub fn save_settings(app: &AppWindow, controller_paths: &[Option]) { config.video.integer_scaling = app.get_integer_scaling(); config.video.fullscreen = app.get_fullscreen(); config.video.widescreen = app.get_widescreen(); + config.video.vsync = app.get_vsync(); config.video.crt = app.get_apply_crt_shader(); config.emulation.overclock = app.get_overclock_n64_cpu(); config.emulation.disable_expansion_pak = app.get_disable_expansion_pak(); diff --git a/src/ui/gui/appwindow.slint b/src/ui/gui/appwindow.slint index abe1dcde..881cffa0 100644 --- a/src/ui/gui/appwindow.slint +++ b/src/ui/gui/appwindow.slint @@ -54,6 +54,7 @@ export component AppWindow inherits Window { in-out property integer_scaling <=> SettingsData.integer_scaling; in-out property fullscreen <=> SettingsData.fullscreen; in-out property widescreen <=> SettingsData.widescreen; + in-out property vsync <=> SettingsData.vsync; in-out property apply_crt_shader <=> SettingsData.apply_crt_shader; in-out property overclock_n64_cpu <=> SettingsData.overclock_n64_cpu; in-out property disable_expansion_pak <=> SettingsData.disable_expansion_pak; diff --git a/src/ui/gui/retroachievements_page.slint b/src/ui/gui/retroachievements_page.slint index 50959341..7a34ce13 100644 --- a/src/ui/gui/retroachievements_page.slint +++ b/src/ui/gui/retroachievements_page.slint @@ -26,7 +26,7 @@ export component RetroAchievements inherits Page { VerticalBox { alignment: start; HorizontalBox { - alignment: center; + alignment: start; CheckBox { text: @tr("Enabled"); checked: RAData.enabled; @@ -44,7 +44,7 @@ export component RetroAchievements inherits Page { } } HorizontalBox { - alignment: center; + alignment: start; CheckBox { text: @tr("Hardcore mode"); checked: RAData.hardcore; @@ -56,7 +56,7 @@ export component RetroAchievements inherits Page { } } HorizontalBox { - alignment: center; + alignment: start; CheckBox { text: @tr("Challenge Indicators"); checked: RAData.challenge; @@ -68,7 +68,7 @@ export component RetroAchievements inherits Page { } } HorizontalBox { - alignment: center; + alignment: start; CheckBox { text: @tr("Leaderboard Trackers"); checked: RAData.leaderboard; diff --git a/src/ui/gui/settings_page.slint b/src/ui/gui/settings_page.slint index d8c0617f..666b5be5 100644 --- a/src/ui/gui/settings_page.slint +++ b/src/ui/gui/settings_page.slint @@ -8,6 +8,7 @@ export global SettingsData { in-out property integer_scaling; in-out property fullscreen; in-out property widescreen; + in-out property vsync; in-out property apply_crt_shader; in-out property overclock_n64_cpu; in-out property disable_expansion_pak; @@ -70,6 +71,17 @@ export component Settings inherits Page { } } + HorizontalBox { + alignment: start; + CheckBox { + text: @tr("VSync"); + checked: SettingsData.vsync; + toggled => { + SettingsData.vsync = self.checked; + } + } + } + HorizontalBox { alignment: start; CheckBox { diff --git a/src/ui/video.rs b/src/ui/video.rs index 3cb7e9d0..6de57848 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -21,6 +21,11 @@ fn build_gfx_info(device: &mut device::Device) -> GFX_INFO { PAL: device.cart.pal, widescreen: device.ui.config.video.widescreen, fullscreen: device.ui.video.fullscreen, + vsync: if device.netplay.is_none() { + device.ui.config.video.vsync + } else { + false + }, integer_scaling: device.ui.config.video.integer_scaling, upscale: device.ui.config.video.upscale, crt: device.ui.config.video.crt, @@ -99,7 +104,6 @@ pub fn init(device: &mut device::Device) { font_bytes.as_ptr() as *const std::ffi::c_void, font_bytes.len(), device.ui.storage.save_state_slot, - device.netplay.is_some(), ) }