Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -9,10 +9,9 @@ import me.cortex.voxy.client.core.rendering.hierachical.AsyncNodeManager;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.HierarchicalOcclusionTraverser;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.NodeCleaner;
|
||||
import me.cortex.voxy.client.core.rendering.post.FullscreenBlit;
|
||||
import me.cortex.voxy.client.core.rendering.section.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.backend.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.util.DownloadStream;
|
||||
import me.cortex.voxy.common.util.TrackedObject;
|
||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
@@ -24,7 +23,6 @@ import static org.lwjgl.opengl.GL11C.GL_ALWAYS;
|
||||
import static org.lwjgl.opengl.GL11C.GL_DEPTH_TEST;
|
||||
import static org.lwjgl.opengl.GL11C.GL_EQUAL;
|
||||
import static org.lwjgl.opengl.GL11C.GL_KEEP;
|
||||
import static org.lwjgl.opengl.GL11C.GL_NEAREST;
|
||||
import static org.lwjgl.opengl.GL11C.GL_REPLACE;
|
||||
import static org.lwjgl.opengl.GL11C.GL_STENCIL_TEST;
|
||||
import static org.lwjgl.opengl.GL11C.glColorMask;
|
||||
@@ -35,7 +33,6 @@ import static org.lwjgl.opengl.GL11C.glStencilMask;
|
||||
import static org.lwjgl.opengl.GL11C.glStencilOp;
|
||||
import static org.lwjgl.opengl.GL30C.GL_FRAMEBUFFER;
|
||||
import static org.lwjgl.opengl.GL30C.glBindFramebuffer;
|
||||
import static org.lwjgl.opengl.GL42.GL_DEPTH_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL42.GL_LEQUAL;
|
||||
import static org.lwjgl.opengl.GL42.GL_NOTEQUAL;
|
||||
import static org.lwjgl.opengl.GL42.glDepthFunc;
|
||||
@@ -43,7 +40,6 @@ import static org.lwjgl.opengl.GL42.*;
|
||||
import static org.lwjgl.opengl.GL45.glClearNamedFramebufferfi;
|
||||
import static org.lwjgl.opengl.GL45.glGetNamedFramebufferAttachmentParameteri;
|
||||
import static org.lwjgl.opengl.GL45C.glBindTextureUnit;
|
||||
import static org.lwjgl.opengl.GL45C.glBlitNamedFramebuffer;
|
||||
|
||||
public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
private final BooleanSupplier frexStillHasWork;
|
||||
|
||||
@@ -7,7 +7,7 @@ import me.cortex.voxy.client.core.rendering.hierachical.AsyncNodeManager;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.HierarchicalOcclusionTraverser;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.NodeCleaner;
|
||||
import me.cortex.voxy.client.core.rendering.post.FullscreenBlit;
|
||||
import me.cortex.voxy.client.core.rendering.section.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.backend.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.util.DepthFramebuffer;
|
||||
import me.cortex.voxy.client.core.rendering.util.UploadStream;
|
||||
import me.cortex.voxy.client.iris.IrisVoxyRenderPipelineData;
|
||||
|
||||
@@ -18,8 +18,9 @@ import me.cortex.voxy.client.core.rendering.building.RenderGenerationService;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.AsyncNodeManager;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.HierarchicalOcclusionTraverser;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.NodeCleaner;
|
||||
import me.cortex.voxy.client.core.rendering.section.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.MDICSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.IUsesMeshlets;
|
||||
import me.cortex.voxy.client.core.rendering.section.backend.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.backend.mdic.MDICSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.geometry.BasicSectionGeometryData;
|
||||
import me.cortex.voxy.client.core.rendering.section.geometry.IGeometryData;
|
||||
import me.cortex.voxy.client.core.rendering.util.DownloadStream;
|
||||
@@ -68,9 +69,9 @@ public class VoxyRenderSystem {
|
||||
|
||||
private final AbstractRenderPipeline pipeline;
|
||||
|
||||
private static AbstractSectionRenderer<?,?> createSectionRenderer(AbstractRenderPipeline pipeline, ModelStore modelStore, IGeometryData geometryData) {
|
||||
private static AbstractSectionRenderer.Factory<?,? extends IGeometryData> getRenderBackendFactory() {
|
||||
//TODO: need todo a thing where selects optimal section render based on if supports the pipeline and geometry data type
|
||||
return new MDICSectionRenderer(pipeline, modelStore, (BasicSectionGeometryData) geometryData);//We only have MDIC backend... for now
|
||||
return MDICSectionRenderer.FACTORY;
|
||||
}
|
||||
|
||||
public VoxyRenderSystem(WorldEngine world, ServiceManager sm) {
|
||||
@@ -93,11 +94,11 @@ public class VoxyRenderSystem {
|
||||
this.worldIn = world;
|
||||
|
||||
long geometryCapacity = getGeometryBufferSize();
|
||||
var backendFactory = getRenderBackendFactory();
|
||||
|
||||
{
|
||||
|
||||
|
||||
this.modelService = new ModelBakerySubsystem(world.getMapper());
|
||||
this.renderGen = new RenderGenerationService(world, this.modelService, sm, false);
|
||||
this.renderGen = new RenderGenerationService(world, this.modelService, sm, IUsesMeshlets.class.isAssignableFrom(backendFactory.clz()));
|
||||
|
||||
this.geometryData = new BasicSectionGeometryData(1 << 20, geometryCapacity);
|
||||
|
||||
@@ -115,7 +116,7 @@ public class VoxyRenderSystem {
|
||||
|
||||
this.pipeline = RenderPipelineFactory.createPipeline(this.nodeManager, this.nodeCleaner, this.traversal, this::frexStillHasWork);
|
||||
this.pipeline.setupExtraModelBakeryData(this.modelService);//Configure the model service
|
||||
var sectionRenderer = createSectionRenderer(this.pipeline, this.modelService.getStore(), this.geometryData);
|
||||
var sectionRenderer = backendFactory.create(this.pipeline, this.modelService.getStore(), this.geometryData);
|
||||
this.pipeline.setSectionRenderer(sectionRenderer);
|
||||
this.viewportSelector = new ViewportSelector<>(sectionRenderer::createViewport);
|
||||
|
||||
@@ -371,7 +372,7 @@ public class VoxyRenderSystem {
|
||||
return base.mulLocal(
|
||||
makeProjectionMatrix(0.05f, Minecraft.getInstance().gameRenderer.getDepthFar()).invert(),
|
||||
new Matrix4f()
|
||||
).mulLocal(makeProjectionMatrix(16, 16*3000));
|
||||
).mulLocal(makeProjectionMatrix(VoxyClient.getOcclusionDebugState()<=1?16f:0.1f, 16*3000));
|
||||
}
|
||||
|
||||
private boolean frexStillHasWork() {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package me.cortex.voxy.client.core.rendering.section;
|
||||
|
||||
|
||||
import me.cortex.voxy.client.core.model.ModelStore;
|
||||
import me.cortex.voxy.client.core.rendering.Viewport;
|
||||
import me.cortex.voxy.client.core.rendering.section.geometry.IGeometryData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//Takes in mesh ids from the hierachical traversal and may perform more culling then renders it
|
||||
public abstract class AbstractSectionRenderer <T extends Viewport<T>, J extends IGeometryData> {
|
||||
protected final J geometryManager;
|
||||
protected final ModelStore modelStore;
|
||||
protected AbstractSectionRenderer(ModelStore modelStore, J geometryManager) {
|
||||
this.geometryManager = geometryManager;
|
||||
this.modelStore = modelStore;
|
||||
}
|
||||
|
||||
public abstract void renderOpaque(T viewport);
|
||||
public abstract void buildDrawCalls(T viewport);
|
||||
public abstract void renderTemporal(T viewport);
|
||||
public abstract void renderTranslucent(T viewport);
|
||||
public abstract T createViewport();
|
||||
public abstract void free();
|
||||
|
||||
public J getGeometryManager() {
|
||||
return this.geometryManager;
|
||||
}
|
||||
|
||||
public void addDebug(List<String> lines) {}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package me.cortex.voxy.client.core.rendering.section.backend;
|
||||
|
||||
|
||||
import me.cortex.voxy.client.core.AbstractRenderPipeline;
|
||||
import me.cortex.voxy.client.core.model.ModelStore;
|
||||
import me.cortex.voxy.client.core.rendering.Viewport;
|
||||
import me.cortex.voxy.client.core.rendering.section.geometry.BasicSectionGeometryData;
|
||||
import me.cortex.voxy.client.core.rendering.section.geometry.IGeometryData;
|
||||
import me.cortex.voxy.common.Logger;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
//Takes in mesh ids from the hierachical traversal and may perform more culling then renders it
|
||||
public abstract class AbstractSectionRenderer <T extends Viewport<T>, J extends IGeometryData> {
|
||||
public interface FactoryConstructor<VIEWPORT extends Viewport<VIEWPORT>, GEODATA extends IGeometryData> {
|
||||
AbstractSectionRenderer<VIEWPORT, GEODATA> create(AbstractRenderPipeline pipeline, ModelStore modelStore, GEODATA geometryData);
|
||||
}
|
||||
|
||||
public record Factory<VIEWPORT extends Viewport<VIEWPORT>, GEODATA extends IGeometryData>(Class<? extends AbstractSectionRenderer<VIEWPORT, GEODATA>> clz, FactoryConstructor<VIEWPORT, GEODATA> constructor) {
|
||||
public AbstractSectionRenderer<VIEWPORT, GEODATA> create(AbstractRenderPipeline pipeline, ModelStore store, IGeometryData geometryData) {
|
||||
return this.constructor.create(pipeline, store, (GEODATA) geometryData);
|
||||
}
|
||||
|
||||
public static <VIEWPORT2 extends Viewport<VIEWPORT2>, GEODATA2 extends IGeometryData> Factory<VIEWPORT2, GEODATA2> create(Class<? extends AbstractSectionRenderer<VIEWPORT2, GEODATA2>> clz) {
|
||||
var constructors = clz.getConstructors();
|
||||
if (constructors.length != 1) {
|
||||
Logger.error("Render backend " + clz.getCanonicalName() + " had more then 1 constructor");
|
||||
return null;
|
||||
}
|
||||
var constructor = constructors[0];
|
||||
var params = constructor.getParameterTypes();
|
||||
if (params.length != 3 || params[0] != AbstractRenderPipeline.class || params[1] != ModelStore.class || !IGeometryData.class.isAssignableFrom(params[2])) {
|
||||
Logger.error("Render backend " + clz.getCanonicalName() + " had invalid constructor");
|
||||
return null;
|
||||
}
|
||||
return new Factory<>(clz, (a,b,c)-> {
|
||||
try {
|
||||
return (AbstractSectionRenderer<VIEWPORT2, GEODATA2>) constructor.newInstance(a,b,c);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final J geometryManager;
|
||||
protected final ModelStore modelStore;
|
||||
protected AbstractSectionRenderer(ModelStore modelStore, J geometryManager) {
|
||||
this.geometryManager = geometryManager;
|
||||
this.modelStore = modelStore;
|
||||
}
|
||||
|
||||
public abstract void renderOpaque(T viewport);
|
||||
public abstract void buildDrawCalls(T viewport);
|
||||
public abstract void renderTemporal(T viewport);
|
||||
public abstract void renderTranslucent(T viewport);
|
||||
public abstract T createViewport();
|
||||
public abstract void free();
|
||||
|
||||
public J getGeometryManager() {
|
||||
return this.geometryManager;
|
||||
}
|
||||
|
||||
public void addDebug(List<String> lines) {}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package me.cortex.voxy.client.core.rendering.section;
|
||||
package me.cortex.voxy.client.core.rendering.section.backend.mdic;
|
||||
|
||||
|
||||
import me.cortex.voxy.client.RenderStatistics;
|
||||
import me.cortex.voxy.client.VoxyClient;
|
||||
import me.cortex.voxy.client.core.AbstractRenderPipeline;
|
||||
import me.cortex.voxy.client.core.gl.Capabilities;
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
@@ -10,6 +11,7 @@ import me.cortex.voxy.client.core.gl.shader.Shader;
|
||||
import me.cortex.voxy.client.core.gl.shader.ShaderLoader;
|
||||
import me.cortex.voxy.client.core.gl.shader.ShaderType;
|
||||
import me.cortex.voxy.client.core.model.ModelStore;
|
||||
import me.cortex.voxy.client.core.rendering.section.backend.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.section.geometry.BasicSectionGeometryData;
|
||||
import me.cortex.voxy.client.core.rendering.util.DownloadStream;
|
||||
import me.cortex.voxy.client.core.rendering.util.LightMapHelper;
|
||||
@@ -40,6 +42,8 @@ import static org.lwjgl.opengl.NVRepresentativeFragmentTest.GL_REPRESENTATIVE_FR
|
||||
|
||||
//Uses MDIC to render the sections
|
||||
public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, BasicSectionGeometryData> {
|
||||
public static final Factory<MDICViewport, BasicSectionGeometryData> FACTORY = AbstractSectionRenderer.Factory.create(MDICSectionRenderer.class);
|
||||
|
||||
private static final int TRANSLUCENT_OFFSET = 400_000;//in draw calls
|
||||
private static final int TEMPORAL_OFFSET = 500_000;//in draw calls
|
||||
private static final int STATISTICS_BUFFER_BINDING = 8;
|
||||
@@ -190,7 +194,14 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
||||
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT|GL_SHADER_STORAGE_BARRIER_BIT);//Barrier everything is needed
|
||||
glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
|
||||
|
||||
if (VoxyClient.getOcclusionDebugState()==3) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
}
|
||||
glMultiDrawElementsIndirectCountARB(GL_TRIANGLES, GL_UNSIGNED_SHORT, indirectOffset, drawCountOffset, maxDrawCount, 0);
|
||||
if (VoxyClient.getOcclusionDebugState()==3) {
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
}
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glBindVertexArray(0);
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.cortex.voxy.client.core.rendering.section;
|
||||
package me.cortex.voxy.client.core.rendering.section.backend.mdic;
|
||||
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
import me.cortex.voxy.client.core.rendering.Viewport;
|
||||
@@ -187,7 +187,7 @@ void main() {
|
||||
hash = hash*1231421+123141;
|
||||
hash ^= hash>>16;
|
||||
hash = hash * 1827364925 + 123325621;
|
||||
outColour = vec4(float(hash&15u)/15, float((hash>>4)&15u)/15, float((hash>>8)&15u)/15, 1);
|
||||
outColour = vec4(float(hash&15u)/15, float((hash>>4)&15u)/15, float((hash>>8)&15u)/15, 0);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
|
||||
|
||||
#ifdef DEBUG_RENDER
|
||||
quadDebug = extractDetail(positionBuffer[gl_BaseInstance]);
|
||||
quadDebug = uint(gl_VertexID)>>(2+5);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user