move from coheriant stuff
This commit is contained in:
@@ -13,7 +13,7 @@ public class GlPersistentMappedBuffer extends TrackedObject {
|
||||
public GlPersistentMappedBuffer(long size, int flags) {
|
||||
this.id = glCreateBuffers();
|
||||
this.size = size;
|
||||
glNamedBufferStorage(this.id, size, GL_CLIENT_STORAGE_BIT|GL_MAP_PERSISTENT_BIT|(flags&(GL_MAP_COHERENT_BIT|GL_MAP_WRITE_BIT|GL_MAP_READ_BIT)));
|
||||
glNamedBufferStorage(this.id, size, GL_MAP_PERSISTENT_BIT|(flags&(GL_MAP_COHERENT_BIT|GL_MAP_WRITE_BIT|GL_MAP_READ_BIT|GL_CLIENT_STORAGE_BIT)));
|
||||
this.addr = nglMapNamedBufferRange(this.id, 0, size, (flags&(GL_MAP_WRITE_BIT|GL_MAP_READ_BIT|GL_MAP_UNSYNCHRONIZED_BIT|GL_MAP_FLUSH_EXPLICIT_BIT))|GL_MAP_PERSISTENT_BIT);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.lwjgl.opengl.GL42C.GL_BUFFER_UPDATE_BARRIER_BIT;
|
||||
import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_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.GL45C.glFlushMappedNamedBufferRange;
|
||||
|
||||
public class UploadStream {
|
||||
private final AllocationArena allocationArena = new AllocationArena();
|
||||
@@ -30,10 +31,10 @@ public class UploadStream {
|
||||
private final LongArrayList thisFrameAllocations = new LongArrayList();
|
||||
private final Deque<UploadData> uploadList = new ArrayDeque<>();
|
||||
|
||||
private static final boolean USE_COHERENT = true;
|
||||
private static final boolean USE_COHERENT = false;
|
||||
|
||||
public UploadStream(long size) {
|
||||
this.uploadBuffer = new GlPersistentMappedBuffer(size,GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|(USE_COHERENT?GL_MAP_COHERENT_BIT:0)).name("UploadStream");
|
||||
this.uploadBuffer = new GlPersistentMappedBuffer(size,GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|(USE_COHERENT?GL_MAP_COHERENT_BIT:GL_MAP_FLUSH_EXPLICIT_BIT)).name("UploadStream");
|
||||
this.allocationArena.setLimit(size);
|
||||
}
|
||||
|
||||
@@ -69,6 +70,9 @@ public class UploadStream {
|
||||
|
||||
long addr;
|
||||
if (this.caddr == -1 || !this.allocationArena.expand(this.caddr, (int) size)) {
|
||||
if ((!USE_COHERENT)&&this.caddr!=-1) {
|
||||
glFlushMappedNamedBufferRange(this.uploadBuffer.id, this.caddr, this.offset);
|
||||
}
|
||||
this.caddr = this.allocationArena.alloc((int) size);//TODO: replace with allocFromLargest
|
||||
if (this.caddr == SIZE_LIMIT) {
|
||||
//Note! we dont commit here, we only try to flush existing memory copies, we dont commit
|
||||
@@ -104,7 +108,12 @@ public class UploadStream {
|
||||
if (this.uploadList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_BUFFER_UPDATE_BARRIER_BIT|(USE_COHERENT?0:GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT));
|
||||
if ((!USE_COHERENT)&&this.caddr != -1) {
|
||||
//Flush this allocation
|
||||
glFlushMappedNamedBufferRange(this.uploadBuffer.id, this.caddr, this.offset);
|
||||
}
|
||||
|
||||
glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
|
||||
//Execute all the copies
|
||||
for (var entry : this.uploadList) {
|
||||
glCopyNamedBufferSubData(this.uploadBuffer.id, entry.target.id, entry.uploadOffset, entry.targetOffset, entry.size);
|
||||
|
||||
Reference in New Issue
Block a user