From 003a85615debe895af6cd41cc67989f76a941f27 Mon Sep 17 00:00:00 2001 From: Asek3 <64613894+Asek3@users.noreply.github.com> Date: Sun, 28 Jan 2024 22:19:29 +0200 Subject: [PATCH] do a little cleanup --- .../sodium/client/render/GameRendererContext.java | 3 +-- .../sodium/client/render/SodiumWorldRenderer.java | 11 ++++++----- .../client/render/chunk/ChunkRenderBackend.java | 5 ++--- .../client/render/chunk/ChunkRenderManager.java | 9 +++------ .../client/render/chunk/shader/ChunkProgram.java | 5 ++--- .../render/chunk/shader/ChunkRenderShaderBackend.java | 7 +++---- .../features/chunk_rendering/MixinWorldRenderer.java | 10 +--------- 7 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/GameRendererContext.java b/src/main/java/me/jellysquid/mods/sodium/client/render/GameRendererContext.java index 8eb80aa56..ef1441e7d 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/GameRendererContext.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/GameRendererContext.java @@ -1,6 +1,5 @@ package me.jellysquid.mods.sodium.client.render; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import me.jellysquid.mods.sodium.mixin.features.chunk_rendering.AccessorActiveRenderInfo; import org.lwjgl.BufferUtils; import repack.joml.Matrix4f; @@ -19,7 +18,7 @@ public class GameRendererContext { * @return A float-buffer on the stack containing the model-view-projection matrix in a format suitable for * uploading as uniform state */ - public static FloatBuffer getModelViewProjectionMatrix(MatrixStack.Entry matrices) { + public static FloatBuffer getModelViewProjectionMatrix() { Matrix4f matrix = new Matrix4f(AccessorActiveRenderInfo.getProjectionMatrix()); Matrix4f model = new Matrix4f(AccessorActiveRenderInfo.getModelViewMatrix()); matrix.mul(model); diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java b/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java index 02027e758..958236112 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/SodiumWorldRenderer.java @@ -18,7 +18,6 @@ import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPassManager; import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheShared; import me.jellysquid.mods.sodium.client.util.math.FrustumExtended; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import me.jellysquid.mods.sodium.client.world.ChunkStatusListener; import me.jellysquid.mods.sodium.client.world.ChunkStatusListenerManager; import me.jellysquid.mods.sodium.common.util.ListUtil; @@ -28,7 +27,6 @@ import net.minecraft.client.renderer.DestroyBlockProgress; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.entity.Entity; import net.minecraft.profiler.Profiler; @@ -36,7 +34,10 @@ import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.*; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.MinecraftForgeClient; import java.util.Map; @@ -242,12 +243,12 @@ public void updateChunks(Frustum frustum, float ticks, boolean hasForcedFrustum, /** * Performs a render pass for the given {@link BlockRenderLayer} and draws all visible chunks for it. */ - public void drawChunkLayer(BlockRenderLayer renderLayer, MatrixStack matrixStack, double x, double y, double z) { + public void drawChunkLayer(BlockRenderLayer renderLayer, double x, double y, double z) { BlockRenderPass pass = this.renderPassManager.getRenderPassForLayer(renderLayer); // TODO startDrawing/endDrawing are handled by 1.12 already //pass.startDrawing(); - this.chunkRenderManager.renderLayer(matrixStack, pass, x, y, z); + this.chunkRenderManager.renderLayer(pass, x, y, z); //pass.endDrawing(); diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderBackend.java b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderBackend.java index 57742da2e..e384e18d7 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderBackend.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderBackend.java @@ -5,7 +5,6 @@ import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType; import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildResult; import me.jellysquid.mods.sodium.client.render.chunk.lists.ChunkRenderListIterator; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import java.util.Collections; import java.util.Iterator; @@ -33,9 +32,9 @@ public interface ChunkRenderBackend { void createShaders(RenderDevice device); - void begin(MatrixStack matrixStack); + void begin(); - void end(MatrixStack matrixStack); + void end(); /** * Deletes this render backend and any resources attached to it. diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderManager.java b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderManager.java index a7b347cc0..bd1f509db 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderManager.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/ChunkRenderManager.java @@ -27,15 +27,12 @@ import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPassManager; import me.jellysquid.mods.sodium.client.util.math.FrustumExtended; import me.jellysquid.mods.sodium.client.util.math.MathChunkPos; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import me.jellysquid.mods.sodium.client.world.ChunkStatusListener; -import me.jellysquid.mods.sodium.common.util.CameraUtil; import me.jellysquid.mods.sodium.common.util.DirectionUtil; import me.jellysquid.mods.sodium.common.util.IdTable; import me.jellysquid.mods.sodium.common.util.collections.FutureDequeDrain; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.ChunkPos; @@ -447,20 +444,20 @@ private ChunkRenderContainer createChunkRender(ChunkRenderColumn column, i return render; } - public void renderLayer(MatrixStack matrixStack, BlockRenderPass pass, double x, double y, double z) { + public void renderLayer(BlockRenderPass pass, double x, double y, double z) { ChunkRenderList chunkRenderList = this.chunkRenderLists[pass.ordinal()]; ChunkRenderListIterator iterator = chunkRenderList.iterator(pass.isTranslucent()); RenderDevice device = RenderDevice.INSTANCE; CommandList commandList = device.createCommandList(); - this.backend.begin(matrixStack); + this.backend.begin(); // Ensure multidraw regions are ordered appropriately if(this.backend instanceof MultidrawChunkRenderBackend) { ((MultidrawChunkRenderBackend) this.backend).setReverseRegions(pass.isTranslucent()); } this.backend.render(commandList, iterator, new ChunkCameraContext(x, y, z)); - this.backend.end(matrixStack); + this.backend.end(); commandList.flush(); } diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkProgram.java b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkProgram.java index 63acededc..0757ea298 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkProgram.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkProgram.java @@ -3,7 +3,6 @@ import me.jellysquid.mods.sodium.client.gl.shader.GlProgram; import me.jellysquid.mods.sodium.client.gl.device.RenderDevice; import me.jellysquid.mods.sodium.client.render.GameRendererContext; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL20; @@ -36,7 +35,7 @@ protected ChunkProgram(RenderDevice owner, ResourceLocation name, int handle, Fu this.fogShader = fogShaderFunction.apply(this); } - public void setup(MatrixStack matrixStack, float modelScale, float textureScale) { + public void setup(float modelScale, float textureScale) { GL20.glUniform1i(this.uBlockTex, 0); GL20.glUniform1i(this.uLightTex, 1); @@ -45,6 +44,6 @@ public void setup(MatrixStack matrixStack, float modelScale, float textureScale) this.fogShader.setup(); - GL20.glUniformMatrix4(this.uModelViewProjectionMatrix, false, GameRendererContext.getModelViewProjectionMatrix(matrixStack.peek())); + GL20.glUniformMatrix4(this.uModelViewProjectionMatrix, false, GameRendererContext.getModelViewProjectionMatrix()); } } diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkRenderShaderBackend.java b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkRenderShaderBackend.java index f6ef361fd..51d3a1719 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkRenderShaderBackend.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/chunk/shader/ChunkRenderShaderBackend.java @@ -11,7 +11,6 @@ import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState; import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderBackend; import me.jellysquid.mods.sodium.client.render.chunk.format.ChunkMeshAttribute; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import net.minecraft.util.ResourceLocation; import java.util.EnumMap; @@ -61,14 +60,14 @@ public final void createShaders(RenderDevice device) { } @Override - public void begin(MatrixStack matrixStack) { + public void begin() { this.activeProgram = this.programs.get(FogHelper.getFogMode()); this.activeProgram.bind(); - this.activeProgram.setup(matrixStack, this.vertexType.getModelScale(), this.vertexType.getTextureScale()); + this.activeProgram.setup(this.vertexType.getModelScale(), this.vertexType.getTextureScale()); } @Override - public void end(MatrixStack matrixStack) { + public void end() { this.activeProgram.unbind(); this.activeProgram = null; } diff --git a/src/main/java/me/jellysquid/mods/sodium/mixin/features/chunk_rendering/MixinWorldRenderer.java b/src/main/java/me/jellysquid/mods/sodium/mixin/features/chunk_rendering/MixinWorldRenderer.java index 52e00bcf1..378213ee0 100644 --- a/src/main/java/me/jellysquid/mods/sodium/mixin/features/chunk_rendering/MixinWorldRenderer.java +++ b/src/main/java/me/jellysquid/mods/sodium/mixin/features/chunk_rendering/MixinWorldRenderer.java @@ -2,21 +2,15 @@ import me.jellysquid.mods.sodium.client.gl.device.RenderDevice; import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; -import me.jellysquid.mods.sodium.client.util.math.MatrixStack; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.client.renderer.culling.ICamera; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.util.BlockRenderLayer; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL13; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -25,9 +19,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import repack.joml.Matrix4f; -import java.nio.FloatBuffer; import java.util.Map; import java.util.Set; @@ -111,7 +103,7 @@ public int renderBlockLayer(BlockRenderLayer blockLayerIn, double partialTicks, double d5 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * partialTicks; try { - this.renderer.drawChunkLayer(blockLayerIn, new MatrixStack(), d3, d4, d5); + this.renderer.drawChunkLayer(blockLayerIn, d3, d4, d5); } finally { RenderDevice.exitManagedCode(); }