added it as an option + possible fix??

This commit is contained in:
Yoshman29
2023-03-26 23:36:25 +02:00
parent 6ecfb6d7d4
commit 548210c51d
6 changed files with 34 additions and 4 deletions
+1
View File
@@ -29,6 +29,7 @@ class Options
public static var splashesEnabled:Bool = true;
public static var hitWindow:Float = 250;
public static var framerate:Int = 120;
public static var gpuOnlyBitmaps:Bool = true;
public static var lastLoadedMod:String = null;
@@ -19,6 +19,14 @@ class AppearanceOptions extends OptionsScreen {
"Low Memory Mode",
"If checked, will disable certain background elements in stages to reduce memory usage.",
"lowMemoryMode"));
#if sys
if (!Main.forceGPUOnlyBitmapsOff) {
add(new Checkbox(
"VRAM-Only Sprites",
"If checked, will only store the bitmaps in the GPU, freeing a LOT of memory (EXPERIMENTAL). Turning this off will consume a lot of memory, especially on bigger sprites. If you aren't sure, leave this on.",
"gpuOnlyBitmaps"));
}
#end
add(new Checkbox(
"Auto Pause",
"If checked, switching windows will pause the game",
@@ -15,6 +15,7 @@ class CommandLineHandler {
#if MOD_SUPPORT
Sys.println("-mod [mod name] | Load a specific mod");
Sys.println("-modfolder [path] | Sets the mod folder path");
Sys.println("-nogpubitmap | Forces GPU only bitmaps off");
#end
Sys.exit(0);
#if MOD_SUPPORT
@@ -27,6 +28,8 @@ class CommandLineHandler {
} else {
Main.modToLoad = arg.trim();
}
case "-nogpubitmap":
Main.forceGPUOnlyBitmapsOff = true;
case "-modfolder":
i++;
var arg = cmd[i];
+1
View File
@@ -38,6 +38,7 @@ class Main extends Sprite
public static var instance:Main;
public static var modToLoad:String = null;
public static var forceGPUOnlyBitmapsOff:Bool = false;
public static var scaleMode:FunkinRatioScaleMode;
@@ -53,4 +53,10 @@ class OptimizedBitmapData extends BitmapData {
return null;
#end
}
public override function dispose() {
if (__texture != null)
__texture.dispose();
super.dispose();
}
}
+15 -4
View File
@@ -1,5 +1,6 @@
package openfl.utils;
import funkin.options.Options;
import funkin.system.OptimizedBitmapData;
import openfl.utils._internal.Log;
import openfl.display.BitmapData;
@@ -109,8 +110,13 @@ class Assets
#if flash
var bitmapData = image.src;
#else
var bitmapData = new OptimizedBitmapData(0, 0, true, 0);
bitmapData.__fromImage(image);
var bitmapData:BitmapData = null;
if (!Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
bitmapData = new OptimizedBitmapData(0, 0, true, 0);
bitmapData.__fromImage(image);
} else {
bitmapData = BitmapData.fromImage(image);
}
#end
if (useCache && cache.enabled)
@@ -488,8 +494,13 @@ class Assets
#if flash
var bitmapData = image.src;
#else
var bitmapData = new OptimizedBitmapData(0, 0, true, 0);
bitmapData.__fromImage(image);
var bitmapData:BitmapData = null;
if (!Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
bitmapData = new OptimizedBitmapData(0, 0, true, 0);
bitmapData.__fromImage(image);
} else {
bitmapData = BitmapData.fromImage(image);
}
#end
if (useCache && cache.enabled)