Skip to content

Commit

Permalink
do a little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Asek3 committed Jan 28, 2024
1 parent 97773ea commit 003a856
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,15 +27,17 @@
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;
import net.minecraft.tileentity.TileEntity;
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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -33,9 +32,9 @@ public interface ChunkRenderBackend<T extends ChunkGraphicsState> {

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -447,20 +444,20 @@ private ChunkRenderContainer<T> createChunkRender(ChunkRenderColumn<T> 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<T> chunkRenderList = this.chunkRenderLists[pass.ordinal()];
ChunkRenderListIterator<T> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 003a856

Please sign in to comment.