From 027294dca7bd08c8a1256ed51b6a4af0158d1fb8 Mon Sep 17 00:00:00 2001 From: FalsePattern Date: Sun, 7 Jan 2024 12:44:30 +0100 Subject: [PATCH] stop renderlists logic from running at all --- .../neodymium/mixin/MixinRenderGlobal.java | 9 ++++--- .../neodymium/mixin/MixinWorldRenderer.java | 25 +++++++++++++++++-- .../neodymium/renderer/NeoRenderer.java | 19 ++++++++------ 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 79037d4..46dc3d1 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java +++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java @@ -29,10 +29,13 @@ private void blockVanillaChunkRendering(int p1, double p2, CallbackInfo ci) { } } - @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 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 b4f86e8..ff7ae7c 100644 --- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java +++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java @@ -11,6 +11,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Group; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.google.common.collect.Lists; @@ -124,8 +125,28 @@ private void prePreRenderBlocks1(CallbackInfo ci, int var1, int var2, int var3, } } + + @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, EntityLiving entity, CallbackInfo ci) { + private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) { /*if(Neodymium.isActive()) { if(nd$chunkMeshes != null) { if(nd$chunkMeshes.get(pass) == null) { @@ -263,4 +284,4 @@ public void updateRendererSort() } postUpdateRenderer(true); } -} \ No newline at end of file +} diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 130df32..6bfb66e 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -104,9 +104,10 @@ public NeoRenderer(World world){ Vector4f transformedOrigin = new Vector4f(); - public void preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { - if(hasInited) { - if(renderPass == 0) { + public int preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[] sortedWorldRenderers) { + int rendered = 0; + if (hasInited) { + if (renderPass == 0) { renderedMeshes = 0; renderedQuads = 0; @@ -149,11 +150,12 @@ public void preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer if(rendererActive && renderWorld) { Minecraft.getMinecraft().entityRenderer.enableLightmap(alpha); - render(renderPass, alpha); + rendered += render(renderPass, alpha); Minecraft.getMinecraft().entityRenderer.disableLightmap(alpha); } } + return rendered; } public void onRenderTickEnd() { @@ -285,10 +287,10 @@ private void handleKeyboard() { Matrix4f modelViewMatrixInv = new Matrix4f(); Matrix4f projMatrix = new Matrix4f(); - private void render(int pass, double alpha) { + private int render(int pass, double alpha) { int shader = getShaderProgram(pass); - if(shader == 0) return; + if(shader == 0) return 0; glBindVertexArray(VAO); glUseProgram(shader); @@ -301,10 +303,12 @@ private void render(int pass, double alpha) { int u_renderOffset = glGetUniformLocation(getShaderProgram(pass), "renderOffset"); 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]); @@ -320,6 +324,7 @@ private void render(int pass, double alpha) { glBindVertexArray(0); glUseProgram(0); + return rendered; } private void updateGLValues() {