From c6c7b94b53f3bae74ffa9972a05476e54d302028 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sun, 25 Aug 2024 09:20:01 -0700 Subject: [PATCH] Upgrade Sodium and fix DH --- build.gradle.kts | 2 +- .../main/java/net/irisshaders/iris/Iris.java | 8 ++-- .../sodium/mixin/MixinBlockRenderer.java | 42 ++++++++++++++++ .../sodium/mixin/MixinCloudRenderer.java | 13 +++-- .../mixin/MixinSodiumWorldRenderer.java | 26 +++++++++- .../CommonVertexAttributeInterface.java | 14 ------ .../entity/MixinCommonVertexAttribute.java | 48 ------------------- .../iris/mixin/MixinItemBlockRenderTypes.java | 9 ++-- .../pipeline/VanillaRenderingPipeline.java | 2 +- .../materialmap/BlockMaterialMapping.java | 3 ++ .../materialmap/WorldRenderingSettings.java | 1 - .../iris/vertices/sodium/CloudVertex.java | 6 --- .../EntityToTerrainVertexSerializer.java | 12 ++--- .../sodium/IrisCommonVertexAttributes.java | 7 --- .../sodium/ModelToEntityVertexSerializer.java | 12 ++--- .../sodium/terrain/XHFPTerrainVertex.java | 4 +- .../resources/mixins.iris.compat.sodium.json | 3 +- fabric/src/main/resources/fabric.mod.json | 2 +- .../forge/MixinItemBlockRenderTypes.java | 9 ++-- 19 files changed, 103 insertions(+), 120 deletions(-) create mode 100644 common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java delete mode 100644 common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/CommonVertexAttributeInterface.java delete mode 100644 common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/MixinCommonVertexAttribute.java delete mode 100644 common/src/main/java/net/irisshaders/iris/vertices/sodium/IrisCommonVertexAttributes.java diff --git a/build.gradle.kts b/build.gradle.kts index c012c0fbae..c88694fe94 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ 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-beta.1+mc1.21.jar" } +val SODIUM_FILE by extra { "sodium-LOADER-0.6.0-snapshot+mc1.21-local.jar" } // https://semver.org/ val MOD_VERSION by extra { "1.8.0-beta.2" } diff --git a/common/src/main/java/net/irisshaders/iris/Iris.java b/common/src/main/java/net/irisshaders/iris/Iris.java index 8d0c811a56..b7027c99e5 100644 --- a/common/src/main/java/net/irisshaders/iris/Iris.java +++ b/common/src/main/java/net/irisshaders/iris/Iris.java @@ -117,10 +117,10 @@ public static void onRenderSystemInit() { PBRTextureManager.INSTANCE.init(); - VertexSerializerRegistry.instance().registerSerializer(VertexFormatRegistry.instance().get(DefaultVertexFormat.NEW_ENTITY), VertexFormatRegistry.instance().get(IrisVertexFormats.TERRAIN), new EntityToTerrainVertexSerializer()); - VertexSerializerRegistry.instance().registerSerializer(VertexFormatRegistry.instance().get(IrisVertexFormats.ENTITY), VertexFormatRegistry.instance().get(IrisVertexFormats.TERRAIN), new IrisEntityToTerrainVertexSerializer()); - VertexSerializerRegistry.instance().registerSerializer(VertexFormatRegistry.instance().get(DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP), VertexFormatRegistry.instance().get(IrisVertexFormats.GLYPH), new GlyphExtVertexSerializer()); - VertexSerializerRegistry.instance().registerSerializer(VertexFormatRegistry.instance().get(DefaultVertexFormat.NEW_ENTITY), VertexFormatRegistry.instance().get(IrisVertexFormats.ENTITY), new ModelToEntityVertexSerializer()); + VertexSerializerRegistry.instance().registerSerializer(DefaultVertexFormat.NEW_ENTITY, IrisVertexFormats.TERRAIN, new EntityToTerrainVertexSerializer()); + VertexSerializerRegistry.instance().registerSerializer(IrisVertexFormats.ENTITY, IrisVertexFormats.TERRAIN, new IrisEntityToTerrainVertexSerializer()); + VertexSerializerRegistry.instance().registerSerializer(DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP, IrisVertexFormats.GLYPH, new GlyphExtVertexSerializer()); + VertexSerializerRegistry.instance().registerSerializer(DefaultVertexFormat.NEW_ENTITY, IrisVertexFormats.ENTITY, new ModelToEntityVertexSerializer()); // Only load the shader pack when we can access OpenGL loadShaderpack(); diff --git a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java new file mode 100644 index 0000000000..4909ff8fdb --- /dev/null +++ b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/MixinBlockRenderer.java @@ -0,0 +1,42 @@ +package net.irisshaders.iris.compat.sodium.mixin; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; +import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; +import net.irisshaders.iris.shaderpack.materialmap.WorldRenderingSettings; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(BlockRenderer.class) +public class MixinBlockRenderer { + @Unique + private boolean hasOverride; + + @Inject(method = "renderModel", at = @At("HEAD")) + private void iris$renderModelHead(BakedModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) { + if (WorldRenderingSettings.INSTANCE.getBlockTypeIds().containsKey(state.getBlock())) { + hasOverride = true; + } + } + + @Inject(method = "renderModel", at = @At("TAIL")) + private void iris$renderModelTail(BakedModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) { + hasOverride = false; + } + + @WrapOperation(method = "bufferQuad", at = @At(value = "INVOKE", target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer;attemptPassDowngrade(Lnet/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableQuadViewImpl;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;)Lnet/caffeinemc/mods/sodium/client/render/chunk/terrain/TerrainRenderPass;")) + private TerrainRenderPass iris$skipPassDowngrade(BlockRenderer instance, MutableQuadViewImpl mutableQuadView, TextureAtlasSprite quad, TerrainRenderPass sprite, Operation original) { + if (hasOverride) return null; + + return original.call(instance, mutableQuadView, quad, sprite); + } +} 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 6600c057fa..75df24746b 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 @@ -4,7 +4,6 @@ import com.mojang.blaze3d.vertex.VertexFormat; import net.caffeinemc.mods.sodium.api.util.NormI8; import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription; import net.caffeinemc.mods.sodium.api.vertex.format.common.ColorVertex; import net.caffeinemc.mods.sodium.client.render.immediate.CloudRenderer; import net.irisshaders.iris.Iris; @@ -79,10 +78,10 @@ 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;JILnet/caffeinemc/mods/sodium/api/vertex/format/VertexFormatDescription;)V"), index = 3) - private static VertexFormatDescription modifyArgIris(VertexFormatDescription vertexFormatDescription) { + @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) + private static VertexFormat modifyArgIris(VertexFormat vertexFormatDescription) { if (IrisApi.getInstance().isShaderPackInUse()) { - return CloudVertex.FORMAT; + return IrisVertexFormats.CLOUDS; } else { return ColorVertex.FORMAT; } @@ -93,10 +92,10 @@ 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;JILnet/caffeinemc/mods/sodium/api/vertex/format/VertexFormatDescription;)V"), index = 3) - private static VertexFormatDescription modifyArgIris2D(VertexFormatDescription vertexFormatDescription) { + @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) + private static VertexFormat modifyArgIris2D(VertexFormat vertexFormatDescription) { if (IrisApi.getInstance().isShaderPackInUse()) { - return CloudVertex.FORMAT; + return IrisVertexFormats.CLOUDS; } else { return ColorVertex.FORMAT; } 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 da24ab1d15..152d38f760 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 @@ -6,6 +6,7 @@ import net.caffeinemc.mods.sodium.client.render.chunk.RenderSectionManager; import net.irisshaders.iris.mixin.LevelRendererAccessor; import net.irisshaders.iris.shadows.ShadowRenderingState; +import net.irisshaders.iris.uniforms.CapturedRenderingState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderBuffers; @@ -23,14 +24,35 @@ @Mixin(SodiumWorldRenderer.class) public class MixinSodiumWorldRenderer { + @Unique + private float lastSunAngle; + @Redirect(method = "setupTerrain", remap = false, at = @At(value = "INVOKE", - target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager;needsUpdate()Z", + target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager;needsUpdate()Z", ordinal = 0, remap = false)) private boolean iris$forceChunkGraphRebuildInShadowPass(RenderSectionManager instance) { + if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) { + float sunAngle = Minecraft.getInstance().level.getSunAngle(CapturedRenderingState.INSTANCE.getTickDelta()); + if (lastSunAngle != sunAngle) { + lastSunAngle = sunAngle; + return true; + } + + return instance.needsUpdate(); + } else { + return instance.needsUpdate(); + } + } + + @Redirect(method = "setupTerrain", remap = false, + at = @At(value = "INVOKE", + target = "Lnet/caffeinemc/mods/sodium/client/render/chunk/RenderSectionManager;needsUpdate()Z", ordinal = 1, + remap = false)) + private boolean iris$forceEndGraphRebuild(RenderSectionManager instance) { if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) { // TODO: Detect when the sun/moon isn't moving - return true; + return false; } else { return instance.needsUpdate(); } diff --git a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/CommonVertexAttributeInterface.java b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/CommonVertexAttributeInterface.java deleted file mode 100644 index 3c613f0421..0000000000 --- a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/CommonVertexAttributeInterface.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.irisshaders.iris.compat.sodium.mixin.entity; - -import com.mojang.blaze3d.vertex.VertexFormatElement; -import net.caffeinemc.mods.sodium.api.vertex.attributes.CommonVertexAttribute; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(CommonVertexAttribute.class) -public interface CommonVertexAttributeInterface { - @Invoker(value = "") - static CommonVertexAttribute createAttribute(String name, int ordinal, VertexFormatElement element) { - throw new AssertionError(); - } -} diff --git a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/MixinCommonVertexAttribute.java b/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/MixinCommonVertexAttribute.java deleted file mode 100644 index c5347fb0d9..0000000000 --- a/common/src/main/java/net/irisshaders/iris/compat/sodium/mixin/entity/MixinCommonVertexAttribute.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.irisshaders.iris.compat.sodium.mixin.entity; - -import net.caffeinemc.mods.sodium.api.vertex.attributes.CommonVertexAttribute; -import net.irisshaders.iris.vertices.IrisVertexFormats; -import net.irisshaders.iris.vertices.sodium.IrisCommonVertexAttributes; -import org.apache.commons.lang3.ArrayUtils; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(CommonVertexAttribute.class) -public class MixinCommonVertexAttribute { - @Mutable - @Shadow(remap = false) - @Final - public static int COUNT; - - @SuppressWarnings("target") - @Shadow(remap = false) - @Final - @Mutable - private static CommonVertexAttribute[] $VALUES; - - static { - int baseOrdinal = $VALUES.length; - - IrisCommonVertexAttributes.TANGENT - = CommonVertexAttributeInterface.createAttribute("TANGENT", baseOrdinal, IrisVertexFormats.TANGENT_ELEMENT); - IrisCommonVertexAttributes.MID_TEX_COORD - = CommonVertexAttributeInterface.createAttribute("MID_TEX_COORD", baseOrdinal + 1, IrisVertexFormats.MID_TEXTURE_ELEMENT); - IrisCommonVertexAttributes.BLOCK_ID - = CommonVertexAttributeInterface.createAttribute("BLOCK_ID", baseOrdinal + 2, IrisVertexFormats.ENTITY_ELEMENT); - IrisCommonVertexAttributes.ENTITY_ID - = CommonVertexAttributeInterface.createAttribute("ENTITY_ID", baseOrdinal + 3, IrisVertexFormats.ENTITY_ID_ELEMENT); - IrisCommonVertexAttributes.MID_BLOCK - = CommonVertexAttributeInterface.createAttribute("MID_BLOCK", baseOrdinal + 4, IrisVertexFormats.MID_BLOCK_ELEMENT); - - $VALUES = ArrayUtils.addAll($VALUES, - IrisCommonVertexAttributes.TANGENT, - IrisCommonVertexAttributes.MID_TEX_COORD, - IrisCommonVertexAttributes.BLOCK_ID, - IrisCommonVertexAttributes.ENTITY_ID, - IrisCommonVertexAttributes.MID_BLOCK); - - COUNT = $VALUES.length; - } -} diff --git a/common/src/main/java/net/irisshaders/iris/mixin/MixinItemBlockRenderTypes.java b/common/src/main/java/net/irisshaders/iris/mixin/MixinItemBlockRenderTypes.java index 3f85bc15ee..080056bd2c 100644 --- a/common/src/main/java/net/irisshaders/iris/mixin/MixinItemBlockRenderTypes.java +++ b/common/src/main/java/net/irisshaders/iris/mixin/MixinItemBlockRenderTypes.java @@ -29,12 +29,9 @@ public class MixinItemBlockRenderTypes { @Inject(method = "getChunkRenderType", at = @At("HEAD"), cancellable = true) private static void iris$setCustomRenderType(BlockState arg, CallbackInfoReturnable cir) { - Map idMap = WorldRenderingSettings.INSTANCE.getBlockTypeIds(); - if (idMap != null) { - BlockRenderType type = idMap.get(arg.getBlock()); - if (type != null) { - cir.setReturnValue(LAYER_SET_VANILLA[type.ordinal()]); - } + BlockRenderType type = WorldRenderingSettings.INSTANCE.getBlockTypeIds().get(arg.getBlock()); + if (type != null) { + cir.setReturnValue(LAYER_SET_VANILLA[type.ordinal()]); } } } diff --git a/common/src/main/java/net/irisshaders/iris/pipeline/VanillaRenderingPipeline.java b/common/src/main/java/net/irisshaders/iris/pipeline/VanillaRenderingPipeline.java index 951a632db2..ed54acf521 100644 --- a/common/src/main/java/net/irisshaders/iris/pipeline/VanillaRenderingPipeline.java +++ b/common/src/main/java/net/irisshaders/iris/pipeline/VanillaRenderingPipeline.java @@ -28,7 +28,7 @@ public VanillaRenderingPipeline() { WorldRenderingSettings.INSTANCE.setAmbientOcclusionLevel(1.0f); WorldRenderingSettings.INSTANCE.setUseExtendedVertexFormat(false); WorldRenderingSettings.INSTANCE.setVoxelizeLightBlocks(false); - WorldRenderingSettings.INSTANCE.setBlockTypeIds(null); + WorldRenderingSettings.INSTANCE.setBlockTypeIds(Object2ObjectMaps.emptyMap()); } @Override diff --git a/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/BlockMaterialMapping.java b/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/BlockMaterialMapping.java index 9098231e20..8f5f2c4e7b 100644 --- a/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/BlockMaterialMapping.java +++ b/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/BlockMaterialMapping.java @@ -3,6 +3,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; import net.irisshaders.iris.Iris; import net.minecraft.client.renderer.RenderType; @@ -97,6 +98,8 @@ private static void addTag(TagEntry tagEntry, Object2IntMap idMap, i } public static Map createBlockTypeMap(Map blockPropertiesMap) { + if (blockPropertiesMap.isEmpty()) return Object2ObjectMaps.emptyMap(); + Map blockTypeIds = new Reference2ReferenceOpenHashMap<>(); blockPropertiesMap.forEach((id, blockType) -> { diff --git a/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/WorldRenderingSettings.java b/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/WorldRenderingSettings.java index 6fc236fe27..aa1dcafda8 100644 --- a/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/WorldRenderingSettings.java +++ b/common/src/main/java/net/irisshaders/iris/shaderpack/materialmap/WorldRenderingSettings.java @@ -59,7 +59,6 @@ public void setBlockStateIds(Object2IntMap blockStateIds) { this.blockStateIds = blockStateIds; } - @Nullable public Map getBlockTypeIds() { return blockTypeIds; } diff --git a/common/src/main/java/net/irisshaders/iris/vertices/sodium/CloudVertex.java b/common/src/main/java/net/irisshaders/iris/vertices/sodium/CloudVertex.java index df0acd0757..fccbf38252 100644 --- a/common/src/main/java/net/irisshaders/iris/vertices/sodium/CloudVertex.java +++ b/common/src/main/java/net/irisshaders/iris/vertices/sodium/CloudVertex.java @@ -4,15 +4,9 @@ import net.caffeinemc.mods.sodium.api.vertex.attributes.common.ColorAttribute; import net.caffeinemc.mods.sodium.api.vertex.attributes.common.NormalAttribute; import net.caffeinemc.mods.sodium.api.vertex.attributes.common.PositionAttribute; -import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription; -import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry; -import net.irisshaders.iris.vertices.IrisVertexFormats; import org.joml.Matrix4f; public final class CloudVertex { - public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance() - .get(IrisVertexFormats.CLOUDS); - public static final int STRIDE = 20; private static final int OFFSET_POSITION = 0; diff --git a/common/src/main/java/net/irisshaders/iris/vertices/sodium/EntityToTerrainVertexSerializer.java b/common/src/main/java/net/irisshaders/iris/vertices/sodium/EntityToTerrainVertexSerializer.java index bf59a8c260..0b200c04f2 100644 --- a/common/src/main/java/net/irisshaders/iris/vertices/sodium/EntityToTerrainVertexSerializer.java +++ b/common/src/main/java/net/irisshaders/iris/vertices/sodium/EntityToTerrainVertexSerializer.java @@ -2,7 +2,7 @@ import net.caffeinemc.mods.sodium.api.memory.MemoryIntrinsics; import net.caffeinemc.mods.sodium.api.util.NormI8; -import net.caffeinemc.mods.sodium.api.vertex.format.common.ModelVertex; +import net.caffeinemc.mods.sodium.api.vertex.format.common.EntityVertex; import net.caffeinemc.mods.sodium.api.vertex.serializer.VertexSerializer; import net.irisshaders.iris.uniforms.CapturedRenderingState; import net.irisshaders.iris.vertices.IrisVertexFormats; @@ -17,12 +17,12 @@ public void serialize(long src, long dst, int vertexCount) { for (int i = 0; i < quadCount; i++) { int normal = MemoryUtil.memGetInt(src + 32); int tangent = NormalHelper.computeTangent(NormI8.unpackX(normal), NormI8.unpackY(normal), NormI8.unpackZ(normal), MemoryUtil.memGetFloat(src), MemoryUtil.memGetFloat(src + 4), MemoryUtil.memGetFloat(src + 8), MemoryUtil.memGetFloat(src + 16), MemoryUtil.memGetFloat(src + 20), - MemoryUtil.memGetFloat(src + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + ModelVertex.STRIDE), - MemoryUtil.memGetFloat(src + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + ModelVertex.STRIDE + ModelVertex.STRIDE)); + MemoryUtil.memGetFloat(src + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + EntityVertex.STRIDE), + MemoryUtil.memGetFloat(src + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + EntityVertex.STRIDE + EntityVertex.STRIDE)); float midU = 0, midV = 0; for (int vertex = 0; vertex < 4; vertex++) { - midU += MemoryUtil.memGetFloat(src + 16 + (ModelVertex.STRIDE * vertex)); - midV += MemoryUtil.memGetFloat(src + 20 + (ModelVertex.STRIDE * vertex)); + midU += MemoryUtil.memGetFloat(src + 16 + (EntityVertex.STRIDE * vertex)); + midV += MemoryUtil.memGetFloat(src + 20 + (EntityVertex.STRIDE * vertex)); } midU /= 4; @@ -39,7 +39,7 @@ public void serialize(long src, long dst, int vertexCount) { MemoryUtil.memPutInt(dst + 44, tangent); MemoryUtil.memPutInt(dst + 48, 0); - src += ModelVertex.STRIDE; + src += EntityVertex.STRIDE; dst += IrisVertexFormats.TERRAIN.getVertexSize(); } } diff --git a/common/src/main/java/net/irisshaders/iris/vertices/sodium/IrisCommonVertexAttributes.java b/common/src/main/java/net/irisshaders/iris/vertices/sodium/IrisCommonVertexAttributes.java deleted file mode 100644 index cecccb1c16..0000000000 --- a/common/src/main/java/net/irisshaders/iris/vertices/sodium/IrisCommonVertexAttributes.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.irisshaders.iris.vertices.sodium; - -import net.caffeinemc.mods.sodium.api.vertex.attributes.CommonVertexAttribute; - -public class IrisCommonVertexAttributes { - public static CommonVertexAttribute TANGENT, MID_TEX_COORD, BLOCK_ID, MID_BLOCK, ENTITY_ID; -} diff --git a/common/src/main/java/net/irisshaders/iris/vertices/sodium/ModelToEntityVertexSerializer.java b/common/src/main/java/net/irisshaders/iris/vertices/sodium/ModelToEntityVertexSerializer.java index c2b5673ab5..c2e76a7e47 100644 --- a/common/src/main/java/net/irisshaders/iris/vertices/sodium/ModelToEntityVertexSerializer.java +++ b/common/src/main/java/net/irisshaders/iris/vertices/sodium/ModelToEntityVertexSerializer.java @@ -2,7 +2,7 @@ import net.caffeinemc.mods.sodium.api.memory.MemoryIntrinsics; import net.caffeinemc.mods.sodium.api.util.NormI8; -import net.caffeinemc.mods.sodium.api.vertex.format.common.ModelVertex; +import net.caffeinemc.mods.sodium.api.vertex.format.common.EntityVertex; import net.caffeinemc.mods.sodium.api.vertex.serializer.VertexSerializer; import net.irisshaders.iris.uniforms.CapturedRenderingState; import net.irisshaders.iris.vertices.IrisVertexFormats; @@ -17,12 +17,12 @@ public void serialize(long src, long dst, int vertexCount) { for (int i = 0; i < quadCount; i++) { int normal = MemoryUtil.memGetInt(src + 32); int tangent = NormalHelper.computeTangent(NormI8.unpackX(normal), NormI8.unpackY(normal), NormI8.unpackZ(normal), MemoryUtil.memGetFloat(src), MemoryUtil.memGetFloat(src + 4), MemoryUtil.memGetFloat(src + 8), MemoryUtil.memGetFloat(src + 16), MemoryUtil.memGetFloat(src + 20), - MemoryUtil.memGetFloat(src + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + ModelVertex.STRIDE), - MemoryUtil.memGetFloat(src + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + ModelVertex.STRIDE + ModelVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + ModelVertex.STRIDE + ModelVertex.STRIDE)); + MemoryUtil.memGetFloat(src + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + EntityVertex.STRIDE), + MemoryUtil.memGetFloat(src + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 4 + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 8 + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 16 + EntityVertex.STRIDE + EntityVertex.STRIDE), MemoryUtil.memGetFloat(src + 20 + EntityVertex.STRIDE + EntityVertex.STRIDE)); float midU = 0, midV = 0; for (int vertex = 0; vertex < 4; vertex++) { - midU += MemoryUtil.memGetFloat(src + 16 + (ModelVertex.STRIDE * vertex)); - midV += MemoryUtil.memGetFloat(src + 20 + (ModelVertex.STRIDE * vertex)); + midU += MemoryUtil.memGetFloat(src + 16 + (EntityVertex.STRIDE * vertex)); + midV += MemoryUtil.memGetFloat(src + 20 + (EntityVertex.STRIDE * vertex)); } midU /= 4; @@ -37,7 +37,7 @@ public void serialize(long src, long dst, int vertexCount) { MemoryUtil.memPutFloat(dst + 46, midV); MemoryUtil.memPutInt(dst + 50, tangent); - src += ModelVertex.STRIDE; + src += EntityVertex.STRIDE; dst += IrisVertexFormats.ENTITY.getVertexSize(); } } diff --git a/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/XHFPTerrainVertex.java b/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/XHFPTerrainVertex.java index 025d76fadd..b1ff6a8949 100644 --- a/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/XHFPTerrainVertex.java +++ b/common/src/main/java/net/irisshaders/iris/vertices/sodium/terrain/XHFPTerrainVertex.java @@ -80,7 +80,7 @@ private static int floorInt(float x) { @Override public long write(long ptr, - Material material, Vertex[] vertices, int section) { + int material, Vertex[] vertices, int section) { // Calculate the center point of the texture region which is mapped to the quad float texCentroidU = 0.0f; float texCentroidV = 0.0f; @@ -127,7 +127,7 @@ public long write(long ptr, MemoryUtil.memPutInt(ptr + 4L, packPositionLo(x, y, z)); MemoryUtil.memPutInt(ptr + 8L, WorldRenderingSettings.INSTANCE.shouldUseSeparateAo() ? ColorABGR.withAlpha(vertex.color, vertex.ao) : ColorHelper.multiplyRGB(vertex.color, vertex.ao)); MemoryUtil.memPutInt(ptr + 12L, packTexture(u, v)); - MemoryUtil.memPutInt(ptr + 16L, packLightAndData(light, material.bits(), section)); + MemoryUtil.memPutInt(ptr + 16L, packLightAndData(light, material, section)); MemoryUtil.memPutShort(ptr + 32, contextHolder.getBlockId()); MemoryUtil.memPutShort(ptr + 34, contextHolder.getRenderType()); diff --git a/common/src/main/resources/mixins.iris.compat.sodium.json b/common/src/main/resources/mixins.iris.compat.sodium.json index 41aeeaf7ad..66fc7ad1a8 100644 --- a/common/src/main/resources/mixins.iris.compat.sodium.json +++ b/common/src/main/resources/mixins.iris.compat.sodium.json @@ -5,8 +5,7 @@ "refmap": "iris.refmap.json", "compatibilityLevel": "JAVA_8", "client": [ - "entity.CommonVertexAttributeInterface", - "entity.MixinCommonVertexAttribute", + "MixinBlockRenderer", "MixinChunkBuildBuffers", "MixinChunkMeshBuildTask", "MixinCloudRenderer", diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 43cb7faa3c..5b7b0d5f21 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -55,7 +55,7 @@ "optifabric": "*", "worldeditcui": "<1.18.1", "physicsmod": "<=3.0.13", - "distanthorizons": "<=2.2.0", + "distanthorizons": "<=2.1.99", "immersive_portals": "<=1.4.2" }, "custom": { diff --git a/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinItemBlockRenderTypes.java b/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinItemBlockRenderTypes.java index 4b7d80eadf..2b2a3cc7ea 100644 --- a/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinItemBlockRenderTypes.java +++ b/neoforge/src/main/java/net/irisshaders/iris/mixin/forge/MixinItemBlockRenderTypes.java @@ -31,12 +31,9 @@ public class MixinItemBlockRenderTypes { @Inject(method = "getRenderLayers", at = @At("HEAD"), cancellable = true) private static void iris$setCustomRenderType(BlockState arg, CallbackInfoReturnable cir) { - Map idMap = WorldRenderingSettings.INSTANCE.getBlockTypeIds(); - if (idMap != null) { - BlockRenderType type = idMap.get(arg.getBlock()); - if (type != null) { - cir.setReturnValue(LAYER_SET[type.ordinal()]); - } + BlockRenderType type = WorldRenderingSettings.INSTANCE.getBlockTypeIds().get(arg.getBlock()); + if (type != null) { + cir.setReturnValue(LAYER_SET[type.ordinal()]); } } }