diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java index 0d3693187..72181d152 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectCullingGroup.java @@ -14,7 +14,7 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; -import org.lwjgl.system.MemoryUtil; +import org.lwjgl.opengl.GL46; import dev.engine_room.flywheel.api.instance.Instance; import dev.engine_room.flywheel.api.instance.InstanceType; @@ -129,12 +129,7 @@ public class IndirectCullingGroup { uploadDraws(stagingBuffer); - stagingBuffer.enqueueCopy(4 * Integer.BYTES, buffers.passTwoDispatch.handle(), 0, ptr -> { - MemoryUtil.memPutInt(ptr, 0); - MemoryUtil.memPutInt(ptr + 4, 1); - MemoryUtil.memPutInt(ptr + 8, 1); - MemoryUtil.memPutInt(ptr + 12, 0); - }); + GL46.nglClearNamedBufferData(buffers.passTwoDispatch.handle(), GL46.GL_R32UI, GL46.GL_RED, GL46.GL_UNSIGNED_INT, 0); } public void dispatchCull() { diff --git a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java index de452a1e5..ab7d8e3a6 100644 --- a/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java +++ b/common/src/backend/java/dev/engine_room/flywheel/backend/engine/indirect/IndirectDrawManager.java @@ -107,7 +107,7 @@ public class IndirectDrawManager extends DrawManager> { matrixBuffer.bind(); Uniforms.bindAll(); - glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); + glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT); visibilityBuffer.bind(); diff --git a/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/early_cull.glsl b/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/early_cull.glsl index 840d3813d..1c82a935d 100644 --- a/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/early_cull.glsl +++ b/common/src/backend/resources/assets/flywheel/flywheel/internal/indirect/early_cull.glsl @@ -112,6 +112,11 @@ void main() { if (targetIndex % 32u == 0u) { // This thread wrote an index that will be at the start of a new workgroup later atomicAdd(_flw_lateCullDispatch.x, 1); + + if (targetIndex == 0) { + _flw_lateCullDispatch.y = 1; + _flw_lateCullDispatch.z = 1; + } } } }