From 2618c6a978fe4576264d1d0fad1baf522af7eced Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Fri, 16 May 2025 14:25:16 +1000 Subject: [PATCH] random things (tinker with barriers :ohno:) --- .../client/core/rendering/ChunkBoundRenderer.java | 4 ++-- .../client/core/rendering/util/DownloadStream.java | 13 ++++++------- .../client/core/rendering/util/UploadStream.java | 6 ++++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java index 68724aaa..7974bfdc 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/ChunkBoundRenderer.java @@ -71,7 +71,7 @@ public class ChunkBoundRenderer { public void render(Viewport viewport) { if (!this.remQueue.isEmpty()) { boolean wasEmpty = this.chunk2idx.isEmpty(); - this.remQueue.forEach(this::_remPos); + this.remQueue.forEach(this::_remPos);//TODO: REPLACE WITH SCATTER COMPUTE this.remQueue.clear(); if (this.chunk2idx.isEmpty()&&!wasEmpty) {//When going from stuff to nothing need to clear the depth buffer glClearNamedFramebufferfv(this.frameBuffer.id, GL_DEPTH, 0, new float[]{0}); @@ -148,7 +148,7 @@ public class ChunkBoundRenderer { if (!this.addQueue.isEmpty()) { - this.addQueue.forEach(this::_addPos); + this.addQueue.forEach(this::_addPos);//TODO: REPLACE WITH SCATTER COMPUTE this.addQueue.clear(); UploadStream.INSTANCE.commit(); } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/util/DownloadStream.java b/src/main/java/me/cortex/voxy/client/core/rendering/util/DownloadStream.java index 23dc4b6b..8a62bc64 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/util/DownloadStream.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/util/DownloadStream.java @@ -14,13 +14,12 @@ import java.util.Deque; import java.util.function.Consumer; import static me.cortex.voxy.common.util.AllocationArena.SIZE_LIMIT; -import static org.lwjgl.opengl.ARBDirectStateAccess.glCopyNamedBufferSubData; -import static org.lwjgl.opengl.ARBMapBufferRange.*; import static org.lwjgl.opengl.GL11.glFinish; +import static org.lwjgl.opengl.GL30C.GL_MAP_READ_BIT; +import static org.lwjgl.opengl.GL42.GL_BUFFER_UPDATE_BARRIER_BIT; import static org.lwjgl.opengl.GL42.glMemoryBarrier; -import static org.lwjgl.opengl.GL42C.GL_BUFFER_UPDATE_BARRIER_BIT; -import static org.lwjgl.opengl.GL44.GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT; -import static org.lwjgl.opengl.GL44.GL_MAP_COHERENT_BIT; +import static org.lwjgl.opengl.GL44.*; +import static org.lwjgl.opengl.GL45.glCopyNamedBufferSubData; public class DownloadStream { public interface DownloadResultConsumer { @@ -36,7 +35,7 @@ public class DownloadStream { private final ArrayList thisFrameDownloadList = new ArrayList<>(); public DownloadStream(long size) { - this.downloadBuffer = new GlPersistentMappedBuffer(size, GL_MAP_READ_BIT|GL_MAP_COHERENT_BIT); + this.downloadBuffer = new GlPersistentMappedBuffer(size, GL_MAP_READ_BIT);//|GL_MAP_COHERENT_BIT this.allocationArena.setLimit(size); } @@ -108,7 +107,7 @@ public class DownloadStream { if (this.downloadList.isEmpty()) { return; } - glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT); + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); //Copies all the data from target buffers into the download stream for (var entry : this.downloadList) { glCopyNamedBufferSubData(entry.target.id, this.downloadBuffer.id, entry.targetOffset, entry.downloadStreamOffset, entry.size); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java b/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java index 0be0b008..80ba90e3 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java @@ -30,8 +30,10 @@ public class UploadStream { private final LongArrayList thisFrameAllocations = new LongArrayList(); private final Deque uploadList = new ArrayDeque<>(); + private static final boolean USE_COHERENT = true; + public UploadStream(long size) { - this.uploadBuffer = new GlPersistentMappedBuffer(size,GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|GL_MAP_COHERENT_BIT).name("UploadStream"); + this.uploadBuffer = new GlPersistentMappedBuffer(size,GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|(USE_COHERENT?GL_MAP_COHERENT_BIT:0)).name("UploadStream"); this.allocationArena.setLimit(size); } @@ -102,7 +104,7 @@ public class UploadStream { if (this.uploadList.isEmpty()) { return; } - glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT|GL_BUFFER_UPDATE_BARRIER_BIT); + glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_BUFFER_UPDATE_BARRIER_BIT|(USE_COHERENT?0:GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT)); //Execute all the copies for (var entry : this.uploadList) { glCopyNamedBufferSubData(this.uploadBuffer.id, entry.target.id, entry.uploadOffset, entry.targetOffset, entry.size);