Skip to content

Commit

Permalink
stop renderlists logic from running at all
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern authored and Arminias committed Nov 2, 2024
1 parent 78fc480 commit 027294d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> cir) {
if(Neodymium.isActive()) {
Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers);
cir.setReturnValue(Neodymium.renderer.preRenderSortedRenderers(renderPass, partialTickTime, sortedWorldRenderers));
}
}

Expand Down
25 changes: 23 additions & 2 deletions src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -263,4 +284,4 @@ public void updateRendererSort()
}
postUpdateRenderer(true);
}
}
}
19 changes: 12 additions & 7 deletions src/main/java/makamys/neodymium/renderer/NeoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand All @@ -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]);

Expand All @@ -320,6 +324,7 @@ private void render(int pass, double alpha) {

glBindVertexArray(0);
glUseProgram(0);
return rendered;
}

private void updateGLValues() {
Expand Down

0 comments on commit 027294d

Please sign in to comment.