hoist common FB
This commit is contained in:
@@ -10,6 +10,7 @@ import me.cortex.voxy.client.core.rendering.hierachical.HierarchicalOcclusionTra
|
||||
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.backend.AbstractSectionRenderer;
|
||||
import me.cortex.voxy.client.core.rendering.util.DepthFramebuffer;
|
||||
import me.cortex.voxy.client.core.rendering.util.DownloadStream;
|
||||
import me.cortex.voxy.common.util.TrackedObject;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -31,6 +32,7 @@ import static org.lwjgl.opengl.GL11C.glEnable;
|
||||
import static org.lwjgl.opengl.GL11C.glStencilFunc;
|
||||
import static org.lwjgl.opengl.GL11C.glStencilMask;
|
||||
import static org.lwjgl.opengl.GL11C.glStencilOp;
|
||||
import static org.lwjgl.opengl.GL30C.GL_DEPTH24_STENCIL8;
|
||||
import static org.lwjgl.opengl.GL30C.GL_FRAMEBUFFER;
|
||||
import static org.lwjgl.opengl.GL30C.glBindFramebuffer;
|
||||
import static org.lwjgl.opengl.GL42.GL_LEQUAL;
|
||||
@@ -53,6 +55,9 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
private final FullscreenBlit depthMaskBlit = new FullscreenBlit("voxy:post/fullscreen2.vert", "voxy:post/noop.frag");
|
||||
private final FullscreenBlit depthSetBlit = new FullscreenBlit("voxy:post/fullscreen2.vert", "voxy:post/depth0.frag");
|
||||
private final FullscreenBlit depthCopy = new FullscreenBlit("voxy:post/fullscreen2.vert", "voxy:post/depth_copy.frag");
|
||||
|
||||
public final DepthFramebuffer fb = new DepthFramebuffer(GL_DEPTH24_STENCIL8);
|
||||
|
||||
private static final int DEPTH_SAMPLER = glGenSamplers();
|
||||
static {
|
||||
glSamplerParameteri(DEPTH_SAMPLER, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
@@ -208,6 +213,7 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
|
||||
@Override
|
||||
protected void free0() {
|
||||
this.fb.free();
|
||||
this.sectionRenderer.free();
|
||||
this.depthMaskBlit.delete();
|
||||
this.depthSetBlit.delete();
|
||||
|
||||
@@ -26,8 +26,7 @@ import static org.lwjgl.opengl.GL45C.*;
|
||||
public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
private final IrisVoxyRenderPipelineData data;
|
||||
private final FullscreenBlit depthBlit = new FullscreenBlit("voxy:post/blit_texture_depth_cutout.frag");
|
||||
public final DepthFramebuffer fb = new DepthFramebuffer(GL_DEPTH24_STENCIL8);
|
||||
public final DepthFramebuffer fbTranslucent = new DepthFramebuffer(GL_DEPTH24_STENCIL8);
|
||||
public final DepthFramebuffer fbTranslucent = new DepthFramebuffer(this.fb.getDepthTex().getFormat());
|
||||
|
||||
private final GlBuffer shaderUniforms;
|
||||
|
||||
@@ -79,7 +78,6 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
this.data.thePipeline = null;
|
||||
|
||||
this.depthBlit.delete();
|
||||
this.fb.free();
|
||||
this.fbTranslucent.free();
|
||||
|
||||
if (this.shaderUniforms != null) {
|
||||
|
||||
@@ -37,7 +37,6 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
|
||||
private GlTexture colourTex;
|
||||
private GlTexture colourSSAOTex;
|
||||
private final GlFramebuffer fbSSAO = new GlFramebuffer();
|
||||
private final DepthFramebuffer fb = new DepthFramebuffer(GL_DEPTH24_STENCIL8);
|
||||
|
||||
private final boolean useEnvFog;
|
||||
private final FullscreenBlit finalBlit;
|
||||
@@ -66,7 +65,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
|
||||
this.colourSSAOTex = new GlTexture().store(GL_RGBA8, 1, viewport.width, viewport.height);
|
||||
|
||||
this.fb.framebuffer.bind(GL_COLOR_ATTACHMENT0, this.colourTex).verify();
|
||||
this.fbSSAO.bind(GL_DEPTH_STENCIL_ATTACHMENT, this.fb.getDepthTex()).bind(GL_COLOR_ATTACHMENT0, this.colourSSAOTex).verify();
|
||||
this.fbSSAO.bind(this.fb.getDepthAttachmentType(), this.fb.getDepthTex()).bind(GL_COLOR_ATTACHMENT0, this.colourSSAOTex).verify();
|
||||
|
||||
|
||||
glTextureParameterf(this.colourTex.id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
@@ -145,7 +144,6 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
|
||||
public void free() {
|
||||
this.finalBlit.delete();
|
||||
this.ssaoCompute.free();
|
||||
this.fb.free();
|
||||
this.fbSSAO.free();
|
||||
if (this.colourTex != null) {
|
||||
this.colourTex.free();
|
||||
|
||||
@@ -96,6 +96,11 @@ public class GlTexture extends TrackedObject {
|
||||
return this.levels;
|
||||
}
|
||||
|
||||
public int getFormat() {
|
||||
this.assertAllocated();
|
||||
return this.format;
|
||||
}
|
||||
|
||||
private long getEstimatedSize() {
|
||||
this.assertAllocated();
|
||||
long elemSize = switch (this.format) {
|
||||
|
||||
@@ -28,12 +28,16 @@ public class DepthFramebuffer {
|
||||
this.depthBuffer.free();
|
||||
}
|
||||
this.depthBuffer = new GlTexture().store(this.depthType, 1, width, height);
|
||||
this.framebuffer.bind(this.depthType == GL_DEPTH24_STENCIL8?GL_DEPTH_STENCIL_ATTACHMENT: GL_DEPTH_ATTACHMENT, this.depthBuffer).verify();
|
||||
this.framebuffer.bind(this.getDepthAttachmentType(), this.depthBuffer).verify();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getDepthAttachmentType() {
|
||||
return this.depthType == GL_DEPTH24_STENCIL8?GL_DEPTH_STENCIL_ATTACHMENT: GL_DEPTH_ATTACHMENT;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.clear(1.0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user