diff options
author | makamys <makamys@outlook.com> | 2022-06-22 03:02:46 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-22 03:02:46 +0200 |
commit | bef6742c00977461daf36a56023432472e79bab5 (patch) | |
tree | 2a069f729d2b2a80a87ec64999491e280df77fba /src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java | |
parent | a5d03b7d6f610d4346fa1ce48d1b9e61f7968fcb (diff) | |
download | Neodymium-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.java | 6 |
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; |