Remove buffer mapping

This commit is contained in:
James Seibel
2026-02-17 07:16:42 -06:00
parent 5adb9afa0a
commit ce17ac71c6
3 changed files with 0 additions and 75 deletions
@@ -35,29 +35,12 @@ public enum EDhApiGpuUploadMethod
/** Picks the best option based on the GPU the user has. */
AUTO(false, false),
// commented out since it isn't currently in use
//BUFFER_STORAGE_MAPPING(true, true),
/** Fast rendering, no stuttering. */
BUFFER_STORAGE(false, true),
/** Fast rendering but may stutter when uploading. */
SUB_DATA(false, false),
///** Don't upload, only should be used for debugging */
//@Deprecated
//NONE(false, false),
/**
* May end up storing buffers in System memory. <br>
* Fast rending if in GPU memory, slow if in system memory, <br>
* but won't stutter when uploading.
*
* @deprecated not currently supported
*/
@Deprecated
BUFFER_MAPPING(true, false),
/** Fast rendering but may stutter when uploading. */
DATA(false, false);
@@ -253,56 +253,6 @@ public class GLBuffer implements AutoCloseable
//================//
// buffer mapping //
//================//
public ByteBuffer mapBuffer(int targetSize, EDhApiGpuUploadMethod uploadMethod, int maxExpansionSize, int bufferHint, int mapFlags)
{
LodUtil.assertTrue(targetSize != 0, "MapBuffer targetSize is 0");
LodUtil.assertTrue(uploadMethod.useEarlyMapping, "Upload method must be one that use early mappings in order to call mapBuffer");
LodUtil.assertTrue(!this.isMapped, "Buffer is already mapped");
// make sure the buffer is ready for uploading
this.createOrChangeBufferTypeForUpload(uploadMethod);
ByteBuffer vboBuffer;
if (this.size < targetSize || this.size > targetSize * BUFFER_SHRINK_TRIGGER)
{
int newSize = (int) (targetSize * BUFFER_EXPANSION_MULTIPLIER);
if (newSize > maxExpansionSize) newSize = maxExpansionSize;
this.size = newSize;
if (this.bufferStorage)
{
GLMC.glDeleteBuffers(this.id);
this.id = GLMC.glGenBuffers();
GL32.glBindBuffer(this.getBufferBindingTarget(), this.id);
GL32.glBindBuffer(this.getBufferBindingTarget(), this.id);
GL44.glBufferStorage(this.getBufferBindingTarget(), newSize, bufferHint);
}
else
{
GL32.glBufferData(GL32.GL_ARRAY_BUFFER, newSize, bufferHint);
}
}
vboBuffer = GL32.glMapBufferRange(GL32.GL_ARRAY_BUFFER, 0, targetSize, mapFlags);
this.isMapped = true;
return vboBuffer;
}
/** Requires the buffer to be bound */
public void unmapBuffer()
{
LodUtil.assertTrue(this.isMapped, "Buffer is not mapped");
this.bind();
GL32.glUnmapBuffer(this.getBufferBindingTarget());
this.isMapped = false;
}
//===========//
// overrides //
//===========//
@@ -85,12 +85,4 @@ public class GLVertexBuffer extends GLBuffer
this.vertexCount = (bufferSize / 4) * 6;
}
public ByteBuffer mapBuffer(int targetSize, EDhApiGpuUploadMethod uploadMethod, int maxExpansionSize)
{
return super.mapBuffer(targetSize, uploadMethod, maxExpansionSize,
uploadMethod.useBufferStorage ? GL32.GL_MAP_WRITE_BIT :
uploadMethod.useEarlyMapping ? GL32.GL_DYNAMIC_DRAW : GL32.GL_STATIC_DRAW,
GL32.GL_MAP_WRITE_BIT | GL32.GL_MAP_UNSYNCHRONIZED_BIT | GL32.GL_MAP_INVALIDATE_BUFFER_BIT);
}
}