diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java index 5cb6855d..06a5f0af 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java @@ -5,6 +5,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.gl.shader.Shader; import me.cortex.voxy.client.core.gl.shader.ShaderType; +import me.cortex.voxy.client.core.rendering.util.DownloadStream; import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.client.mixin.joml.AccessFrustumIntersection; import net.minecraft.block.Blocks; @@ -138,16 +139,26 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer { glClearNamedBufferData(this.glCommandCountBuffer.id, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, new int[1]); this.commandGen.bind(); - glDispatchCompute((this.geometry.getSectionCount() + 127) / 128, 1, 1); + glDispatchCompute((this.geometry.getSectionCount()+127)/128, 1, 1); glMemoryBarrier(GL_COMMAND_BARRIER_BIT | GL_SHADER_STORAGE_BARRIER_BIT | GL_UNIFORM_BARRIER_BIT); this.lodShader.bind(); glDisable(GL_CULL_FACE); //glPointSize(10); glMultiDrawElementsIndirectCountARB(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, 0, (int) (this.geometry.getSectionCount()*4.4), 0); - //glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, (int) (this.geometry.getSectionCount()*4.4), 0); + //glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, 100, 0); glEnable(GL_CULL_FACE); + /* + glFinish(); + DownloadStream.INSTANCE.download(this.glCommandCountBuffer, 0, 4, (ptr, siz) -> { + int cnt = MemoryUtil.memGetInt(ptr); + System.out.println(cnt); + }); + DownloadStream.INSTANCE.commit(); + DownloadStream.INSTANCE.tick(); + */ + glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT); this.cullShader.bind(); 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 9565f212..61dbd0f1 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 @@ -81,7 +81,7 @@ public class DownloadStream { public void commit() { //Copies all the data from target buffers into the download stream for (var entry : this.downloadList) { - glCopyNamedBufferSubData(entry.target.id, this.downloadBuffer.id, entry.downloadOffset, entry.targetOffset, entry.size); + glCopyNamedBufferSubData(entry.target.id, this.downloadBuffer.id, entry.targetOffset, entry.downloadStreamOffset, entry.size); } thisFrameDownloadList.addAll(this.downloadList); this.downloadList.clear(); @@ -110,7 +110,7 @@ public class DownloadStream { //Apply all the callbacks for (var data : frame.data) { - data.resultConsumer.consume(this.downloadBuffer.addr() + data.downloadOffset, data.size); + data.resultConsumer.consume(this.downloadBuffer.addr() + data.downloadStreamOffset, data.size); } frame.allocations.forEach(this.allocationArena::free); @@ -119,7 +119,7 @@ public class DownloadStream { } private record DownloadFrame(GlFence fence, LongArrayList allocations, ArrayList data) {} - private record DownloadData(GlBuffer target, long downloadOffset, long targetOffset, long size, DownloadResultConsumer resultConsumer) {} + private record DownloadData(GlBuffer target, long downloadStreamOffset, long targetOffset, long size, DownloadResultConsumer resultConsumer) {} // Global download stream diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46/cmdgen.comp b/src/main/resources/assets/voxy/shaders/lod/gl46/cmdgen.comp index cf4f16de..f0c980b8 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46/cmdgen.comp +++ b/src/main/resources/assets/voxy/shaders/lod/gl46/cmdgen.comp @@ -1,7 +1,7 @@ #version 450 #extension GL_ARB_gpu_shader_int64 : enable -layout(local_size_x = 128, local_size_y = 1, local_size_x = 1) in; +layout(local_size_x = 128) in; #import #import diff --git a/src/main/resources/assets/voxy/shaders/post/ssao.comp b/src/main/resources/assets/voxy/shaders/post/ssao.comp index efb31bb5..d90054f3 100644 --- a/src/main/resources/assets/voxy/shaders/post/ssao.comp +++ b/src/main/resources/assets/voxy/shaders/post/ssao.comp @@ -1,5 +1,5 @@ #version 450 -layout(local_size_x = 32, local_size_y = 32, local_size_x = 1) in; +layout(local_size_x = 32, local_size_y = 32) in; layout(binding = 0, rgba8) uniform restrict image2D colourTex;