Skip to content

Commit

Permalink
Reimplement vanilla world renderer stats in F3 overlay
Browse files Browse the repository at this point in the history
Fixes regression in ad42f10, which caused all values to be 0
  • Loading branch information
makamys committed Feb 2, 2024
1 parent 4e253b3 commit 2c0e73c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/main/java/makamys/neodymium/renderer/NeoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import makamys.neodymium.util.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumChatFormatting;
Expand Down Expand Up @@ -146,6 +147,10 @@ public int preRenderSortedRenderers(int renderPass, double alpha, WorldRenderer[
sort(frameCount % 100 == 0, frameCount % Config.sortFrequency == 0);

initIndexBuffers();

if(!Constants.KEEP_RENDER_LIST_LOGIC) {
updateRenderGlobalStats();
}
}

frameCount++;
Expand Down Expand Up @@ -206,7 +211,7 @@ private void initIndexBuffers() {
for (int j = piCount[i].position() - meshes; j < piCount[i].position(); j++) {
renderedQuads += piCount[i].get(j) / 4;
}
if(Compat.isHodgepodgeSpeedupAnimationsEnabled() && !Constants.KEEP_RENDER_LIST_LOGIC) {
if(Compat.isHodgepodgeSpeedupAnimationsEnabled() && !Constants.KEEP_RENDER_LIST_LOGIC) {
// Hodgepodge hooks this method to decide what animations to play, make sure it runs
wr.getGLCallListForPass(i);
}
Expand All @@ -233,6 +238,26 @@ private boolean shouldRenderMesh(Mesh mesh) {
}
return false;
}

private static void updateRenderGlobalStats() {
// Normally renderSortedRenderers does this, but we cancelled it

RenderGlobal rg = Minecraft.getMinecraft().renderGlobal;

for(WorldRenderer wr : rg.sortedWorldRenderers) {
++rg.renderersLoaded;

if (wr.skipRenderPass[0]) {
++rg.renderersSkippingRenderPass;
} else if (!wr.isInFrustum) {
++rg.renderersBeingClipped;
} else if (rg.occlusionEnabled && !wr.isVisible) {
++rg.renderersBeingOccluded;
} else {
++rg.renderersBeingRendered;
}
}
}

private void mainLoop() {
if (Minecraft.getMinecraft().playerController.netClientHandler.doneLoadingTerrain) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/neodymium_at.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ public net.minecraft.client.renderer.Tessellator field_78409_u #drawMode
public net.minecraft.client.renderer.Tessellator field_78408_v #xOffset
public net.minecraft.client.renderer.Tessellator field_78407_w #yOffset
public net.minecraft.client.renderer.Tessellator field_78417_x #zOffset

public net.minecraft.client.renderer.RenderGlobal field_72751_K # renderersLoaded
public net.minecraft.client.renderer.RenderGlobal field_72744_L # renderersBeingClipped
public net.minecraft.client.renderer.RenderGlobal field_72745_M # renderersBeingOccluded
public net.minecraft.client.renderer.RenderGlobal field_72746_N # renderersBeingRendered
public net.minecraft.client.renderer.RenderGlobal field_72747_O # renderersSkippingRenderPass
public net.minecraft.client.renderer.RenderGlobal field_72774_t # occlusionEnabled
public net.minecraft.client.renderer.RenderGlobal field_72768_k # sortedWorldRenderers

0 comments on commit 2c0e73c

Please sign in to comment.