aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-22 03:02:46 +0200
committermakamys <makamys@outlook.com>2022-06-22 03:02:46 +0200
commitbef6742c00977461daf36a56023432472e79bab5 (patch)
tree2a069f729d2b2a80a87ec64999491e280df77fba /src/main/java
parenta5d03b7d6f610d4346fa1ce48d1b9e61f7968fcb (diff)
downloadNeodymium-bef6742c00977461daf36a56023432472e79bab5.tar.gz
Neodymium-bef6742c00977461daf36a56023432472e79bab5.tar.bz2
Neodymium-bef6742c00977461daf36a56023432472e79bab5.zip
Increase GC rate if the remaining free space is low
Fixes buffer getting full when FPS limit is set to 30
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java6
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java
index da5c92b..a353ad5 100644
--- a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java
+++ b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java
@@ -47,7 +47,11 @@ public class GPUMemoryManager {
int timesReachedEnd = 0;
int checksLeft = sentMeshes.size();
- while((!full && (moved < 4 && checksLeft-- > 0)) || (full && timesReachedEnd < 2) && !sentMeshes.isEmpty()) {
+ final int MB256 = 256 * 1024 * 1024;
+
+ int panicRate = (int)(((float)Math.max(MB256 - (bufferSize - end()), 0) / (float)MB256) * 64f);
+
+ while((!full && (moved < (4 + panicRate) && checksLeft-- > 0)) || (full && timesReachedEnd < 2) && !sentMeshes.isEmpty()) {
nextMesh++;
if(nextMesh >= sentMeshes.size()) {
nextMesh = 0;
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index d307c28..7bc582c 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -132,9 +132,7 @@ public class NeoRenderer {
if(Minecraft.getMinecraft().currentScreen == null) {
handleKeyboard();
}
- if(frameCount % 2 == 0) {
- mem.runGC(false);
- }
+ mem.runGC(false);
lastGCTime = System.currentTimeMillis();
if(lastSaveTime == -1 || (System.currentTimeMillis() - lastSaveTime) > saveInterval && Config.saveMeshes) {
onSave();