re-add GPU upload config including "none"
This commit is contained in:
+4
@@ -44,6 +44,10 @@ public enum EDhApiGpuUploadMethod
|
|||||||
/** Fast rendering but may stutter when uploading. */
|
/** Fast rendering but may stutter when uploading. */
|
||||||
SUB_DATA(false, false),
|
SUB_DATA(false, false),
|
||||||
|
|
||||||
|
/** Don't upload, only should be used for debugging */
|
||||||
|
@Deprecated // TODO remove before release
|
||||||
|
NONE(false, false),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* May end up storing buffers in System memory. <br>
|
* May end up storing buffers in System memory. <br>
|
||||||
* Fast rending if in GPU memory, slow if in system memory, <br>
|
* Fast rending if in GPU memory, slow if in system memory, <br>
|
||||||
|
|||||||
@@ -1083,6 +1083,13 @@ public class Config
|
|||||||
+ "")
|
+ "")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
public static ConfigEntry<EDhApiGpuUploadMethod> glUploadMode = new ConfigEntry.Builder<EDhApiGpuUploadMethod>()
|
||||||
|
.set(EDhApiGpuUploadMethod.AUTO)
|
||||||
|
.comment(""
|
||||||
|
+ "\n"
|
||||||
|
+ "")
|
||||||
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ColumnBuilderDebugging
|
public static class ColumnBuilderDebugging
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public class ColumnRenderBufferBuilder
|
|||||||
{
|
{
|
||||||
DhBlockPos minBlockPos = new DhBlockPos(DhSectionPos.getMinCornerBlockX(pos), clientLevel.getLevelWrapper().getMinHeight(), DhSectionPos.getMinCornerBlockZ(pos));
|
DhBlockPos minBlockPos = new DhBlockPos(DhSectionPos.getMinCornerBlockX(pos), clientLevel.getLevelWrapper().getMinHeight(), DhSectionPos.getMinCornerBlockZ(pos));
|
||||||
LodBufferContainer bufferContainer = new LodBufferContainer(pos, minBlockPos);
|
LodBufferContainer bufferContainer = new LodBufferContainer(pos, minBlockPos);
|
||||||
CompletableFuture<LodBufferContainer> uploadFuture = bufferContainer.makeAndUploadBuffersAsync(quadBuilder, GLProxy.getInstance().getGpuUploadMethod());
|
CompletableFuture<LodBufferContainer> uploadFuture = bufferContainer.makeAndUploadBuffersAsync(quadBuilder);
|
||||||
uploadFuture.whenComplete((uploadedBuffer, exception) ->
|
uploadFuture.whenComplete((uploadedBuffer, exception) ->
|
||||||
{
|
{
|
||||||
// clean up if not uploaded
|
// clean up if not uploaded
|
||||||
|
|||||||
+9
-5
@@ -82,7 +82,7 @@ public class LodBufferContainer implements AutoCloseable
|
|||||||
//==================//
|
//==================//
|
||||||
|
|
||||||
/** Should be run on a DH thread. */
|
/** Should be run on a DH thread. */
|
||||||
public synchronized CompletableFuture<LodBufferContainer> makeAndUploadBuffersAsync(LodQuadBuilder builder, EDhApiGpuUploadMethod gpuUploadMethod)
|
public synchronized CompletableFuture<LodBufferContainer> makeAndUploadBuffersAsync(LodQuadBuilder builder)
|
||||||
{
|
{
|
||||||
// separate variable to prevent race condition when checking null
|
// separate variable to prevent race condition when checking null
|
||||||
CompletableFuture<LodBufferContainer> future = this.uploadFuture;
|
CompletableFuture<LodBufferContainer> future = this.uploadFuture;
|
||||||
@@ -117,6 +117,8 @@ public class LodBufferContainer implements AutoCloseable
|
|||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDhApiGpuUploadMethod gpuUploadMethod = GLProxy.getInstance().getGpuUploadMethod();
|
||||||
|
|
||||||
// upload on the render thread
|
// upload on the render thread
|
||||||
uploadBuffersDirect(this.vbos, opaqueBuffers, gpuUploadMethod);
|
uploadBuffersDirect(this.vbos, opaqueBuffers, gpuUploadMethod);
|
||||||
uploadBuffersDirect(this.vbosTransparent, transparentBuffers, gpuUploadMethod);
|
uploadBuffersDirect(this.vbosTransparent, transparentBuffers, gpuUploadMethod);
|
||||||
@@ -177,7 +179,9 @@ public class LodBufferContainer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
return newVbos;
|
return newVbos;
|
||||||
}
|
}
|
||||||
private static void uploadBuffersDirect(GLVertexBuffer[] vbos, ArrayList<ByteBuffer> byteBuffers, EDhApiGpuUploadMethod method) throws InterruptedException
|
private static void uploadBuffersDirect(
|
||||||
|
GLVertexBuffer[] vbos, ArrayList<ByteBuffer> byteBuffers,
|
||||||
|
EDhApiGpuUploadMethod uploadMethod) throws InterruptedException
|
||||||
{
|
{
|
||||||
int vboIndex = 0;
|
int vboIndex = 0;
|
||||||
for (int i = 0; i < byteBuffers.size(); i++)
|
for (int i = 0; i < byteBuffers.size(); i++)
|
||||||
@@ -191,7 +195,7 @@ public class LodBufferContainer implements AutoCloseable
|
|||||||
// get or create the VBO
|
// get or create the VBO
|
||||||
if (vbos[vboIndex] == null)
|
if (vbos[vboIndex] == null)
|
||||||
{
|
{
|
||||||
vbos[vboIndex] = new GLVertexBuffer(method.useBufferStorage);
|
vbos[vboIndex] = new GLVertexBuffer(uploadMethod.useBufferStorage);
|
||||||
}
|
}
|
||||||
GLVertexBuffer vbo = vbos[vboIndex];
|
GLVertexBuffer vbo = vbos[vboIndex];
|
||||||
|
|
||||||
@@ -202,13 +206,13 @@ public class LodBufferContainer implements AutoCloseable
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
vbo.bind();
|
vbo.bind();
|
||||||
vbo.uploadBuffer(buffer, size / LodUtil.LOD_VERTEX_FORMAT.getByteSize(), method, FULL_SIZED_BUFFER);
|
vbo.uploadBuffer(buffer, size / LodUtil.LOD_VERTEX_FORMAT.getByteSize(), uploadMethod, FULL_SIZED_BUFFER);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
vbos[vboIndex] = null;
|
vbos[vboIndex] = null;
|
||||||
vbo.close();
|
vbo.close();
|
||||||
LOGGER.error("Failed to upload buffer: ", e);
|
LOGGER.error("Failed to upload buffer. Error: ["+e.getMessage()+"].", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
vboIndex++;
|
vboIndex++;
|
||||||
|
|||||||
@@ -220,7 +220,16 @@ public class GLProxy
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EDhApiGpuUploadMethod getGpuUploadMethod() { return this.preferredUploadMethod; }
|
public EDhApiGpuUploadMethod getGpuUploadMethod()
|
||||||
|
{
|
||||||
|
EDhApiGpuUploadMethod uploadOverride = Config.Client.Advanced.Debugging.OpenGl.glUploadMode.get();
|
||||||
|
if (uploadOverride == EDhApiGpuUploadMethod.AUTO)
|
||||||
|
{
|
||||||
|
return this.preferredUploadMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
return uploadOverride;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean runningOnRenderThread()
|
public boolean runningOnRenderThread()
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-3
@@ -27,7 +27,6 @@ import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
|||||||
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||||
import com.seibel.distanthorizons.core.util.LodUtil;
|
import com.seibel.distanthorizons.core.util.LodUtil;
|
||||||
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
import com.seibel.distanthorizons.core.util.ThreadUtil;
|
||||||
import com.seibel.distanthorizons.core.util.math.UnitBytes;
|
|
||||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
|
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper;
|
||||||
import org.lwjgl.opengl.GL32;
|
import org.lwjgl.opengl.GL32;
|
||||||
import org.lwjgl.opengl.GL44;
|
import org.lwjgl.opengl.GL44;
|
||||||
@@ -187,7 +186,6 @@ public class GLBuffer implements AutoCloseable
|
|||||||
{
|
{
|
||||||
LodUtil.assertNotReach("maxExpansionSize is [" + maxExpansionSize + "] but buffer size is [" + bbSize + "]!");
|
LodUtil.assertNotReach("maxExpansionSize is [" + maxExpansionSize + "] but buffer size is [" + bbSize + "]!");
|
||||||
}
|
}
|
||||||
GLProxy.LOGGER.debug("Uploading buffer with ["+new UnitBytes(bbSize)+"].");
|
|
||||||
|
|
||||||
// Don't upload an empty buffer
|
// Don't upload an empty buffer
|
||||||
if (bbSize == 0)
|
if (bbSize == 0)
|
||||||
@@ -200,6 +198,8 @@ public class GLBuffer implements AutoCloseable
|
|||||||
|
|
||||||
switch (uploadMethod)
|
switch (uploadMethod)
|
||||||
{
|
{
|
||||||
|
case NONE:
|
||||||
|
return;
|
||||||
case AUTO:
|
case AUTO:
|
||||||
LodUtil.assertNotReach("GpuUploadMethod AUTO must be resolved before call to uploadBuffer()!");
|
LodUtil.assertNotReach("GpuUploadMethod AUTO must be resolved before call to uploadBuffer()!");
|
||||||
case BUFFER_STORAGE:
|
case BUFFER_STORAGE:
|
||||||
@@ -379,6 +379,7 @@ public class GLBuffer implements AutoCloseable
|
|||||||
{
|
{
|
||||||
int id = PHANTOM_TO_BUFFER_ID.get(phantomRef);
|
int id = PHANTOM_TO_BUFFER_ID.get(phantomRef);
|
||||||
destroyBufferIdAsync(id);
|
destroyBufferIdAsync(id);
|
||||||
|
LOGGER.warn("Buffer Phantom collected, ID: ["+id+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
phantomRef = PHANTOM_REFERENCE_QUEUE.poll();
|
phantomRef = PHANTOM_REFERENCE_QUEUE.poll();
|
||||||
@@ -386,7 +387,7 @@ public class GLBuffer implements AutoCloseable
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LOGGER.error("Unexpected error in cleanup thread: [" + e.getMessage() + "].", e);
|
LOGGER.error("Unexpected error in buffer cleanup thread: [" + e.getMessage() + "].", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -509,6 +509,10 @@
|
|||||||
"Validate Buffer IDs Before Rendering",
|
"Validate Buffer IDs Before Rendering",
|
||||||
"distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering.@tooltip":
|
"distanthorizons.config.client.advanced.debugging.openGl.validateBufferIdsBeforeRendering.@tooltip":
|
||||||
"Massively reduces FPS. \nShould only be used if mysterious EXCEPTION_ACCESS_VIOLATION crashes are happening in DH's rendering code and you're attempting to troubleshoot it.",
|
"Massively reduces FPS. \nShould only be used if mysterious EXCEPTION_ACCESS_VIOLATION crashes are happening in DH's rendering code and you're attempting to troubleshoot it.",
|
||||||
|
"distanthorizons.config.client.advanced.debugging.openGl.glUploadMode":
|
||||||
|
"Uploade Mode",
|
||||||
|
"distanthorizons.config.client.advanced.debugging.openGl.glUploadMode.@tooltip":
|
||||||
|
"Only for debugging",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1046,6 +1050,8 @@
|
|||||||
|
|
||||||
"distanthorizons.config.enum.EDhApiGpuUploadMethod.AUTO":
|
"distanthorizons.config.enum.EDhApiGpuUploadMethod.AUTO":
|
||||||
"Auto",
|
"Auto",
|
||||||
|
"distanthorizons.config.enum.EDhApiGpuUploadMethod.NONE":
|
||||||
|
"None",
|
||||||
"distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_STORAGE":
|
"distanthorizons.config.enum.EDhApiGpuUploadMethod.BUFFER_STORAGE":
|
||||||
"Buffer storage",
|
"Buffer storage",
|
||||||
"distanthorizons.config.enum.EDhApiGpuUploadMethod.SUB_DATA":
|
"distanthorizons.config.enum.EDhApiGpuUploadMethod.SUB_DATA":
|
||||||
|
|||||||
Reference in New Issue
Block a user