Add DATA as a gpu upload method

This commit is contained in:
James Seibel
2021-11-21 13:46:11 -06:00
parent b5050b2fa9
commit 86a5d2ece9
5 changed files with 27 additions and 6 deletions
@@ -145,6 +145,9 @@ public class ClientApi
// CONFIG.client().worldGenerator().setDistanceGenerationMode(DistanceGenerationMode.SURFACE);
// CONFIG.client().graphics().advancedGraphics().setGpuUploadMethod(GpuUploadMethod.BUFFER_STORAGE);
CONFIG.client().advanced().debugging().setDebugKeybindingsEnabled(true);
}
@@ -68,7 +68,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
* rendered by the LodRenderer.
*
* @author James Seibel
* @version 11-13-2021
* @version 11-21-2021
*/
public class LodBufferBuilderFactory
{
@@ -868,6 +868,11 @@ public class LodBufferBuilderFactory
// (uploading into GPU memory directly can only be done
// through the glCopyBufferSubData/glCopyNamed... methods)
GL45.glCopyNamedBufferSubData(vbo.id, storageBufferId, 0, 0, uploadBuffer.capacity());
// alternative way that doesn't require GL45
// GL15.glBindBuffer(GL45.GL_COPY_WRITE_BUFFER, storageBufferId);
// GL45.glCopyBufferSubData(GL15.GL_ARRAY_BUFFER, GL45.GL_COPY_WRITE_BUFFER, 0, 0, uploadBuffer.capacity());
// GL15.glBindBuffer(GL45.GL_COPY_WRITE_BUFFER, 0);
}
}
else if (uploadMethod == GpuUploadMethod.BUFFER_MAPPING)
@@ -898,6 +903,14 @@ public class LodBufferBuilderFactory
vboBuffer.put(uploadBuffer);
}
}
else if (uploadMethod == GpuUploadMethod.DATA)
{
// hybrid bufferData //
// high stutter, low GPU usage
// But simplest/most compatible
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, uploadBuffer, GL15.GL_DYNAMIC_DRAW);
}
else
{
// hybrid subData/bufferData //
@@ -23,7 +23,7 @@ package com.seibel.lod.core.enums.config;
* Buffer_Storage, Sub_Data, Buffer_Mapping
*
* @author James Seibel
* @version 10-23-2021
* @version 11-21-2021
*/
public enum GpuUploadMethod
{
@@ -32,6 +32,9 @@ public enum GpuUploadMethod
/** Default if OpenGL 4.5 is NOT supported. Fast rendering but may stutter when uploading. */
SUB_DATA,
/** Fast rendering but will stutter when uploading. */
DATA,
/** May end up storing buffers in System memory. Slower rendering but won't stutter when uploading. */
BUFFER_MAPPING,
@@ -50,7 +50,7 @@ import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftWrapper;
* https://gamedev.stackexchange.com/questions/91995/edit-vbo-data-or-create-a-new-one <br><br>
*
* @author James Seibel
* @version 11-20-2021
* @version 11-21-2021
*/
public class GLProxy
{
@@ -160,7 +160,7 @@ public class GLProxy
// get specific capabilities
// TODO re-add buffer storage support
bufferStorageSupported = false; //lodBuilderGlCapabilities.glBufferStorage != 0;
bufferStorageSupported = lodBuilderGlCapabilities.glBufferStorage != 0;
mapBufferRangeSupported = lodBuilderGlCapabilities.glMapBufferRange != 0;
@@ -42,7 +42,7 @@ import com.seibel.lod.core.util.LodUtil;
* the options that should be implemented in a configWrapperSingleton.
*
* @author James Seibel
* @version 11-16-2021
* @version 11-21-2021
*/
public interface ILodConfigWrapperSingleton
{
@@ -212,10 +212,12 @@ public interface ILodConfigWrapperSingleton
GpuUploadMethod GPU_UPLOAD_METHOD_DEFAULT = GpuUploadMethod.BUFFER_STORAGE;
String GPU_UPLOAD_METHOD_DESC = ""
+ " What method should be used to upload geometry to the GPU? \n\n"
+ " What method should be used to upload geometry to the GPU? \n"
+ " Listed in the suggested order of best to worst. \n\n"
+ ""
+ " " + GpuUploadMethod.BUFFER_STORAGE + ": Default if OpenGL 4.5 is supported. Fast rendering, no stuttering. \n"
+ " " + GpuUploadMethod.SUB_DATA + ": Default if OpenGL 4.5 is NOT supported. Fast rendering but may stutter when uploading. \n"
+ " " + GpuUploadMethod.DATA + ": Fast rendering but will stutter when uploading. \n"
+ " " + GpuUploadMethod.BUFFER_MAPPING + ": Slow rendering but won't stutter when uploading. Possibly better than " + GpuUploadMethod.SUB_DATA + " if using a integrated GPU. \n";
public GpuUploadMethod getGpuUploadMethod();
public void setGpuUploadMethod(GpuUploadMethod newDisableVanillaFog);