remove update thingie

This commit is contained in:
mcrcortex
2025-05-02 16:45:18 +10:00
parent ad0d1ede41
commit b064032d8f

View File

@@ -47,8 +47,6 @@ public class ChunkBoundRenderer {
private GlTexture depthBuffer = new GlTexture().store(GL_DEPTH_COMPONENT24, 1, 128, 128); private GlTexture depthBuffer = new GlTexture().store(GL_DEPTH_COMPONENT24, 1, 128, 128);
private final GlFramebuffer frameBuffer = new GlFramebuffer().bind(GL_DEPTH_ATTACHMENT, this.depthBuffer).verify(); private final GlFramebuffer frameBuffer = new GlFramebuffer().bind(GL_DEPTH_ATTACHMENT, this.depthBuffer).verify();
private final Int2LongOpenHashMap updates = new Int2LongOpenHashMap();
public ChunkBoundRenderer() { public ChunkBoundRenderer() {
this.chunk2idx.defaultReturnValue(-1); this.chunk2idx.defaultReturnValue(-1);
} }
@@ -65,7 +63,7 @@ public class ChunkBoundRenderer {
this.chunk2idx.put(pos, idx); this.chunk2idx.put(pos, idx);
this.idx2chunk[idx] = pos; this.idx2chunk[idx] = pos;
this.updates.put(idx, pos); this.put(idx, pos);
} }
public void removeChunk(long pos) { public void removeChunk(long pos) {
@@ -90,7 +88,7 @@ public class ChunkBoundRenderer {
this.idx2chunk[idx] = ePos; this.idx2chunk[idx] = ePos;
//Put the end pos into the new idx //Put the end pos into the new idx
this.updates.put(idx, ePos); this.put(idx, ePos);
} }
//Bind and render, changing as little gl state as possible so that the caller may configure how it wants to render //Bind and render, changing as little gl state as possible so that the caller may configure how it wants to render
@@ -158,23 +156,14 @@ public class ChunkBoundRenderer {
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
}
//Only apply after private void put(int idx, long pos) {
if (!this.updates.isEmpty()) { long ptr2 = UploadStream.INSTANCE.upload(this.chunkPosBuffer, 8L*idx, 8);
var iter = this.updates.int2LongEntrySet().fastIterator(); //Need to do it in 2 parts because ivec2 is 2 parts
while (iter.hasNext()) { MemoryUtil.memPutInt(ptr2, (int)(pos&0xFFFFFFFFL)); ptr2 += 4;
var entry = iter.next(); MemoryUtil.memPutInt(ptr2, (int)((pos>>>32)&0xFFFFFFFFL));
int idx = entry.getIntKey(); UploadStream.INSTANCE.commit();
long pos = entry.getLongValue();
long ptr2 = UploadStream.INSTANCE.upload(this.chunkPosBuffer, 8L*idx, 8);
//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();
}
this.updates.clear();
}
} }
public void reset() { public void reset() {