|
63 | 63 | public class RenderSectionManager {
|
64 | 64 | private static final float NEARBY_REBUILD_DISTANCE = Mth.square(16.0f);
|
65 | 65 | private static final float NEARBY_SORT_DISTANCE = Mth.square(25.0f);
|
66 |
| - |
| 66 | + |
67 | 67 | private static final float FRAME_DURATION_UPLOAD_FRACTION = 0.1f;
|
68 | 68 | private static final long MIN_UPLOAD_DURATION_BUDGET = 2_000_000L; // 2ms
|
69 | 69 |
|
@@ -117,7 +117,7 @@ public class RenderSectionManager {
|
117 | 117 |
|
118 | 118 | public RenderSectionManager(ClientLevel level, int renderDistance, SortBehavior sortBehavior, CommandList commandList) {
|
119 | 119 | this.meshTaskSizeEstimator = new MeshTaskSizeEstimator(level);
|
120 |
| - |
| 120 | + |
121 | 121 | this.chunkRenderer = new DefaultChunkRenderer(RenderDevice.INSTANCE, ChunkMeshFormats.COMPACT);
|
122 | 122 |
|
123 | 123 | this.level = level;
|
@@ -177,14 +177,15 @@ private boolean createTerrainRenderList(Camera camera, Viewport viewport, FogPar
|
177 | 177 |
|
178 | 178 | RenderListProvider renderListProvider;
|
179 | 179 | var importantRebuildQueueType = SodiumClientMod.options().performance.chunkBuildDeferMode.getImportantRebuildQueueType();
|
| 180 | + var importantSortQueueType = this.sortBehavior.getDeferMode().getImportantRebuildQueueType(); |
180 | 181 | if (this.isOutOfGraph(viewport.getChunkCoord())) {
|
181 |
| - var visitor = new TreeSectionCollector(frame, importantRebuildQueueType, this.sectionByPosition); |
| 182 | + var visitor = new TreeSectionCollector(frame, importantRebuildQueueType, importantSortQueueType, this.sectionByPosition); |
182 | 183 | this.renderableSectionTree.prepareForTraversal();
|
183 | 184 | this.renderableSectionTree.traverse(visitor, viewport, searchDistance);
|
184 | 185 |
|
185 | 186 | renderListProvider = visitor;
|
186 | 187 | } else {
|
187 |
| - var visitor = new OcclusionSectionCollector(frame, importantRebuildQueueType); |
| 188 | + var visitor = new OcclusionSectionCollector(frame, importantRebuildQueueType, importantSortQueueType); |
188 | 189 | this.occlusionCuller.findVisible(visitor, viewport, searchDistance, useOcclusionCulling, frame);
|
189 | 190 |
|
190 | 191 | renderListProvider = visitor;
|
@@ -511,19 +512,13 @@ public void updateChunks(boolean updateImmediately) {
|
511 | 512 | // an estimator is used estimate task duration and limit the execution time to the available worker capacity.
|
512 | 513 | // separately, tasks are limited by their estimated upload size and duration.
|
513 | 514 | var uploadBudget = new LimitedResourceBudget(
|
514 |
| - Math.max((long)(this.averageFrameDuration * FRAME_DURATION_UPLOAD_FRACTION), MIN_UPLOAD_DURATION_BUDGET), |
| 515 | + Math.max((long) (this.averageFrameDuration * FRAME_DURATION_UPLOAD_FRACTION), MIN_UPLOAD_DURATION_BUDGET), |
515 | 516 | this.regions.getStagingBuffer().getUploadSizeLimit(this.averageFrameDuration));
|
516 | 517 |
|
517 | 518 | var nextFrameBlockingCollector = new ChunkJobCollector(this.buildResults::add);
|
518 | 519 | var deferredCollector = new ChunkJobCollector(remainingDuration, this.buildResults::add);
|
519 | 520 |
|
520 |
| - // if zero frame delay is allowed, submit important sorts with the current frame blocking collector. |
521 |
| - // otherwise submit with the collector that the next frame is blocking on. |
522 |
| - if (this.sortBehavior.getDeferMode() == DeferMode.ZERO_FRAMES) { |
523 |
| - this.submitSectionTasks(thisFrameBlockingCollector, nextFrameBlockingCollector, deferredCollector, uploadBudget); |
524 |
| - } else { |
525 |
| - this.submitSectionTasks(nextFrameBlockingCollector, nextFrameBlockingCollector, deferredCollector, uploadBudget); |
526 |
| - } |
| 521 | + this.submitSectionTasks(thisFrameBlockingCollector, nextFrameBlockingCollector, deferredCollector, uploadBudget); |
527 | 522 |
|
528 | 523 | this.thisFrameBlockingTasks = thisFrameBlockingCollector.getSubmittedTaskCount();
|
529 | 524 | this.nextFrameBlockingTasks = nextFrameBlockingCollector.getSubmittedTaskCount();
|
|
0 commit comments