Skip to content

Commit 77f3630

Browse files
committed
done, methinks
1 parent 4299a13 commit 77f3630

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

source/funkin/FunkinMemory.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FunkinMemory
2828

2929
static var purgeFilter:Array<String> = ["/week", "/characters", "/charSelect", "/results"];
3030

31-
public static var allowVRAMCaching:Bool = true;
31+
public static var allowVRAMCaching:Bool = #if desktop true #else false #end;
3232

3333
/**
3434
* Caches textures that are always required.

source/funkin/Preferences.hx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,33 @@ import funkin.ui.debug.FunkinDebugDisplay.DebugDisplayMode;
1515
@:nullSafety
1616
class Preferences
1717
{
18+
/**
19+
* VRAM Caching allows to decrease some used RAM memory for optimization and better use.
20+
* @default `true` on desktop, otherwise `false`
21+
*/
22+
public static var vramCaching(get, set):Bool;
23+
24+
static function get_vramCaching():Bool
25+
{
26+
#if desktop
27+
return Save?.instance?.options?.vramCaching ?? true;
28+
#else
29+
return false;
30+
#end
31+
}
32+
33+
static function set_vramCaching(value:Bool):Bool
34+
{
35+
#if desktop
36+
Save.instance.options.vramCaching = value;
37+
openfl.utils.Assets.allowGPU = FunkinMemory.allowVRAMCaching = value;
38+
Save.instance.flush();
39+
return value;
40+
#else
41+
return false;
42+
#end
43+
}
44+
1845
/**
1946
* FPS
2047
* Always the refresh rate of the display on mobile, or 60 on web.
@@ -516,6 +543,10 @@ class Preferences
516543
// Apply the allowScreenTimeout setting.
517544
lime.system.System.allowScreenTimeout = Preferences.screenTimeout;
518545
#end
546+
547+
#if desktop
548+
openfl.utils.Assets.allowGPU = FunkinMemory.allowVRAMCaching = Preferences.vramCaching;
549+
#end
519550
}
520551

521552
static function toggleFramerateCap(unlocked:Bool):Void

source/funkin/save/Save.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class Save implements ConsoleClass
120120
framerate: #if mobile refreshRate #else 60 #end,
121121
naughtyness: true,
122122
downscroll: false,
123+
vramCaching: true,
123124
flashingLights: true,
124125
zoomCamera: true,
125126
debugDisplay: 'Off',
@@ -1593,6 +1594,12 @@ typedef SaveDataOptions =
15931594
*/
15941595
var downscroll:Bool;
15951596

1597+
/**
1598+
* If enabled, sprites will load into VRAM.
1599+
* @default `true`
1600+
*/
1601+
var vramCaching:Bool;
1602+
15961603
/**
15971604
* If disabled, flashing lights in the main menu and other areas will be less intense.
15981605
* @default `true`

source/funkin/ui/options/PreferencesMenu.hx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ class PreferencesMenu extends Page<OptionsState.OptionsMenuPageName>
138138
Preferences.hapticsIntensityMultiplier = value;
139139
}, null, Preferences.hapticsIntensityMultiplier, 0.1, 5, 0.1, 1);
140140
#end
141+
142+
#if desktop
143+
createPrefItemCheckbox('VRAM Caching', 'If enabled, most sprites will be loaded into VRAM.', function(value:Bool):Void {
144+
Preferences.vramCaching = value;
145+
}, Preferences.vramCaching);
146+
#end
147+
141148
createPrefItemCheckbox('Flashing Lights', 'If disabled, it will dampen flashing effects. Useful for people with photosensitive epilepsy.',
142149
function(value:Bool):Void {
143150
Preferences.flashingLights = value;

0 commit comments

Comments
 (0)