diff options
Diffstat (limited to 'src/main/java/makamys/neodymium/renderer')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java | 21 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/NeoRenderer.java | 19 |
2 files changed, 29 insertions, 11 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java index 34fafd9..16a72d5 100644 --- a/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java +++ b/src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java @@ -6,12 +6,15 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import makamys.neodymium.Compat; import makamys.neodymium.Neodymium; import makamys.neodymium.config.Config; import makamys.neodymium.renderer.Mesh.GPUStatus; import makamys.neodymium.util.GuiHelper; import makamys.neodymium.util.ChatUtil; +import static makamys.neodymium.Constants.LOGGER; + /** Manages dynamic memory allocation inside a fixed buffer on the GPU. */ public class GPUMemoryManager { @@ -25,7 +28,10 @@ public class GPUMemoryManager { private long usedVRAM; private long lastUsedVRAMUpdate; - private static final long USED_VRAM_UPDATE_RATE = 1_000_000_000; + private static final long USED_VRAM_UPDATE_RATE = 1_000_000_000L; + + private static final long MAX_VRAM_FULLNESS_INTERVAL = 30L * 1_000_000_000L; + private static long lastVRAMFullness = -1; public GPUMemoryManager() { VBO = glGenBuffers(); @@ -99,9 +105,18 @@ public class GPUMemoryManager { } if(end() + mesh.bufferSize() >= bufferSize) { - ChatUtil.showNeoChatMessage("VRAM is full! Reverting to vanilla renderer. Try increasing the VRAM buffer size in the config, if possible.", ChatUtil.MessageVerbosity.ERROR); Neodymium.renderer.destroyPending = true; - // TODO restart renderer with more VRAM allocated when this happens. + + long t = System.nanoTime(); + + if(lastVRAMFullness != -1 && t - lastVRAMFullness < MAX_VRAM_FULLNESS_INTERVAL) { + ChatUtil.showNeoChatMessage("VRAM keeps getting full! Reverting to vanilla renderer. Try increasing the VRAM buffer size in the config, if possible.", ChatUtil.MessageVerbosity.ERROR, false); + Compat.onNotEnoughVRAM(Config.VRAMSize); + } else { + LOGGER.debug("Reloading renderer because VRAM is full."); + // TODO restart renderer with more VRAM allocated when this happens. + } + lastVRAMFullness = t; return; } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 0ba82d1..74daa4f 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -159,18 +159,21 @@ public class NeoRenderer { } public void onRenderTickEnd() { - if(destroyPending) { + if(Neodymium.isActive()) { + if(reloadPending) { + Minecraft.getMinecraft().renderGlobal.loadRenderers(); + } + if(showMemoryDebugger && mem != null) { + GuiHelper.begin(); + mem.drawInfo(); + GuiHelper.end(); + } + } else if(destroyPending) { destroy(); + destroyPending = false; Neodymium.renderer = null; - return; - } else if(reloadPending) { Minecraft.getMinecraft().renderGlobal.loadRenderers(); } - if(showMemoryDebugger && mem != null) { - GuiHelper.begin(); - mem.drawInfo(); - GuiHelper.end(); - } } private void sort(boolean pass0, boolean pass1) { |