Skip to content

Commit

Permalink
simplify gpu caching code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Sep 19, 2024
1 parent 36b3135 commit 1e3b43d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

<assets path="version.txt" />
<!--https://github.com/FunkinCrew/Funkin/pull/3318-->
<assets path="alsoft.ini" /> <!--this is important i think-->
<assets path="alsoft.ini" if="lime_openal"/> <!--this is important i think-->

<assets path="crash/bin/Crash-windows.exe" if="windows" rename="Crash.exe" />
<assets path="crash/bin/Crash-linux.x86_64" if="linux" rename="Crash.x86_64" />
Expand Down
18 changes: 4 additions & 14 deletions source/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import openfl.display3D.textures.RectangleTexture;
class Paths {
public static var currentLevel:String = "preload";

public static var bitmaps:Map<String, FlxGraphic> = new Map<String, FlxGraphic>();
public static var graphics:Map<String, FlxGraphic> = new Map<String, FlxGraphic>();

public static function getPath(file:String, type:AssetType, library:Null<String>):String {
if (library != null)
Expand Down Expand Up @@ -107,27 +107,17 @@ class Paths {
return file;
}
@:privateAccess {
if(!bitmaps.exists(file)){
trace('loading $file to the gpu', DEBUG);
bitmap.lock();
if (bitmap.__texture == null) {
bitmap.image.premultiplied = true;
bitmap.getTexture(FlxG.stage.context3D);
}
bitmap.getSurface();
if(!graphics.exists(file)){
bitmap.disposeImage();
bitmap.image.data = null;
bitmap.image = null;
bitmap.readable = true; // hashlink fix
}
else{
bitmap = null;
return bitmaps.get(file);
return graphics.get(file);
}
}
var graphic:FlxGraphic = FlxGraphic.fromBitmapData(bitmap, false, file, false);
graphic.persist = true;
bitmaps.set(file, graphic);
graphics.set(file, graphic);
return graphic;
}

Expand Down
2 changes: 1 addition & 1 deletion source/states/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MusicBeatState extends #if MODCHARTING_TOOLS modcharting.ModchartMusicBeat
lime_cache.audio.remove(key);
};

Paths.bitmaps.clear();
Paths.graphics.clear();

// Run built-in garbage collector
#if cpp
Expand Down
1 change: 0 additions & 1 deletion source/ui/ModIcon.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ui;

#if MODDING_ALLOWED
import sys.io.File;
import openfl.display.BitmapData;
import flixel.FlxSprite;

Expand Down

0 comments on commit 1e3b43d

Please sign in to comment.