From 365ae58c70b21e1705dcdcc56ef4d16650755c37 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sat, 3 May 2025 15:34:34 +1000 Subject: [PATCH] timing + other --- .../cortex/voxy/client/TimingStatistics.java | 1 + .../voxy/client/core/VoxyRenderSystem.java | 8 +++--- .../core/model/ModelBakerySubsystem.java | 21 +++++++-------- .../client/core/rendering/RenderService.java | 2 +- .../building/RenderDataFactory45.java | 26 ++++++++++++++++--- .../voxy/common/world/SaveLoadSystem3.java | 3 +-- 6 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/TimingStatistics.java b/src/main/java/me/cortex/voxy/client/TimingStatistics.java index f12a7b51..21855640 100644 --- a/src/main/java/me/cortex/voxy/client/TimingStatistics.java +++ b/src/main/java/me/cortex/voxy/client/TimingStatistics.java @@ -73,6 +73,7 @@ public class TimingStatistics { public static TimeSampler all = new TimeSampler(); public static TimeSampler main = new TimeSampler(); public static TimeSampler dynamic = new TimeSampler(); + public static TimeSampler postDynamic = new TimeSampler(); public static void update() { diff --git a/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java b/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java index f520b35a..8e19dabd 100644 --- a/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java +++ b/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java @@ -200,6 +200,8 @@ public class VoxyRenderSystem { this.postProcessing.renderPost(projection, matrices.projection(), boundFB); + TimingStatistics.main.stop(); + TimingStatistics.postDynamic.start(); PrintfDebugUtil.tick(); @@ -211,11 +213,11 @@ public class VoxyRenderSystem { this.renderDistanceTracker.setCenterAndProcess(cameraX, cameraZ); //Done here as is allows less gl state resetup - this.renderer.tickModelService(5_000_000-(System.nanoTime()-startTime)); + this.renderer.tickModelService(Math.max(5_000_000-(System.nanoTime()-startTime), 75_000)); } + TimingStatistics.postDynamic.stop(); glBindFramebuffer(GlConst.GL_FRAMEBUFFER, oldFB); - TimingStatistics.main.stop(); TimingStatistics.all.stop(); } @@ -224,7 +226,7 @@ public class VoxyRenderSystem { this.renderer.addDebugData(debug); { TimingStatistics.update(); - debug.add("Voxy frame runtime (millis): " + TimingStatistics.dynamic.pVal() + ", " + TimingStatistics.main.pVal()+ ", " + TimingStatistics.all.pVal()); + debug.add("Voxy frame runtime (millis): " + TimingStatistics.dynamic.pVal() + ", " + TimingStatistics.main.pVal()+ ", " + TimingStatistics.postDynamic.pVal()+ ", " + TimingStatistics.all.pVal()); } PrintfDebugUtil.addToOut(debug); } diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java index cf03c65d..7d60c82c 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java @@ -70,17 +70,16 @@ public class ModelBakerySubsystem { VarHandle.fullFence(); { long budget = Math.min(totalBudget-150_000, totalBudget-(this.factory.resultJobs.size()*10_000L))-150_000; - if (budget > 50_000) { - Integer i = this.blockIdQueue.poll(); - if (i != null) { - do { - this.factory.addEntry(i); - i = this.blockIdQueue.poll(); - } while (i != null && (System.nanoTime() - start < budget)); - if (i != null) {//We timedout on our budget and we have an entry so we must add it back - this.blockIdQueue.add(i); - } - } + + //Always do 1 iteration minimum + Integer i = this.blockIdQueue.poll(); + if (i != null) { + do { + this.factory.addEntry(i); + if (budget<(System.nanoTime() - start)+1000) + break; + i = this.blockIdQueue.poll(); + } while (i != null); } } 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 9497d1b0..7be45a04 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 @@ -142,7 +142,7 @@ public class RenderService, J extends Vi //if (this.modelService.getProcessingCount() < 750) {//Very bad hack to try control things - this.geometryUpdateQueue.consumeNano(2_000_000 - (System.nanoTime() - frameStart)); + this.geometryUpdateQueue.consumeNano(3_000_000 - (System.nanoTime() - frameStart)); } this.nodeCleaner.tick(this.traversal.getNodeBuffer());//Probably do this here?? diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java index 57f42596..cb3a02dc 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java @@ -371,12 +371,19 @@ public class RenderDataFactory45 { int iA = idx * 2 + (facingForward == 1 ? 0 : shift); int iB = idx * 2 + (facingForward == 1 ? shift : 0); + //Check if next culls this face + if (false) { + if (ModelQueries.faceOccludes(this.sectionData[iB + 1], (axis << 1) | (1 - facingForward))) { + this.blockMesher.skip(1); + continue; + } + } + long selfModel = this.sectionData[iA]; long nextModel = this.sectionData[iB]; - this.blockMesher.putNext(((long) facingForward) |//Facing selfModel | - (nextModel&(0xFFL<<55))//Apply lighting + (nextModel & (0xFFL << 55))//Apply lighting ); } } @@ -783,8 +790,19 @@ public class RenderDataFactory45 { long B = this.sectionData[(idx + 1) * 2]; //Flip data with respect to facing direction - long selfModel = facingForward==1?A:B; - long nextModel = facingForward==1?B:A; + int iA = idx * 2 + (facingForward == 1 ? 0 : 2); + int iB = idx * 2 + (facingForward == 1 ? 2 : 0); + + //Check if next culls this face + if (false) { + if (ModelQueries.faceOccludes(this.sectionData[iB + 1], (2 << 1) | (1 - facingForward))) { + mesher.skip(1); + continue; + } + } + + long selfModel = this.sectionData[iA]; + long nextModel = this.sectionData[iB]; //Example thing thats just wrong but as example mesher.putNext(((long) facingForward) |//Facing diff --git a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem3.java b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem3.java index feaa6453..a71f4a9e 100644 --- a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem3.java +++ b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem3.java @@ -51,8 +51,7 @@ public class SaveLoadSystem3 { long metadataPtr = ptr; ptr += 8; long blockPtr = ptr; ptr += WorldSection.SECTION_VOLUME*2; - for (int i = 0; i < WorldSection.SECTION_VOLUME; i++) { - long block = data[i]; + for (long block : data) { short mapping = LUT.putIfAbsent(block, (short) LUT.size()); if (mapping == -1) { mapping = (short) (LUT.size()-1);