Skip to content

Commit e7399d2

Browse files
committed
Reset shader cache in Main.refreshAssets
1 parent ca12bc6 commit e7399d2

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • source/funkin/backend/system

source/funkin/backend/system/Main.hx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ class Main extends Sprite
162162
initTransition();
163163
}
164164

165+
static var persistShaderKeys:Map<String, Bool>;
166+
165167
public static function refreshAssets() @:privateAccess {
166168
FunkinCache.instance.clearSecondLayer();
167169

@@ -178,6 +180,18 @@ class Main extends Sprite
178180
}
179181

180182
game.addChildAt(game.soundTray = daSndTray, index);
183+
184+
if (persistShaderKeys == null) {
185+
persistShaderKeys = [for (k in @:privateAccess Lib.current.stage.context3D.__programs.keys()) k => true];
186+
}
187+
else {
188+
for (key => program in @:privateAccess Lib.current.stage.context3D.__programs) {
189+
if (persistShaderKeys.get(key) || Type.resolveClass(key) != null) continue;
190+
191+
program.dispose();
192+
@:privateAccess Lib.current.stage.context3D.__programs.remove(key);
193+
}
194+
}
181195
}
182196

183197
public static function initTransition() {

0 commit comments

Comments
 (0)