more-shader-refactors #11

Merged
embeddedt merged 9 commits from mitchej123/celeritas:more-shader-refactors into stonecutter 2025-04-26 16:37:18 -04:00
38 changed files with 146 additions and 89 deletions
Showing only changes of commit 6e0827eb6c - Show all commits

No files matched your search

@@ -58,11 +58,12 @@ import java.util.stream.Stream;
import java.util.zip.ZipError;
import java.util.zip.ZipException;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class Iris {
public static final IrisLogging logger = IrisLogging.IRIS_LOGGER;
public static final IrisLogging logger = IRIS_LOGGER;
private static final Map<String, String> shaderPackOptionQueue = new HashMap<>();
// Change this for snapshots!
private static final String backupVersionNumber = "1.20.3";
@@ -103,7 +104,7 @@ public class Iris {
*/
public static void onRenderSystemInit() {
if (!initialized) {
Iris.logger.warn("Iris::onRenderSystemInit was called, but Iris::onEarlyInitialize was not called." +
IRIS_LOGGER.warn("Iris::onRenderSystemInit was called, but Iris::onEarlyInitialize was not called." +
" Trying to avoid a crash but this is an odd state.");
return;
}
@@ -128,7 +129,7 @@ public class Iris {
*/
public static void onLoadingComplete() {
if (!initialized) {
Iris.logger.warn("Iris::onLoadingComplete was called, but Iris::onEarlyInitialize was not called." +
IRIS_LOGGER.warn("Iris::onLoadingComplete was called, but Iris::onEarlyInitialize was not called." +
" Trying to avoid a crash but this is an odd state.");
return;
}
@@ -369,7 +370,7 @@ public class Iris {
irisConfig.setDebugEnabled(enable);
irisConfig.save();
} catch (IOException e) {
Iris.logger.fatal("Failed to save config!", e);
IRIS_LOGGER.fatal("Failed to save config!", e);
}
int success;
@@ -462,7 +463,7 @@ public class Iris {
}
} catch (ZipError zipError) {
// Java 8 seems to throw a ZipError instead of a subclass of IOException
Iris.logger.warn("The ZIP at " + pack + " is corrupt");
IRIS_LOGGER.warn("The ZIP at " + pack + " is corrupt");
} catch (IOException ignored) {
// ignored, not a valid shader pack.
}
@@ -6,6 +6,8 @@ import net.irisshaders.iris.config.IrisConfig;
import java.io.IOException;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class IrisApiV0ConfigImpl implements IrisApiConfig {
@Override
public boolean areShadersEnabled() {
@@ -21,13 +23,13 @@ public class IrisApiV0ConfigImpl implements IrisApiConfig {
try {
config.save();
} catch (IOException e) {
Iris.logger.error("Error saving configuration file!", e);
IRIS_LOGGER.error("Error saving configuration file!", e);
}
try {
Iris.reload();
} catch (IOException e) {
Iris.logger.error("Error reloading shader pack while applying changes!", e);
IRIS_LOGGER.error("Error reloading shader pack while applying changes!", e);
}
}
}
@@ -13,6 +13,8 @@ import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.InvocationTargetException;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class DHCompat {
private static boolean dhPresent = true;
private static boolean lastIncompatible;
@@ -81,7 +83,7 @@ public class DHCompat {
throw new RuntimeException("DH found, but one or more API methods are missing. Iris requires DH [2.0.4] or DH API version [1.1.0] or newer. Please make sure you are on the latest version of DH and Iris.", e);
}
} else {
Iris.logger.info("DH not found, and classes not found.");
IRIS_LOGGER.info("DH not found, and classes not found.");
}
}
}
@@ -3,6 +3,7 @@ package net.irisshaders.iris.compat.dh;
import java.io.IOException;
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiFramebuffer;
@@ -54,7 +55,7 @@ public class DHCompatInternal {
}
if (pipeline.getDHTerrainShader().isEmpty() && pipeline.getDHWaterShader().isEmpty()) {
Iris.logger.warn("No DH shader found in this pack.");
IRIS_LOGGER.warn("No DH shader found in this pack.");
incompatible = true;
return;
}
@@ -1,6 +1,7 @@
package net.irisshaders.iris.compat.dh;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import com.seibel.distanthorizons.api.DhApi;
import com.seibel.distanthorizons.api.enums.rendering.EDhApiFogDrawMode;
@@ -48,12 +49,12 @@ public class LodRendererEvents {
public static void setupEventHandlers() {
if (!eventHandlersBound) {
eventHandlersBound = true;
Iris.logger.info("Queuing DH event binding...");
IRIS_LOGGER.info("Queuing DH event binding...");
DhApiAfterDhInitEvent beforeCleanupEvent = new DhApiAfterDhInitEvent() {
@Override
public void afterDistantHorizonsInit(DhApiEventParam<Void> event) {
Iris.logger.info("DH Ready, binding Iris event handlers...");
IRIS_LOGGER.info("DH Ready, binding Iris event handlers...");
Iris.loadShaderpackWhenPossible();
@@ -69,7 +70,7 @@ public class LodRendererEvents {
setupBeforeRenderPassEvent();
setupBeforeApplyShaderEvent();
DHCompatInternal.dhEnabled = DhApi.Delayed.configs.graphics().renderingEnabled().getValue();
Iris.logger.info("DH Iris events bound.");
IRIS_LOGGER.info("DH Iris events bound.");
}
};
DhApi.events.bind(DhApiAfterDhInitEvent.class, beforeCleanupEvent);
@@ -273,7 +274,7 @@ public class LodRendererEvents {
DhApi.Delayed.configs.graphics().fog().drawMode().setValue(EDhApiFogDrawMode.FOG_DISABLED);
if (event.value.renderPass == EDhApiRenderPass.OPAQUE_AND_TRANSPARENT) {
Iris.logger.error("Unexpected; somehow the Opaque + Translucent pass ran with shaders on.");
IRIS_LOGGER.error("Unexpected; somehow the Opaque + Translucent pass ran with shaders on.");
}
} else {
DhApi.Delayed.configs.graphics().ambientOcclusion().enabled().clearValue();
@@ -309,7 +310,7 @@ public class LodRendererEvents {
//float nearClip = DhApi.Delayed.renderProxy.getNearClipPlaneDistanceInBlocks(partialTicks);
//float farClip = (float) ((double) (DHCompatInternal.getDhBlockRenderDistance() + 512) * Math.sqrt(2.0));
//Iris.logger.info("event near clip: "+event.value.nearClipPlane+" event far clip: "+event.value.farClipPlane+
//IRIS_LOGGER.info("event near clip: "+event.value.nearClipPlane+" event far clip: "+event.value.farClipPlane+
// " \niris near clip: "+nearClip+" iris far clip: "+farClip);
instance.getSolidShader().fillUniformData(
@@ -342,7 +343,7 @@ public class LodRendererEvents {
//float nearClip = DhApi.Delayed.renderProxy.getNearClipPlaneDistanceInBlocks(partialTicks);
//float farClip = (float) ((double) (DHCompatInternal.getDhBlockRenderDistance() + 512) * Math.sqrt(2.0));
GL_STATE_MANAGER.disableCullFace();
//Iris.logger.info("event near clip: "+event.value.nearClipPlane+" event far clip: "+event.value.farClipPlane+
//IRIS_LOGGER.info("event near clip: "+event.value.nearClipPlane+" event far clip: "+event.value.farClipPlane+
// " \niris near clip: "+nearClip+" iris far clip: "+farClip);
instance.getTranslucentShader().fillUniformData(
@@ -19,6 +19,8 @@ import org.embeddedt.embeddium.impl.gui.SodiumGameOptionPages;
import java.io.IOException;
import java.util.Set;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class IrisSodiumOptions {
private static final OptionStorage<IrisConfig> irisOpts = new OptionStorage<IrisConfig>() {
@Override
@@ -35,7 +37,7 @@ public class IrisSodiumOptions {
Iris.reload();
}
} catch (IOException e) {
Iris.logger.error("Error saving config", e);
IRIS_LOGGER.error("Error saving config", e);
}
}
};
@@ -6,6 +6,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import static org.embeddedt.embeddium.compat.dh.DHCompatService.DH_COMPAT;
@@ -111,7 +112,7 @@ public class StandardMacros {
String[] splitVersion = version.split("\\.");
if (splitVersion.length < 2) {
Iris.logger.error("Could not parse game version \"" + version + "\"");
IRIS_LOGGER.error("Could not parse game version \"" + version + "\"");
splitVersion = Iris.getBackupVersionNumber().split("\\.");
}
@@ -38,6 +38,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ShaderPackOptionList extends IrisContainerObjectSelectionList<ShaderPackOptionList.BaseEntry> {
private final List<AbstractElementWidget<?>> elementWidgets = new ArrayList<>();
private final ShaderPackScreen screen;
@@ -284,7 +286,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
"Shader Pack Settings (.txt)", "*.txt")
.whenComplete((path, err) -> {
if (err != null) {
Iris.logger.error("Error selecting shader settings from file", err);
IRIS_LOGGER.error("Error selecting shader settings from file", err);
return;
}
@@ -320,7 +322,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
"Shader Pack Settings (.txt)", "*.txt")
.whenComplete((path, err) -> {
if (err != null) {
Iris.logger.error("Error selecting file to export shader settings", err);
IRIS_LOGGER.error("Error selecting file to export shader settings", err);
return;
}
@@ -342,7 +344,7 @@ public class ShaderPackOptionList extends IrisContainerObjectSelectionList<Shade
try (OutputStream out = Files.newOutputStream(p)) {
toSave.store(out, null);
} catch (IOException e) {
Iris.logger.error("Error saving properties to \"" + p + "\"", e);
IRIS_LOGGER.error("Error saving properties to \"" + p + "\"", e);
}
});
});
@@ -26,6 +26,8 @@ import java.nio.file.WatchService;
import java.util.List;
import java.util.function.Function;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackSelectionList.BaseEntry> {
private static final Component PACK_LIST_LABEL = Component.translatable("pack.iris.list.label").withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY);
@@ -55,7 +57,7 @@ public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackS
StandardWatchEventKinds.ENTRY_DELETE);
keyValid = true;
} catch (IOException e) {
Iris.logger.error("Couldn't register file watcher!", e);
IRIS_LOGGER.error("Couldn't register file watcher!", e);
watcher1 = null;
key1 = null;
keyValid = false;
@@ -119,7 +121,7 @@ public class ShaderPackSelectionList extends IrisObjectSelectionList<ShaderPackS
try {
names = Iris.getShaderpacksDirectoryManager().enumerate();
} catch (Throwable e) {
Iris.logger.error("Error reading files while constructing selection UI", e);
IRIS_LOGGER.error("Error reading files while constructing selection UI", e);
// Not translating this since it's going to be seen very rarely,
// We're just trying to get more information on a seemingly untraceable bug:
@@ -42,6 +42,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
@@ -401,7 +402,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
return;
} catch (IOException e) {
Iris.logger.warn("Error copying dragged shader pack", e);
IRIS_LOGGER.warn("Error copying dragged shader pack", e);
this.notificationDialog = Component.translatable(
"options.iris.shaderPackSelection.copyError",
@@ -502,7 +503,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
} catch (Exception e) {
// If the file could not be properly parsed or loaded,
// log the error and display a message to the user
Iris.logger.error("Error importing shader settings file \"" + settingFile.toString() + "\"", e);
IRIS_LOGGER.error("Error importing shader settings file \"" + settingFile.toString() + "\"", e);
this.notificationDialog = Component.translatable(
"options.iris.shaderPackOptions.failedImport",
@@ -523,7 +524,7 @@ public class ShaderPackScreen extends Screen implements HudHideable {
try {
shaderPackList.close();
} catch (IOException e) {
Iris.logger.error("Failed to safely close shaderpack selection!", e);
IRIS_LOGGER.error("Failed to safely close shaderpack selection!", e);
}
this.minecraft.setScreen(parent);
@@ -13,6 +13,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@Mixin(ClientPacketListener.class)
public class MixinClientPacketListener {
@Inject(method = "handleLogin", at = @At("TAIL"))
@@ -26,7 +28,7 @@ public class MixinClientPacketListener {
if (Iris.loadedIncompatiblePack()) {
Minecraft.getInstance().gui.setTimes(10, 70, 140);
Iris.logger.warn("Incompatible pack for DH!");
IRIS_LOGGER.warn("Incompatible pack for DH!");
Minecraft.getInstance().player.displayClientMessage(Component.literal("This pack doesn't have DH support.").withStyle(ChatFormatting.BOLD, ChatFormatting.RED), false);
Minecraft.getInstance().player.displayClientMessage(Component.literal("Distant Horizons (DH) chunks won't show up. This isn't a bug, get another shader.").withStyle(ChatFormatting.RED), false);
}
@@ -34,6 +34,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.ArrayList;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@Mixin(GameRenderer.class)
public class MixinGameRenderer {
@Shadow
@@ -75,10 +77,10 @@ public class MixinGameRenderer {
@Inject(method = "<init>", at = @At("TAIL"))
private void iris$logSystem(Minecraft arg, ItemInHandRenderer arg2, ResourceManager arg3, RenderBuffers arg4, CallbackInfo ci) {
Iris.logger.info("Hardware information:");
Iris.logger.info("CPU: " + GlUtil.getCpuInfo());
Iris.logger.info("GPU: " + GlUtil.getRenderer() + " (Supports OpenGL " + GlUtil.getOpenGLVersion() + ")");
Iris.logger.info("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ")");
IRIS_LOGGER.info("Hardware information:");
IRIS_LOGGER.info("CPU: " + GlUtil.getCpuInfo());
IRIS_LOGGER.info("GPU: " + GlUtil.getRenderer() + " (Supports OpenGL " + GlUtil.getOpenGLVersion() + ")");
IRIS_LOGGER.info("OS: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ")");
}
@WrapWithCondition(method = "renderItemInHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderHandsWithItems(FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/player/LocalPlayer;I)V"))
@@ -11,6 +11,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@Mixin(Minecraft.class)
public class MixinMinecraft_PipelineManagement {
/**
@@ -52,7 +54,7 @@ public class MixinMinecraft_PipelineManagement {
@Inject(method = "updateLevelInEngines", at = @At("HEAD"))
private void iris$resetPipeline(@Nullable ClientLevel level, CallbackInfo ci) {
if (Iris.getCurrentDimension() != Iris.lastDimension) {
Iris.logger.info("Reloading pipeline on dimension change: " + Iris.lastDimension + " => " + Iris.getCurrentDimension());
IRIS_LOGGER.info("Reloading pipeline on dimension change: " + Iris.lastDimension + " => " + Iris.getCurrentDimension());
// Destroy pipelines when changing dimensions.
Iris.getPipelineManager().destroyPipeline();
@@ -50,6 +50,8 @@ import java.lang.invoke.MethodType;
import java.util.Map;
import java.util.Objects;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
//? if <1.21.2
@Mixin(ShaderInstance.class)
//? if >=1.21.2
@@ -127,7 +129,7 @@ public abstract class MixinShaderInstance implements ShaderInstanceInterface {
shouldSkip = shouldSkipList.computeIfAbsent(getClass(), x -> {
try {
MethodHandle iris$skipDraw = MethodHandles.lookup().findVirtual(x, "iris$skipDraw", MethodType.methodType(boolean.class));
Iris.logger.warn("Class " + x.getName() + " has opted out of being rendered with shaders.");
IRIS_LOGGER.warn("Class " + x.getName() + " has opted out of being rendered with shaders.");
return iris$skipDraw;
} catch (NoSuchMethodException | IllegalAccessException e) {
return NONE;
@@ -10,6 +10,8 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@Mixin(value = Window.class, priority = 1010)
public class MixinWindow {
@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwDefaultWindowHints()V"))
@@ -17,7 +19,7 @@ public class MixinWindow {
GLFW.glfwDefaultWindowHints();
if (Iris.getIrisConfig().areDebugOptionsEnabled()) {
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE);
Iris.logger.info("OpenGL debug context activated.");
IRIS_LOGGER.info("OpenGL debug context activated.");
}
}
}
@@ -11,6 +11,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@Mixin(LevelRenderer.class)
public class MixinDisableFabulousGraphics {
@Inject(method = "onResourceManagerReload", at = @At("HEAD"))
@@ -35,7 +37,7 @@ public class MixinDisableFabulousGraphics {
}
if (options.graphicsMode().get() == GraphicsStatus.FABULOUS) {
Iris.logger.warn("Fabulous mode is forcefully disabled if shaders are on");
IRIS_LOGGER.warn("Fabulous mode is forcefully disabled if shaders are on");
// Disable fabulous graphics when shaders are enabled.
options.graphicsMode().set(GraphicsStatus.FANCY);
}
@@ -16,6 +16,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
@Mixin(SpriteContents.class)
public class MixinSpriteContents implements SpriteContentsExtension {
@Unique
@@ -30,7 +32,7 @@ public class MixinSpriteContents implements SpriteContentsExtension {
try {
return (NativeImage[])(Object)generator.generateMipLevels((MCNativeImage[])(Object)nativeImages, mipLevel);
} catch (Exception e) {
Iris.logger.error("ERROR MIPMAPPING", e);
IRIS_LOGGER.error("ERROR MIPMAPPING", e);
}
}
}
@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Optional;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
@@ -61,7 +62,7 @@ public class CustomTextureManager {
try {
customTextureIds.put(samplerName, createCustomTexture(textureData));
} catch (IOException | ResourceLocationException e) {
Iris.logger.error("Unable to parse the image data for the custom texture on stage "
IRIS_LOGGER.error("Unable to parse the image data for the custom texture on stage "
+ textureStage + ", sampler " + samplerName, e);
}
});
@@ -73,7 +74,7 @@ public class CustomTextureManager {
try {
irisCustomTextures.put(name, createCustomTexture(texture));
} catch (IOException e) {
Iris.logger.error("Unable to parse the image data for the custom texture on sampler " + name, e);
IRIS_LOGGER.error("Unable to parse the image data for the custom texture on sampler " + name, e);
}
});
@@ -81,7 +82,7 @@ public class CustomTextureManager {
try {
return Optional.of(createCustomTexture(textureData));
} catch (IOException | ResourceLocationException e) {
Iris.logger.error("Unable to parse the image data for the custom noise texture", e);
IRIS_LOGGER.error("Unable to parse the image data for the custom noise texture", e);
return Optional.empty();
}
@@ -9,6 +9,7 @@ import java.util.function.Supplier;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableList;
@@ -430,7 +431,7 @@ public class IrisRenderingPipeline implements WorldRenderingPipeline, ShaderRend
}
watch.stop();
Iris.logger.info("Loaded shaders in {}", watch);
IRIS_LOGGER.info("Loaded shaders in {}", watch);
// We need to defer creation of the block state mappings, like Iris 1.8, because tags may not exist at launch time
blockIdsNeedPopulation = true;
@@ -6,6 +6,7 @@ import java.util.Optional;
import java.util.function.Function;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import net.irisshaders.iris.Iris;
import net.irisshaders.iris.shaderpack.materialmap.NamespacedId;
@@ -29,7 +30,7 @@ public class PipelineManager {
SystemTimeUniforms.COUNTER.reset();
SystemTimeUniforms.TIMER.reset();
Iris.logger.info("Creating pipeline for dimension {}", currentDimension);
IRIS_LOGGER.info("Creating pipeline for dimension {}", currentDimension);
pipeline = pipelineFactory.apply(currentDimension);
pipelinesPerDimension.put(currentDimension, pipeline);
@@ -76,7 +77,7 @@ public class PipelineManager {
*/
public void destroyPipeline() {
pipelinesPerDimension.forEach((dimensionId, pipeline) -> {
Iris.logger.info("Destroying pipeline {}", dimensionId);
IRIS_LOGGER.info("Destroying pipeline {}", dimensionId);
resetTextureState();
pipeline.destroy();
});
@@ -25,6 +25,7 @@ import java.util.function.Supplier;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
public class ShaderTransformationDiskCache {
@@ -61,12 +62,12 @@ public class ShaderTransformationDiskCache {
if(map != null && !map.isEmpty()) {
return map;
} else {
Iris.logger.error("Cache data is corrupt");
IRIS_LOGGER.error("Cache data is corrupt");
Files.deleteIfExists(path);
}
} catch(FileNotFoundException | NoSuchFileException ignored) {
} catch(IOException e) {
Iris.logger.error("Error loading transformed shader, will re-transform now", e);
IRIS_LOGGER.error("Error loading transformed shader, will re-transform now", e);
}
Map<PatchShaderType, String> results = transformFn.get();
@@ -77,7 +78,7 @@ public class ShaderTransformationDiskCache {
writer.write(new Gson().toJson(results, typeToken.getType()));
}
} catch(IOException e) {
Iris.logger.error("Error writing transformed shader to disk", e);
IRIS_LOGGER.error("Error writing transformed shader to disk", e);
}
return results;
@@ -19,6 +19,8 @@ import net.irisshaders.iris.shaderpack.texture.TextureStage;
import java.lang.reflect.Method;
import java.util.Map;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class TransformPatcherBridge {
private static final boolean USE_GLSL_TRANSFORMER;
@@ -35,7 +37,7 @@ public class TransformPatcherBridge {
}
if(useGlslTransformer && transform == null) {
Iris.logger.warn("glsl-transformer is requested, but is not available in this jar");
IRIS_LOGGER.warn("glsl-transformer is requested, but is not available in this jar");
useGlslTransformer = false;
}
@@ -7,6 +7,7 @@ import java.util.function.Consumer;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static com.mitchej123.glsm.RenderSystemService.RENDER_SYSTEM;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
import com.mojang.blaze3d.preprocessor.GlslPreprocessor;
@@ -246,7 +247,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
});
GLDebug.nameObject(KHRDebug.GL_SHADER, this.geometry.getId(), name.getPath() + "_geometry.gsh");
} catch (IOException e) {
Iris.logger.error("Failed to create shader program", e);
IRIS_LOGGER.error("Failed to create shader program", e);
}
});
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_tessControl.tcs")).ifPresent(tessControl -> {
@@ -260,7 +261,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
});
GLDebug.nameObject(KHRDebug.GL_SHADER, this.tessControl.getId(), name.getPath() + "_tessControl.tcs");
} catch (IOException e) {
Iris.logger.error("Failed to create shader program", e);
IRIS_LOGGER.error("Failed to create shader program", e);
}
});
factory.getResource(ResourceLocationUtil.make(name.getNamespace(), name.getPath() + "_tessEval.tes")).ifPresent(tessEval -> {
@@ -274,7 +275,7 @@ public class ExtendedShader extends ShaderInstance implements ShaderInstanceInte
});
GLDebug.nameObject(KHRDebug.GL_SHADER, this.tessEval.getId(), name.getPath() + "_tessEval.tes");
} catch (IOException e) {
Iris.logger.error("Failed to create shader program", e);
IRIS_LOGGER.error("Failed to create shader program", e);
}
});
}
@@ -29,6 +29,7 @@ import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.*;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.PlatformUtilService.PLATFORM_UTIL;
/**
@@ -102,7 +103,7 @@ public class IdMap {
try {
properties.load(propertiesReader);
} catch (IOException e) {
Iris.logger.error("Error loading " + name + " at " + shaderPath, e);
IRIS_LOGGER.error("Error loading " + name + " at " + shaderPath, e);
return Optional.empty();
}
@@ -124,11 +125,11 @@ public class IdMap {
// ID maps should be encoded in ISO_8859_1.
return Files.readString(shaderPath.resolve(name), StandardCharsets.ISO_8859_1);
} catch (NoSuchFileException e) {
Iris.logger.debug("An " + name + " file was not found in the current shaderpack");
IRIS_LOGGER.debug("An " + name + " file was not found in the current shaderpack");
return null;
} catch (IOException e) {
Iris.logger.error("An IOException occurred reading " + name + " from the current shaderpack", e);
IRIS_LOGGER.error("An IOException occurred reading " + name + " from the current shaderpack", e);
return null;
}
@@ -164,7 +165,7 @@ public class IdMap {
intId = Integer.parseInt(key.substring(keyPrefix.length()));
} catch (NumberFormatException e) {
// Not a valid property line
Iris.logger.warn("Failed to parse line in " + fileName + ": invalid key " + key);
IRIS_LOGGER.warn("Failed to parse line in " + fileName + ": invalid key " + key);
return;
}
@@ -172,7 +173,7 @@ public class IdMap {
for (String part : value.split("\\s+")) {
if (part.contains("=")) {
// Avoid tons of logspam for now
Iris.logger.warn("Failed to parse an ResourceLocation in " + fileName + " for the key " + key + ": state properties are currently not supported: " + part);
IRIS_LOGGER.warn("Failed to parse an ResourceLocation in " + fileName + " for the key " + key + ": state properties are currently not supported: " + part);
continue;
}
@@ -203,7 +204,7 @@ public class IdMap {
intId = Integer.parseInt(key.substring(keyPrefix.length()));
} catch (NumberFormatException e) {
// Not a valid property line
Iris.logger.warn("Failed to parse line in " + fileName + ": invalid key " + key);
IRIS_LOGGER.warn("Failed to parse line in " + fileName + ": invalid key " + key);
return;
}
@@ -218,7 +219,7 @@ public class IdMap {
try {
entries.add(BlockEntry.parse(part));
} catch (Exception e) {
Iris.logger.warn("Unexpected error while parsing an entry from " + fileName + " for the key " + key + ":", e);
IRIS_LOGGER.warn("Unexpected error while parsing an entry from " + fileName + " for the key " + key + ":", e);
}
}
@@ -254,7 +255,7 @@ public class IdMap {
BlockRenderType renderType = BlockRenderType.fromString(keyWithoutPrefix).orElse(null);
if (renderType == null) {
Iris.logger.warn("Failed to parse line in " + fileName + ": invalid block render type: " + key);
IRIS_LOGGER.warn("Failed to parse line in " + fileName + ": invalid block render type: " + key);
return;
}
@@ -11,6 +11,8 @@ import java.nio.file.Path;
import java.util.*;
import java.util.stream.Stream;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class LanguageMap {
private final Map<String, Map<String, String>> translationMaps;
@@ -46,7 +48,7 @@ public class LanguageMap {
try (InputStreamReader isr = new InputStreamReader(Files.newInputStream(path), StandardCharsets.UTF_8)) {
properties.load(isr);
} catch (IOException e) {
Iris.logger.error("Failed to parse shader pack language file " + path, e);
IRIS_LOGGER.error("Failed to parse shader pack language file " + path, e);
}
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
@@ -18,6 +18,7 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates, boolean isTag) {
@@ -90,8 +91,8 @@ public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates
String[] propertyParts = splitStates[index].split("=");
if (propertyParts.length != 2) {
Iris.logger.warn("Warning: the block ID map entry \"" + entry + "\" could not be fully parsed:");
Iris.logger.warn("- Block state property filters must be of the form \"key=value\", but "
IRIS_LOGGER.warn("Warning: the block ID map entry \"" + entry + "\" could not be fully parsed:");
IRIS_LOGGER.warn("- Block state property filters must be of the form \"key=value\", but "
+ splitStates[index] + " is not of that form!");
// Continue and ignore the invalid entry.
@@ -117,7 +118,7 @@ public record BlockEntry(NamespacedId id, Map<String, String> propertyPredicates
*///?}
if (!tagOpt.isPresent()) {
Iris.logger.warn("Failed to find the block tag {}", tag.location());
IRIS_LOGGER.warn("Failed to find the block tag {}", tag.location());
return Collections.emptyList();
}
@@ -19,6 +19,8 @@ import org.embeddedt.embeddium.impl.util.ResourceLocationUtil;
import java.lang.reflect.Method;
import java.util.*;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class BlockMaterialMapping {
public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
Object2IntMap<BlockState> blockStateIds = new Object2IntOpenHashMap<>();
@@ -104,8 +106,8 @@ public class BlockMaterialMapping {
}
if (isAppearanceChangingBlock(block)) {
Iris.logger.warn("Warning while parsing the block ID map entry for \"" + "block." + intId + "\":");
Iris.logger.warn("- The block {} can change appearance, skipping!", resourceLocation);
IRIS_LOGGER.warn("Warning while parsing the block ID map entry for \"" + "block." + intId + "\":");
IRIS_LOGGER.warn("- The block {} can change appearance, skipping!", resourceLocation);
return;
}
@@ -133,8 +135,8 @@ public class BlockMaterialMapping {
Property<?> property = stateManager.getProperty(key);
if (property == null) {
Iris.logger.warn("Error while parsing the block ID map entry for \"" + "block." + intId + "\":");
Iris.logger.warn("- The block " + resourceLocation + " has no property with the name " + key + ", ignoring!");
IRIS_LOGGER.warn("Error while parsing the block ID map entry for \"" + "block." + intId + "\":");
IRIS_LOGGER.warn("- The block " + resourceLocation + " has no property with the name " + key + ", ignoring!");
return;
}
@@ -32,6 +32,8 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ModelTextureAnalyzer {
/**
* Whether or not to use multithreading for texture analysis. Disabled by default as this appears to dramatically
@@ -184,7 +186,7 @@ public class ModelTextureAnalyzer {
Stopwatch watch = Stopwatch.createStarted();
var result = runAnalysis(blockStateIds).join();
watch.stop();
Iris.logger.info("Analyzed texture materials in {}", watch);
IRIS_LOGGER.info("Analyzed texture materials in {}", watch);
return result;
}
@@ -305,7 +307,7 @@ public class ModelTextureAnalyzer {
try {
this.tasks.forEach(this::voteOnStates);
} catch(Throwable e) {
Iris.logger.error("Exception encountered during texture analysis", e);
IRIS_LOGGER.error("Exception encountered during texture analysis", e);
} finally {
this.completableFuture.complete(null);
}
@@ -13,6 +13,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class OptionMenuContainer {
public final OptionMenuElementScreen mainScreen;
public final Map<String, OptionMenuElementScreen> subScreens = new HashMap<>();
@@ -58,7 +60,7 @@ public class OptionMenuContainer {
}
}
} catch (IllegalArgumentException error) {
Iris.logger.warn(error);
IRIS_LOGGER.warn(error);
elementsToInsert.add(OptionMenuElement.EMPTY);
}
@@ -8,6 +8,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class OptionMenuElementScreen {
public final List<OptionMenuElement> elements = new ArrayList<>();
@@ -34,7 +36,7 @@ public class OptionMenuElementScreen {
}
}
} catch (IllegalArgumentException error) {
Iris.logger.warn(error.getMessage());
IRIS_LOGGER.warn(error.getMessage());
this.elements.add(OptionMenuElement.EMPTY);
}
@@ -5,16 +5,18 @@ import net.irisshaders.iris.shaderpack.programs.ComputeSource;
import org.joml.Vector2f;
import org.joml.Vector3i;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ComputeDirectiveParser {
public static void setComputeWorkGroups(ComputeSource source, ConstDirectiveParser.ConstDirective directive) {
if (!directive.getValue().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 = directive.getValue().substring("ivec3".length()).trim();
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);
@@ -26,7 +28,7 @@ public class ComputeDirectiveParser {
}
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);
}
@@ -36,19 +38,19 @@ public class ComputeDirectiveParser {
Integer.parseInt(parts[1]),
Integer.parseInt(parts[2])));
} catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e);
IRIS_LOGGER.error("Failed to process " + directive, e);
}
}
public static void setComputeWorkGroupsRelative(ComputeSource source, ConstDirectiveParser.ConstDirective directive) {
if (!directive.getValue().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 = directive.getValue().substring("vec2".length()).trim();
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);
@@ -60,7 +62,7 @@ public class ComputeDirectiveParser {
}
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);
}
@@ -70,7 +72,7 @@ public class ComputeDirectiveParser {
Float.parseFloat(parts[1])
));
} catch (NumberFormatException e) {
Iris.logger.error("Failed to process " + directive, e);
IRIS_LOGGER.error("Failed to process " + directive, e);
}
}
}
@@ -20,6 +20,8 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ProgramSet implements ProgramSetInterface {
private final PackDirectives packDirectives;
@@ -202,7 +204,7 @@ public class ProgramSet implements ProgramSetInterface {
if (vertexSource == null && fragmentSource != null) {
// This is for really old packs that do not use a vertex shader.
Iris.logger.warn("Found a program (" + program + ") that has a fragment shader but no vertex shader? This is very legacy behavior and might not work right.");
IRIS_LOGGER.warn("Found a program (" + program + ") that has a fragment shader but no vertex shader? This is very legacy behavior and might not work right.");
vertexSource = """
#version 120
@@ -364,7 +366,7 @@ public class ProgramSet implements ProgramSetInterface {
}
packDirectives.getRenderTargetDirectives().getRenderTargetSettings().forEach((index, settings) ->
Iris.logger.debug("Render target settings for colortex" + index + ": " + settings));
IRIS_LOGGER.debug("Render target settings for colortex" + index + ": " + settings));
}
public Optional<ProgramSource> getShadow() {
@@ -289,7 +289,7 @@ public class ShadowRenderTargets {
if (drawBuffers[i] >= getRenderTargetCount()) {
// If a shader is using an invalid drawbuffer, they're most likely relying on the Optifine behavior of ignoring DRAWBUFFERS in the shadow pass.
// We need to fix this for them, since apparantly this is a common issue.
// Iris.logger.warn("Invalid framebuffer was attempted to be created! Forcing a framebuffer with DRAWBUFFERS 01 for shadow.");
// IRIS_LOGGER.warn("Invalid framebuffer was attempted to be created! Forcing a framebuffer with DRAWBUFFERS 01 for shadow.");
ownedFramebuffers.remove(framebuffer);
framebuffer.destroy();
return createColorFramebuffer(stageWritesToMain, new int[]{0, 1});
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
@@ -90,7 +91,7 @@ public class PBRAtlasTexture extends AbstractTexture implements PBRDumpable {
writer.write(String.format(Locale.ROOT, "%s\tx=%d\ty=%d\tw=%d\th=%d%n", entry.getKey(), sprite.getX(), sprite.getY(), sprite.contents().width(), sprite.contents().height()));
}
} catch (IOException e) {
Iris.logger.warn("Failed to write file {}", path, e);
IRIS_LOGGER.warn("Failed to write file {}", path, e);
}
}
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.nio.file.Path;
import static com.mitchej123.glsm.GLStateManagerService.GL_STATE_MANAGER;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@@ -59,7 +60,7 @@ public class PBRTextureManager {
try {
dumpable.dumpContents(id, path);
} catch (IOException e) {
Iris.logger.error("Failed to dump texture {}", id, e);
IRIS_LOGGER.error("Failed to dump texture {}", id, e);
}
}
@@ -117,7 +118,7 @@ public class PBRTextureManager {
loader.load(texture, Minecraft.getInstance().getResourceManager(), consumer);
return consumer.toHolder();
} catch (Exception e) {
Iris.logger.debug("Failed to load PBR textures for texture " + id, e);
IRIS_LOGGER.debug("Failed to load PBR textures for texture " + id, e);
} finally {
GL_STATE_MANAGER.bindTexture(previousTextureBinding);
}
@@ -32,6 +32,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
import static org.embeddedt.embeddium.compat.mc.MinecraftVersionShimService.MINECRAFT_SHIM;
public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
@@ -99,7 +100,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
try {
animationMetadata = resource.metadata();
} catch (Exception e) {
Iris.logger.error("Unable to parse metadata from {}", pbrImageLocation, e);
IRIS_LOGGER.error("Unable to parse metadata from {}", pbrImageLocation, e);
return null;
}
@@ -107,7 +108,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
try (InputStream stream = resource.open()) {
nativeImage = NativeImage.read(stream);
} catch (IOException e) {
Iris.logger.error("Using missing texture, unable to load {}", pbrImageLocation, e);
IRIS_LOGGER.error("Using missing texture, unable to load {}", pbrImageLocation, e);
return null;
}
@@ -118,7 +119,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
int frameWidth = frameSize.width();
int frameHeight = frameSize.height();
if (!Mth.isMultipleOf(imageWidth, frameWidth) || !Mth.isMultipleOf(imageHeight, frameHeight)) {
Iris.logger.error("Image {} size {},{} is not multiple of frame size {},{}", pbrImageLocation, imageWidth, imageHeight, frameWidth, frameHeight);
IRIS_LOGGER.error("Image {} size {},{} is not multiple of frame size {},{}", pbrImageLocation, imageWidth, imageHeight, frameWidth, frameHeight);
nativeImage.close();
return null;
}
@@ -156,7 +157,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureAtlas> {
}
}
} catch (Exception e) {
Iris.logger.error("Something bad happened trying to load PBR texture " + spriteName.getPath() + pbrType.getSuffix() + "!", e);
IRIS_LOGGER.error("Something bad happened trying to load PBR texture " + spriteName.getPath() + pbrType.getSuffix() + "!", e);
throw e;
}
}
@@ -14,8 +14,8 @@ public class BuiltinReplacementUniforms {
public static void addBuiltinReplacementUniforms(UniformHolder uniforms) {
uniforms.uniformMatrix(UniformUpdateFrequency.ONCE, "iris_LightmapTextureMatrix", () -> {
//Iris.logger.warn("A shader appears to require the lightmap texture matrix even after transformations have occurred");
//Iris.logger.warn("Iris handles this correctly but it indicates that the shader is doing weird things with lightmap coordinates");
//IRIS_LOGGER.warn("A shader appears to require the lightmap texture matrix even after transformations have occurred");
//IRIS_LOGGER.warn("Iris handles this correctly but it indicates that the shader is doing weird things with lightmap coordinates");
return lightmapTextureMatrix;
});
@@ -16,6 +16,8 @@ import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
import static net.irisshaders.iris.IrisLogging.IRIS_LOGGER;
public class ShaderOverrideEngine {
private static final Map<String, Supplier<ShaderInstance>> iris$overrides = new Object2ObjectOpenHashMap<>();
private static final Set<String> missingOverrides = new ObjectOpenHashSet<>();
@@ -41,7 +43,7 @@ public class ShaderOverrideEngine {
if (overrideSupplier != null) {
return overrideSupplier.get();
} else if (missingOverrides.add(name)) {
Iris.logger.warn("Missing shader override for '{}'", name);
IRIS_LOGGER.warn("Missing shader override for '{}'", name);
}
return null;