diff options
author | makamys <makamys@outlook.com> | 2021-05-07 17:40:26 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-07 17:59:49 +0200 |
commit | 47f060337a22042daa65ef9724baf34230e308fa (patch) | |
tree | dc218fe1d6d41034a5c04b03f49b13e9aadb0299 /src/main/java/makamys/lodmod | |
parent | b79ed9cc4f0162b030ce51b880ea1c2bc4a927a5 (diff) | |
download | Neodymium-47f060337a22042daa65ef9724baf34230e308fa.tar.gz Neodymium-47f060337a22042daa65ef9724baf34230e308fa.tar.bz2 Neodymium-47f060337a22042daa65ef9724baf34230e308fa.zip |
Add used RAM and mesh count to F3
Diffstat (limited to 'src/main/java/makamys/lodmod')
5 files changed, 42 insertions, 4 deletions
diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java index 6b0e2c7..485f867 100644 --- a/src/main/java/makamys/lodmod/LODMod.java +++ b/src/main/java/makamys/lodmod/LODMod.java @@ -78,8 +78,12 @@ public class LODMod ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); int w = scaledresolution.getScaledWidth(); int h = scaledresolution.getScaledHeight(); - String s = renderer.getDebugText(); - fontRenderer.drawStringWithShadow(s, w - fontRenderer.getStringWidth(s) - 10, 80, 0xFFFFFF); + + int yOffset = 0; + for(String s : renderer.getDebugText()) { + fontRenderer.drawStringWithShadow(s, w - fontRenderer.getStringWidth(s) - 10, 80 + yOffset, 0xFFFFFF); + yOffset += 10; + } } } } diff --git a/src/main/java/makamys/lodmod/renderer/ChunkMesh.java b/src/main/java/makamys/lodmod/renderer/ChunkMesh.java index 4175b9f..2251da8 100644 --- a/src/main/java/makamys/lodmod/renderer/ChunkMesh.java +++ b/src/main/java/makamys/lodmod/renderer/ChunkMesh.java @@ -17,6 +17,7 @@ import java.util.List; import org.lwjgl.BufferUtils; +import makamys.lodmod.LODMod; import makamys.lodmod.ducks.IWorldRenderer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; @@ -32,6 +33,9 @@ public class ChunkMesh extends Mesh { int z; Flags flags; + public static int usedRAM = 0; + public static int instances = 0; + private ChunkMesh(int x, int y, int z, Flags flags, int quadCount, byte[] data, List<String> stringTable) { this.x = x; this.y = y; @@ -40,6 +44,9 @@ public class ChunkMesh extends Mesh { this.quadCount = quadCount; this.buffer = createBuffer(data, stringTable); + + usedRAM += buffer.limit(); + instances++; } public ChunkMesh(int x, int y, int z, Flags flags, int quadCount, List<MeshQuad> quads) { @@ -50,6 +57,14 @@ public class ChunkMesh extends Mesh { this.quadCount = quadCount; this.buffer = createBuffer(quads); + + usedRAM += buffer.limit(); + instances++; + } + + void destroy() { + usedRAM -= buffer.limit(); + instances--; } private ByteBuffer createBuffer(List<MeshQuad> quads) { diff --git a/src/main/java/makamys/lodmod/renderer/LODChunk.java b/src/main/java/makamys/lodmod/renderer/LODChunk.java index 29d4198..e1582b1 100644 --- a/src/main/java/makamys/lodmod/renderer/LODChunk.java +++ b/src/main/java/makamys/lodmod/renderer/LODChunk.java @@ -37,6 +37,7 @@ public class LODChunk { for(int i = 0; i < 2; i++) { if(chunkMeshes[cy * 2 + i] != null) { renderer.setMeshVisible(chunkMeshes[cy * 2 + i], false); + chunkMeshes[cy * 2 + i].destroy(); chunkMeshes[cy * 2 + i] = null; } } diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index b28b654..4c5c50f 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -13,6 +13,7 @@ import net.minecraft.world.gen.ChunkProviderServer; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -338,6 +339,11 @@ public class LODRenderer { glDeleteProgram(shaderProgram); glDeleteVertexArrays(VAO); glDeleteBuffers(VBO); + + SimpleChunkMesh.instances = 0; + SimpleChunkMesh.usedRAM = 0; + ChunkMesh.instances = 0; + ChunkMesh.usedRAM = 0; } public void onWorldRendererPost(WorldRenderer wr) { @@ -561,8 +567,13 @@ public class LODRenderer { return null; } - public String getDebugText() { - return "VRAM: " + (nextMeshOffset / 1024 / 1024) + "MB / " + (BUFFER_SIZE / 1024 / 1024) + "MB"; + public List<String> getDebugText() { + return Arrays.asList( + "VRAM: " + (nextMeshOffset / 1024 / 1024) + "MB / " + (BUFFER_SIZE / 1024 / 1024) + "MB", + "Simple meshes: " + SimpleChunkMesh.instances + " (" + SimpleChunkMesh.usedRAM / 1024 / 1024 + "MB)", + "Full meshes: " + ChunkMesh.instances + " (" + ChunkMesh.usedRAM / 1024 / 1024 + "MB)", + "Total RAM used: " + ((SimpleChunkMesh.usedRAM + ChunkMesh.usedRAM) / 1024 / 1024) + " MB" + ); } public static class LODChunkComparator implements Comparator<LODChunk> { diff --git a/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java b/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java index 190a398..960c48d 100644 --- a/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java +++ b/src/main/java/makamys/lodmod/renderer/SimpleChunkMesh.java @@ -14,6 +14,7 @@ import java.nio.IntBuffer; import org.lwjgl.BufferUtils; +import makamys.lodmod.LODMod; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -26,6 +27,9 @@ public class SimpleChunkMesh extends Mesh { private FloatBuffer vertices; + public static int usedRAM; + public static int instances; + public SimpleChunkMesh(Chunk target) { int divisions = 4; quadCount = divisions * divisions * 5; @@ -74,6 +78,9 @@ public class SimpleChunkMesh extends Mesh { } } vertices.flip(); + + usedRAM += buffer.limit(); + instances++; } private void addCube(float x, float y, float z, float sizeX, float sizeZ, float sizeY, IIcon icon, int color) { |