From 3c57b124d56442e92515c80f65fbe36b989d361c Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 29 May 2021 16:59:02 -0500 Subject: [PATCH] Improve profile tracking --- .../java/com/backsun/lod/proxy/ClientProxy.java | 11 +++++++++++ .../com/backsun/lod/renderer/LodRenderer.java | 15 +++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/backsun/lod/proxy/ClientProxy.java b/src/main/java/com/backsun/lod/proxy/ClientProxy.java index 2a9986837..57defb88c 100644 --- a/src/main/java/com/backsun/lod/proxy/ClientProxy.java +++ b/src/main/java/com/backsun/lod/proxy/ClientProxy.java @@ -10,6 +10,7 @@ import com.backsun.lod.renderer.LodRenderer; import com.backsun.lod.util.LodUtils; import net.minecraft.client.Minecraft; +import net.minecraft.profiler.IProfiler; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; @@ -83,8 +84,18 @@ public class ClientProxy } + // Note to self: + // if "unspecified" shows up in the pie chart, it is + // possibly because the amount of time between sections + // is too small for the profile to measure + IProfiler profiler = mc.getProfiler(); + profiler.endSection(); // get out of "terrain" + profiler.startSection("LOD"); renderer.drawLODs(lodDim, partialTicks, mc.getProfiler()); + + profiler.endSection(); // end LOD + profiler.startSection("terrain"); // restart terrain } diff --git a/src/main/java/com/backsun/lod/renderer/LodRenderer.java b/src/main/java/com/backsun/lod/renderer/LodRenderer.java index 47154ce5a..a50adbc20 100644 --- a/src/main/java/com/backsun/lod/renderer/LodRenderer.java +++ b/src/main/java/com/backsun/lod/renderer/LodRenderer.java @@ -111,7 +111,6 @@ public class LodRenderer * @param newDimension The dimension to draw, if null doesn't replace the current dimension. * @param partialTicks how far into the current tick this method was called. */ - @SuppressWarnings("deprecation") public void drawLODs(LodDimension lodDim, float partialTicks, IProfiler newProfiler) { if (lodDim == null) @@ -130,11 +129,7 @@ public class LodRenderer // initial setup // //===============// - - // used for debugging and viewing how long different processes take profiler = newProfiler; - profiler.endSection(); - profiler.startSection("LOD"); profiler.startSection("LOD setup"); ClientPlayerEntity player = mc.player; @@ -266,6 +261,7 @@ public class LodRenderer //===========// // rendering // //===========// + profiler.endStartSection("LOD draw"); setupFog(fogSetting.nearFogSetting, reflectionHandler.getFogQuality()); sendLodsToGpuAndDraw(nearVbo, modelViewMatrix); @@ -312,8 +308,7 @@ public class LodRenderer GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - - // end of profiler tracking + // end of internal LOD profiling profiler.endSection(); } @@ -329,15 +324,12 @@ public class LodRenderer if (vbo == null) return; - profiler.endStartSection("LOD draw setup"); vbo.bindBuffer(); - // 0L is the starting pointer, and the value doesn't appear to matter + // 0L is the starting pointer LOD_VERTEX_FORMAT.setupBufferState(0L); - profiler.endStartSection("LOD draw"); vbo.draw(modelViewMatrix, GL11.GL_QUADS); - profiler.endStartSection("LOD draw cleanup"); VertexBuffer.unbindBuffer(); LOD_VERTEX_FORMAT.clearBufferState(); } @@ -494,7 +486,6 @@ public class LodRenderer /** * setup the lighting to be used for the LODs */ - @SuppressWarnings("deprecation") private void setupLighting(LodDimension lodDimension, float partialTicks) { float sunBrightness = lodDimension.dimension.hasSkyLight() ? mc.world.getSunBrightness(partialTicks) : 0.2f;