More config options

This commit is contained in:
mcrcortex
2024-01-24 08:33:48 +10:00
parent a3216b26eb
commit 48ec40c5c2
8 changed files with 39 additions and 12 deletions

View File

@@ -21,6 +21,8 @@ public class ZenithConfig {
public boolean enabled = true;
public int qualityScale = 20;
public int maxSections = 200_000;
public int geometryBufferSize = (1<<30)/8;
public int ingestThreads = 2;
public int savingThreads = 10;
public int renderThreads = 5;

View File

@@ -25,7 +25,7 @@ public class ZenithConfigScreenFactory implements ModMenuApi {
private static Screen buildConfigScreen(Screen parent, ZenithConfig config) {
ConfigBuilder builder = ConfigBuilder.create()
.setParentScreen(parent)
.setTitle(Text.translatable("title.zenith.config"));
.setTitle(Text.translatable("zenith.config.title"));
addGeneralCategory(builder, config);
@@ -61,6 +61,18 @@ public class ZenithConfigScreenFactory implements ModMenuApi {
.setDefaultValue(DEFAULT.qualityScale)
.build());
category.addEntry(entryBuilder.startIntSlider(Text.translatable("zenith.config.general.geometryBuffer"), config.geometryBufferSize, (1<<27)/8, ((1<<31)-1)/8)
.setTooltip(Text.translatable("zenith.config.general.geometryBuffer.tooltip"))
.setSaveConsumer(val -> config.geometryBufferSize = val)
.setDefaultValue(DEFAULT.geometryBufferSize)
.build());
category.addEntry(entryBuilder.startIntSlider(Text.translatable("zenith.config.general.maxSections"), config.maxSections, 100_000, 400_000)
.setTooltip(Text.translatable("zenith.config.general.maxSections.tooltip"))
.setSaveConsumer(val -> config.maxSections = val)
.setDefaultValue(DEFAULT.maxSections)
.build());
category.addEntry(entryBuilder.startIntSlider(Text.translatable("zenith.config.general.compression"), config.savingCompressionLevel, 1, 21)
.setTooltip(Text.translatable("zenith.config.general.compression.tooltip"))
.setSaveConsumer(val -> config.savingCompressionLevel = val)

View File

@@ -1,5 +1,6 @@
package me.cortex.zenith.client.core;
import me.cortex.zenith.client.Zenith;
import me.cortex.zenith.client.config.ZenithConfig;
import me.cortex.zenith.client.core.rendering.*;
import me.cortex.zenith.client.core.rendering.building.RenderGenerationService;
@@ -65,7 +66,7 @@ public class VoxelCore {
//Trigger the shared index buffer loading
SharedIndexBuffer.INSTANCE.id();
this.renderer = new Gl46FarWorldRenderer();
this.renderer = new Gl46FarWorldRenderer(ZenithConfig.CONFIG.geometryBufferSize, ZenithConfig.CONFIG.maxSections);
System.out.println("Renderer initialized");
this.world = new WorldEngine(new FragmentedStorageBackendAdaptor(new File(ZenithConfig.CONFIG.storagePath)), ZenithConfig.CONFIG.ingestThreads, ZenithConfig.CONFIG.savingThreads, ZenithConfig.CONFIG.savingCompressionLevel, 5);//"storagefile.db"//"ethoslab.db"
System.out.println("World engine");

View File

@@ -50,13 +50,13 @@ public abstract class AbstractFarWorldRenderer {
protected FrustumIntersection frustum;
public AbstractFarWorldRenderer() {
public AbstractFarWorldRenderer(int geometrySize, int maxSections) {
this.uniformBuffer = new GlBuffer(1024, 0);
//TODO: make these both dynamically sized
this.stateDataBuffer = new GlBuffer((1<<16)*28, 0);//Capacity for 1<<16 entries
this.biomeDataBuffer = new GlBuffer(512*4*2, 0);//capacity for 1<<9 entries
this.lightDataBuffer = new GlBuffer(256*4, 0);//256 of uint
this.geometry = new GeometryManager();
this.geometry = new GeometryManager(geometrySize*8L, maxSections);
}
protected abstract void setupVao();

View File

@@ -42,9 +42,9 @@ public class GeometryManager {
private final BufferArena geometryBuffer;
public GeometryManager() {
this.sectionMetaBuffer = new GlBuffer(1L << 23, 0);
this.geometryBuffer = new BufferArena((1L << 30) - 1024, 8);
public GeometryManager(long geometryBufferSize, int maxSections) {
this.sectionMetaBuffer = new GlBuffer(((long) maxSections) * SECTION_METADATA_SIZE, 0);
this.geometryBuffer = new BufferArena(geometryBufferSize, 8);
this.pos2id.defaultReturnValue(-1);
}

View File

@@ -18,11 +18,14 @@ import static org.lwjgl.opengl.ARBMultiDrawIndirect.glMultiDrawElementsIndirect;
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_SHORT;
import static org.lwjgl.opengl.GL30.glBindVertexArray;
import static org.lwjgl.opengl.GL30C.GL_R8UI;
import static org.lwjgl.opengl.GL30C.GL_RED_INTEGER;
import static org.lwjgl.opengl.GL40C.GL_DRAW_INDIRECT_BUFFER;
import static org.lwjgl.opengl.GL42.*;
import static org.lwjgl.opengl.GL42.GL_FRAMEBUFFER_BARRIER_BIT;
import static org.lwjgl.opengl.GL43.*;
import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_BUFFER;
import static org.lwjgl.opengl.GL45C.glClearNamedBufferData;
import static org.lwjgl.opengl.NVRepresentativeFragmentTest.GL_REPRESENTATIVE_FRAGMENT_TEST_NV;
public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
@@ -42,11 +45,15 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
.add(ShaderType.FRAGMENT, "zenith:lod/gl46/cull/raster.frag")
.compile();
private final GlBuffer glCommandBuffer = new GlBuffer(200_000*5*4, 0);
private final GlBuffer glVisibilityBuffer = new GlBuffer(200_000*4, 0);
private final GlBuffer glCommandBuffer;
private final GlBuffer glVisibilityBuffer;
public Gl46FarWorldRenderer() {
super();
public Gl46FarWorldRenderer(int geometryBuffer, int maxSections) {
super(geometryBuffer, maxSections);
glCommandBuffer = new GlBuffer(maxSections*5L*4, 0);
glVisibilityBuffer = new GlBuffer(maxSections*4L, 0);
glClearNamedBufferData(glCommandBuffer.id, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, new int[1]);
glClearNamedBufferData(glVisibilityBuffer.id, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, new int[1]);
setupVao();
}

View File

@@ -19,6 +19,11 @@ public class NvFarWorldRenderer extends AbstractFarWorldRenderer {
.add(ShaderType.MESH, "voxelmon:lod/nvmesh/primary.mesh")
.add(ShaderType.FRAGMENT, "voxelmon:lod/nvmesh/primary.frag")
.compile();
public NvFarWorldRenderer(int geometrySize, int maxSections) {
super(geometrySize, maxSections);
}
@Override
protected void setupVao() {

View File

@@ -216,7 +216,7 @@ public class WorldImporter {
biomes,
(bx, by, bz, state) -> {
int block = 0;
int sky = 0;
int sky = 15;//since sky is inverted
if (blockLight != null) {
block = blockLight.get(bx, by, bz);
}