From 066b23c7856b3f1a72792c8d8c65b8ca073b4dba Mon Sep 17 00:00:00 2001 From: James Seibel Date: Tue, 9 Jul 2024 17:40:21 -0500 Subject: [PATCH] Add toggleable logging for GL Buffer garbage collection Will need to be tested by someone who is experiencing issue #718, so far I've been unable to reproduce anything meaningful. --- .../com/seibel/distanthorizons/core/config/Config.java | 9 +++++++++ .../core/render/glObject/buffer/GLBuffer.java | 6 +++++- .../resources/assets/distanthorizons/lang/en_us.json | 6 +++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index 71654580c..a84aba1ad 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -1238,6 +1238,15 @@ public class Config + "") .build(); + public static ConfigEntry logBufferGarbageCollection = new ConfigEntry.Builder() + .set(false) + .comment("" + + "If true OpenGL Buffer garbage collection will be logged \n" + + "this also includes the number of live buffers. \n" + + "") + .build(); + + // Note: This will reset on game restart, and should have a warning on the tooltip public static ConfigEntry allowUnsafeValues = new ConfigEntry.Builder() .set(false) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java index 7d8608a83..bdfee1f4b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/render/glObject/buffer/GLBuffer.java @@ -20,6 +20,7 @@ package com.seibel.distanthorizons.core.render.glObject.buffer; import com.seibel.distanthorizons.api.enums.config.EDhApiGpuUploadMethod; +import com.seibel.distanthorizons.core.config.Config; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.render.glObject.GLProxy; import com.seibel.distanthorizons.core.util.LodUtil; @@ -140,7 +141,10 @@ public class GLBuffer implements AutoCloseable GL32.glDeleteBuffers(id); bufferCount.decrementAndGet(); - //LOGGER.info("destroyed buffer ["+id+"], remaining: ["+BUFFER_ID_TO_PHANTOM.size()+"]"); + if (Config.Client.Advanced.Debugging.logBufferGarbageCollection.get()) + { + LOGGER.info("destroyed buffer [" + id + "], remaining: [" + BUFFER_ID_TO_PHANTOM.size() + "]"); + } } }); } diff --git a/core/src/main/resources/assets/distanthorizons/lang/en_us.json b/core/src/main/resources/assets/distanthorizons/lang/en_us.json index 08ba41a32..b60a7e5eb 100644 --- a/core/src/main/resources/assets/distanthorizons/lang/en_us.json +++ b/core/src/main/resources/assets/distanthorizons/lang/en_us.json @@ -474,7 +474,11 @@ "distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors": "Show overlapping quad errors", "distanthorizons.config.client.advanced.debugging.showOverlappingQuadErrors.@tooltip": - "f true overlapping quads will be rendered as bright red for easy identification. \nIf false the quads will be rendered normally.", + "If true overlapping quads will be rendered as bright red for easy identification. \nIf false the quads will be rendered normally.", + "distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection": + "Log Buffer Garbage Collection", + "distanthorizons.config.client.advanced.debugging.logBufferGarbageCollection.@tooltip": + "If true OpenGL Buffer garbage collection will be logged \nthis also includes the number of live buffers. ", "distanthorizons.config.client.advanced.debugging.allowUnsafeValues": "Allow Unsafe UI Values", "distanthorizons.config.client.advanced.debugging.allowUnsafeValues.@tooltip":