From d29fed8da31a3dea6cc908b20676f622eb3110fa Mon Sep 17 00:00:00 2001 From: minjaesong Date: Tue, 11 Feb 2020 02:46:15 +0900 Subject: [PATCH] global framerate limit should help with some edge cases that occur when GPU is overloaded --- src/net/torvald/terrarum/AppLoader.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/net/torvald/terrarum/AppLoader.java b/src/net/torvald/terrarum/AppLoader.java index e54f93811..a4b4ea3b6 100644 --- a/src/net/torvald/terrarum/AppLoader.java +++ b/src/net/torvald/terrarum/AppLoader.java @@ -145,6 +145,8 @@ public class AppLoader implements ApplicationListener { public static int GL_VERSION; public static final int MINIMAL_GL_VERSION = 320; + public static final int GLOBAL_FRAMERATE_LIMIT = 300; + public static final float TV_SAFE_GRAPHICS = 0.05f; // as per EBU recommendation (https://tech.ebu.ch/docs/r/r095.pdf) public static final float TV_SAFE_ACTION = 0.035f; // as per EBU recommendation (https://tech.ebu.ch/docs/r/r095.pdf) @@ -317,13 +319,16 @@ public class AppLoader implements ApplicationListener { //appConfig.height = 740; // photographic ratio (1.5:1) appConfig.width = getConfigInt("screenwidth"); appConfig.height = getConfigInt("screenheight"); - appConfig.backgroundFPS = getConfigInt("displayfps"); - appConfig.foregroundFPS = getConfigInt("displayfps"); + appConfig.backgroundFPS = Math.min(GLOBAL_FRAMERATE_LIMIT, getConfigInt("displayfps")); + appConfig.foregroundFPS = Math.min(GLOBAL_FRAMERATE_LIMIT, getConfigInt("displayfps")); appConfig.title = GAME_NAME; appConfig.forceExit = true; // it seems KDE 5 likes this one better... // (Plasma freezes upon app exit. with forceExit = true, it's only frozen for a minute; with forceExit = false, it's indefinite) appConfig.samples = 4; // force the AA on, if the graphics driver didn't do already + if (appConfig.backgroundFPS <= 0) appConfig.backgroundFPS = GLOBAL_FRAMERATE_LIMIT; + if (appConfig.foregroundFPS <= 0) appConfig.foregroundFPS = GLOBAL_FRAMERATE_LIMIT; + // load app icon int[] appIconSizes = new int[]{256,128,64,32,16}; for (int size : appIconSizes) { @@ -705,10 +710,13 @@ public class AppLoader implements ApplicationListener { shaderHicolour.dispose(); shaderPassthruRGB.dispose(); shaderColLUT.dispose(); + shaderReflect.dispose(); CommonResourcePool.INSTANCE.dispose(); fullscreenQuad.dispose(); logoBatch.dispose(); + batch.dispose(); + shapeRender.dispose(); fontGame.dispose(); fontSmallNumbers.dispose();