Clear for debugging

- Nsight explodes with the scatter shader resetting the indirect
  dispatch buffer
- Instead, issue a clear buffer and buffer update barrier
This commit is contained in:
Jozufozu 2024-09-13 21:06:48 -07:00
parent 861009ed11
commit 0151364b8a
3 changed files with 8 additions and 8 deletions

View file

@ -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<I extends Instance> {
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() {

View file

@ -107,7 +107,7 @@ public class IndirectDrawManager extends DrawManager<IndirectInstancer<?>> {
matrixBuffer.bind();
Uniforms.bindAll();
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT);
visibilityBuffer.bind();

View file

@ -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;
}
}
}
}