aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-22 21:44:58 +0200
committermakamys <makamys@outlook.com>2022-06-22 21:44:58 +0200
commit0b2d306a9b05320a2194a5a9d1058d9bf34b1217 (patch)
tree1095617533564d43481d126af64ac1d7bc619b60 /src/main/java/makamys/neodymium
parent388d49110799bd4f41547e852dc8f285d642700f (diff)
downloadNeodymium-0b2d306a9b05320a2194a5a9d1058d9bf34b1217.tar.gz
Neodymium-0b2d306a9b05320a2194a5a9d1058d9bf34b1217.tar.bz2
Neodymium-0b2d306a9b05320a2194a5a9d1058d9bf34b1217.zip
Make GC lazy when the buffer is barely fragmented
I'm not sure how much this improves performance.
Diffstat (limited to 'src/main/java/makamys/neodymium')
-rw-r--r--src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java4
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java4
2 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java
index a353ad5..882b0c6 100644
--- a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java
+++ b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java
@@ -232,4 +232,8 @@ public class GPUMemoryManager {
GuiHelper.drawRectangle((bufferSize / scale) % rowLength, (bufferSize / scale) / rowLength + yOff, 4, 4, 0xFF0000);
}
+ public float getCoherenceRate() {
+ return (float)ChunkMesh.usedRAM / (float)end();
+ }
+
}
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index fed8a48..3e1abe5 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -132,7 +132,9 @@ public class NeoRenderer {
if(Minecraft.getMinecraft().currentScreen == null) {
handleKeyboard();
}
- mem.runGC(false);
+ if(mem.getCoherenceRate() < 0.95f || frameCount % 4 == 0) {
+ mem.runGC(false);
+ }
lastGCTime = System.currentTimeMillis();
if(lastSaveTime == -1 || (System.currentTimeMillis() - lastSaveTime) > saveInterval && Config.saveMeshes) {
onSave();