diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index d774f86536..78681f4b11 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -107,6 +107,10 @@ shadowscovermap = false renderer.scale = 1.0 renderer.upscale.technique = "fsr" +; Allows to disable rendering when the game window is out of focus. It might +; save some performance or fix old driver crashes on out of focus. +renderer.renderwhenoutoffocus = "true" + vsync = false particles = true fog = true diff --git a/binaries/data/mods/public/gui/options/options.json b/binaries/data/mods/public/gui/options/options.json index 3f0e02d47f..af21c39ba8 100644 --- a/binaries/data/mods/public/gui/options/options.json +++ b/binaries/data/mods/public/gui/options/options.json @@ -174,6 +174,12 @@ "label": "Mouse grab in window mode", "tooltip": "Constrain mouse in the window mode to the window boundaries.", "config": "window.mousegrabinwindowmode" + }, + { + "type": "boolean", + "label": "Render out of focus", + "tooltip": "To save GPU workload, disable rendering when the game window is out of focus.", + "config": "renderer.renderwhenoutoffocus" } ] }, diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 7940c7a815..9a3b7190c2 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -508,7 +508,9 @@ void CRenderer::Resize(int width, int height) bool CRenderer::ShouldRender() const { - return !g_app_minimized && (g_app_has_focus || !g_VideoMode.IsInFullscreen()); + const bool shouldRenderWhenOutOfFocus{ + g_ConfigDB.Get("renderer.renderwhenoutoffocus", true)}; + return !g_app_minimized && (g_app_has_focus || shouldRenderWhenOutOfFocus); } void CRenderer::RenderFrame(const bool needsPresent)