Add complete multidraw

This commit is contained in:
James Seibel
2024-07-17 17:39:52 -05:00
parent 618707533b
commit 1e6eb4c096
4 changed files with 32 additions and 25 deletions
@@ -59,8 +59,8 @@ public class ColumnRenderBuffer implements AutoCloseable
public boolean buffersUploaded = false;
private SharedVbo.BufferSlice[] opaqueBufferSlices;
private SharedVbo.BufferSlice[] transparentBufferSlices;
public SharedVbo.BufferSlice[] opaqueBufferSlices;
public SharedVbo.BufferSlice[] transparentBufferSlices;
@@ -236,17 +236,17 @@ public class ColumnRenderBuffer implements AutoCloseable
// render //
//========//
public void renderOpaque(LodRenderer renderContext, DhApiRenderParam renderEventParam)
{
renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
renderContext.drawSharedVbo(SharedVbo.OPAQUE, this.opaqueBufferSlices);
}
public void renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
{
renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
renderContext.drawSharedVbo(SharedVbo.TRANSPARENT, this.transparentBufferSlices);
}
//public void renderOpaque(LodRenderer renderContext, DhApiRenderParam renderEventParam)
//{
// renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
// renderContext.drawSharedVbo(SharedVbo.OPAQUE, this.opaqueBufferSlices);
//}
//
//public void renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
//{
// renderContext.setModelViewMatrixOffset(this.pos, renderEventParam);
// renderContext.drawSharedVbo(SharedVbo.TRANSPARENT, this.transparentBufferSlices);
//}
@@ -19,8 +19,8 @@ public class SharedVbo
{
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
public static final SharedVbo OPAQUE = new SharedVbo(1_000_000_000/*1GB*/, 1024 * 1024/*1MB*/);
public static final SharedVbo TRANSPARENT = new SharedVbo(1_000_000_000/*1GB*/, 1024 * 1024/*1MB*/);
public static final SharedVbo OPAQUE = new SharedVbo(2_000_000_000L/*1GB*/, 1024 * 1024/*1MB*/);
public static final SharedVbo TRANSPARENT = new SharedVbo(2_000_000_000L/*1GB*/, 1024 * 1024/*1MB*/);
public final int vboId;
@@ -25,11 +25,13 @@ import com.seibel.distanthorizons.api.interfaces.override.rendering.IDhApiShadow
import com.seibel.distanthorizons.api.methods.events.sharedParameterObjects.DhApiRenderParam;
import com.seibel.distanthorizons.core.config.Config;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.ColumnRenderBuffer;
import com.seibel.distanthorizons.core.dataObjects.render.bufferBuilding.SharedVbo;
import com.seibel.distanthorizons.core.dependencyInjection.ModAccessorInjector;
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
import com.seibel.distanthorizons.core.enums.EDhDirection;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.logging.f3.F3Screen;
import com.seibel.distanthorizons.core.pos.DhBlockPos;
import com.seibel.distanthorizons.core.pos.DhLodPos;
import com.seibel.distanthorizons.core.pos.DhSectionPos;
import com.seibel.distanthorizons.core.pos.Pos2D;
@@ -48,9 +50,7 @@ import org.apache.logging.log4j.Logger;
import org.joml.Matrix4f;
import org.joml.Matrix4fc;
import java.util.Comparator;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -348,7 +348,11 @@ public class RenderBufferHandler implements AutoCloseable
// TODO why can these sometimes be null when teleporting between multiverses
if (this.loadedNearToFarBuffers != null)
{
this.loadedNearToFarBuffers.forEach(loadedBuffer -> loadedBuffer.buffer.renderOpaque(renderContext, renderEventParam));
renderContext.setModelViewMatrixOffset(DhBlockPos.ZERO, renderEventParam);
ArrayList<SharedVbo.BufferSlice> sliceList = new ArrayList<>();
this.loadedNearToFarBuffers.forEach(loadedBuffer -> sliceList.addAll(Arrays.asList(loadedBuffer.buffer.opaqueBufferSlices)));
renderContext.drawSharedVbo(SharedVbo.OPAQUE, sliceList.toArray(new SharedVbo.BufferSlice[0]));
}
}
public void renderTransparent(LodRenderer renderContext, DhApiRenderParam renderEventParam)
@@ -356,12 +360,11 @@ public class RenderBufferHandler implements AutoCloseable
// TODO why can these sometimes be null when teleporting between multiverses
if (this.loadedNearToFarBuffers != null)
{
ListIterator<LoadedRenderBuffer> iter = this.loadedNearToFarBuffers.listIterator(this.loadedNearToFarBuffers.size());
while (iter.hasPrevious())
{
LoadedRenderBuffer loadedBuffer = iter.previous();
loadedBuffer.buffer.renderTransparent(renderContext, renderEventParam);
}
renderContext.setModelViewMatrixOffset(DhBlockPos.ZERO, renderEventParam);
ArrayList<SharedVbo.BufferSlice> sliceList = new ArrayList<>();
this.loadedNearToFarBuffers.forEach(loadedBuffer -> sliceList.addAll(Arrays.asList(loadedBuffer.buffer.transparentBufferSlices)));
renderContext.drawSharedVbo(SharedVbo.TRANSPARENT, sliceList.toArray(new SharedVbo.BufferSlice[0]));
}
}
@@ -305,8 +305,11 @@ public class LodRenderer
// terrain
profiler.popPush("LOD Opaque");
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
this.bufferHandler.renderOpaque(this, renderEventParam);
// custom objects with SSAO
if (Config.Client.Advanced.Graphics.GenericRendering.enableRendering.get())
{
@@ -470,6 +473,7 @@ public class LodRenderer
GL32.glBlendEquation(GL32.GL_FUNC_ADD);
GL32.glBlendFuncSeparate(GL32.GL_SRC_ALPHA, GL32.GL_ONE_MINUS_SRC_ALPHA, GL32.GL_ONE, GL32.GL_ONE_MINUS_SRC_ALPHA);
ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeRenderPassEvent.class, renderEventParam);
this.bufferHandler.renderTransparent(this, renderEventParam);
GL32.glDepthMask(true); // Apparently the depth mask state is stored in the FBO, so glState fails to restore it...