summaryrefslogtreecommitdiff
path: root/hotfix-02_perf-disable-vsync-by-default-4414.patch
diff options
context:
space:
mode:
Diffstat (limited to 'hotfix-02_perf-disable-vsync-by-default-4414.patch')
-rw-r--r--hotfix-02_perf-disable-vsync-by-default-4414.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/hotfix-02_perf-disable-vsync-by-default-4414.patch b/hotfix-02_perf-disable-vsync-by-default-4414.patch
new file mode 100644
index 0000000..4220a06
--- /dev/null
+++ b/hotfix-02_perf-disable-vsync-by-default-4414.patch
@@ -0,0 +1,53 @@
+From 404ca35f036358419353107cfbbfcf7c95f89ba8 Mon Sep 17 00:00:00 2001
+From: scarf <greenscarf005@gmail.com>
+Date: Mon, 1 Apr 2024 00:50:26 +0900
+Subject: [PATCH] perf: disable vsync by default (#4414)
+
+* perf: disable vsync by default
+
+* fix: warn vsync performance
+---
+ src/options.cpp | 7 +++++++
+ src/sdltiles.cpp | 8 ++++++--
+ 2 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/options.cpp b/src/options.cpp
+index 85832403dc0..684e8cbd48e 100644
+--- a/src/options.cpp
++++ b/src/options.cpp
+@@ -2090,6 +2090,13 @@ void options_manager::add_options_graphics()
+ false, COPT_CURSES_HIDE
+ );
+
++#if defined(SDL_HINT_RENDER_VSYNC)
++ add( "VSYNC", graphics, translate_marker( "Use VSync" ),
++ translate_marker( "Enable vertical synchronization to prevent screen tearing. VSync can slow the game down a lot. Requires restart." ),
++ false, COPT_CURSES_HIDE
++ );
++#endif
++
+ #if defined(__ANDROID__)
+ get_option( "FRAMEBUFFER_ACCEL" ).setPrerequisite( "SOFTWARE_RENDERING" );
+ #else
+diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp
+index 226513ad2ff..561d2e767da 100644
+--- a/src/sdltiles.cpp
++++ b/src/sdltiles.cpp
+@@ -350,8 +350,12 @@ static void WinCreate()
+ if( !software_renderer ) {
+ dbg( DL::Info ) << "Attempting to initialize accelerated SDL renderer.";
+
+- renderer.reset( SDL_CreateRenderer( ::window.get(), renderer_id, SDL_RENDERER_ACCELERATED |
+- SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE ) );
++ int init_flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
++ if( get_option<bool>( "VSYNC" ) ) {
++ init_flags |= SDL_RENDERER_PRESENTVSYNC;
++ }
++
++ renderer.reset( SDL_CreateRenderer( ::window.get(), renderer_id, init_flags ) );
+ if( printErrorIf( !renderer,
+ "Failed to initialize accelerated renderer, falling back to software rendering" ) ) {
+ software_renderer = true;
+--
+2.43.0
+