aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.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/makamys/neodymium/renderer/GPUMemoryManager.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/makamys/neodymium/renderer/GPUMemoryManager.java')
-rw-r--r--src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java6
1 files changed, 5 insertions, 1 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;