diff --git a/build.gradle.kts b/build.gradle.kts index c88694fe94..615d3abf53 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,10 +8,10 @@ val MINECRAFT_VERSION by extra { "1.21.1" } val NEOFORGE_VERSION by extra { "21.1.19" } val FABRIC_LOADER_VERSION by extra { "0.16.0" } val FABRIC_API_VERSION by extra { "0.102.0+1.21.1" } -val SODIUM_FILE by extra { "sodium-LOADER-0.6.0-snapshot+mc1.21-local.jar" } +val SODIUM_FILE by extra { "sodium-LOADER-0.6.0-beta.2+mc1.21.1.jar" } // https://semver.org/ -val MOD_VERSION by extra { "1.8.0-beta.2" } +val MOD_VERSION by extra { "1.8.0-beta.4" } allprojects { apply(plugin = "java") diff --git a/common/src/main/java/net/irisshaders/iris/Iris.java b/common/src/main/java/net/irisshaders/iris/Iris.java index 84443e5506..15f4e0c5e4 100644 --- a/common/src/main/java/net/irisshaders/iris/Iris.java +++ b/common/src/main/java/net/irisshaders/iris/Iris.java @@ -46,6 +46,7 @@ import net.minecraft.network.chat.HoverEvent; import org.jetbrains.annotations.NotNull; import org.lwjgl.glfw.GLFW; +import org.lwjgl.system.Configuration; import java.io.IOException; import java.io.InputStream; @@ -100,6 +101,7 @@ public class Iris { private static String IRIS_VERSION; private static UpdateChecker updateChecker; private static boolean fallback; + private static boolean loadShaderPackWhenPossible; static { if (!BuildConfig.ACTIVATE_RENDERDOC && IrisPlatformHelpers.getInstance().isDevelopmentEnvironment() && System.getProperty("user.name").contains("ims") && Util.getPlatform() == Util.OS.LINUX) { @@ -124,7 +126,9 @@ public static void onRenderSystemInit() { VertexSerializerRegistry.instance().registerSerializer(DefaultVertexFormat.NEW_ENTITY, IrisVertexFormats.ENTITY, new ModelToEntityVertexSerializer()); // Only load the shader pack when we can access OpenGL - loadShaderpack(); + if (!IrisPlatformHelpers.getInstance().isModLoaded("distanthorizons")) { + loadShaderpack(); + } } public static void duringRenderSystemInit() { @@ -149,6 +153,11 @@ public static void onLoadingComplete() { } public static void handleKeybinds(Minecraft minecraft) { + if (loadShaderPackWhenPossible) { + loadShaderPackWhenPossible = false; + Iris.loadShaderpack(); + } + if (reloadKeybind.consumeClick()) { try { reload(); @@ -720,7 +729,11 @@ public static boolean isPackInUseQuick() { return getPipelineManager().getPipelineNullable() instanceof IrisRenderingPipeline; } - /** + public static void loadShaderpackWhenPossible() { + loadShaderPackWhenPossible = true; + } + + /** * Called very early on in Minecraft initialization. At this point we *cannot* safely access OpenGL, but we can do * some very basic setup, config loading, and environment checks. * diff --git a/common/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java b/common/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java index 9cdec9f665..fe4479796d 100644 --- a/common/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java +++ b/common/src/main/java/net/irisshaders/iris/compat/dh/LodRendererEvents.java @@ -55,6 +55,8 @@ public static void setupEventHandlers() { public void afterDistantHorizonsInit(DhApiEventParam event) { Iris.logger.info("DH Ready, binding Iris event handlers..."); + Iris.loadShaderpackWhenPossible(); + setupSetDeferredBeforeRenderingEvent(); setupReconnectDepthTextureEvent(); setupGenericEvent(); diff --git a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinCloudRenderer.java b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinCloudRenderer.java index 75df24746b..35a461d04d 100644 --- a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinCloudRenderer.java +++ b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinCloudRenderer.java @@ -78,7 +78,7 @@ private static VertexFormat rebuild(VertexFormat p_350837_) { return IrisApi.getInstance().isShaderPackInUse() ? IrisVertexFormats.CLOUDS : p_350837_; } - @ModifyArg(remap = false, method = "emitCellGeometry3D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3) + @ModifyArg(method = "emitCellGeometry3D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3) private static VertexFormat modifyArgIris(VertexFormat vertexFormatDescription) { if (IrisApi.getInstance().isShaderPackInUse()) { return IrisVertexFormats.CLOUDS; @@ -92,7 +92,7 @@ private static int allocateNewSize2D(int size) { return IrisApi.getInstance().isShaderPackInUse() ? 80 : size; } - @ModifyArg(remap = false, method = "emitCellGeometry2D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3) + @ModifyArg(method = "emitCellGeometry2D", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter;push(Lorg/lwjgl/system/MemoryStack;JILcom/mojang/blaze3d/vertex/VertexFormat;)V"), index = 3) private static VertexFormat modifyArgIris2D(VertexFormat vertexFormatDescription) { if (IrisApi.getInstance().isShaderPackInUse()) { return IrisVertexFormats.CLOUDS; diff --git a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinSodiumWorldRenderer.java b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinSodiumWorldRenderer.java index 152d38f760..734dec167e 100644 --- a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinSodiumWorldRenderer.java +++ b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinSodiumWorldRenderer.java @@ -1,5 +1,6 @@ package net.irisshaders.iris.compat.sodium.mixin; +import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; @@ -8,6 +9,7 @@ import net.irisshaders.iris.shadows.ShadowRenderingState; import net.irisshaders.iris.uniforms.CapturedRenderingState; import net.minecraft.client.Minecraft; +import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderBuffers; import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; @@ -67,7 +69,7 @@ public class MixinSodiumWorldRenderer { ShadowRenderingState.setBlockEntityRenderFunction((shadowRenderer, bufferSource, modelView, camera, cameraX, cameraY, cameraZ, tickDelta, hasEntityFrustum, lightsOnly) -> { renderLightsOnly = lightsOnly; - SodiumWorldRenderer.instance().renderBlockEntities(modelView, bufferSource, ((LevelRendererAccessor) Minecraft.getInstance().levelRenderer).getDestructionProgress(), camera, tickDelta); + SodiumWorldRenderer.instance().renderBlockEntities(modelView, bufferSource, ((LevelRendererAccessor) Minecraft.getInstance().levelRenderer).getDestructionProgress(), camera, tickDelta, null); int finalBeList = beList; @@ -78,7 +80,7 @@ public class MixinSodiumWorldRenderer { } @Inject(method = "renderBlockEntity", at = @At("HEAD"), cancellable = true) - private static void checkRenderShadow(PoseStack matrices, RenderBuffers bufferBuilders, Long2ObjectMap> blockBreakingProgressions, float tickDelta, MultiBufferSource.BufferSource immediate, double x, double y, double z, BlockEntityRenderDispatcher dispatcher, BlockEntity entity, CallbackInfo ci) { + private static void checkRenderShadow(PoseStack matrices, RenderBuffers bufferBuilders, Long2ObjectMap> blockBreakingProgressions, float tickDelta, MultiBufferSource.BufferSource immediate, double x, double y, double z, BlockEntityRenderDispatcher dispatcher, BlockEntity entity, LocalPlayer player, LocalBooleanRef isGlowing, CallbackInfo ci) { if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) { if (renderLightsOnly && entity.getBlockState().getLightEmission() == 0) { ci.cancel(); diff --git a/common/src/main/java/net/irisshaders/iris/helpers/StringPair.java b/common/src/main/java/net/irisshaders/iris/helpers/StringPair.java index ce8c248c68..d173f12563 100644 --- a/common/src/main/java/net/irisshaders/iris/helpers/StringPair.java +++ b/common/src/main/java/net/irisshaders/iris/helpers/StringPair.java @@ -8,20 +8,4 @@ * An absurdly simple class for storing pairs of strings because Java lacks pair / tuple types. */ public record StringPair(String key, String value) { - public StringPair(@NotNull String key, @NotNull String value) { - this.key = Objects.requireNonNull(key); - this.value = Objects.requireNonNull(value); - } - - @Override - @NotNull - public String key() { - return key; - } - - @Override - @NotNull - public String value() { - return value; - } } diff --git a/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java b/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java index c159092b57..1e34241e62 100644 --- a/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java +++ b/common/src/main/java/net/irisshaders/iris/pipeline/programs/SodiumPrograms.java @@ -159,8 +159,7 @@ private GlProgram buildProgram(GlProgram.Builder builder, Supplier> flipState, boolean containsTessellation) { return builder - .bindAttribute("a_PositionHi", ChunkShaderBindingPoints.ATTRIBUTE_POSITION_HI) - .bindAttribute("a_PositionLo", ChunkShaderBindingPoints.ATTRIBUTE_POSITION_LO) + .bindAttribute("a_Position", ChunkShaderBindingPoints.ATTRIBUTE_POSITION) .bindAttribute("a_Color", ChunkShaderBindingPoints.ATTRIBUTE_COLOR) .bindAttribute("a_TexCoord", ChunkShaderBindingPoints.ATTRIBUTE_TEXTURE) .bindAttribute("a_LightAndData", ChunkShaderBindingPoints.ATTRIBUTE_LIGHT_MATERIAL_INDEX) diff --git a/common/src/main/java/net/irisshaders/iris/pipeline/transform/transformer/SodiumTransformer.java b/common/src/main/java/net/irisshaders/iris/pipeline/transform/transformer/SodiumTransformer.java index 9d01a533df..99af18605f 100644 --- a/common/src/main/java/net/irisshaders/iris/pipeline/transform/transformer/SodiumTransformer.java +++ b/common/src/main/java/net/irisshaders/iris/pipeline/transform/transformer/SodiumTransformer.java @@ -133,9 +133,9 @@ public static void injectVertInit( "uint _draw_id;", "const uint MATERIAL_USE_MIP_OFFSET = 0u;", """ - uvec3 _deinterleave_u20x3(uint packed_hi, uint packed_lo) { - uvec3 hi = (uvec3(packed_hi) >> uvec3(0u, 10u, 20u)) & 0x3FFu; - uvec3 lo = (uvec3(packed_lo) >> uvec3(0u, 10u, 20u)) & 0x3FFu; + uvec3 _deinterleave_u20x3(uvec2 data) { + uvec3 hi = (uvec3(data.x) >> uvec3(0u, 10u, 20u)) & 0x3FFu; + uvec3 lo = (uvec3(data.y) >> uvec3(0u, 10u, 20u)) & 0x3FFu; return (hi << 10u) | lo; } @@ -154,7 +154,7 @@ vec2 _get_texcoord_bias() { " return ((material >> MATERIAL_USE_MIP_OFFSET) & 1u) != 0u ? 0.0f : -4.0f;\n" + "}", "void _vert_init() {" + - "_vert_position = ((_deinterleave_u20x3(a_PositionHi, a_PositionLo) * VERTEX_SCALE) + VERTEX_OFFSET);" + + "_vert_position = ((_deinterleave_u20x3(a_Position) * VERTEX_SCALE) + VERTEX_OFFSET);" + "_vert_tex_diffuse_coord = _get_texcoord() + _get_texcoord_bias();" + "_vert_tex_light_coord = vec2(a_LightAndData.xy);" + "_vert_color = a_Color;" + @@ -167,8 +167,7 @@ vec2 _get_texcoord_bias() { "vec3 _get_draw_translation(uint pos) {\n" + " return _get_relative_chunk_coord(pos) * vec3(16.0f);\n" + "}\n"); - addIfNotExists(root, t, tree, "a_PositionHi", Type.UINT32, StorageQualifier.StorageType.IN); - addIfNotExists(root, t, tree, "a_PositionLo", Type.UINT32, StorageQualifier.StorageType.IN); + addIfNotExists(root, t, tree, "a_Position", Type.U32VEC2, StorageQualifier.StorageType.IN); addIfNotExists(root, t, tree, "a_TexCoord", Type.U32VEC2, StorageQualifier.StorageType.IN); addIfNotExists(root, t, tree, "a_Color", Type.F32VEC4, StorageQualifier.StorageType.IN); addIfNotExists(root, t, tree, "a_LightAndData", Type.U32VEC4, StorageQualifier.StorageType.IN); diff --git a/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/FormatAnalyzer.java b/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/FormatAnalyzer.java index 4973c1fcce..2535125152 100644 --- a/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/FormatAnalyzer.java +++ b/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/FormatAnalyzer.java @@ -77,8 +77,7 @@ public static ChunkVertexType createFormat(boolean blockId, boolean normal, bool } GlVertexFormat.Builder VERTEX_FORMAT = GlVertexFormat.builder(offset) - .addElement(DefaultChunkMeshAttributes.POSITION_HI, ChunkShaderBindingPoints.ATTRIBUTE_POSITION_HI, 0) - .addElement(DefaultChunkMeshAttributes.POSITION_LO, ChunkShaderBindingPoints.ATTRIBUTE_POSITION_LO, 4) + .addElement(DefaultChunkMeshAttributes.POSITION, ChunkShaderBindingPoints.ATTRIBUTE_POSITION, 0) .addElement(DefaultChunkMeshAttributes.COLOR, ChunkShaderBindingPoints.ATTRIBUTE_COLOR, 8) .addElement(DefaultChunkMeshAttributes.TEXTURE, ChunkShaderBindingPoints.ATTRIBUTE_TEXTURE, 12) .addElement(DefaultChunkMeshAttributes.LIGHT_MATERIAL_INDEX, ChunkShaderBindingPoints.ATTRIBUTE_LIGHT_MATERIAL_INDEX, 16); diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 905cffab98..9c53520c7c 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -82,7 +82,6 @@ loom { configName = "Fabric Client" ideConfigGenerated(true) runDir("run") - environmentVariable("LD_PRELOAD", "/usr/lib/librenderdoc.so") } named("server") { server()