aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r--src/main/java/makamys/neodymium/Compat.java18
-rw-r--r--src/main/java/makamys/neodymium/Neodymium.java3
-rw-r--r--src/main/java/makamys/neodymium/renderer/GPUMemoryManager.java21
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java19
-rw-r--r--src/main/java/makamys/neodymium/util/ChatUtil.java2
5 files changed, 50 insertions, 13 deletions
diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java
index e6bedea..f37c1f4 100644
--- a/src/main/java/makamys/neodymium/Compat.java
+++ b/src/main/java/makamys/neodymium/Compat.java
@@ -10,6 +10,7 @@ import org.lwjgl.opengl.GLContext;
import com.falsepattern.triangulator.api.ToggleableTessellator;
import cpw.mods.fml.common.Loader;
+import makamys.neodymium.config.Config;
import makamys.neodymium.util.OFUtil;
import makamys.neodymium.util.virtualjar.IVirtualJar;
import makamys.neodymium.util.virtualjar.VirtualJar;
@@ -20,6 +21,8 @@ public class Compat {
private static boolean wasAdvancedOpenGLEnabled;
+ private static int notEnoughVRAMAmountMB = -1;
+
public static void applyCompatibilityTweaks() {
if (Loader.isModLoaded("triangulator")) {
disableTriangulator();
@@ -53,6 +56,9 @@ public class Compat {
if(!GLContext.getCapabilities().OpenGL33) {
criticalWarns.add("OpenGL 3.3 is not supported.");
}
+ if(detectedNotEnoughVRAM()) {
+ criticalWarns.add("Not enough VRAM");
+ }
}
public static boolean hasChanged() {
@@ -66,6 +72,18 @@ public class Compat {
return changed;
}
+
+ public static void onNotEnoughVRAM(int amountMB) {
+ notEnoughVRAMAmountMB = amountMB;
+ }
+
+ public static void reset() {
+ notEnoughVRAMAmountMB = -1;
+ }
+
+ private static boolean detectedNotEnoughVRAM() {
+ return Config.VRAMSize == notEnoughVRAMAmountMB;
+ }
public static void forceEnableOptiFineDetectionOfFastCraft() {
if(Compat.class.getResource("/fastcraft/Tweaker.class") != null) {
diff --git a/src/main/java/makamys/neodymium/Neodymium.java b/src/main/java/makamys/neodymium/Neodymium.java
index 5340550..b140a3c 100644
--- a/src/main/java/makamys/neodymium/Neodymium.java
+++ b/src/main/java/makamys/neodymium/Neodymium.java
@@ -86,6 +86,7 @@ public class Neodymium
{
Config.reloadConfig();
ChatUtil.resetShownChatMessages();
+ Compat.reset();
}
private void onPlayerWorldChanged(World newWorld) {
@@ -167,7 +168,7 @@ public class Neodymium
renderer.forceRenderFog = true;
}
} else if(event.phase == TickEvent.Phase.END) {
- if(isActive()) {
+ if(renderer != null) {
renderer.onRenderTickEnd();
}
}
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) {
diff --git a/src/main/java/makamys/neodymium/util/ChatUtil.java b/src/main/java/makamys/neodymium/util/ChatUtil.java
index 7c2337f..06b4ee4 100644
--- a/src/main/java/makamys/neodymium/util/ChatUtil.java
+++ b/src/main/java/makamys/neodymium/util/ChatUtil.java
@@ -31,7 +31,7 @@ public class ChatUtil {
}
public static void showNeoChatMessage(String text, MessageVerbosity verbosity, boolean once) {
- if(shownChatMessages.contains(text)) return;
+ if(once && shownChatMessages.contains(text)) return;
String verbosityText =
verbosity == MessageVerbosity.WARNING