From 53bb17f18232072e6c3cec6bbb1626d9ee79daf2 Mon Sep 17 00:00:00 2001 From: SmileyAG Date: Fri, 17 Feb 2023 12:10:22 +0400 Subject: [PATCH 1/3] Added 'bxt_disable_v_sync' to disable V-Sync in pre-Steampipe builds --- BunnymodXT/modules/HwDLL.cpp | 17 +++++++++++++++++ BunnymodXT/modules/HwDLL.hpp | 1 + 2 files changed, 18 insertions(+) diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index 66d415fc..e5428df7 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -2425,6 +2425,22 @@ void HwDLL::StartTASPlayback() } } +struct HwDLL::Cmd_BXT_Disable_V_Sync +{ + NO_USAGE(); + + static void handler() + { + #ifdef _WIN32 + typedef BOOL(APIENTRY* PFNWGLSWAPINTERVALPROC)(int); + PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT"); + if (wglSwapIntervalEXT) + wglSwapIntervalEXT(0); + #endif + } +}; + struct HwDLL::Cmd_BXT_TAS_LoadScript { USAGE("Usage: bxt_tas_loadscript \n"); @@ -4639,6 +4655,7 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded() CmdFuncs::AddCommand("notarget", ORIG_Host_Notarget_f); } + wrapper::Add>("bxt_disable_v_sync"); wrapper::Add>("bxt_tas_loadscript"); wrapper::Add>("bxt_tas_exportscript"); wrapper::Add>("bxt_tas_export_libtas_input"); diff --git a/BunnymodXT/modules/HwDLL.hpp b/BunnymodXT/modules/HwDLL.hpp index 90e1d9cb..961d2fb8 100644 --- a/BunnymodXT/modules/HwDLL.hpp +++ b/BunnymodXT/modules/HwDLL.hpp @@ -401,6 +401,7 @@ class HwDLL : public IHookableNameFilterOrdered void FindStuff(); + struct Cmd_BXT_Disable_V_Sync; struct Cmd_BXT_TAS_LoadScript; struct Cmd_BXT_TAS_ExportScript; struct Cmd_BXT_TAS_ExportLibTASInput; From 27d54b5919caf4637f054af071bab4faaaa41ac8 Mon Sep 17 00:00:00 2001 From: SmileyAG Date: Sat, 18 Feb 2023 20:33:05 +0400 Subject: [PATCH 2/3] Replaced with 'BXT_DISABLE_VSYNC' environment variable --- BunnymodXT/modules/ClientDLL.cpp | 17 +++++++++++++++++ BunnymodXT/modules/HwDLL.cpp | 17 ----------------- BunnymodXT/modules/HwDLL.hpp | 1 - README.md | 1 + 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/BunnymodXT/modules/ClientDLL.cpp b/BunnymodXT/modules/ClientDLL.cpp index 9d6f42d5..003aca5d 100644 --- a/BunnymodXT/modules/ClientDLL.cpp +++ b/BunnymodXT/modules/ClientDLL.cpp @@ -1637,6 +1637,23 @@ HOOK_DEF_1(ClientDLL, void, __cdecl, HUD_Frame, double, time) orig_forcehltv_found = HwDLL::GetInstance().ORIG_Cmd_FindCmd("dem_forcehltv"); } + #ifdef _WIN32 + static bool check_vsync = true; + if (check_vsync) + { + bool bxtDisableVSync = getenv("BXT_DISABLE_VSYNC"); + if (bxtDisableVSync) + { + typedef BOOL(APIENTRY* PFNWGLSWAPINTERVALPROC)(int); + PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; + wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT"); + if (wglSwapIntervalEXT) + wglSwapIntervalEXT(0); + } + check_vsync = false; + } + #endif + if (CVars::_bxt_taslog.GetBool() && pEngfuncs) pEngfuncs->Con_Printf(const_cast("HUD_Frame time: %f\n"), time); diff --git a/BunnymodXT/modules/HwDLL.cpp b/BunnymodXT/modules/HwDLL.cpp index e5428df7..66d415fc 100644 --- a/BunnymodXT/modules/HwDLL.cpp +++ b/BunnymodXT/modules/HwDLL.cpp @@ -2425,22 +2425,6 @@ void HwDLL::StartTASPlayback() } } -struct HwDLL::Cmd_BXT_Disable_V_Sync -{ - NO_USAGE(); - - static void handler() - { - #ifdef _WIN32 - typedef BOOL(APIENTRY* PFNWGLSWAPINTERVALPROC)(int); - PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = 0; - wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT"); - if (wglSwapIntervalEXT) - wglSwapIntervalEXT(0); - #endif - } -}; - struct HwDLL::Cmd_BXT_TAS_LoadScript { USAGE("Usage: bxt_tas_loadscript \n"); @@ -4655,7 +4639,6 @@ void HwDLL::RegisterCVarsAndCommandsIfNeeded() CmdFuncs::AddCommand("notarget", ORIG_Host_Notarget_f); } - wrapper::Add>("bxt_disable_v_sync"); wrapper::Add>("bxt_tas_loadscript"); wrapper::Add>("bxt_tas_exportscript"); wrapper::Add>("bxt_tas_export_libtas_input"); diff --git a/BunnymodXT/modules/HwDLL.hpp b/BunnymodXT/modules/HwDLL.hpp index 961d2fb8..90e1d9cb 100644 --- a/BunnymodXT/modules/HwDLL.hpp +++ b/BunnymodXT/modules/HwDLL.hpp @@ -401,7 +401,6 @@ class HwDLL : public IHookableNameFilterOrdered void FindStuff(); - struct Cmd_BXT_Disable_V_Sync; struct Cmd_BXT_TAS_LoadScript; struct Cmd_BXT_TAS_ExportScript; struct Cmd_BXT_TAS_ExportLibTASInput; diff --git a/README.md b/README.md index c873be78..15b1a7d7 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Use the [Bunnymod XT Launcher](https://github.com/YaLTeR/bxt-launcher). - **SPTLIB_DEBUG** - if set to 1, logs all dlopen, dlclose and dlsym calls. - **BXT_DISABLE_DEBUG_CONSOLE** - if set, disables the Bunnymod XT debug console. - **BXT_DISABLE_DISCORD_RPC** - if set, disables the Discord RPC module. +- **BXT_DISABLE_VSYNC** - if set, disables the V-Sync on initialization. ## Building From f8ab4fc0d1bd2a31dd92b41adbcf24a56241197f Mon Sep 17 00:00:00 2001 From: SmileyAG <58108407+SmileyAG@users.noreply.github.com> Date: Sat, 18 Feb 2023 21:39:44 +0400 Subject: [PATCH 3/3] README: Specify that 'BXT_DISABLE_VSYNC' is only supported for Windows --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15b1a7d7..b036e824 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Use the [Bunnymod XT Launcher](https://github.com/YaLTeR/bxt-launcher). - **SPTLIB_DEBUG** - if set to 1, logs all dlopen, dlclose and dlsym calls. - **BXT_DISABLE_DEBUG_CONSOLE** - if set, disables the Bunnymod XT debug console. - **BXT_DISABLE_DISCORD_RPC** - if set, disables the Discord RPC module. -- **BXT_DISABLE_VSYNC** - if set, disables the V-Sync on initialization. +- **BXT_DISABLE_VSYNC** - if set, disables the V-Sync on initialization (Windows-only). ## Building