From f8a7153fdd75ef88c3b9ad98d5e7bd1b14458a57 Mon Sep 17 00:00:00 2001 From: Logan McNaughton <848146+loganmc10@users.noreply.github.com> Date: Fri, 17 Apr 2026 15:07:15 +0200 Subject: [PATCH] enable vsync if required (#765) * enable vsync if required * add note * more * more --- parallel-rdp/interface.cpp | 13 +++++++++---- parallel-rdp/interface.hpp | 2 +- src/ui/video.rs | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/parallel-rdp/interface.cpp b/parallel-rdp/interface.cpp index c932a8c..0f78472 100644 --- a/parallel-rdp/interface.cpp +++ b/parallel-rdp/interface.cpp @@ -254,7 +254,8 @@ 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) { + size_t font_size, uint32_t save_state_slot, + bool netplay_enabled) { memset(&rdp_device, 0, sizeof(RDP_DEVICE)); window = (SDL_Window *)_window; @@ -275,13 +276,17 @@ void rdp_init(void *_window, GFX_INFO _gfx_info, const void *font, fragment_size = sizeof(plain_fragment_spirv); } - bool window_vsync = 0; wsi = new WSI; wsi_platform = new SDL_WSIPlatform; wsi_platform->set_window(window); wsi->set_platform(wsi_platform); - wsi->set_present_mode(window_vsync ? PresentMode::SyncToVBlank - : PresentMode::UnlockedMaybeTear); + if (netplay_enabled) { + // VK_PRESENT_MODE_MAILBOX_KHR, fallback to VK_PRESENT_MODE_IMMEDIATE_KHR + wsi->set_present_mode(PresentMode::UnlockedMaybeTear); + } else { + // VK_PRESENT_MODE_MAILBOX_KHR, fallback to VK_PRESENT_MODE_FIFO_KHR + wsi->set_present_mode(PresentMode::UnlockedNoTearing); + } wsi->set_backbuffer_srgb(false); Context::SystemHandles handles = {}; if (!::Vulkan::Context::init_loader( diff --git a/parallel-rdp/interface.hpp b/parallel-rdp/interface.hpp index da286bf..7182a6b 100644 --- a/parallel-rdp/interface.hpp +++ b/parallel-rdp/interface.hpp @@ -37,7 +37,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); + size_t font_size, uint32_t save_state_slot, bool netplay_enabled); void rdp_close(); void rdp_set_vi_register(uint32_t reg, uint32_t value); void rdp_update_screen(); diff --git a/src/ui/video.rs b/src/ui/video.rs index 56a7c05..b67e656 100644 --- a/src/ui/video.rs +++ b/src/ui/video.rs @@ -99,6 +99,7 @@ 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(), ) } }