From a6ed4968f5047d9316d3943e9e4c85da9613168f Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 28 Aug 2021 23:38:51 -0500 Subject: [PATCH] Add a config option for the number of buffer builder threads --- .../seibel/lod/builders/LodBufferBuilder.java | 2 +- .../com/seibel/lod/handlers/LodConfig.java | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java b/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java index dfc5133e8..4a1ecce85 100644 --- a/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java +++ b/src/main/java/com/seibel/lod/builders/LodBufferBuilder.java @@ -60,7 +60,7 @@ public class LodBufferBuilder /** * This holds the threads used to generate buffers. */ - private ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(LodConfig.CLIENT.numberOfWorldGenerationThreads.get(), new LodThreadFactory(this.getClass().getSimpleName() + " - builder")); + private ExecutorService bufferBuilderThreads = Executors.newFixedThreadPool(LodConfig.CLIENT.numberOfBufferBuilderThreads.get(), new LodThreadFactory(this.getClass().getSimpleName() + " - builder")); /** * The buffers that are used to create LODs using far fog diff --git a/src/main/java/com/seibel/lod/handlers/LodConfig.java b/src/main/java/com/seibel/lod/handlers/LodConfig.java index d5e2f53cd..67d67570b 100644 --- a/src/main/java/com/seibel/lod/handlers/LodConfig.java +++ b/src/main/java/com/seibel/lod/handlers/LodConfig.java @@ -71,6 +71,8 @@ public class LodConfig public ForgeConfigSpec.IntValue numberOfWorldGenerationThreads; + public ForgeConfigSpec.IntValue numberOfBufferBuilderThreads; + public ForgeConfigSpec.EnumValue shadingMode; public ForgeConfigSpec.EnumValue lodDistanceCalculatorType; @@ -246,15 +248,27 @@ public class LodConfig numberOfWorldGenerationThreads = builder .comment("\n\n" - + " This is how many threads are used when generating terrain. \n" - + " If you experience stuttering when generating terrain, decrease \n" + + " This is how many threads are used when generating LODs outside \n" + + " the normal render distance. \n" + + " If you experience stuttering when generating distant LODs, decrease \n" + " this number. If you want to increase LOD generation speed, \n" - + " increase the number. \n" - + " The max is the number of processors on your CPU. \n" - + "\n" + + " increase this number. \n" + + " \n" + + " The maximum value is the number of processors on your CPU. \n" + " Requires a restart to take effect. \n") .defineInRange("numberOfWorldGenerationThreads", Runtime.getRuntime().availableProcessors() / 2, 1, Runtime.getRuntime().availableProcessors()); + numberOfBufferBuilderThreads = builder + .comment("\n\n" + + " This is how many threads are used when building vertex buffers \n" + + " (The things I send to the GPU to draw the LODs). \n" + + " If you experience high CPU useage when NOT generating distant \n" + + " LODs lower this number. \n" + + " \n" + + " The maximum value is the number of processors on your CPU. \n" + + " Requires a restart to take effect. \n") + .defineInRange("numberOfBufferBuilderThreads", Runtime.getRuntime().availableProcessors(), 1, Runtime.getRuntime().availableProcessors()); + shadingMode = builder .comment("\n\n" + " What kind of shading should the LODs have? \n"