diff options
author | FalsePattern <me@falsepattern.com> | 2024-01-07 12:44:30 +0100 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2024-01-08 22:49:40 +0100 |
commit | ad42f10bad1aa7417ebeb9c3c1f31cd5b19b9220 (patch) | |
tree | 3be51649a11aa90a25f724d0e2a884e9727c8d8f /src | |
parent | 6cf175b96bf97aabd76fdc2e074cc6c04223d652 (diff) | |
download | Neodymium-ad42f10bad1aa7417ebeb9c3c1f31cd5b19b9220.tar.gz Neodymium-ad42f10bad1aa7417ebeb9c3c1f31cd5b19b9220.tar.bz2 Neodymium-ad42f10bad1aa7417ebeb9c3c1f31cd5b19b9220.zip |
stop renderlists logic from running at all
Diffstat (limited to 'src')
3 files changed, 41 insertions, 12 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java index f3a4301..791dd5d 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java @@ -30,10 +30,13 @@ abstract class MixinRenderGlobal { } } - @Inject(method = "renderSortedRenderers", at = @At(value = "HEAD")) - public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable cir) { + @Inject(method = "renderSortedRenderers", + at = @At(value = "HEAD"), + cancellable = true, + require = 1) + public void preRenderSortedRenderers(int startRenderer, int numRenderers, int renderPass, double partialTickTime, CallbackInfoReturnable<Integer> cir) { if(Neodymium.isActive()) { - Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers); + cir.setReturnValue(Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers)); } } diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java index 42cedfe..6ddf377 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -10,11 +10,14 @@ import makamys.neodymium.renderer.NeoRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.entity.EntityLivingBase; + +import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Collections; @@ -90,6 +93,25 @@ abstract class MixinWorldRenderer implements IWorldRenderer { ChunkMesh.setCaptureTarget(cm); } } + + @Redirect(method = "preRenderBlocks", + at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glNewList(II)V"), + require = 1) + private void noNewList(int list, int mode) { + if (!Neodymium.isActive()) { + GL11.glNewList(list, mode); + } + } + + @Redirect(method = "postRenderBlocks", + at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glEndList()V"), + require = 1) + private void noEndList() { + if (!Neodymium.isActive()) + GL11.glEndList(); + } @Inject(method = "postRenderBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I")) private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) { diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 0cc7692..7d5928d 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -104,7 +104,8 @@ public class NeoRenderer { Vector4f transformedOrigin = new Vector4f(); - public void preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { + public int preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { + int rendered = 0; if (hasInited) { if (renderPass == 0) { renderedMeshes = 0; @@ -149,11 +150,12 @@ public class NeoRenderer { if (rendererActive && renderWorld) { Minecraft.getMinecraft().entityRenderer.enableLightmap((double) alpha); - render(renderPass, alpha); + rendered += render(renderPass, alpha); Minecraft.getMinecraft().entityRenderer.disableLightmap((double) alpha); } } + return rendered; } public void onRenderTickEnd() { @@ -285,18 +287,17 @@ public class NeoRenderer { Matrix4f modelViewMatrixInv = new Matrix4f(); Matrix4f projMatrix = new Matrix4f(); - private void render(int pass, double alpha) { - int shader = getShaderProgram(pass); - - if (shader == 0) return; - - glBindVertexArray(VAO); - + private int render(int pass, double alpha) { if (!Compat.isShaders()) { + int shader = getShaderProgram(pass); + + if (shader == 0) return 0; glUseProgram(shader); updateUniforms(alpha, pass); } + glBindVertexArray(VAO); + if (isWireframeEnabled()) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } @@ -308,9 +309,11 @@ public class NeoRenderer { int oldLimit = piFirst[pass].limit(); + int rendered = 0; int order = pass == 0 ? 1 : -1; for (int regionI = order == 1 ? 0 : loadedRegionsList.size() - 1; regionI >= 0 && regionI < loadedRegionsList.size(); regionI += order) { NeoRegion.RenderData region = loadedRegionsList.get(regionI).getRenderData(); + rendered += region.batchLimit[pass] - region.batchFirst[pass]; Util.setPositionAndLimit(piFirst[pass], region.batchFirst[pass], region.batchLimit[pass]); Util.setPositionAndLimit(piCount[pass], region.batchFirst[pass], region.batchLimit[pass]); @@ -344,6 +347,7 @@ public class NeoRenderer { } glBindVertexArray(0); + return rendered; } private void updateGLValues() { |