Cache Iris Shaders (#2206)

This commit is contained in:
Eclipse-Sol authored and GitHub committed 2026-10-03 20:06:39 -07:00
1 parent 231a2ab216
commit 0a4d48964e
21 files changed
+1354 -554

No files matched your search

@@ -1,5 +1,6 @@
package net.coderbot.iris.config;
import com.gtnewhorizons.angelica.glsm.shader.ProgramBinaryCache;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gui.option.IrisVideoSettings;
@@ -40,6 +41,8 @@ public class IrisConfig {
private boolean allowUnknownShaders;
private boolean saveCompiledShaders;
private final Path propertiesPath;
public IrisConfig(Path propertiesPath) {
@@ -48,6 +51,7 @@ public class IrisConfig {
disableUpdateMessage = false;
enableDebugOptions = false;
allowUnknownShaders = false;
saveCompiledShaders = false;
this.propertiesPath = propertiesPath;
}
@@ -135,6 +139,16 @@ public class IrisConfig {
save();
}
public boolean shouldSaveCompiledShaders() {
return saveCompiledShaders;
}
public void setSaveCompiledShaders(boolean save) throws IOException {
this.saveCompiledShaders = save;
ProgramBinaryCache.setEnabled(save);
save();
}
/**
* loads the config file and then populates the string, int, and boolean entries with the parsed entries
*
@@ -156,6 +170,8 @@ public class IrisConfig {
enableDebugOptions = "true".equals(properties.getProperty("enableDebugOptions"));
allowUnknownShaders = "true".equals(properties.getProperty("allowUnknownShaders"));
disableUpdateMessage = "true".equals(properties.getProperty("disableUpdateMessage"));
saveCompiledShaders = "true".equals(properties.getProperty("saveCompiledShaders"));
ProgramBinaryCache.setEnabled(saveCompiledShaders);
// TODO: GUI
try {
IrisVideoSettings.shadowDistance = Integer.parseInt(properties.getProperty("maxShadowRenderDistance", "32"));
@@ -184,6 +200,7 @@ public class IrisConfig {
properties.setProperty("enableDebugOptions", enableDebugOptions ? "true" : "false");
properties.setProperty("allowUnknownShaders", allowUnknownShaders ? "true" : "false");
properties.setProperty("disableUpdateMessage", disableUpdateMessage ? "true" : "false");
properties.setProperty("saveCompiledShaders", saveCompiledShaders ? "true" : "false");
properties.setProperty("maxShadowRenderDistance", String.valueOf(IrisVideoSettings.shadowDistance));
// NB: This uses ISO-8859-1 with unicode escapes as the encoding
try (OutputStream os = Files.newOutputStream(propertiesPath)) {