[Scummvm-git-logs] scummvm master -> 928f5bbcff70ff41937eda1c8029be929852e0ea
sev-
noreply at scummvm.org
Tue Sep 3 08:59:00 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
928f5bbcff BACKENDS: Minimal render rate support (force-frame-update)
Commit: 928f5bbcff70ff41937eda1c8029be929852e0ea
https://github.com/scummvm/scummvm/commit/928f5bbcff70ff41937eda1c8029be929852e0ea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2024-09-03T10:58:56+02:00
Commit Message:
BACKENDS: Minimal render rate support (force-frame-update)
Originally authored by @magicmyth in PR #1039
ScummVM is optimised to render frames when something changes on screen.
As some host environments can perform poorly if the app does not
reliably refresh its output regularly (notably Steam overlay) this new
option ensures that Scummvm outputs a minimal amount of frames even if
nothing is changing in the game renderer.
Currently this is only implemented in the SDL OpenGL renderer.
The new config option is called force-frame-update and it takes a
integer value representing the desired minimum milliseconds Scummvm
should wait before forcing a screen update/refresh. E.g: 50.
Note that the rendering system will not force a re-draw of a frame if
the app has rendered a changed frame within the desired minimum refresh.
Thus if the app is outputting 30fps and force-frame-update is set to
100ms (~10fps) then no duplicate frame will be shown (in theory).
As this is implemented in OpenGLSdlGraphicsManager::updateScreen()
OpenGLGraphicsManager::_forceRedraw has had its access changed to
*protected* so that it can be access by it's descendant. The reason this
has been done in OpenGLSdlGraphicsManager::updateScreen() is so
SDL_GetTicks() can be used to track the elapsed time. If it is useful
for other platforms using OpenGL to have this feature it could be
implemented within OpenGLGraphicsManager::updateScreen() provided a
suitable platform independent replacement for SDL_GetTicks() is used.
This would potentially be better as OpenGLSdlGraphicsManager checks
various other states when deciding if the screen should update.
Changed paths:
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/openglsdl/openglsdl-graphics.h
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index bdf4a22f593..c9f0844a8ae 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -146,6 +146,10 @@ OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager(SdlEventSource *eventSource,
// Thus SDL always use the desktop resolution and it is useless to try to use something else.
// Do nothing here as adding the desktop resolution to _fullscreenVideoModes is done as a fallback.
_fullscreenVideoModes.push_back(VideoMode(desktopRes.width(), desktopRes.height()));
+
+ if (ConfMan.hasKey("force_frame_update")) {
+ _forceFrameUpdate = ConfMan.getInt("force_frame_update", Common::ConfigManager::kApplicationDomain);
+ }
#else
const SDL_Rect *const *availableModes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
// TODO: NULL means that there are no fullscreen modes supported. We
@@ -292,6 +296,27 @@ void OpenGLSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFor
}
void OpenGLSdlGraphicsManager::updateScreen() {
+#if SDL_VERSION_ATLEAST(2, 0, 0)
+ static uint32 lastUpdateTime = 0;
+
+ if (_forceFrameUpdate) {
+ if (_forceRedraw) {
+ lastUpdateTime = SDL_GetTicks();
+ } else {
+ // This works for the most part. Anything between 20 and 40 yields
+ // around 24fps. It's not till we set it to 20 that it changes and
+ // jumps to around 40fps.
+ // 50 ~ 16fps
+ // 40 ~ 24fps
+ // 20 ~ 45fps
+ if (SDL_GetTicks() - lastUpdateTime > _forceFrameUpdate) {
+ _forceRedraw = true;
+ lastUpdateTime = SDL_GetTicks();
+ }
+ }
+ }
+#endif
+
if (_ignoreResizeEvents) {
--_ignoreResizeEvents;
}
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index d8774628478..076d574ec4c 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -86,6 +86,7 @@ private:
OpenGL::ContextType _glContextType;
+ uint _forceFrameUpdate = 0;
uint _lastRequestedWidth;
uint _lastRequestedHeight;
uint _graphicsScale;
More information about the Scummvm-git-logs
mailing list