Micro improvements

This commit is contained in:
mcrcortex
2025-05-14 22:52:49 +10:00
parent 3221702fc2
commit c2be58b0f2
7 changed files with 31 additions and 6 deletions

View File

@@ -215,7 +215,7 @@ public class VoxyRenderSystem {
this.renderDistanceTracker.setCenterAndProcess(cameraX, cameraZ);
//Done here as is allows less gl state resetup
this.renderer.tickModelService(Math.max(3_000_000-(System.nanoTime()-startTime), 75_000));
this.renderer.tickModelService(Math.max(3_000_000-(System.nanoTime()-startTime), 500_000));
}
TimingStatistics.postDynamic.stop();

View File

@@ -88,7 +88,7 @@ public class ModelBakerySubsystem {
do {
this.factory.addEntry(i);
j++;
if (25<j)//budget<(System.nanoTime() - start)+1000
if (24<j)//budget<(System.nanoTime() - start)+1000
break;
i = this.blockIdQueue.poll();
} while (i != null);

View File

@@ -150,6 +150,7 @@ public class ChunkBoundRenderer {
if (!this.addQueue.isEmpty()) {
this.addQueue.forEach(this::_addPos);
this.addQueue.clear();
UploadStream.INSTANCE.commit();
}
}
@@ -213,7 +214,6 @@ public class ChunkBoundRenderer {
//Need to do it in 2 parts because ivec2 is 2 parts
MemoryUtil.memPutInt(ptr2, (int)(pos&0xFFFFFFFFL)); ptr2 += 4;
MemoryUtil.memPutInt(ptr2, (int)((pos>>>32)&0xFFFFFFFFL));
UploadStream.INSTANCE.commit();
}
public void reset() {

View File

@@ -69,6 +69,8 @@ public class AsyncNodeManager {
private volatile SyncResults resultCache1 = new SyncResults();
private volatile SyncResults resultCache2 = new SyncResults();
//Yes. this is stupid. yes. it is a large amount of runtime. Is it profiler bias, probably
private ConcurrentLinkedDeque<MemoryBuffer> buffersToFreeQueue = new ConcurrentLinkedDeque<>();
//locals for during iteration
@@ -148,6 +150,14 @@ public class AsyncNodeManager {
.compile();
private void run() {
while (true) {
var buffer = this.buffersToFreeQueue.poll();
if (buffer == null) {
break;
}
buffer.free();
}
if (this.workCounter.get() == 0) {
LockSupport.park();
if (this.workCounter.get() == 0 || !this.running) {//No work
@@ -264,7 +274,7 @@ public class AsyncNodeManager {
if (this.workCounter.addAndGet(-workDone) < 0) {
try {
Thread.sleep(1);
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
@@ -461,7 +471,8 @@ public class AsyncNodeManager {
var val = iter.next();
var buffer = val.getValue();
UploadStream.INSTANCE.upload(store.getGeometryBuffer(), Integer.toUnsignedLong(val.getIntKey()) * 8L, buffer);
buffer.free();//Free the buffer was uploading
//Put the queue into the buffer queue to free... yes this is stupid that need todo this...
this.buffersToFreeQueue.add(buffer);//buffer.free();//Free the buffer was uploading
}
UploadStream.INSTANCE.commit();
}
@@ -633,6 +644,15 @@ public class AsyncNodeManager {
}
this.scatterWrite.free();
while (true) {
var buffer = this.buffersToFreeQueue.poll();
if (buffer == null) {
break;
}
buffer.free();
}
}
//Results object, which is to be synced between the render thread and worker thread

View File

@@ -64,6 +64,8 @@ public class HiZBuffer {
this.width = width;
this.height = height;
this.fb.bind(GL_DEPTH_ATTACHMENT, this.texture, 0).verify();
}
public void buildMipChain(int srcDepthTex, int width, int height) {
@@ -77,7 +79,6 @@ public class HiZBuffer {
glBindVertexArray(RenderService.STATIC_VAO);
int boundFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING);
this.hiz.bind();
this.fb.bind(GL_DEPTH_ATTACHMENT, this.texture, 0);//.verify();
glBindFramebuffer(GL_FRAMEBUFFER, this.fb.id);
glDepthFunc(GL_ALWAYS);

View File

@@ -22,6 +22,7 @@ public class MixinWindow {
}
//Force the current thread priority to be realtime
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
ThreadUtils.SetSelfThreadPriorityWin32(ThreadUtils.WIN32_THREAD_PRIORITY_TIME_CRITICAL);
}
}

View File

@@ -254,6 +254,9 @@ public class ServiceThreadPool {
if (this.totalJobWeight.addAndGet(-service.weightPerJob)<0) {
throw new IllegalStateException("Total job weight is negative");
}
//Sleep for a bit after running a job, yeild the thread
Thread.yield();
break;
}
}