Only set/access texture info cache from the main thread

This commit is contained in:
Jason Mitchell committed 2024-05-14 22:35:21 -07:00
1 parent f684bc0a1b
commit e158faada0
2 files changed
+5 -2

No files matched your search

@@ -236,6 +236,9 @@ public class GLStateManager {
}
public static boolean isMainThread() {
return Thread.currentThread() == MainThread;
}
public static void assertMainThread() {
if (Thread.currentThread() != CurrentThread && !runningSplash) {
@@ -21,7 +21,7 @@ public class TextureInfoCache {
}
public TextureInfo getInfo(int id) {
if(id < 0) return null;
if(id < 0 || !GLStateManager.isMainThread()) return null;
return cache.computeIfAbsent(id, TextureInfo::new);
}
@@ -45,7 +45,7 @@ public class TextureInfoCache {
}
public void onDeleteTexture(int id) {
if(id >= 0) cache.remove(id);
if(id >= 0 && GLStateManager.isMainThread()) cache.remove(id);
}
}