Common and version specific shader packages #10

Merged
embeddedt merged 24 commits from mitchej123/celeritas:common-shaders-and-enhancements into stonecutter 2025-03-31 19:52:28 -04:00
38 changed files with 100 additions and 78 deletions
Showing only changes of commit 81231d4089 - Show all commits

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ dependencies {
compileOnly "org.lwjgl:lwjgl:${lwjglVersion}" compileOnly "org.lwjgl:lwjgl:${lwjglVersion}"
compileOnly "org.lwjgl:lwjgl-opengl:${lwjglVersion}" compileOnly "org.lwjgl:lwjgl-opengl:${lwjglVersion}"
compileOnly "org.joml:joml:1.10.5" compileOnly "org.joml:joml:1.10.5"
compileOnly "it.unimi.dsi:fastutil:7.1.0" compileOnly "it.unimi.dsi:fastutil:8.5.9"
compileOnly "org.apache.logging.log4j:log4j-api:2.0-beta9" compileOnly "org.apache.logging.log4j:log4j-api:2.0-beta9"
compileOnly "org.jetbrains:annotations:24.1.0" compileOnly "org.jetbrains:annotations:24.1.0"
compileOnly("org.projectlombok:lombok:1.18.30") compileOnly("org.projectlombok:lombok:1.18.30")
@@ -87,6 +87,15 @@ public interface IrisApi {
*/ */
boolean isShadowDistanceSliderEnabled(); boolean isShadowDistanceSliderEnabled();
/**
* Checks whether debug options are enabled. Debug options give much
* more detailed OpenGL error outputs at the cost of performance.
*
* @return Whether debug options are enabled.
* @since API v0.2
*/
boolean areDebugOptionsEnabled();
/** /**
* Opens the main Iris GUI screen. It's up to Iris to decide * Opens the main Iris GUI screen. It's up to Iris to decide
* what this screen is, but generally this is the shader selection * what this screen is, but generally this is the shader selection
@@ -1,6 +1,6 @@
package net.irisshaders.iris.pipeline.transform; package net.irisshaders.iris.pipeline.transform;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.api.v0.IrisApi;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import java.io.IOException; import java.io.IOException;
@@ -11,6 +11,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL; import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/** /**
@@ -43,7 +44,7 @@ public class ShaderPrinter {
Files.createDirectories(debugOutDir); Files.createDirectories(debugOutDir);
} catch (IOException e) { } catch (IOException e) {
Iris.logger.warn("Failed to initialize debug patched shader source location", e); IRIS_LOGGER.warn("Failed to initialize debug patched shader source location", e);
} }
outputLocationCleared = true; outputLocationCleared = true;
} }
@@ -56,7 +57,7 @@ public class ShaderPrinter {
public static class ProgramPrintBuilder { public static class ProgramPrintBuilder {
// copy the debug flag if for some reason the debug flag changes during the // copy the debug flag if for some reason the debug flag changes during the
// lifetime of this builder object // lifetime of this builder object
private final boolean isActive = Iris.getIrisConfig().areDebugOptionsEnabled(); private final boolean isActive = IrisApi.getInstance().areDebugOptionsEnabled();
// the prefix is created at instantiation time so that all sources attached to // the prefix is created at instantiation time so that all sources attached to
// this builder use the same counter prefix // this builder use the same counter prefix
@@ -134,7 +135,7 @@ public class ShaderPrinter {
Files.createDirectories(debugOutDir); Files.createDirectories(debugOutDir);
} catch (IOException e) { } catch (IOException e) {
Iris.logger.warn("Failed to initialize debug patched shader source location", e); IRIS_LOGGER.warn("Failed to initialize debug patched shader source location", e);
} }
outputLocationCleared = true; outputLocationCleared = true;
} }
@@ -144,7 +145,7 @@ public class ShaderPrinter {
Files.writeString(debugOutDir.resolve(sources.get(i)), sources.get(i + 1)); Files.writeString(debugOutDir.resolve(sources.get(i)), sources.get(i + 1));
} }
} catch (IOException e) { } catch (IOException e) {
Iris.logger.warn("Failed to write debug patched shader source", e); IRIS_LOGGER.warn("Failed to write debug patched shader source", e);
} }
} }
} }
@@ -2,7 +2,6 @@ package net.irisshaders.iris.shaderpack.parsing;
import it.unimi.dsi.fastutil.booleans.BooleanConsumer; import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import it.unimi.dsi.fastutil.floats.FloatConsumer; import it.unimi.dsi.fastutil.floats.FloatConsumer;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.IrisLogging; import net.irisshaders.iris.IrisLogging;
import org.joml.Vector2f; import org.joml.Vector2f;
import org.joml.Vector3i; import org.joml.Vector3i;
@@ -13,6 +12,8 @@ import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.IntConsumer; import java.util.function.IntConsumer;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class DispatchingDirectiveHolder implements DirectiveHolder { public class DispatchingDirectiveHolder implements DirectiveHolder {
private final Map<String, BooleanConsumer> booleanConstVariables; private final Map<String, BooleanConsumer> booleanConstVariables;
private final Map<String, Consumer<String>> stringConstVariables; private final Map<String, Consumer<String>> stringConstVariables;
@@ -46,7 +47,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
} else if ("false".equals(value)) { } else if ("false".equals(value)) {
consumer.accept(false); consumer.accept(false);
} else { } else {
Iris.logger.error("Failed to process " + directive + ": " + value + " is not a valid boolean value"); IRIS_LOGGER.error("Failed to process " + directive + ": " + value + " is not a valid boolean value");
} }
return; return;
@@ -54,7 +55,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
// Only logspam in dev // Only logspam in dev
Iris.logger.info("Found potential unhandled directive: " + directive); IRIS_LOGGER.info("Found potential unhandled directive: " + directive);
} }
typeCheckHelper("int", intConstVariables, directive); typeCheckHelper("int", intConstVariables, directive);
@@ -77,7 +78,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
try { try {
intConsumer.accept(Integer.parseInt(value)); intConsumer.accept(Integer.parseInt(value));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e); IRIS_LOGGER.error("Failed to process " + directive, e);
} }
return; return;
@@ -85,7 +86,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
// Only logspam in dev // Only logspam in dev
Iris.logger.info("Found potential unhandled directive: " + directive); IRIS_LOGGER.info("Found potential unhandled directive: " + directive);
} }
typeCheckHelper("bool", booleanConstVariables, directive); typeCheckHelper("bool", booleanConstVariables, directive);
@@ -98,7 +99,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
try { try {
consumer.accept(Float.parseFloat(value)); consumer.accept(Float.parseFloat(value));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e); IRIS_LOGGER.error("Failed to process " + directive, e);
} }
return; return;
@@ -106,7 +107,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
// Only logspam in dev // Only logspam in dev
Iris.logger.info("Found potential unhandled directive: " + directive); IRIS_LOGGER.info("Found potential unhandled directive: " + directive);
} }
typeCheckHelper("bool", booleanConstVariables, directive); typeCheckHelper("bool", booleanConstVariables, directive);
@@ -118,13 +119,13 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
if (consumer != null) { if (consumer != null) {
if (!value.startsWith("vec2")) { if (!value.startsWith("vec2")) {
Iris.logger.error("Failed to process " + directive + ": value was not a valid vec2 constructor"); IRIS_LOGGER.error("Failed to process " + directive + ": value was not a valid vec2 constructor");
} }
String vec2Args = value.substring("vec2".length()).trim(); String vec2Args = value.substring("vec2".length()).trim();
if (!vec2Args.startsWith("(") || !vec2Args.endsWith(")")) { if (!vec2Args.startsWith("(") || !vec2Args.endsWith(")")) {
Iris.logger.error("Failed to process " + directive + ": value was not a valid vec2 constructor"); IRIS_LOGGER.error("Failed to process " + directive + ": value was not a valid vec2 constructor");
} }
vec2Args = vec2Args.substring(1, vec2Args.length() - 1); vec2Args = vec2Args.substring(1, vec2Args.length() - 1);
@@ -136,7 +137,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
} }
if (parts.length != 2) { if (parts.length != 2) {
Iris.logger.error("Failed to process " + directive + IRIS_LOGGER.error("Failed to process " + directive +
": expected 2 arguments to a vec2 constructor, got " + parts.length); ": expected 2 arguments to a vec2 constructor, got " + parts.length);
} }
@@ -146,7 +147,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
Float.parseFloat(parts[1]) Float.parseFloat(parts[1])
)); ));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e); IRIS_LOGGER.error("Failed to process " + directive, e);
} }
return; return;
@@ -161,13 +162,13 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
if (consumer != null) { if (consumer != null) {
if (!value.startsWith("ivec3")) { if (!value.startsWith("ivec3")) {
Iris.logger.error("Failed to process " + directive + ": value was not a valid ivec3 constructor"); IRIS_LOGGER.error("Failed to process " + directive + ": value was not a valid ivec3 constructor");
} }
String ivec3Args = value.substring("ivec3".length()).trim(); String ivec3Args = value.substring("ivec3".length()).trim();
if (!ivec3Args.startsWith("(") || !ivec3Args.endsWith(")")) { if (!ivec3Args.startsWith("(") || !ivec3Args.endsWith(")")) {
Iris.logger.error("Failed to process " + directive + ": value was not a valid ivec3 constructor"); IRIS_LOGGER.error("Failed to process " + directive + ": value was not a valid ivec3 constructor");
} }
ivec3Args = ivec3Args.substring(1, ivec3Args.length() - 1); ivec3Args = ivec3Args.substring(1, ivec3Args.length() - 1);
@@ -179,7 +180,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
} }
if (parts.length != 3) { if (parts.length != 3) {
Iris.logger.error("Failed to process " + directive + IRIS_LOGGER.error("Failed to process " + directive +
": expected 3 arguments to a ivec3 constructor, got " + parts.length); ": expected 3 arguments to a ivec3 constructor, got " + parts.length);
} }
@@ -190,7 +191,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
Integer.parseInt(parts[2]) Integer.parseInt(parts[2])
)); ));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e); IRIS_LOGGER.error("Failed to process " + directive, e);
} }
return; return;
@@ -205,13 +206,13 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
if (consumer != null) { if (consumer != null) {
if (!value.startsWith("vec4")) { if (!value.startsWith("vec4")) {
Iris.logger.error("Failed to process " + directive + ": value was not a valid vec4 constructor"); IRIS_LOGGER.error("Failed to process " + directive + ": value was not a valid vec4 constructor");
} }
String vec4Args = value.substring("vec4".length()).trim(); String vec4Args = value.substring("vec4".length()).trim();
if (!vec4Args.startsWith("(") || !vec4Args.endsWith(")")) { if (!vec4Args.startsWith("(") || !vec4Args.endsWith(")")) {
Iris.logger.error("Failed to process " + directive + ": value was not a valid vec4 constructor"); IRIS_LOGGER.error("Failed to process " + directive + ": value was not a valid vec4 constructor");
} }
vec4Args = vec4Args.substring(1, vec4Args.length() - 1); vec4Args = vec4Args.substring(1, vec4Args.length() - 1);
@@ -223,7 +224,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
} }
if (parts.length != 4) { if (parts.length != 4) {
Iris.logger.error("Failed to process " + directive + IRIS_LOGGER.error("Failed to process " + directive +
": expected 4 arguments to a vec4 constructor, got " + parts.length); ": expected 4 arguments to a vec4 constructor, got " + parts.length);
} }
@@ -235,7 +236,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
Float.parseFloat(parts[3]) Float.parseFloat(parts[3])
)); ));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e); IRIS_LOGGER.error("Failed to process " + directive, e);
} }
return; return;
@@ -250,7 +251,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
private void typeCheckHelper(String expected, Map<String, ?> candidates, ConstDirectiveParser.ConstDirective directive) { private void typeCheckHelper(String expected, Map<String, ?> candidates, ConstDirectiveParser.ConstDirective directive) {
if (candidates.containsKey(directive.getKey())) { if (candidates.containsKey(directive.getKey())) {
Iris.logger.warn("Ignoring " + directive + " because it is of the wrong type, a type of " + expected + " is expected."); IRIS_LOGGER.warn("Ignoring " + directive + " because it is of the wrong type, a type of " + expected + " is expected.");
} }
} }
@@ -258,7 +259,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
public void acceptUniformDirective(String name, Runnable onDetected) { public void acceptUniformDirective(String name, Runnable onDetected) {
// TODO // TODO
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
Iris.logger.warn("Not looking for a uniform directive with the name " + name + " since this type of directive is not currently supported."); IRIS_LOGGER.warn("Not looking for a uniform directive with the name " + name + " since this type of directive is not currently supported.");
} }
} }
@@ -266,7 +267,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
public void acceptCommentStringDirective(String name, Consumer<String> consumer) { public void acceptCommentStringDirective(String name, Consumer<String> consumer) {
// TODO // TODO
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
Iris.logger.warn("Not looking for a comment string directive with the name " + name + " since this type of directive is not currently supported."); IRIS_LOGGER.warn("Not looking for a comment string directive with the name " + name + " since this type of directive is not currently supported.");
} }
} }
@@ -274,7 +275,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
public void acceptCommentIntDirective(String name, IntConsumer consumer) { public void acceptCommentIntDirective(String name, IntConsumer consumer) {
// TODO // TODO
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
Iris.logger.warn("Not looking for a comment int directive with the name " + name + " since this type of directive is not currently supported."); IRIS_LOGGER.warn("Not looking for a comment int directive with the name " + name + " since this type of directive is not currently supported.");
} }
} }
@@ -282,7 +283,7 @@ public class DispatchingDirectiveHolder implements DirectiveHolder {
public void acceptCommentFloatDirective(String name, FloatConsumer consumer) { public void acceptCommentFloatDirective(String name, FloatConsumer consumer) {
// TODO // TODO
if (IrisLogging.ENABLE_SPAM) { if (IrisLogging.ENABLE_SPAM) {
Iris.logger.warn("Not looking for a comment float directive with the name " + name + " since this type of directive is not currently supported."); IRIS_LOGGER.warn("Not looking for a comment float directive with the name " + name + " since this type of directive is not currently supported.");
} }
} }
@@ -1,6 +1,5 @@
package net.irisshaders.iris.shaderpack.preprocessor; package net.irisshaders.iris.shaderpack.preprocessor;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.helpers.StringPair; import net.irisshaders.iris.helpers.StringPair;
import net.irisshaders.iris.shaderpack.option.ShaderPackOptions; import net.irisshaders.iris.shaderpack.option.ShaderPackOptions;
import org.anarres.cpp.Feature; import org.anarres.cpp.Feature;
@@ -19,6 +18,8 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class PropertiesPreprocessor { public class PropertiesPreprocessor {
// Derived from ShaderProcessor.glslPreprocessSource, which is derived from GlShader from Canvas, licenced under LGPL // Derived from ShaderProcessor.glslPreprocessSource, which is derived from GlShader from Canvas, licenced under LGPL
public static String preprocessSource(String source, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) { public static String preprocessSource(String source, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
@@ -42,7 +43,7 @@ public class PropertiesPreprocessor {
try { try {
pp.addMacro(name, value); pp.addMacro(name, value);
} catch (LexerException e) { } catch (LexerException e) {
Iris.logger.fatal("Failed to preprocess property file!", e); IRIS_LOGGER.fatal("Failed to preprocess property file!", e);
} }
}); });
@@ -66,7 +67,7 @@ public class PropertiesPreprocessor {
preprocessor.addMacro(envDefine.key(), envDefine.value()); preprocessor.addMacro(envDefine.key(), envDefine.value());
} }
} catch (LexerException e) { } catch (LexerException e) {
Iris.logger.fatal("Failed to preprocess property file!", e); IRIS_LOGGER.fatal("Failed to preprocess property file!", e);
} }
return process(preprocessor, source); return process(preprocessor, source);
@@ -111,7 +112,7 @@ public class PropertiesPreprocessor {
builder.append(tok.getText()); builder.append(tok.getText());
} }
} catch (final Exception e) { } catch (final Exception e) {
Iris.logger.error("Properties pre-processing failed", e); IRIS_LOGGER.error("Properties pre-processing failed", e);
} }
source = builder.toString(); source = builder.toString();
@@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.IrisLimits; import net.irisshaders.iris.gl.IrisLimits;
import net.irisshaders.iris.gl.texture.InternalTextureFormat; import net.irisshaders.iris.gl.texture.InternalTextureFormat;
import net.irisshaders.iris.shaderpack.parsing.DirectiveHolder; import net.irisshaders.iris.shaderpack.parsing.DirectiveHolder;
@@ -17,6 +16,8 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class PackRenderTargetDirectives { public class PackRenderTargetDirectives {
public static final ImmutableList<String> LEGACY_RENDER_TARGETS = ImmutableList.of( public static final ImmutableList<String> LEGACY_RENDER_TARGETS = ImmutableList.of(
"gcolor", "gcolor",
@@ -80,7 +81,7 @@ public class PackRenderTargetDirectives {
} else if ("RGB16".equals(format)) { } else if ("RGB16".equals(format)) {
colortex7.requestedFormat = InternalTextureFormat.RGB16; colortex7.requestedFormat = InternalTextureFormat.RGB16;
} else { } else {
Iris.logger.warn("Ignoring GAUX4FORMAT directive /* GAUX4FORMAT:" + format + "*/ because " + format IRIS_LOGGER.warn("Ignoring GAUX4FORMAT directive /* GAUX4FORMAT:" + format + "*/ because " + format
+ " must be RGBA32F, RGB32F, or RGB16. Use `const int colortex7Format = " + format + ";` + instead."); + " must be RGBA32F, RGB32F, or RGB16. Use `const int colortex7Format = " + format + ";` + instead.");
} }
}); });
@@ -112,7 +113,7 @@ public class PackRenderTargetDirectives {
if (internalFormat.isPresent()) { if (internalFormat.isPresent()) {
settings.requestedFormat = internalFormat.get(); settings.requestedFormat = internalFormat.get();
} else { } else {
Iris.logger.warn("Unrecognized internal texture format " + format + " specified for " + bufferName + "Format, ignoring."); IRIS_LOGGER.warn("Unrecognized internal texture format " + format + " specified for " + bufferName + "Format, ignoring.");
} }
}); });
@@ -6,7 +6,7 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.irisshaders.iris.Iris; import net.irisshaders.iris.api.v0.IrisApi;
import net.irisshaders.iris.gl.IrisRenderSystem; import net.irisshaders.iris.gl.IrisRenderSystem;
import net.irisshaders.iris.gl.blending.AlphaTest; import net.irisshaders.iris.gl.blending.AlphaTest;
import net.irisshaders.iris.gl.blending.AlphaTestFunction; import net.irisshaders.iris.gl.blending.AlphaTestFunction;
@@ -48,6 +48,7 @@ import java.util.Properties;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL; import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/** /**
@@ -125,7 +126,7 @@ public class ShaderProperties {
public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) { public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines); String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines);
if (Iris.getIrisConfig().areDebugOptionsEnabled()) { if (IrisApi.getInstance().areDebugOptionsEnabled()) {
try { try {
Files.writeString(PLATFORM_UTIL.getGameDir().resolve("preprocessed.properties"), preprocessedContents); Files.writeString(PLATFORM_UTIL.getGameDir().resolve("preprocessed.properties"), preprocessedContents);
Files.writeString(PLATFORM_UTIL.getGameDir().resolve("original.properties"), contents); Files.writeString(PLATFORM_UTIL.getGameDir().resolve("original.properties"), contents);
@@ -140,7 +141,7 @@ public class ShaderProperties {
preprocessed.load(new StringReader(preprocessedContents)); preprocessed.load(new StringReader(preprocessedContents));
original.load(new StringReader(contents)); original.load(new StringReader(contents));
} catch (IOException e) { } catch (IOException e) {
Iris.logger.error("Error loading shaders.properties!", e); IRIS_LOGGER.error("Error loading shaders.properties!", e);
} }
preprocessed.forEach((keyObject, valueObject) -> { preprocessed.forEach((keyObject, valueObject) -> {
@@ -160,7 +161,7 @@ public class ShaderProperties {
} else if ("fancy".equals(value)) { } else if ("fancy".equals(value)) {
cloudSetting = CloudSetting.FANCY; cloudSetting = CloudSetting.FANCY;
} else { } else {
Iris.logger.error("Unrecognized clouds setting: " + value); IRIS_LOGGER.error("Unrecognized clouds setting: " + value);
} }
if (dhCloudSetting == CloudSetting.DEFAULT) { if (dhCloudSetting == CloudSetting.DEFAULT) {
@@ -174,7 +175,7 @@ public class ShaderProperties {
} else if ("on".equals(value) || "fancy".equals(value)) { } else if ("on".equals(value) || "fancy".equals(value)) {
dhCloudSetting = CloudSetting.FANCY; dhCloudSetting = CloudSetting.FANCY;
} else { } else {
Iris.logger.error("Unrecognized DH clouds setting (need off, on): " + value); IRIS_LOGGER.error("Unrecognized DH clouds setting (need off, on): " + value);
} }
} }
@@ -186,7 +187,7 @@ public class ShaderProperties {
} else if ("reversed".equals(value)) { } else if ("reversed".equals(value)) {
shadowCulling = ShadowCullState.REVERSED; shadowCulling = ShadowCullState.REVERSED;
} else { } else {
Iris.logger.error("Unrecognized shadow culling setting: " + value); IRIS_LOGGER.error("Unrecognized shadow culling setting: " + value);
} }
} }
@@ -250,7 +251,7 @@ public class ShaderProperties {
offsetY = Float.parseFloat(parts[2]); offsetY = Float.parseFloat(parts[2]);
} }
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
Iris.logger.error("Unable to parse scale directive for " + pass + ": " + value, e); IRIS_LOGGER.error("Unable to parse scale directive for " + pass + ": " + value, e);
return; return;
} }
@@ -261,7 +262,7 @@ public class ShaderProperties {
String[] parts = value.split(" "); String[] parts = value.split(" ");
if (parts.length != 2) { if (parts.length != 2) {
Iris.logger.error("Unable to parse size.buffer directive for " + pass + ": " + value); IRIS_LOGGER.error("Unable to parse size.buffer directive for " + pass + ": " + value);
return; return;
} }
@@ -277,16 +278,16 @@ public class ShaderProperties {
String[] parts = value.split(" "); String[] parts = value.split(" ");
if (parts.length > 2) { if (parts.length > 2) {
Iris.logger.warn("Weird alpha test directive for " + pass + " contains more parts than we expected: " + value); IRIS_LOGGER.warn("Weird alpha test directive for " + pass + " contains more parts than we expected: " + value);
} else if (parts.length < 2) { } else if (parts.length < 2) {
Iris.logger.error("Invalid alpha test directive for " + pass + ": " + value); IRIS_LOGGER.error("Invalid alpha test directive for " + pass + ": " + value);
return; return;
} }
Optional<AlphaTestFunction> function = AlphaTestFunction.fromString(parts[0]); Optional<AlphaTestFunction> function = AlphaTestFunction.fromString(parts[0]);
if (!function.isPresent()) { if (!function.isPresent()) {
Iris.logger.error("Unable to parse alpha test directive for " + pass + ", unknown alpha test function " + parts[0] + ": " + value); IRIS_LOGGER.error("Unable to parse alpha test directive for " + pass + ", unknown alpha test function " + parts[0] + ": " + value);
return; return;
} }
@@ -295,7 +296,7 @@ public class ShaderProperties {
try { try {
reference = Float.parseFloat(parts[1]); reference = Float.parseFloat(parts[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Unable to parse alpha test directive for " + pass + ": " + value, e); IRIS_LOGGER.error("Unable to parse alpha test directive for " + pass + ": " + value, e);
return; return;
} }
@@ -368,7 +369,7 @@ public class ShaderProperties {
indirectPointers.put(pass, new IndirectPointer(Integer.parseInt(locations[0]), Long.parseLong(locations[1]))); indirectPointers.put(pass, new IndirectPointer(Integer.parseInt(locations[0]), Long.parseLong(locations[1])));
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
Iris.logger.fatal("Failed to parse indirect command for " + pass + "! " + value); IRIS_LOGGER.fatal("Failed to parse indirect command for " + pass + "! " + value);
} }
}); });
@@ -387,12 +388,12 @@ public class ShaderProperties {
trueIndex = Integer.parseInt(index); trueIndex = Integer.parseInt(index);
trueSize = Integer.parseInt(value); trueSize = Integer.parseInt(value);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
Iris.logger.error("Number format exception parsing SSBO index/size!", e); IRIS_LOGGER.error("Number format exception parsing SSBO index/size!", e);
return; return;
} }
if (trueIndex > 8) { if (trueIndex > 8) {
Iris.logger.fatal("SSBO's cannot use buffer numbers higher than 8, they're reserved!"); IRIS_LOGGER.fatal("SSBO's cannot use buffer numbers higher than 8, they're reserved!");
return; return;
} }
@@ -411,12 +412,12 @@ public class ShaderProperties {
scaleX = Float.parseFloat(parts[2]); scaleX = Float.parseFloat(parts[2]);
scaleY = Float.parseFloat(parts[3]); scaleY = Float.parseFloat(parts[3]);
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
Iris.logger.error("Number format exception parsing SSBO index/size, or not correct format!", e); IRIS_LOGGER.error("Number format exception parsing SSBO index/size, or not correct format!", e);
return; return;
} }
if (trueIndex > 8) { if (trueIndex > 8) {
Iris.logger.fatal("SSBO's cannot use buffer numbers higher than 8, they're reserved!"); IRIS_LOGGER.fatal("SSBO's cannot use buffer numbers higher than 8, they're reserved!");
return; return;
} }
@@ -437,7 +438,7 @@ public class ShaderProperties {
Optional<TextureStage> optionalTextureStage = TextureStage.parse(stageName); Optional<TextureStage> optionalTextureStage = TextureStage.parse(stageName);
if (!optionalTextureStage.isPresent()) { if (!optionalTextureStage.isPresent()) {
Iris.logger.warn("Unknown texture stage " + "\"" + stageName + "\"," + " ignoring custom texture directive for " + key); IRIS_LOGGER.warn("Unknown texture stage " + "\"" + stageName + "\"," + " ignoring custom texture directive for " + key);
return; return;
} }
@@ -461,7 +462,7 @@ public class ShaderProperties {
type = TextureType.TEXTURE_3D; type = TextureType.TEXTURE_3D;
irisCustomTextures.put(newSamplerName, new TextureDefinition.RawDefinition(parts[0], TextureType.valueOf(parts[1].toUpperCase(Locale.ROOT)), InternalTextureFormat.fromString(parts[2]).orElseThrow(IllegalArgumentException::new), Integer.parseInt(parts[3]), Integer.parseInt(parts[4]), Integer.parseInt(parts[5]), PixelFormat.fromString(parts[6]).orElseThrow(IllegalArgumentException::new), PixelType.fromString(parts[7]).orElseThrow(IllegalArgumentException::new))); irisCustomTextures.put(newSamplerName, new TextureDefinition.RawDefinition(parts[0], TextureType.valueOf(parts[1].toUpperCase(Locale.ROOT)), InternalTextureFormat.fromString(parts[2]).orElseThrow(IllegalArgumentException::new), Integer.parseInt(parts[3]), Integer.parseInt(parts[4]), Integer.parseInt(parts[5]), PixelFormat.fromString(parts[6]).orElseThrow(IllegalArgumentException::new), PixelType.fromString(parts[7]).orElseThrow(IllegalArgumentException::new)));
} else { } else {
Iris.logger.warn("Unknown texture directive for " + key + ": " + value); IRIS_LOGGER.warn("Unknown texture directive for " + key + ": " + value);
} }
customTexturePatching.put(new Tri<>(samplerName, type, stage), newSamplerName); customTexturePatching.put(new Tri<>(samplerName, type, stage), newSamplerName);
@@ -489,7 +490,7 @@ public class ShaderProperties {
// 3D texture handling // 3D texture handling
irisCustomTextures.put(samplerName, new TextureDefinition.RawDefinition(parts[0], TextureType.valueOf(parts[1].toUpperCase(Locale.ROOT)), InternalTextureFormat.fromString(parts[2]).orElseThrow(IllegalArgumentException::new), Integer.parseInt(parts[3]), Integer.parseInt(parts[4]), Integer.parseInt(parts[5]), PixelFormat.fromString(parts[6]).orElseThrow(IllegalArgumentException::new), PixelType.fromString(parts[7]).orElseThrow(IllegalArgumentException::new))); irisCustomTextures.put(samplerName, new TextureDefinition.RawDefinition(parts[0], TextureType.valueOf(parts[1].toUpperCase(Locale.ROOT)), InternalTextureFormat.fromString(parts[2]).orElseThrow(IllegalArgumentException::new), Integer.parseInt(parts[3]), Integer.parseInt(parts[4]), Integer.parseInt(parts[5]), PixelFormat.fromString(parts[6]).orElseThrow(IllegalArgumentException::new), PixelType.fromString(parts[7]).orElseThrow(IllegalArgumentException::new)));
} else { } else {
Iris.logger.warn("Unknown texture directive for " + key + ": " + value); IRIS_LOGGER.warn("Unknown texture directive for " + key + ": " + value);
} }
return; return;
@@ -503,7 +504,7 @@ public class ShaderProperties {
String key2 = key.substring(6); String key2 = key.substring(6);
if (irisCustomImages.size() > 15) { if (irisCustomImages.size() > 15) {
Iris.logger.error("Only up to 16 images are allowed, but tried to add another image! " + key); IRIS_LOGGER.error("Only up to 16 images are allowed, but tried to add another image! " + key);
return; return;
} }
@@ -518,7 +519,7 @@ public class ShaderProperties {
PixelType pixelType = PixelType.fromString(parts[3]).orElse(null); PixelType pixelType = PixelType.fromString(parts[3]).orElse(null);
if (format == null || internalFormat == null || pixelType == null) { if (format == null || internalFormat == null || pixelType == null) {
Iris.logger.error("Image " + key2 + " is invalid! Format: " + format + " Internal format: " + internalFormat + " Pixel type: " + pixelType); IRIS_LOGGER.error("Image " + key2 + " is invalid! Format: " + format + " Internal format: " + internalFormat + " Pixel type: " + pixelType);
} }
boolean clear = Boolean.parseBoolean(parts[4]); boolean clear = Boolean.parseBoolean(parts[4]);
@@ -548,7 +549,7 @@ public class ShaderProperties {
height = Integer.parseInt(parts[7]); height = Integer.parseInt(parts[7]);
depth = Integer.parseInt(parts[8]); depth = Integer.parseInt(parts[8]);
} else { } else {
Iris.logger.error("Unknown image type! " + key2 + " = " + value); IRIS_LOGGER.error("Unknown image type! " + key2 + " = " + value);
return; return;
} }
image = new ImageInformation(key2, samplerName, type, format, internalFormat, pixelType, width, height, depth, clear, false, 0, 0); image = new ImageInformation(key2, samplerName, type, format, internalFormat, pixelType, width, height, depth, clear, false, 0, 0);
@@ -567,7 +568,7 @@ public class ShaderProperties {
handlePassDirective("variable.", key, value, pass -> { handlePassDirective("variable.", key, value, pass -> {
String[] parts = pass.split("\\."); String[] parts = pass.split("\\.");
if (parts.length != 2) { if (parts.length != 2) {
Iris.logger.warn("Custom variables should take the form of `variable.<type>.<name> = <expression>. Ignoring " + key); IRIS_LOGGER.warn("Custom variables should take the form of `variable.<type>.<name> = <expression>. Ignoring " + key);
return; return;
} }
@@ -577,7 +578,7 @@ public class ShaderProperties {
handlePassDirective("uniform.", key, value, pass -> { handlePassDirective("uniform.", key, value, pass -> {
String[] parts = pass.split("\\."); String[] parts = pass.split("\\.");
if (parts.length != 2) { if (parts.length != 2) {
Iris.logger.warn("Custom uniforms should take the form of `uniform.<type>.<name> = <expression>. Ignoring " + key); IRIS_LOGGER.warn("Custom uniforms should take the form of `uniform.<type>.<name> = <expression>. Ignoring " + key);
return; return;
} }
@@ -620,7 +621,7 @@ public class ShaderProperties {
} else if ("false".equals(value)) { } else if ("false".equals(value)) {
handler.accept(false); handler.accept(false);
} else { } else {
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false"); IRIS_LOGGER.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
} }
} }
@@ -634,7 +635,7 @@ public class ShaderProperties {
} else if ("false".equals(value)) { } else if ("false".equals(value)) {
handler.accept(OptionalBoolean.FALSE); handler.accept(OptionalBoolean.FALSE);
} else { } else {
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false"); IRIS_LOGGER.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
} }
} }
@@ -648,7 +649,7 @@ public class ShaderProperties {
handler.accept(result); handler.accept(result);
} catch (NumberFormatException nex) { } catch (NumberFormatException nex) {
Iris.logger.warn("Unexpected value for integer key " + key + " in shaders.properties: got " + value + ", but expected an integer"); IRIS_LOGGER.warn("Unexpected value for integer key " + key + " in shaders.properties: got " + value + ", but expected an integer");
} }
return true; return true;
@@ -670,7 +671,7 @@ public class ShaderProperties {
handler.accept(affixStrippedKey, result); handler.accept(affixStrippedKey, result);
} catch (NumberFormatException nex) { } catch (NumberFormatException nex) {
Iris.logger.warn("Unexpected value for integer key " + key + " in shaders.properties: got " + value + ", but expected an integer"); IRIS_LOGGER.warn("Unexpected value for integer key " + key + " in shaders.properties: got " + value + ", but expected an integer");
} }
return true; return true;
@@ -3,7 +3,6 @@ package net.irisshaders.iris.uniforms.custom;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import kroppeb.stareval.function.Type; import kroppeb.stareval.function.Type;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.uniform.FloatSupplier; import net.irisshaders.iris.gl.uniform.FloatSupplier;
import net.irisshaders.iris.gl.uniform.UniformHolder; import net.irisshaders.iris.gl.uniform.UniformHolder;
import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency; import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency;
@@ -33,6 +32,8 @@ import java.util.function.DoubleSupplier;
import java.util.function.IntSupplier; import java.util.function.IntSupplier;
import java.util.function.Supplier; import java.util.function.Supplier;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class CustomUniformFixedInputUniformsHolder { public class CustomUniformFixedInputUniformsHolder {
final private ImmutableMap<String, CachedUniform> inputVariables; final private ImmutableMap<String, CachedUniform> inputVariables;
@@ -71,7 +72,7 @@ public class CustomUniformFixedInputUniformsHolder {
private Builder put(String name, CachedUniform uniform) { private Builder put(String name, CachedUniform uniform) {
if (inputVariables.containsKey(name)) { if (inputVariables.containsKey(name)) {
Iris.logger.warn("Duplicated fixed uniform supplied as inputs to the Custom uniform holder: " + name); IRIS_LOGGER.warn("Duplicated fixed uniform supplied as inputs to the Custom uniform holder: " + name);
return this; return this;
} }
inputVariables.put(name, uniform); inputVariables.put(name, uniform);
@@ -15,7 +15,6 @@ import kroppeb.stareval.function.FunctionReturn;
import kroppeb.stareval.function.Type; import kroppeb.stareval.function.Type;
import kroppeb.stareval.parser.Parser; import kroppeb.stareval.parser.Parser;
import kroppeb.stareval.resolver.ExpressionResolver; import kroppeb.stareval.resolver.ExpressionResolver;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.uniform.LocationalUniformHolder; import net.irisshaders.iris.gl.uniform.LocationalUniformHolder;
import net.irisshaders.iris.gl.uniform.UniformHolder; import net.irisshaders.iris.gl.uniform.UniformHolder;
import net.irisshaders.iris.parsing.IrisFunctions; import net.irisshaders.iris.parsing.IrisFunctions;
@@ -31,6 +30,8 @@ import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class CustomUniforms implements FunctionContext { public class CustomUniforms implements FunctionContext {
private final Map<String, CachedUniform> variables = new Object2ObjectLinkedOpenHashMap<>(); private final Map<String, CachedUniform> variables = new Object2ObjectLinkedOpenHashMap<>();
@@ -66,9 +67,9 @@ public class CustomUniforms implements FunctionContext {
if (variable.uniform) { if (variable.uniform) {
this.uniforms.add(cachedUniform); this.uniforms.add(cachedUniform);
} }
//Iris.logger.info("Was able to resolve uniform " + variable.name + " = " + variable.expression); //IRIS_LOGGER.info("Was able to resolve uniform " + variable.name + " = " + variable.expression);
} catch (Exception e) { } catch (Exception e) {
Iris.logger IRIS_LOGGER
.warn("Failed to resolve uniform " + variable.name + ", reason: " + e .warn("Failed to resolve uniform " + variable.name + ", reason: " + e
.getMessage() + " ( = " + variable.expression + ")", e); .getMessage() + " ( = " + variable.expression + ")", e);
} }
@@ -158,7 +159,7 @@ public class CustomUniforms implements FunctionContext {
} }
if (!brokenUniforms.isEmpty()) { if (!brokenUniforms.isEmpty()) {
Iris.logger.warn( IRIS_LOGGER.warn(
"The following uniforms won't work, either because they are broken, or reference a broken uniform: \n" + "The following uniforms won't work, either because they are broken, or reference a broken uniform: \n" +
brokenUniforms.stream().map(CachedUniform::getName).collect(Collectors.joining(", "))); brokenUniforms.stream().map(CachedUniform::getName).collect(Collectors.joining(", ")));
} }
@@ -309,13 +310,13 @@ public class CustomUniforms implements FunctionContext {
public void addVariable(String type, String name, String expression, boolean isUniform) { public void addVariable(String type, String name, String expression, boolean isUniform) {
if (variables.containsKey(name)) { if (variables.containsKey(name)) {
Iris.logger.warn("Ignoring duplicated custom uniform name: " + name); IRIS_LOGGER.warn("Ignoring duplicated custom uniform name: " + name);
return; return;
} }
Type parsedType = types.get(type); Type parsedType = types.get(type);
if (parsedType == null) { if (parsedType == null) {
Iris.logger.warn("Ignoring invalid uniform type: " + type + " of " + name); IRIS_LOGGER.warn("Ignoring invalid uniform type: " + type + " of " + name);
return; return;
} }
@@ -323,14 +324,14 @@ public class CustomUniforms implements FunctionContext {
ExpressionElement ast = Parser.parse(expression, IrisOptions.options); ExpressionElement ast = Parser.parse(expression, IrisOptions.options);
variables.put(name, new Variable(parsedType, name, ast, isUniform)); variables.put(name, new Variable(parsedType, name, ast, isUniform));
} catch (Exception e) { } catch (Exception e) {
Iris.logger.warn("Failed to parse custom variable/uniform " + name + " with expression " + expression, e); IRIS_LOGGER.warn("Failed to parse custom variable/uniform " + name + " with expression " + expression, e);
} }
} }
public CustomUniforms build( public CustomUniforms build(
CustomUniformFixedInputUniformsHolder inputHolder CustomUniformFixedInputUniformsHolder inputHolder
) { ) {
Iris.logger.info("Starting custom uniform resolving"); IRIS_LOGGER.info("Starting custom uniform resolving");
return new CustomUniforms(inputHolder, this.variables); return new CustomUniforms(inputHolder, this.variables);
} }
@@ -2,12 +2,13 @@ package net.irisshaders.iris.uniforms.custom.cached;
import kroppeb.stareval.function.FunctionReturn; import kroppeb.stareval.function.FunctionReturn;
import kroppeb.stareval.function.Type; import kroppeb.stareval.function.Type;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency; import net.irisshaders.iris.gl.uniform.UniformUpdateFrequency;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier; import java.util.function.Supplier;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public abstract class VectorCachedUniform<T> extends CachedUniform { public abstract class VectorCachedUniform<T> extends CachedUniform {
final protected T cached; final protected T cached;
@@ -25,7 +26,7 @@ public abstract class VectorCachedUniform<T> extends CachedUniform {
protected boolean doUpdate() { protected boolean doUpdate() {
T other = this.supplier.get(); T other = this.supplier.get();
if (other == null) { if (other == null) {
Iris.logger.warn("Cached Uniform supplier gave null back"); IRIS_LOGGER.warn("Cached Uniform supplier gave null back");
return false; return false;
} }
if (!this.cached.equals(other)) { if (!this.cached.equals(other)) {
@@ -52,6 +52,11 @@ public class IrisApiV0Impl implements IrisApi {
.orElse(true); .orElse(true);
} }
@Override
public boolean areDebugOptionsEnabled() {
return Iris.getIrisConfig().areDebugOptionsEnabled();
}
@Override @Override
public Object openMainIrisScreenObj(Object parent) { public Object openMainIrisScreenObj(Object parent) {
return new ShaderPackScreen((Screen) parent); return new ShaderPackScreen((Screen) parent);