From e7073dc0373cbbd07997c87758dd6a0918e82a28 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier Date: Wed, 3 May 2017 02:47:29 +0000 Subject: [PATCH] ALL: Add an option to control dirty rectangless TinyGL optimisation Exposed to command line via --[no-]dirtyrects. As dirty rectangles make the workload vary a lot between frames, it makes performance regressions harder to spot. Disabling it produces lower, but much more regular FPS counts. --- base/commandLine.cpp | 6 ++++++ engines/grim/gfx_tinygl.cpp | 2 ++ engines/myst3/gfx_tinygl.cpp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 5a5e50da8a0..85e8763814f 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -126,6 +126,8 @@ static const char HELP_STRING[] = " --aspect-ratio Enable aspect ratio correction\n" " --bpp=NUM Select number of bits per pixel, 0 (auto-detect), 16, 32\n" " (default: 0) (only supported by software renderer)\n" + " --[no-]dirtyrects Enable dirty rectangles optimisation in software renderer\n" + " (default: enabled)\n" #ifdef ENABLE_EVENTRECORDER " --record-mode=MODE Specify record mode for event recorder (record, playback,\n" " passthrough [default])\n" @@ -171,6 +173,7 @@ void registerDefaults() { ConfMan.registerDefault("filtering", false); ConfMan.registerDefault("show_fps", false); ConfMan.registerDefault("aspect_ratio", false); + ConfMan.registerDefault("dirtyrects", true); ConfMan.registerDefault("bpp", 0); // Sound & Music @@ -514,6 +517,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha DO_LONG_OPTION_INT("bpp") END_OPTION + DO_LONG_OPTION_BOOL("dirtyrects") + END_OPTION + DO_LONG_OPTION("gamma") END_OPTION // ResidualVM specific start diff --git a/engines/grim/gfx_tinygl.cpp b/engines/grim/gfx_tinygl.cpp index e9ca6d3e7f5..f3dec686c8e 100644 --- a/engines/grim/gfx_tinygl.cpp +++ b/engines/grim/gfx_tinygl.cpp @@ -20,6 +20,7 @@ * */ +#include "common/config-manager.h" #include "common/endian.h" #include "common/system.h" @@ -94,6 +95,7 @@ byte *GfxTinyGL::setupScreen(int screenW, int screenH, bool fullscreen) { _pixelFormat = buf.getFormat(); _zb = new TinyGL::FrameBuffer(screenW, screenH, buf); TinyGL::glInit(_zb, 256); + tglEnableDirtyRects(ConfMan.getBool("dirtyrects")); _storedDisplay.create(_pixelFormat, _gameWidth * _gameHeight, DisposeAfterUse::YES); _storedDisplay.clear(_gameWidth * _gameHeight); diff --git a/engines/myst3/gfx_tinygl.cpp b/engines/myst3/gfx_tinygl.cpp index 3e39fb346b3..ce3980a3d80 100644 --- a/engines/myst3/gfx_tinygl.cpp +++ b/engines/myst3/gfx_tinygl.cpp @@ -26,6 +26,7 @@ #undef ARRAYSIZE #endif +#include "common/config-manager.h" #include "common/rect.h" #include "common/textconsole.h" @@ -71,6 +72,7 @@ void TinyGLRenderer::init() { Graphics::PixelBuffer screenBuffer = _system->getScreenPixelBuffer(); _fb = new TinyGL::FrameBuffer(kOriginalWidth, kOriginalHeight, screenBuffer); TinyGL::glInit(_fb, 512); + tglEnableDirtyRects(ConfMan.getBool("dirtyrects")); tglMatrixMode(TGL_PROJECTION); tglLoadIdentity();