diff --git a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java index affb820f..6ca19bdc 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/bakery/ModelTextureBakery.java @@ -176,9 +176,9 @@ public class ModelTextureBakery { //SOMEBODY PLEASE FUCKING EXPLAIN TO ME WHY MUST CLEAR THE FRAMEBUFFER HERE WHEN IT IS LITERALLY CLEARED AT THE START OF THE FRAME // WITHOUT THIS, WATER DOESNT RENDER //TODO: FIXME, WHAT THE ACTUAL FUCK - //glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); - //glClearDepth(1); - //glClear(GL_DEPTH_BUFFER_BIT); + glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); + glClearDepth(1); + glClear(GL_DEPTH_BUFFER_BIT); glBindFramebuffer(GL_FRAMEBUFFER, 0); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java index b3c0f728..f5aee8d0 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java @@ -100,7 +100,7 @@ public class RenderService, J extends Vi this.nodeManager.removeTopLevelNode(pos); } - public void setup(Camera camera) { + public void tickModelService() { this.modelService.tick(); } @@ -135,7 +135,7 @@ public class RenderService, J extends Vi //Cap the number of consumed sections per frame to 40 + 2% of the queue size, cap of 200 //int geoUpdateCap = 20;//Math.max(100, Math.min((int)(0.15*this.geometryUpdateQueue.count()), 260)); - this.geometryUpdateQueue.consumeMillis(2); + this.geometryUpdateQueue.consumeMillis(1); if (this.nodeManager.writeChanges(this.traversal.getNodeBuffer())) {//TODO: maybe move the node buffer out of the traversal class UploadStream.INSTANCE.commit(); } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/VoxyRenderSystem.java b/src/main/java/me/cortex/voxy/client/core/rendering/VoxyRenderSystem.java index cb96b0be..e38000b9 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/VoxyRenderSystem.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/VoxyRenderSystem.java @@ -31,6 +31,7 @@ import org.joml.Matrix4f; import org.lwjgl.opengl.GL11; import org.lwjgl.system.MemoryUtil; +import java.lang.invoke.VarHandle; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -45,6 +46,7 @@ public class VoxyRenderSystem { private final PostProcessing postProcessing; private final WorldEngine worldIn; private final RenderDistanceTracker renderDistanceTracker; + private long runTimeNano = 0; public VoxyRenderSystem(WorldEngine world, ServiceThreadPool threadPool) { //Trigger the shared index buffer loading @@ -98,11 +100,18 @@ public class VoxyRenderSystem { downstream.submit(); downstream.tick(); }*/ + VarHandle.fullFence(); + long start = System.nanoTime(); + VarHandle.fullFence(); this.renderDistanceTracker.setCenterAndProcess(camera.getBlockPos().getX(), camera.getBlockPos().getZ()); - this.renderer.setup(camera); + this.renderer.tickModelService(); PrintfDebugUtil.tick(); + + VarHandle.fullFence(); + this.runTimeNano = System.nanoTime() - start; + VarHandle.fullFence(); } private static Matrix4f makeProjectionMatrix(float near, float far) { @@ -128,9 +137,9 @@ public class VoxyRenderSystem { } public void renderOpaque(MatrixStack matrices, double cameraX, double cameraY, double cameraZ) { - - //if (true) return; - + VarHandle.fullFence(); + long startTime = System.nanoTime(); + VarHandle.fullFence(); if (IrisUtil.irisShadowActive()) { return; @@ -200,11 +209,20 @@ public class VoxyRenderSystem { this.postProcessing.renderPost(projection, RenderSystem.getProjectionMatrix(), boundFB); glBindFramebuffer(GlConst.GL_FRAMEBUFFER, oldFB); + + VarHandle.fullFence(); + this.runTimeNano += System.nanoTime() - startTime; + VarHandle.fullFence(); } + private double role = 0; public void addDebugInfo(List debug) { debug.add("GlBuffer, Count/Size (mb): " + GlBuffer.getCount() + "/" + (GlBuffer.getTotalSize()/1_000_000)); this.renderer.addDebugData(debug); + double aa = (((double)(this.runTimeNano/1000))/1000); + + this.role = Math.max(Math.ceil((this.role * 0.99 + (aa*0.01))*1000)/1000, aa); + debug.add("Voxy frame runtime (millis): " + this.role); PrintfDebugUtil.addToOut(debug); } diff --git a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java index 6b0e6aae..091d7f32 100644 --- a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java +++ b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java @@ -25,7 +25,7 @@ public class VoxelIngestService { private final ConcurrentLinkedDeque ingestQueue = new ConcurrentLinkedDeque<>(); public VoxelIngestService(ServiceThreadPool pool) { - this.threads = pool.createServiceNoCleanup("Ingest service", 1000, ()-> this::processJob); + this.threads = pool.createServiceNoCleanup("Ingest service", 5000, ()-> this::processJob); } private void processJob() {