From ae70becdb2655e0d7238be6cfd8f803539435b6d Mon Sep 17 00:00:00 2001 From: JellySquid Date: Thu, 15 Aug 2024 15:34:59 -0500 Subject: [PATCH 01/17] Fix crash when enumerating adapters without an OpenGL ICD Closes #2591 --- .../client/compatibility/checks/PreLaunchChecks.java | 3 ++- .../client/platform/windows/api/d3dkmt/D3DKMT.java | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/checks/PreLaunchChecks.java b/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/checks/PreLaunchChecks.java index 966e5488ee..d89ebae6ef 100644 --- a/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/checks/PreLaunchChecks.java +++ b/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/compatibility/checks/PreLaunchChecks.java @@ -116,12 +116,13 @@ private static void showCriticalErrorAndClose(String title, String message, Stri for (var adapter : GraphicsAdapterProbe.getAdapters()) { if (adapter instanceof D3DKMT.WDDMAdapterInfo wddmAdapterInfo) { @Nullable var driverName = wddmAdapterInfo.getOpenGlIcdName(); - var driverVersion = wddmAdapterInfo.openglIcdVersion(); if (driverName == null) { continue; } + var driverVersion = wddmAdapterInfo.openglIcdVersion(); + // Intel OpenGL ICD for Generation 7 GPUs if (driverName.matches("ig7icd(32|64)")) { // https://www.intel.com/content/www/us/en/support/articles/000005654/graphics.html diff --git a/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/platform/windows/api/d3dkmt/D3DKMT.java b/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/platform/windows/api/d3dkmt/D3DKMT.java index a18c4f6423..ed71c373bd 100644 --- a/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/platform/windows/api/d3dkmt/D3DKMT.java +++ b/common/src/workarounds/java/net/caffeinemc/mods/sodium/client/platform/windows/api/d3dkmt/D3DKMT.java @@ -192,11 +192,11 @@ public record WDDMAdapterInfo( @NotNull GraphicsAdapterVendor vendor, @NotNull String name, int adapterType, - String openglIcdFilePath, - WindowsFileVersion openglIcdVersion + @Nullable String openglIcdFilePath, + @Nullable WindowsFileVersion openglIcdVersion ) implements GraphicsAdapterInfo { - public String getOpenGlIcdName() { - return D3DKMT.getOpenGlIcdName(this.name); + public @Nullable String getOpenGlIcdName() { + return D3DKMT.getOpenGlIcdName(this.openglIcdFilePath); } @Override @@ -206,6 +206,7 @@ public String toString() { } } + // Returns (null) if input is (null). private static String getOpenGlIcdName(String path) { return FilenameUtils.removeExtension(FilenameUtils.getName(path)); } From acb25b4e10961dd5ad0149e6fe6536519cc8d521 Mon Sep 17 00:00:00 2001 From: JellySquid Date: Thu, 15 Aug 2024 15:50:51 -0500 Subject: [PATCH 02/17] Update the tooltip for the brightness video setting Closes #2388 Closes #2347 --- common/src/main/resources/assets/sodium/lang/en_us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/resources/assets/sodium/lang/en_us.json b/common/src/main/resources/assets/sodium/lang/en_us.json index 79a6be914a..b128222a27 100644 --- a/common/src/main/resources/assets/sodium/lang/en_us.json +++ b/common/src/main/resources/assets/sodium/lang/en_us.json @@ -9,7 +9,7 @@ "sodium.options.pages.advanced": "Advanced", "sodium.options.view_distance.tooltip": "The render distance controls how far away terrain will be rendered. Shorter distances mean that less terrain will be rendered, improving frame rates.", "sodium.options.simulation_distance.tooltip": "The simulation distance controls how far away terrain and entities will be loaded and ticked. Shorter distances can reduce the internal server's load and may improve frame rates.", - "sodium.options.brightness.tooltip": "Controls the brightness (gamma) of the game.", + "sodium.options.brightness.tooltip": "Controls the minimum brightness in the world. When increased, darker areas of the world will appear brighter. This does not affect the brightness of already well-lit areas.", "sodium.options.gui_scale.tooltip": "Sets the maximum scale factor to be used for the user interface. If \"auto\" is used, then the largest scale factor will always be used.", "sodium.options.fullscreen.tooltip": "If enabled, the game will display in full-screen (if supported).", "sodium.options.v_sync.tooltip": "If enabled, the game's frame rate will be synchronized to the monitor's refresh rate, making for a generally smoother experience at the expense of overall input latency. This setting might reduce performance if your system is too slow.", From 1744347c6d31dbef49fd2ba7d4373ef9efbe39cf Mon Sep 17 00:00:00 2001 From: IMS212 Date: Thu, 15 Aug 2024 19:42:44 -0700 Subject: [PATCH 03/17] Fix vertex alphas and No Error Context on Fabric --- .../model/color/DefaultColorProviders.java | 20 +++---------------- .../mods/sodium/mixin/core/WindowMixin.java | 12 +++++++---- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/DefaultColorProviders.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/DefaultColorProviders.java index e02fdc2734..848896141b 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/DefaultColorProviders.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/DefaultColorProviders.java @@ -24,7 +24,7 @@ private GrassColorProvider() { @Override protected int getColor(LevelSlice slice, T state, BlockPos pos) { - return BiomeColors.getAverageGrassColor(slice, pos); + return 0xFF000000 | BiomeColors.getAverageGrassColor(slice, pos); } } @@ -37,21 +37,7 @@ private FoliageColorProvider() { @Override protected int getColor(LevelSlice slice, T state, BlockPos pos) { - return BiomeColors.getAverageFoliageColor(slice, pos); - } - } - - public static class WaterColorProvider extends BlendedColorProvider { - public static final ColorProvider BLOCKS = new WaterColorProvider<>(); - public static final ColorProvider FLUIDS = new WaterColorProvider<>(); - - private WaterColorProvider() { - - } - - @Override - protected int getColor(LevelSlice slice, T state, BlockPos pos) { - return BiomeColors.getAverageWaterColor(slice, pos); + return 0xFF000000 | BiomeColors.getAverageFoliageColor(slice, pos); } } @@ -64,7 +50,7 @@ private VanillaAdapter(BlockColor color) { @Override public void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, BlockState state, ModelQuadView quad, int[] output) { - Arrays.fill(output, this.color.getColor(state, slice, pos, quad.getColorIndex())); + Arrays.fill(output, 0xFF000000 | this.color.getColor(state, slice, pos, quad.getColorIndex())); } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java index a04acec7d1..999262e84e 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/WindowMixin.java @@ -1,8 +1,11 @@ package net.caffeinemc.mods.sodium.mixin.core; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.platform.Window; import net.caffeinemc.mods.sodium.client.SodiumClientMod; import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds; +import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; import org.lwjgl.glfw.GLFW; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -10,12 +13,13 @@ @Mixin(Window.class) public class WindowMixin { - //@Redirect(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwCreateWindow(IILjava/lang/CharSequence;JJ)J"), require = 0) - public long setAdditionalWindowHints(int width, int height, CharSequence title, long monitor, long share) { - if (SodiumClientMod.options().performance.useNoErrorGLContext && + @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwCreateWindow(IILjava/lang/CharSequence;JJ)J"), require = 0) + public long setAdditionalWindowHints(int titleEncoded, int width, CharSequence height, long title, long monitor, Operation original) { + if (!PlatformRuntimeInformation.getInstance().platformHasEarlyLoadingScreen() && SodiumClientMod.options().performance.useNoErrorGLContext && !Workarounds.isWorkaroundEnabled(Workarounds.Reference.NO_ERROR_CONTEXT_UNSUPPORTED)) { GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_NO_ERROR, GLFW.GLFW_TRUE); } - return GLFW.glfwCreateWindow(width, height, title, monitor, share); + + return original.call(titleEncoded, width, height, title, monitor); } } From cd18e7f9a19e0925ce80a1f43ce70d926366fd28 Mon Sep 17 00:00:00 2001 From: JellySquid <1363084+jellysquid3@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:45:58 -0600 Subject: [PATCH 04/17] Use hardware copy for render target blits where possible (#2676) Minecraft performs a blit using a fragment shader, which is unnecessary when blending is not used. Using the fixed function hardware to perform the blit is much faster and doesn't utilize the rasterization engine. --- .../client/data/config/MixinConfig.java | 2 + .../render/compositing/RenderTargetMixin.java | 44 +++++++++++++++++++ common/src/main/resources/sodium.mixins.json | 1 + 3 files changed, 47 insertions(+) create mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java index f44b99d7f9..fd846edf38 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java @@ -49,6 +49,8 @@ protected MixinConfig() { this.addMixinRule("features.render", true); + this.addMixinRule("features.render.compositing", true); + this.addMixinRule("features.render.entity", true); this.addMixinRule("features.render.entity.cull", true); this.addMixinRule("features.render.entity.shadow", true); diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java new file mode 100644 index 0000000000..c63e4a0c87 --- /dev/null +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/compositing/RenderTargetMixin.java @@ -0,0 +1,44 @@ +package net.caffeinemc.mods.sodium.mixin.features.render.compositing; + + +import com.mojang.blaze3d.pipeline.RenderTarget; +import org.lwjgl.opengl.GL32C; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RenderTarget.class) +public class RenderTargetMixin { + @Shadow + public int frameBufferId; + + @Shadow + public int width; + + @Shadow + public int height; + + /** + * @author JellySquid + * @reason Use fixed function hardware for framebuffer blits + */ + @Inject(method = "blitToScreen(IIZ)V", at = @At("HEAD"), cancellable = true) + public void blitToScreen(int width, int height, boolean disableBlend, CallbackInfo ci) { + if (disableBlend) { + ci.cancel(); + + // When blending is not used, we can directly copy the contents of one + // framebuffer to another using the blitting engine. This can save a lot of time + // when compared to going through the rasterization pipeline. + GL32C.glBindFramebuffer(GL32C.GL_READ_FRAMEBUFFER, this.frameBufferId); + GL32C.glBlitFramebuffer( + 0, 0, width, height, + 0, 0, width, height, + GL32C.GL_COLOR_BUFFER_BIT, GL32C.GL_LINEAR); + GL32C.glBindFramebuffer(GL32C.GL_READ_FRAMEBUFFER, 0); + } + } + +} \ No newline at end of file diff --git a/common/src/main/resources/sodium.mixins.json b/common/src/main/resources/sodium.mixins.json index 7dbaeb8053..e110e980ee 100644 --- a/common/src/main/resources/sodium.mixins.json +++ b/common/src/main/resources/sodium.mixins.json @@ -41,6 +41,7 @@ "features.options.render_layers.LeavesBlockMixin", "features.options.render_layers.ItemBlockRenderTypesMixin", "features.options.weather.LevelRendererMixin", + "features.render.compositing.RenderTargetMixin", "features.render.entity.CubeMixin", "features.render.entity.ModelPartMixin", "features.render.entity.cull.EntityRendererMixin", From 5e3c95a345166c4cb9ec563cb470b9bd92f1e84a Mon Sep 17 00:00:00 2001 From: IMS212 Date: Thu, 15 Aug 2024 20:15:20 -0700 Subject: [PATCH 05/17] Merge final changes to vertex alpha --- .../render/chunk/compile/pipeline/DefaultFluidRenderer.java | 4 +--- .../mods/sodium/fabric/render/FabricColorProviders.java | 2 +- .../mods/sodium/fabric/render/FluidRendererImpl.java | 2 +- .../mods/sodium/neoforge/render/FluidRendererImpl.java | 2 +- .../mods/sodium/neoforge/render/ForgeColorProviders.java | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java index 35e3d958cd..b49cde9421 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java @@ -58,13 +58,11 @@ public class DefaultFluidRenderer { private final float[] brightness = new float[4]; private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad(); - private final ColorProviderRegistry colorProviderRegistry; - public DefaultFluidRenderer(ColorProviderRegistry colorProviderRegistry, LightPipelineProvider lighters) { + public DefaultFluidRenderer(LightPipelineProvider lighters) { this.quad.setLightFace(Direction.UP); this.lighters = lighters; - this.colorProviderRegistry = colorProviderRegistry; } private boolean isFluidOccluded(BlockAndTintGetter world, int x, int y, int z, Direction dir, BlockState blockState, Fluid fluid) { diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java index ddc6ef80e0..9781b80354 100644 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java @@ -23,7 +23,7 @@ public FabricFluidAdapter(FluidRenderHandler handler) { @Override public void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, FluidState state, ModelQuadView quad, int[] output) { - Arrays.fill(output, this.handler.getFluidColor(slice, pos, state)); + Arrays.fill(output, 0xFF000000 |this.handler.getFluidColor(slice, pos, state)); } } } diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java index 70388b5eb2..3c37a1947f 100644 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java @@ -33,7 +33,7 @@ public class FluidRendererImpl extends FluidRenderer { public FluidRendererImpl(ColorProviderRegistry colorProviderRegistry, LightPipelineProvider lighters) { this.colorProviderRegistry = colorProviderRegistry; - defaultRenderer = new DefaultFluidRenderer(colorProviderRegistry, lighters); + defaultRenderer = new DefaultFluidRenderer(lighters); defaultContext = new DefaultRenderContext(); } diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/FluidRendererImpl.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/FluidRendererImpl.java index a3e413a1b5..44e64c4540 100644 --- a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/FluidRendererImpl.java +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/FluidRendererImpl.java @@ -32,7 +32,7 @@ public class FluidRendererImpl extends FluidRenderer { public FluidRendererImpl(ColorProviderRegistry colorProviderRegistry, LightPipelineProvider lighters) { this.colorProviderRegistry = colorProviderRegistry; - defaultRenderer = new DefaultFluidRenderer(colorProviderRegistry, lighters); + defaultRenderer = new DefaultFluidRenderer(lighters); } public void render(LevelSlice level, BlockState blockState, FluidState fluidState, BlockPos blockPos, BlockPos offset, TranslucentGeometryCollector collector, ChunkBuildBuffers buffers) { diff --git a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/ForgeColorProviders.java b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/ForgeColorProviders.java index 703d0369f3..53e4348db0 100644 --- a/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/ForgeColorProviders.java +++ b/neoforge/src/main/java/net/caffeinemc/mods/sodium/neoforge/render/ForgeColorProviders.java @@ -24,7 +24,7 @@ public ForgeFluidAdapter(IClientFluidTypeExtensions handler) { @Override public void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, FluidState state, ModelQuadView quad, int[] output) { - Arrays.fill(output, ColorARGB.withAlpha(this.handler.getTintColor(state, slice, pos), 255)); + Arrays.fill(output,this.handler.getTintColor(state, slice, pos)); } } } From e7413def68367ce3003236f529da3cc04b6eaff2 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Thu, 15 Aug 2024 20:21:24 -0700 Subject: [PATCH 06/17] Fix Fabric Block View API support Fixes #2670 --- .../caffeinemc/mods/sodium/client/world/LevelSlice.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java index 9ab896d82d..5f24211177 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java @@ -7,6 +7,7 @@ import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; import net.caffeinemc.mods.sodium.client.world.cloned.ClonedChunkSection; import net.caffeinemc.mods.sodium.client.world.cloned.ClonedChunkSectionCache; +import net.fabricmc.fabric.api.blockview.v2.FabricBlockView; import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; @@ -46,7 +47,7 @@ * *

Object pooling should be used to avoid huge allocations as this class contains many large arrays.

*/ -public final class LevelSlice implements BlockAndTintGetter, RenderAttachedBlockView { +public final class LevelSlice implements BlockAndTintGetter, RenderAttachedBlockView, FabricBlockView { private static final LightLayer[] LIGHT_TYPES = LightLayer.values(); // The number of blocks in a section. @@ -399,12 +400,12 @@ public SodiumModelData getPlatformModelData(BlockPos pos) { return modelMap.getModelData(pos); } - //@Override + @Override public boolean hasBiomes() { return true; } - //@Override + @Override public Holder getBiomeFabric(BlockPos pos) { return this.biomeSlice.getBiome(pos.getX(), pos.getY(), pos.getZ()); } From 278de5de9ca2f298d8e9aa7b6fb6ea907a9720b9 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Thu, 15 Aug 2024 20:23:15 -0700 Subject: [PATCH 07/17] Suppress annoying unchecked compiler message --- .../java/net/caffeinemc/mods/sodium/fabric/SodiumFabricMod.java | 1 + 1 file changed, 1 insertion(+) diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/SodiumFabricMod.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/SodiumFabricMod.java index 9d24177c5c..22875cab22 100644 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/SodiumFabricMod.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/SodiumFabricMod.java @@ -23,6 +23,7 @@ public class SodiumFabricMod implements ClientModInitializer { @Override + @SuppressWarnings("unchecked") public void onInitializeClient() { ModContainer mod = FabricLoader.getInstance() .getModContainer("sodium") From 823913efa1c68905c3a92b18ffec8fef0f6a4ac8 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Fri, 16 Aug 2024 06:34:27 -0700 Subject: [PATCH 08/17] Fix last commented override --- .../net/caffeinemc/mods/sodium/client/world/LevelSlice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java index 5f24211177..c6b18eac52 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java @@ -363,7 +363,7 @@ public int getMinBuildHeight() { return this.level.getMinBuildHeight(); } - //@Override + @Override public @Nullable Object getBlockEntityRenderData(BlockPos pos) { if (!this.volume.isInside(pos.getX(), pos.getY(), pos.getZ())) { return null; From 27c2412631cf113b877ef9d22c6b754af2aab278 Mon Sep 17 00:00:00 2001 From: JellySquid Date: Fri, 16 Aug 2024 10:15:45 -0500 Subject: [PATCH 09/17] Remove non-functional debug mixins --- .../render/util/DeferredRenderTask.java | 33 ------------- .../debug/checks/AbstractTextureMixin.java | 24 --------- .../debug/checks/BufferUploaderMixin.java | 15 ------ .../debug/checks/DynamicTextureMixin.java | 15 ------ .../debug/checks/GlStateManagerMixin.java | 17 ------- .../mixin/debug/checks/HttpTextureMixin.java | 29 ----------- .../mixin/debug/checks/NativeImageMixin.java | 17 ------- .../debug/checks/PreloadedTextureMixin.java | 20 -------- .../mixin/debug/checks/RenderSystemMixin.java | 49 ------------------- .../mixin/debug/checks/RenderTargetMixin.java | 19 ------- .../SpriteContentsAnimatorImplMixin.java | 17 ------- .../mixin/debug/checks/TextureAtlasMixin.java | 17 ------- .../debug/checks/TextureManagerMixin.java | 37 -------------- .../mixin/debug/checks/VertexBufferMixin.java | 17 ------- .../mixin/debug/checks/VertexFormatMixin.java | 18 ------- 15 files changed, 344 deletions(-) delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/DeferredRenderTask.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/AbstractTextureMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/BufferUploaderMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/DynamicTextureMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/GlStateManagerMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/HttpTextureMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/NativeImageMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/PreloadedTextureMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderSystemMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderTargetMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/SpriteContentsAnimatorImplMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureAtlasMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureManagerMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexBufferMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexFormatMixin.java diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/DeferredRenderTask.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/DeferredRenderTask.java deleted file mode 100644 index 514c32a6d8..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/DeferredRenderTask.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.util; - -import java.util.concurrent.ConcurrentLinkedDeque; - -public class DeferredRenderTask { - private static final ConcurrentLinkedDeque queue = new ConcurrentLinkedDeque<>(); - - /** - * Schedules a render task to be executed on the main render thread as soon as possible. This is often at the - * start of the next frame. - * @param runnable The task to be executed on the render thread - */ - public static void schedule(Runnable runnable) { - queue.add(runnable); - } - - /** - * Executes all currently pending render tasks. This should only be called from the main render thread! - */ - public static void runAll() { - RenderAsserts.validateCurrentThread(); - - Runnable runnable; - - while ((runnable = queue.poll()) != null) { - try { - runnable.run(); - } catch (Throwable throwable) { - throw new RuntimeException("Failed to execute deferred render task", throwable); - } - } - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/AbstractTextureMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/AbstractTextureMixin.java deleted file mode 100644 index 562bd216ad..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/AbstractTextureMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import net.minecraft.client.renderer.texture.AbstractTexture; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(AbstractTexture.class) -public class AbstractTextureMixin { - @Redirect(method = { - "releaseId" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$cleanup() { - return RenderAsserts.validateCurrentThread(); - } - - @Redirect(method = { - "bind" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThreadOrInit()Z")) - private boolean validateCurrentThread$bind() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/BufferUploaderMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/BufferUploaderMixin.java deleted file mode 100644 index 2852f7e405..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/BufferUploaderMixin.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.vertex.BufferUploader; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(BufferUploader.class) -public class BufferUploaderMixin { - @Redirect(method = "drawWithShader", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThreadOrInit()Z")) - private static boolean validateCurrentThread$draw() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/DynamicTextureMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/DynamicTextureMixin.java deleted file mode 100644 index e94c38306d..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/DynamicTextureMixin.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import net.minecraft.client.renderer.texture.DynamicTexture; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(DynamicTexture.class) -public class DynamicTextureMixin { - @Redirect(method = "(Lcom/mojang/blaze3d/platform/NativeImage;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$init() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/GlStateManagerMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/GlStateManagerMixin.java deleted file mode 100644 index 61447200b1..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/GlStateManagerMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.platform.GlStateManager; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(GlStateManager.class) -public class GlStateManagerMixin { - @Redirect(method = { - "upload", - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThreadOrInit()Z"), remap = false) - private static boolean validateCurrentThread$upload() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/HttpTextureMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/HttpTextureMixin.java deleted file mode 100644 index 132746f80d..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/HttpTextureMixin.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.platform.NativeImage; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.HttpTexture; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(HttpTexture.class) -public abstract class HttpTextureMixin { - @Shadow - private boolean uploaded; - - @Shadow - protected abstract void upload(NativeImage image); - - @Inject(method = "loadCallback", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;execute(Ljava/lang/Runnable;)V", shift = At.Shift.BEFORE), cancellable = true) - private void validateCurrentThread$loadTextureCallback(NativeImage image, CallbackInfo ci) { - Minecraft.getInstance().execute(() -> { - this.uploaded = true; - this.upload(image); - }); - - ci.cancel(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/NativeImageMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/NativeImageMixin.java deleted file mode 100644 index c92c680742..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/NativeImageMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.platform.NativeImage; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(NativeImage.class) -public class NativeImageMixin { - @Redirect(method = { - "upload(IIIIIIIZZZZ)V" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThreadOrInit()Z")) - private boolean validateCurrentThread$upload() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/PreloadedTextureMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/PreloadedTextureMixin.java deleted file mode 100644 index 24d62ed4ba..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/PreloadedTextureMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import net.caffeinemc.mods.sodium.client.render.util.DeferredRenderTask; -import net.minecraft.client.renderer.texture.PreloadedTexture; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import java.util.concurrent.Executor; - -@Mixin(PreloadedTexture.class) -public class PreloadedTextureMixin { - /** - * @author JellySquid - * @reason Redirect asynchronous render commands to our helper - */ - @Overwrite - private static Executor executor(Executor executor) { - return DeferredRenderTask::schedule; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderSystemMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderSystemMixin.java deleted file mode 100644 index 9b2c9b9c2f..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderSystemMixin.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.pipeline.RenderCall; -import com.mojang.blaze3d.systems.RenderSystem; -import net.caffeinemc.mods.sodium.client.render.util.DeferredRenderTask; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(RenderSystem.class) -public abstract class RenderSystemMixin { - /** - * @author JellySquid - * @reason Disallow the use of RenderSystem.recordRenderCall entirely - */ - @Overwrite(remap = false) - public static void recordRenderCall(RenderCall call) { - throw new UnsupportedOperationException("RenderSystem#recordRenderCall is not supported when using Sodium"); - } - - @Inject(method = "replayQueue", at = @At("HEAD"), remap = false) - private static void onReplayQueue(CallbackInfo ci) { - DeferredRenderTask.runAll(); - } - - @Redirect(method = { - "setShaderColor", - "lineWidth", - "glGenBuffers", - "glGenVertexArrays", - "setShader", - "setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V", - "setShaderTexture(II)V", - "setProjectionMatrix", - "setTextureMatrix", - "resetTextureMatrix", - "applyModelViewMatrix", - "backupProjectionMatrix", - "restoreProjectionMatrix", - "setShaderGameTime" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z"), remap = false) - private static boolean validateCurrentThread$glCommands() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderTargetMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderTargetMixin.java deleted file mode 100644 index fe10114bcf..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/RenderTargetMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.pipeline.RenderTarget; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(RenderTarget.class) -public class RenderTargetMixin { - @Redirect(method = { - "resize", - "bindWrite", - "unbindWrite", - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$imageOperations() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/SpriteContentsAnimatorImplMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/SpriteContentsAnimatorImplMixin.java deleted file mode 100644 index 819a9c77bf..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/SpriteContentsAnimatorImplMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import net.minecraft.client.renderer.texture.SpriteContents; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(SpriteContents.Ticker.class) -public class SpriteContentsAnimatorImplMixin { - @Redirect(method = { - "tickAndUpload" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$tick() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureAtlasMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureAtlasMixin.java deleted file mode 100644 index 36acaf0593..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureAtlasMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import net.minecraft.client.renderer.texture.TextureAtlas; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(TextureAtlas.class) -public class TextureAtlasMixin { - @Redirect(method = { - "tick" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$tick() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureManagerMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureManagerMixin.java deleted file mode 100644 index e0aaa1b14f..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/TextureManagerMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import net.caffeinemc.mods.sodium.client.render.util.DeferredRenderTask; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import net.minecraft.client.renderer.texture.TextureManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.function.Consumer; - -@Mixin(TextureManager.class) -public class TextureManagerMixin { - /** - * @author JellySquid - * @reason Use our own asynchronous executor for render commands - */ - @Overwrite - private static void execute(Runnable runnable) { - DeferredRenderTask.schedule(runnable); - } - - @Redirect(method = "reload", at = @At(value = "INVOKE", target = "Ljava/util/concurrent/CompletableFuture;thenAcceptAsync(Ljava/util/function/Consumer;Ljava/util/concurrent/Executor;)Ljava/util/concurrent/CompletableFuture;")) - public CompletableFuture redirectReloadTask(CompletableFuture instance, Consumer consumer, Executor executor) { - return instance.thenAcceptAsync(consumer, TextureManagerMixin::execute); - } - - @Redirect(method = { - "bindForSetup" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$bindTexture() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexBufferMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexBufferMixin.java deleted file mode 100644 index 2057f8ee00..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexBufferMixin.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.vertex.VertexBuffer; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(VertexBuffer.class) -public class VertexBufferMixin { - @Redirect(method = { - "drawWithShader(Lorg/joml/Matrix4f;Lorg/joml/Matrix4f;Lnet/minecraft/client/renderer/ShaderInstance;)V", - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$draw() { - return RenderAsserts.validateCurrentThread(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexFormatMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexFormatMixin.java deleted file mode 100644 index 79dce4739e..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/debug/checks/VertexFormatMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.debug.checks; - -import com.mojang.blaze3d.vertex.VertexFormat; -import net.caffeinemc.mods.sodium.client.render.util.RenderAsserts; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(VertexFormat.class) -public class VertexFormatMixin { - @Redirect(method = { - "setupBufferState", - "clearBufferState" - }, at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;isOnRenderThread()Z")) - private boolean validateCurrentThread$modifyState() { - return RenderAsserts.validateCurrentThread(); - } -} From 345b2c3b743785644c245d9150cc3e3a635b764a Mon Sep 17 00:00:00 2001 From: MrMangoHands Date: Fri, 16 Aug 2024 17:29:05 -0700 Subject: [PATCH 10/17] Ignore alpha in non-terrain block rendering (#2685) Co-authored-by: MrMangoHands --- .../render/frapi/render/NonTerrainBlockRenderContext.java | 2 +- .../mods/sodium/fabric/render/FabricColorProviders.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java index 4c78b8c84e..35433471b6 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java @@ -106,7 +106,7 @@ protected void processQuad(MutableQuadViewImpl quad) { private void colorizeQuad(MutableQuadViewImpl quad, int colorIndex) { if (colorIndex != -1) { - final int blockColor = this.colorMap.getColor(this.state, this.level, this.pos, colorIndex); + final int blockColor = 0xFF000000 | this.colorMap.getColor(this.state, this.level, this.pos, colorIndex); for (int i = 0; i < 4; i++) { quad.color(i, ColorHelper.multiplyColor(blockColor, quad.color(i))); diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java index 9781b80354..28dec3befe 100644 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java @@ -23,7 +23,7 @@ public FabricFluidAdapter(FluidRenderHandler handler) { @Override public void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, FluidState state, ModelQuadView quad, int[] output) { - Arrays.fill(output, 0xFF000000 |this.handler.getFluidColor(slice, pos, state)); + Arrays.fill(output, 0xFF000000 | this.handler.getFluidColor(slice, pos, state)); } } } From 2d2ee7ade040a9905d6e771c6be9d6da177e918b Mon Sep 17 00:00:00 2001 From: MrMangoHands Date: Fri, 16 Aug 2024 17:30:19 -0700 Subject: [PATCH 11/17] Convert max position coordinate to float in vertex scale calculation (#2684) Fixes #2678 Co-authored-by: MrMangoHands --- .../resources/assets/sodium/shaders/include/chunk_vertex.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/resources/assets/sodium/shaders/include/chunk_vertex.glsl b/common/src/main/resources/assets/sodium/shaders/include/chunk_vertex.glsl index b6a1ae4deb..c594aa23f2 100644 --- a/common/src/main/resources/assets/sodium/shaders/include/chunk_vertex.glsl +++ b/common/src/main/resources/assets/sodium/shaders/include/chunk_vertex.glsl @@ -25,7 +25,7 @@ const uint TEXTURE_BITS = 15u; const uint TEXTURE_MAX_COORD = 1u << TEXTURE_BITS; const uint TEXTURE_MAX_VALUE = TEXTURE_MAX_COORD - 1u; -const float VERTEX_SCALE = 32.0 / POSITION_MAX_COORD; +const float VERTEX_SCALE = 32.0 / float(POSITION_MAX_COORD); const float VERTEX_OFFSET = -8.0; // The amount of inset the texture coordinates from the edges of the texture, to avoid texture bleeding From 9085a12d9d65ffc582fc89bc24eff7b42adf2560 Mon Sep 17 00:00:00 2001 From: MrMangoHands Date: Sat, 17 Aug 2024 18:22:42 -0700 Subject: [PATCH 12/17] Update compatible Minecraft versions (#2689) --- fabric/src/main/resources/fabric.mod.json | 1 + neoforge/src/main/resources/META-INF/neoforge.mods.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 20bd70b9d5..ae169fd74d 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -70,6 +70,7 @@ "sodium-fabric.mixins.json" ], "depends" : { + "minecraft" : ["1.21", "1.21.1"], "fabricloader" : ">=0.12.0", "fabric-block-view-api-v2" : "*", "fabric-renderer-api-v1" : "*", diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index 99fcd1e10a..6fa9e9d886 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -26,7 +26,7 @@ provides = ["indium"] [[dependencies.sodium]] modId = "minecraft" type = "required" -versionRange = "[1.20.4,1.21.1)" +versionRange = "[1.21,1.21.1]" ordering = "NONE" side = "CLIENT" From e1efb0d555bd74edb1f6f08c5b6803afb28d1b79 Mon Sep 17 00:00:00 2001 From: IMS Date: Wed, 21 Aug 2024 19:49:32 -0700 Subject: [PATCH 13/17] Multiple misc changes to shader interfaces (#2690) * Multiple misc changes to shader interfaces * Replace ShaderBindingContext methods with optional and non-optional --- .../serializer/VertexSerializerRegistry.java | 2 + .../gl/attribute/GlVertexAttributeFormat.java | 3 + .../client/gl/attribute/GlVertexFormat.java | 70 +++++++++-------- .../client/gl/buffer/IndexedVertexData.java | 2 +- .../sodium/client/gl/shader/GlProgram.java | 29 ++++++- .../sodium/client/gl/shader/ShaderType.java | 15 ++++ .../gl/tessellation/GlPrimitiveType.java | 6 +- .../client/gui/SodiumGameOptionPages.java | 6 +- .../sodium/client/gui/options/OptionImpl.java | 11 +-- .../render/chunk/DefaultChunkRenderer.java | 14 +--- .../render/chunk/ShaderChunkRenderer.java | 12 ++- .../chunk/shader/ChunkShaderInterface.java | 66 ++-------------- .../chunk/shader/DefaultShaderInterface.java | 75 +++++++++++++++++++ .../chunk/shader/ShaderBindingContext.java | 10 +++ .../vertex/format/ChunkMeshAttribute.java | 10 --- .../chunk/vertex/format/ChunkVertexType.java | 2 +- .../format/impl/CompactChunkVertex.java | 17 ++--- .../impl/DefaultChunkMeshAttributes.java | 12 +++ .../render/vertex/VertexFormatAttribute.java | 7 ++ .../VertexSerializerRegistryImpl.java | 5 ++ 20 files changed, 235 insertions(+), 139 deletions(-) create mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/DefaultShaderInterface.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkMeshAttribute.java create mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/DefaultChunkMeshAttributes.java create mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatAttribute.java diff --git a/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/serializer/VertexSerializerRegistry.java b/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/serializer/VertexSerializerRegistry.java index 8aecabc7d9..cd870e90b4 100644 --- a/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/serializer/VertexSerializerRegistry.java +++ b/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/serializer/VertexSerializerRegistry.java @@ -12,4 +12,6 @@ static VertexSerializerRegistry instance() { } VertexSerializer get(VertexFormatDescription srcFormat, VertexFormatDescription dstFormat); + + void registerSerializer(VertexFormatDescription srcFormat, VertexFormatDescription dstFormat, VertexSerializer serializer); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexAttributeFormat.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexAttributeFormat.java index 91d42c1662..7bcdfc628a 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexAttributeFormat.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexAttributeFormat.java @@ -7,6 +7,9 @@ */ public record GlVertexAttributeFormat(int typeId, int size) { public static final GlVertexAttributeFormat FLOAT = new GlVertexAttributeFormat(GL33C.GL_FLOAT, 4); + public static final GlVertexAttributeFormat INT = new GlVertexAttributeFormat(GL33C.GL_INT, 4); + public static final GlVertexAttributeFormat SHORT = new GlVertexAttributeFormat(GL33C.GL_SHORT, 2); + public static final GlVertexAttributeFormat BYTE = new GlVertexAttributeFormat(GL33C.GL_BYTE, 1); public static final GlVertexAttributeFormat UNSIGNED_SHORT = new GlVertexAttributeFormat(GL33C.GL_UNSIGNED_SHORT, 2); public static final GlVertexAttributeFormat UNSIGNED_BYTE = new GlVertexAttributeFormat(GL33C.GL_UNSIGNED_BYTE, 1); public static final GlVertexAttributeFormat UNSIGNED_INT = new GlVertexAttributeFormat(GL33C.GL_UNSIGNED_INT, 4); diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexFormat.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexFormat.java index aee75108d0..f0d3e615c0 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexFormat.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/attribute/GlVertexFormat.java @@ -1,34 +1,38 @@ package net.caffeinemc.mods.sodium.client.gl.attribute; +import it.unimi.dsi.fastutil.objects.Object2IntArrayMap; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.caffeinemc.mods.sodium.client.render.vertex.VertexFormatAttribute; + import java.util.EnumMap; +import java.util.Map; /** - * Provides a generic vertex format which contains the attributes defined by {@param T}. Other code can then retrieve + * Provides a generic vertex format which contains the attributes defined by a {@link VertexFormatAttribute}. Other code can then retrieve * the attributes and work with encoded data in a generic manner without needing to rely on a specific format. - * - * @param The enumeration over the vertex attributes */ -public class GlVertexFormat> { - private final Class attributeEnum; - private final EnumMap attributesKeyed; +public class GlVertexFormat { + private final Map attributesKeyed; private final int stride; + private final GlVertexAttributeBinding[] bindings; - public GlVertexFormat(Class attributeEnum, EnumMap attributesKeyed, int stride) { - this.attributeEnum = attributeEnum; + public GlVertexFormat(Map attributesKeyed, GlVertexAttributeBinding[] bindings, int stride) { this.attributesKeyed = attributesKeyed; + this.bindings = bindings; this.stride = stride; } - public static > Builder builder(Class type, int stride) { - return new Builder<>(type, stride); + public static Builder builder(int stride) { + return new Builder(stride); } /** * Returns the {@link GlVertexAttribute} of this vertex format bound to the type {@param name}. * @throws NullPointerException If the attribute does not exist in this format */ - public GlVertexAttribute getAttribute(T name) { + public GlVertexAttribute getAttribute(VertexFormatAttribute name) { GlVertexAttribute attr = this.attributesKeyed.get(name); if (attr == null) { @@ -47,23 +51,27 @@ public int getStride() { @Override public String toString() { - return String.format("GlVertexFormat<%s>{attributes=%d,stride=%d}", this.attributeEnum.getName(), + return String.format("GlVertexFormat{attributes=%d,stride=%d}", this.attributesKeyed.size(), this.stride); } - public static class Builder> { - private final EnumMap attributes; - private final Class type; + public GlVertexAttributeBinding[] getShaderBindings() { + return bindings; + } + + public static class Builder { + private final Map attributes; + private final Object2IntMap bindings; private final int stride; - public Builder(Class type, int stride) { - this.type = type; - this.attributes = new EnumMap<>(type); + public Builder(int stride) { + this.attributes = new Object2ObjectArrayMap<>(); + this.bindings = new Object2IntArrayMap<>(); this.stride = stride; } - public Builder addElement(T type, int pointer, GlVertexAttributeFormat format, int count, boolean normalized, boolean intType) { - return this.addElement(type, new GlVertexAttribute(format, count, normalized, pointer, this.stride, intType)); + public Builder addElement(VertexFormatAttribute attribute, int binding, int pointer) { + return this.addElement(attribute, binding, new GlVertexAttribute(attribute.format(), attribute.count(), attribute.normalized(), pointer, this.stride, attribute.intType())); } /** @@ -73,7 +81,7 @@ public Builder addElement(T type, int pointer, GlVertexAttributeFormat format * @param attribute The attribute to bind * @throws IllegalStateException If an attribute is already bound to the generic type */ - private Builder addElement(T type, GlVertexAttribute attribute) { + private Builder addElement(VertexFormatAttribute type, int binding, GlVertexAttribute attribute) { if (attribute.getPointer() >= this.stride) { throw new IllegalArgumentException("Element starts outside vertex format"); } @@ -86,22 +94,20 @@ private Builder addElement(T type, GlVertexAttribute attribute) { throw new IllegalStateException("Generic attribute " + type.name() + " already defined in vertex format"); } + if (binding != -1) { + this.bindings.put(attribute, binding); + } + return this; } /** * Creates a {@link GlVertexFormat} from the current builder. */ - public GlVertexFormat build() { + public GlVertexFormat build() { int size = 0; - for (T key : this.type.getEnumConstants()) { - GlVertexAttribute attribute = this.attributes.get(key); - - if (attribute == null) { - throw new NullPointerException("Generic attribute not assigned to enumeration " + key.name()); - } - + for (GlVertexAttribute attribute : this.attributes.values()) { size = Math.max(size, attribute.getPointer() + attribute.getSize()); } @@ -111,7 +117,11 @@ public GlVertexFormat build() { throw new IllegalArgumentException("Stride is too small"); } - return new GlVertexFormat<>(this.type, this.attributes, this.stride); + GlVertexAttributeBinding[] bindings = this.bindings.object2IntEntrySet().stream() + .map(entry -> new GlVertexAttributeBinding(entry.getIntValue(), entry.getKey())) + .toArray(GlVertexAttributeBinding[]::new); + + return new GlVertexFormat(this.attributes, bindings, this.stride); } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/IndexedVertexData.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/IndexedVertexData.java index e76d54d4fd..12b879ba99 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/IndexedVertexData.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/buffer/IndexedVertexData.java @@ -6,7 +6,7 @@ /** * Helper type for tagging the vertex format alongside the raw buffer data. */ -public record IndexedVertexData(GlVertexFormat vertexFormat, +public record IndexedVertexData(GlVertexFormat vertexFormat, NativeBuffer vertexBuffer, NativeBuffer indexBuffer) { public void delete() { diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/GlProgram.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/GlProgram.java index 94038561df..7fd17298cd 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/GlProgram.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/GlProgram.java @@ -8,6 +8,7 @@ import net.minecraft.resources.ResourceLocation; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL20C; import org.lwjgl.opengl.GL30C; import org.lwjgl.opengl.GL32C; @@ -51,7 +52,7 @@ public void delete() { } @Override - public > U bindUniform(String name, IntFunction factory) { + public > @NotNull U bindUniform(String name, IntFunction factory) { int index = GL20C.glGetUniformLocation(this.handle(), name); if (index < 0) { @@ -62,7 +63,18 @@ public > U bindUniform(String name, IntFunction factor } @Override - public GlUniformBlock bindUniformBlock(String name, int bindingPoint) { + public > U bindUniformOptional(String name, IntFunction factory) { + int index = GL20C.glGetUniformLocation(this.handle(), name); + + if (index < 0) { + return null; + } + + return factory.apply(index); + } + + @Override + public @NotNull GlUniformBlock bindUniformBlock(String name, int bindingPoint) { int index = GL32C.glGetUniformBlockIndex(this.handle(), name); if (index < 0) { @@ -74,6 +86,19 @@ public GlUniformBlock bindUniformBlock(String name, int bindingPoint) { return new GlUniformBlock(bindingPoint); } + @Override + public GlUniformBlock bindUniformBlockOptional(String name, int bindingPoint) { + int index = GL32C.glGetUniformBlockIndex(this.handle(), name); + + if (index < 0) { + return null; + } + + GL32C.glUniformBlockBinding(this.handle(), index, bindingPoint); + + return new GlUniformBlock(bindingPoint); + } + public static class Builder { private final ResourceLocation name; private final int program; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/ShaderType.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/ShaderType.java index 4d4f1842bf..b7ce23c2e0 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/ShaderType.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/shader/ShaderType.java @@ -1,12 +1,17 @@ package net.caffeinemc.mods.sodium.client.gl.shader; import org.lwjgl.opengl.GL20C; +import org.lwjgl.opengl.GL32C; +import org.lwjgl.opengl.GL40C; /** * An enumeration over the supported OpenGL shader types. */ public enum ShaderType { VERTEX(GL20C.GL_VERTEX_SHADER), + GEOMETRY(GL32C.GL_GEOMETRY_SHADER), + TESS_CONTROL(GL40C.GL_TESS_CONTROL_SHADER), + TESS_EVALUATION(GL40C.GL_TESS_EVALUATION_SHADER), FRAGMENT(GL20C.GL_FRAGMENT_SHADER); public final int id; @@ -14,4 +19,14 @@ public enum ShaderType { ShaderType(int id) { this.id = id; } + + public static ShaderType fromGlShaderType(int id) { + for (ShaderType type : values()) { + if (type.id == id) { + return type; + } + } + + return null; + } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlPrimitiveType.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlPrimitiveType.java index 2946bc40b6..19380ff653 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlPrimitiveType.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gl/tessellation/GlPrimitiveType.java @@ -1,9 +1,13 @@ package net.caffeinemc.mods.sodium.client.gl.tessellation; import org.lwjgl.opengl.GL20C; +import org.lwjgl.opengl.GL40C; public enum GlPrimitiveType { - TRIANGLES(GL20C.GL_TRIANGLES); + POINTS(GL20C.GL_POINTS), + LINES(GL20C.GL_LINES), + TRIANGLES(GL20C.GL_TRIANGLES), + PATCHES(GL40C.GL_PATCHES); private final int id; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/SodiumGameOptionPages.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/SodiumGameOptionPages.java index f0cb6c37c9..b512dddc4e 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/SodiumGameOptionPages.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/SodiumGameOptionPages.java @@ -308,7 +308,7 @@ public static OptionPage performance() { .setControl(TickBoxControl::new) .setImpact(OptionImpact.LOW) .setBinding((opts, value) -> opts.performance.useNoErrorGLContext = value, opts -> opts.performance.useNoErrorGLContext) - .setEnabled(supportsNoErrorContext()) + .setEnabled(SodiumGameOptionPages::supportsNoErrorContext) .setFlags(OptionFlag.REQUIRES_GAME_RESTART) .build()) .build()); @@ -338,13 +338,15 @@ private static boolean supportsNoErrorContext() { public static OptionPage advanced() { List groups = new ArrayList<>(); + boolean isPersistentMappingSupported = MappedStagingBuffer.isSupported(RenderDevice.INSTANCE); + groups.add(OptionGroup.createBuilder() .add(OptionImpl.createBuilder(boolean.class, sodiumOpts) .setName(Component.translatable("sodium.options.use_persistent_mapping.name")) .setTooltip(Component.translatable("sodium.options.use_persistent_mapping.tooltip")) .setControl(TickBoxControl::new) .setImpact(OptionImpact.MEDIUM) - .setEnabled(MappedStagingBuffer.isSupported(RenderDevice.INSTANCE)) + .setEnabled(() -> isPersistentMappingSupported) .setBinding((opts, value) -> opts.advanced.useAdvancedStagingBuffers = value, opts -> opts.advanced.useAdvancedStagingBuffers) .setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD) .build() diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionImpl.java index 42c4af342d..893bea4363 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionImpl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/gui/options/OptionImpl.java @@ -11,6 +11,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.function.BiConsumer; +import java.util.function.BooleanSupplier; import java.util.function.Function; public class OptionImpl implements Option { @@ -29,7 +30,7 @@ public class OptionImpl implements Option { private T value; private T modifiedValue; - private final boolean enabled; + private final BooleanSupplier enabled; private OptionImpl(OptionStorage storage, Component name, @@ -38,7 +39,7 @@ private OptionImpl(OptionStorage storage, Function, Control> control, EnumSet flags, OptionImpact impact, - boolean enabled) { + BooleanSupplier enabled) { this.storage = storage; this.name = name; this.tooltip = tooltip; @@ -94,7 +95,7 @@ public OptionStorage getStorage() { @Override public boolean isAvailable() { - return this.enabled; + return this.enabled.getAsBoolean(); } @Override @@ -125,7 +126,7 @@ public static class Builder { private Function, Control> control; private OptionImpact impact; private final EnumSet flags = EnumSet.noneOf(OptionFlag.class); - private boolean enabled = true; + private BooleanSupplier enabled = () -> true; private Builder(OptionStorage storage) { this.storage = storage; @@ -179,7 +180,7 @@ public Builder setImpact(OptionImpact impact) { return this; } - public Builder setEnabled(boolean value) { + public Builder setEnabled(BooleanSupplier value) { this.enabled = value; return this; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/DefaultChunkRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/DefaultChunkRenderer.java index 51d630203b..19b131f4e0 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/DefaultChunkRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/DefaultChunkRenderer.java @@ -20,7 +20,6 @@ import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderInterface; import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.SortBehavior; -import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkMeshAttribute; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; import net.caffeinemc.mods.sodium.client.render.viewport.CameraTransform; import net.caffeinemc.mods.sodium.client.util.BitwiseMath; @@ -316,18 +315,7 @@ private GlTessellation prepareIndexedTessellation(CommandList commandList, Rende private GlTessellation createRegionTessellation(CommandList commandList, RenderRegion.DeviceResources resources, boolean useSharedIndexBuffer) { return commandList.createTessellation(GlPrimitiveType.TRIANGLES, new TessellationBinding[] { - TessellationBinding.forVertexBuffer(resources.getGeometryBuffer(), new GlVertexAttributeBinding[] { - new GlVertexAttributeBinding(ChunkShaderBindingPoints.ATTRIBUTE_POSITION_HI, - this.vertexFormat.getAttribute(ChunkMeshAttribute.POSITION_HI)), - new GlVertexAttributeBinding(ChunkShaderBindingPoints.ATTRIBUTE_POSITION_LO, - this.vertexFormat.getAttribute(ChunkMeshAttribute.POSITION_LO)), - new GlVertexAttributeBinding(ChunkShaderBindingPoints.ATTRIBUTE_COLOR, - this.vertexFormat.getAttribute(ChunkMeshAttribute.COLOR)), - new GlVertexAttributeBinding(ChunkShaderBindingPoints.ATTRIBUTE_TEXTURE, - this.vertexFormat.getAttribute(ChunkMeshAttribute.TEXTURE)), - new GlVertexAttributeBinding(ChunkShaderBindingPoints.ATTRIBUTE_LIGHT_MATERIAL_INDEX, - this.vertexFormat.getAttribute(ChunkMeshAttribute.LIGHT_MATERIAL_INDEX)) - }), + TessellationBinding.forVertexBuffer(resources.getGeometryBuffer(), this.vertexFormat.getShaderBindings()), TessellationBinding.forElementBuffer(useSharedIndexBuffer ? this.sharedIndexBuffer.getBufferObject() : resources.getIndexBuffer()) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ShaderChunkRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ShaderChunkRenderer.java index ccd34ac6d4..fecce3ba8f 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ShaderChunkRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/ShaderChunkRenderer.java @@ -4,14 +4,10 @@ import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexFormat; import net.caffeinemc.mods.sodium.client.gl.device.CommandList; import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice; +import net.caffeinemc.mods.sodium.client.render.chunk.shader.*; import net.caffeinemc.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; -import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkMeshAttribute; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; import net.caffeinemc.mods.sodium.client.gl.shader.*; -import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkFogMode; -import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderBindingPoints; -import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderInterface; -import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderOptions; import net.minecraft.resources.ResourceLocation; import java.util.Map; @@ -19,7 +15,7 @@ public abstract class ShaderChunkRenderer implements ChunkRenderer { private final Map> programs = new Object2ObjectOpenHashMap<>(); protected final ChunkVertexType vertexType; - protected final GlVertexFormat vertexFormat; + protected final GlVertexFormat vertexFormat; protected final RenderDevice device; @@ -60,7 +56,7 @@ private GlProgram createShader(String path, ChunkShaderOpt .bindAttribute("a_TexCoord", ChunkShaderBindingPoints.ATTRIBUTE_TEXTURE) .bindAttribute("a_LightAndData", ChunkShaderBindingPoints.ATTRIBUTE_LIGHT_MATERIAL_INDEX) .bindFragmentData("fragColor", ChunkShaderBindingPoints.FRAG_COLOR) - .link((shader) -> new ChunkShaderInterface(shader, options)); + .link((shader) -> new DefaultShaderInterface(shader, options)); } finally { vertShader.delete(); fragShader.delete(); @@ -79,6 +75,8 @@ protected void begin(TerrainRenderPass pass) { } protected void end(TerrainRenderPass pass) { + this.activeProgram.getInterface() + .resetState(); this.activeProgram.unbind(); this.activeProgram = null; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderInterface.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderInterface.java index a5da4ac192..a5e51f3518 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderInterface.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ChunkShaderInterface.java @@ -1,67 +1,17 @@ package net.caffeinemc.mods.sodium.client.render.chunk.shader; -import com.mojang.blaze3d.platform.GlStateManager; -import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat3v; -import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformInt; -import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformMatrix4f; -import net.caffeinemc.mods.sodium.client.util.TextureUtil; import org.joml.Matrix4fc; -import org.lwjgl.opengl.GL32C; -import java.util.EnumMap; -import java.util.Map; +public interface ChunkShaderInterface { + @Deprecated + void setupState(); -/** - * A forward-rendering shader program for chunks. - */ -public class ChunkShaderInterface { - private final Map uniformTextures; + @Deprecated + void resetState(); - private final GlUniformMatrix4f uniformModelViewMatrix; - private final GlUniformMatrix4f uniformProjectionMatrix; - private final GlUniformFloat3v uniformRegionOffset; + void setProjectionMatrix(Matrix4fc matrix); - // The fog shader component used by this program in order to setup the appropriate GL state - private final ChunkShaderFogComponent fogShader; + void setModelViewMatrix(Matrix4fc matrix); - public ChunkShaderInterface(ShaderBindingContext context, ChunkShaderOptions options) { - this.uniformModelViewMatrix = context.bindUniform("u_ModelViewMatrix", GlUniformMatrix4f::new); - this.uniformProjectionMatrix = context.bindUniform("u_ProjectionMatrix", GlUniformMatrix4f::new); - this.uniformRegionOffset = context.bindUniform("u_RegionOffset", GlUniformFloat3v::new); - - this.uniformTextures = new EnumMap<>(ChunkShaderTextureSlot.class); - this.uniformTextures.put(ChunkShaderTextureSlot.BLOCK, context.bindUniform("u_BlockTex", GlUniformInt::new)); - this.uniformTextures.put(ChunkShaderTextureSlot.LIGHT, context.bindUniform("u_LightTex", GlUniformInt::new)); - - this.fogShader = options.fog().getFactory().apply(context); - } - - @Deprecated // the shader interface should not modify pipeline state - public void setupState() { - this.bindTexture(ChunkShaderTextureSlot.BLOCK, TextureUtil.getBlockTextureId()); - this.bindTexture(ChunkShaderTextureSlot.LIGHT, TextureUtil.getLightTextureId()); - - this.fogShader.setup(); - } - - @Deprecated(forRemoval = true) // should be handled properly in GFX instead. - private void bindTexture(ChunkShaderTextureSlot slot, int textureId) { - GlStateManager._activeTexture(GL32C.GL_TEXTURE0 + slot.ordinal()); - GlStateManager._bindTexture(textureId); - - var uniform = this.uniformTextures.get(slot); - uniform.setInt(slot.ordinal()); - } - - public void setProjectionMatrix(Matrix4fc matrix) { - this.uniformProjectionMatrix.set(matrix); - } - - public void setModelViewMatrix(Matrix4fc matrix) { - this.uniformModelViewMatrix.set(matrix); - } - - public void setRegionOffset(float x, float y, float z) { - this.uniformRegionOffset.set(x, y, z); - } + void setRegionOffset(float x, float y, float z); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/DefaultShaderInterface.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/DefaultShaderInterface.java new file mode 100644 index 0000000000..1ce8947477 --- /dev/null +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/DefaultShaderInterface.java @@ -0,0 +1,75 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.shader; + +import com.mojang.blaze3d.platform.GlStateManager; +import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat3v; +import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformInt; +import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformMatrix4f; +import net.caffeinemc.mods.sodium.client.util.TextureUtil; +import org.joml.Matrix4fc; +import org.lwjgl.opengl.GL32C; + +import java.util.EnumMap; +import java.util.Map; + +/** + * A forward-rendering shader program for chunks. + */ +public class DefaultShaderInterface implements ChunkShaderInterface { + private final Map uniformTextures; + + private final GlUniformMatrix4f uniformModelViewMatrix; + private final GlUniformMatrix4f uniformProjectionMatrix; + private final GlUniformFloat3v uniformRegionOffset; + + // The fog shader component used by this program in order to setup the appropriate GL state + private final ChunkShaderFogComponent fogShader; + + public DefaultShaderInterface(ShaderBindingContext context, ChunkShaderOptions options) { + this.uniformModelViewMatrix = context.bindUniform("u_ModelViewMatrix", GlUniformMatrix4f::new); + this.uniformProjectionMatrix = context.bindUniform("u_ProjectionMatrix", GlUniformMatrix4f::new); + this.uniformRegionOffset = context.bindUniform("u_RegionOffset", GlUniformFloat3v::new); + + this.uniformTextures = new EnumMap<>(ChunkShaderTextureSlot.class); + this.uniformTextures.put(ChunkShaderTextureSlot.BLOCK, context.bindUniform("u_BlockTex", GlUniformInt::new)); + this.uniformTextures.put(ChunkShaderTextureSlot.LIGHT, context.bindUniform("u_LightTex", GlUniformInt::new)); + + this.fogShader = options.fog().getFactory().apply(context); + } + + @Override // the shader interface should not modify pipeline state + public void setupState() { + this.bindTexture(ChunkShaderTextureSlot.BLOCK, TextureUtil.getBlockTextureId()); + this.bindTexture(ChunkShaderTextureSlot.LIGHT, TextureUtil.getLightTextureId()); + + this.fogShader.setup(); + } + + @Override // the shader interface should not modify pipeline state + public void resetState() { + // This is used by alternate implementations. + } + + @Deprecated(forRemoval = true) // should be handled properly in GFX instead. + private void bindTexture(ChunkShaderTextureSlot slot, int textureId) { + GlStateManager._activeTexture(GL32C.GL_TEXTURE0 + slot.ordinal()); + GlStateManager._bindTexture(textureId); + + var uniform = this.uniformTextures.get(slot); + uniform.setInt(slot.ordinal()); + } + + @Override + public void setProjectionMatrix(Matrix4fc matrix) { + this.uniformProjectionMatrix.set(matrix); + } + + @Override + public void setModelViewMatrix(Matrix4fc matrix) { + this.uniformModelViewMatrix.set(matrix); + } + + @Override + public void setRegionOffset(float x, float y, float z) { + this.uniformRegionOffset.set(x, y, z); + } +} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ShaderBindingContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ShaderBindingContext.java index 0797ff5408..3af314a743 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ShaderBindingContext.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/shader/ShaderBindingContext.java @@ -2,11 +2,21 @@ import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniform; import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformBlock; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.function.IntFunction; public interface ShaderBindingContext { + @NotNull > U bindUniform(String name, IntFunction factory); + @Nullable + > U bindUniformOptional(String name, IntFunction factory); + + @NotNull GlUniformBlock bindUniformBlock(String name, int bindingPoint); + + @Nullable + GlUniformBlock bindUniformBlockOptional(String name, int bindingPoint); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkMeshAttribute.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkMeshAttribute.java deleted file mode 100644 index fd9b793f98..0000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkMeshAttribute.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format; - -public enum ChunkMeshAttribute { - POSITION_HI, - POSITION_LO, - - COLOR, - TEXTURE, - LIGHT_MATERIAL_INDEX, -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexType.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexType.java index e3e01b492e..be35c4bf7c 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexType.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/ChunkVertexType.java @@ -3,7 +3,7 @@ import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexFormat; public interface ChunkVertexType { - GlVertexFormat getVertexFormat(); + GlVertexFormat getVertexFormat(); ChunkVertexEncoder getEncoder(); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java index 1220f078e4..970a6afb31 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/CompactChunkVertex.java @@ -1,8 +1,7 @@ package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.impl; -import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexAttributeFormat; import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexFormat; -import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkMeshAttribute; +import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderBindingPoints; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType; import net.caffeinemc.mods.sodium.client.render.frapi.helper.ColorHelper; @@ -12,12 +11,12 @@ public class CompactChunkVertex implements ChunkVertexType { public static final int STRIDE = 20; - public static final GlVertexFormat VERTEX_FORMAT = GlVertexFormat.builder(ChunkMeshAttribute.class, STRIDE) - .addElement(ChunkMeshAttribute.POSITION_HI, 0, GlVertexAttributeFormat.UNSIGNED_INT, 1, false, true) - .addElement(ChunkMeshAttribute.POSITION_LO, 4, GlVertexAttributeFormat.UNSIGNED_INT, 1, false, true) - .addElement(ChunkMeshAttribute.COLOR, 8, GlVertexAttributeFormat.UNSIGNED_BYTE, 4, true, false) - .addElement(ChunkMeshAttribute.TEXTURE, 12, GlVertexAttributeFormat.UNSIGNED_SHORT, 2, false, true) - .addElement(ChunkMeshAttribute.LIGHT_MATERIAL_INDEX, 16, GlVertexAttributeFormat.UNSIGNED_BYTE, 4, false, true) + public static final GlVertexFormat VERTEX_FORMAT = GlVertexFormat.builder(STRIDE) + .addElement(DefaultChunkMeshAttributes.POSITION_HI, ChunkShaderBindingPoints.ATTRIBUTE_POSITION_HI, 0) + .addElement(DefaultChunkMeshAttributes.POSITION_LO, ChunkShaderBindingPoints.ATTRIBUTE_POSITION_LO, 4) + .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) .build(); private static final int POSITION_MAX_VALUE = 1 << 20; @@ -27,7 +26,7 @@ public class CompactChunkVertex implements ChunkVertexType { private static final float MODEL_RANGE = 32.0f; @Override - public GlVertexFormat getVertexFormat() { + public GlVertexFormat getVertexFormat() { return VERTEX_FORMAT; } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/DefaultChunkMeshAttributes.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/DefaultChunkMeshAttributes.java new file mode 100644 index 0000000000..5da6117115 --- /dev/null +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/vertex/format/impl/DefaultChunkMeshAttributes.java @@ -0,0 +1,12 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.impl; + +import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexAttributeFormat; +import net.caffeinemc.mods.sodium.client.render.vertex.VertexFormatAttribute; + +public class DefaultChunkMeshAttributes { + public static final VertexFormatAttribute POSITION_HI = new VertexFormatAttribute("POSITION_HI", GlVertexAttributeFormat.UNSIGNED_INT, 1, false, true); + public static final VertexFormatAttribute POSITION_LO = new VertexFormatAttribute("POSITION_LO", GlVertexAttributeFormat.UNSIGNED_INT, 1, false, true); + public static final VertexFormatAttribute COLOR = new VertexFormatAttribute("COLOR", GlVertexAttributeFormat.UNSIGNED_BYTE, 4, true, false); + public static final VertexFormatAttribute TEXTURE = new VertexFormatAttribute("TEXTURE", GlVertexAttributeFormat.UNSIGNED_SHORT, 2, false, true); + public static final VertexFormatAttribute LIGHT_MATERIAL_INDEX = new VertexFormatAttribute("LIGHT_MATERIAL_INDEX", GlVertexAttributeFormat.UNSIGNED_BYTE, 4, false, true); +} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatAttribute.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatAttribute.java new file mode 100644 index 0000000000..f2e8231168 --- /dev/null +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatAttribute.java @@ -0,0 +1,7 @@ +package net.caffeinemc.mods.sodium.client.render.vertex; + +import net.caffeinemc.mods.sodium.client.gl.attribute.GlVertexAttributeFormat; + +public record VertexFormatAttribute(String name, GlVertexAttributeFormat format, int count, boolean normalized, boolean intType) { + +} \ No newline at end of file diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/serializers/VertexSerializerRegistryImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/serializers/VertexSerializerRegistryImpl.java index ff85ca4f34..e7e4efe593 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/serializers/VertexSerializerRegistryImpl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/serializers/VertexSerializerRegistryImpl.java @@ -46,6 +46,11 @@ public VertexSerializer get(VertexFormatDescription srcFormat, VertexFormatDescr return serializer; } + @Override + public void registerSerializer(VertexFormatDescription srcFormat, VertexFormatDescription dstFormat, VertexSerializer serializer) { + this.cache.put(createKey(srcFormat, dstFormat), serializer); + } + private VertexSerializer create(long identifier, VertexFormatDescription srcFormat, VertexFormatDescription dstFormat) { var stamp = this.lock.writeLock(); From 5f92b769234679a115d56be12d6bc63a165cb4d7 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Wed, 21 Aug 2024 20:02:46 -0700 Subject: [PATCH 14/17] Bump to 0.6.0-beta.1 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index aa87c1055e..a492f94d36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ val FABRIC_API_VERSION by extra { "0.101.0+1.21" } val PARCHMENT_VERSION by extra { "2024.07.28" } // https://semver.org/ -val MOD_VERSION by extra { "0.6.0" } +val MOD_VERSION by extra { "0.6.0-beta.1" } allprojects { apply(plugin = "java") From 22b59e1033f3a956328b72f2e7f966d6b30eef06 Mon Sep 17 00:00:00 2001 From: JellySquid <1363084+jellysquid3@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:26:07 -0600 Subject: [PATCH 15/17] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 33acfecc0b..995884d091 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ micro-stutter, while fixing many graphical issues in Minecraft. ### 📥 Installation -The latest releases of Sodium are published to our official [Modrinth](https://modrinth.com/mod/sodium) and -[GitHub release](https://github.com/CaffeineMC/sodium-fabric/releases) pages. These releases are considered by our -team to be suitable for general use, but they are not guaranteed to be free of bugs and other issues. +The latest version of Sodium can be downloaded from our official [Modrinth](https://modrinth.com/mod/sodium) and +[CurseForge](https://www.curseforge.com/minecraft/mc-mods/sodium) pages. -For more information about downloading and installing the mod, you can read our installation guide on -[Modrinth](https://modrinth.com/mod/sodium#installation). -It also contains information about any currently known compatibility issues, which are often useful to read. +Since the release of Sodium 0.6.0, both the _Fabric_ and _NeoForge_ mod loaders are supported. We generally recommend +that new users prefer to use the _Fabric_ mod loader, since it is more lightweight and stable (for the time being.) + +For more information about downloading and installing the mod, please refer to our [Installation Guide](https://github.com/CaffeineMC/sodium-fabric/wiki/Installation). ### 🐛 Reporting Issues From d614a3621f3ab8ab367f9109f708e38d4e5aca89 Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sat, 24 Aug 2024 09:13:50 -0700 Subject: [PATCH 16/17] Fix mixin overrides not applying on non-first launch --- .../caffeinemc/mods/sodium/client/data/config/MixinConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java index fd846edf38..b9ad8c36e8 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/data/config/MixinConfig.java @@ -210,7 +210,7 @@ public static MixinConfig load(File file) { MixinConfig config = new MixinConfig(); config.readProperties(props); - PlatformMixinOverrides.getInstance().applyModOverrides(); + PlatformMixinOverrides.getInstance().applyModOverrides().forEach(config::applyModOverride); return config; } From c91efa8bbb4e65204192b479a687aabebc873bbf Mon Sep 17 00:00:00 2001 From: IMS212 Date: Sat, 24 Aug 2024 10:34:41 -0700 Subject: [PATCH 17/17] Disable quad reorientation --- .../client/render/chunk/compile/pipeline/BlockRenderer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java index 93fdcac9f5..ab63a602e3 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java @@ -151,7 +151,8 @@ private void colorizeQuad(MutableQuadViewImpl quad, int colorIndex) { } private void bufferQuad(MutableQuadViewImpl quad, float[] brightnesses, Material material, ChunkModelBuilder modelBuilder) { - ModelQuadOrientation orientation = defaultLightMode == LightMode.FLAT ? ModelQuadOrientation.NORMAL : ModelQuadOrientation.orientByBrightness(brightnesses, quad); + // TODO: Find a way to reimplement quad reorientation + ModelQuadOrientation orientation = ModelQuadOrientation.NORMAL; ChunkVertexEncoder.Vertex[] vertices = this.vertices; Vector3f offset = this.posOffset;