Inital support for lower resolution rendering
This commit is contained in:
@@ -69,15 +69,15 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
this.sectionRenderer = sectionRenderer;
|
||||
}
|
||||
|
||||
protected abstract int setup(Viewport<?> viewport, int sourceFramebuffer);
|
||||
protected abstract int setup(Viewport<?> viewport, int sourceFramebuffer, int srcWidth, int srcHeight);
|
||||
protected abstract void postOpaquePreTranslucent(Viewport<?> viewport);
|
||||
protected void finish(Viewport<?> viewport, int sourceFrameBuffer) {
|
||||
protected void finish(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, sourceFrameBuffer);
|
||||
}
|
||||
|
||||
public void runPipeline(Viewport<?> viewport, int sourceFrameBuffer) {
|
||||
int depthTexture = this.setup(viewport, sourceFrameBuffer);
|
||||
public void runPipeline(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
|
||||
int depthTexture = this.setup(viewport, sourceFrameBuffer, srcWidth, srcHeight);
|
||||
|
||||
var rs = ((AbstractSectionRenderer)this.sectionRenderer);
|
||||
rs.renderOpaque(viewport);
|
||||
@@ -89,13 +89,13 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
|
||||
rs.renderTranslucent(viewport);
|
||||
|
||||
this.finish(viewport, sourceFrameBuffer);
|
||||
this.finish(viewport, sourceFrameBuffer, srcWidth, srcHeight);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, sourceFrameBuffer);
|
||||
}
|
||||
|
||||
protected void initDepthStencil(int sourceFrameBuffer, int targetFb, int width, int height) {
|
||||
protected void initDepthStencil(int sourceFrameBuffer, int targetFb, int srcWidth, int srcHeight, int width, int height) {
|
||||
glClearNamedFramebufferfi(targetFb, GL_DEPTH_STENCIL, 0, 1.0f, 1);
|
||||
glBlitNamedFramebuffer(sourceFrameBuffer, targetFb, 0,0, width, height, 0,0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
glBlitNamedFramebuffer(sourceFrameBuffer, targetFb, 0,0, srcWidth, srcHeight, 0,0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebuffer(GL30.GL_FRAMEBUFFER, targetFb);
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int setup(Viewport<?> viewport, int sourceFramebuffer) {
|
||||
protected int setup(Viewport<?> viewport, int sourceFramebuffer, int srcWidth, int srcHeight) {
|
||||
if (this.shaderUniforms != null) {
|
||||
//Update the uniforms
|
||||
long ptr = UploadStream.INSTANCE.uploadTo(this.shaderUniforms);
|
||||
@@ -109,7 +109,7 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
this.initDepthStencil(sourceFramebuffer, this.fb.framebuffer.id, viewport.width, viewport.height);
|
||||
this.initDepthStencil(sourceFramebuffer, this.fb.framebuffer.id, srcWidth, srcHeight, viewport.width, viewport.height);
|
||||
return this.fb.getDepthTex().id;
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish(Viewport<?> viewport, int sourceFrameBuffer) {
|
||||
if (this.data.renderToVanillaDepth) {
|
||||
protected void finish(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
|
||||
if (this.data.renderToVanillaDepth && srcWidth == viewport.width && srcHeight == viewport.height) {//We can only depthblit out if destination size is the same
|
||||
glColorMask(false, false, false, false);
|
||||
AbstractRenderPipeline.transformBlitDepth(this.depthBlit,
|
||||
this.fbTranslucent.getDepthTex().id, sourceFrameBuffer,
|
||||
|
||||
@@ -54,7 +54,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int setup(Viewport<?> viewport, int sourceFB) {
|
||||
protected int setup(Viewport<?> viewport, int sourceFB, int srcWidth, int srcHeight) {
|
||||
if (this.colourTex == null || this.colourTex.getHeight() != viewport.height || this.colourTex.getWidth() != viewport.width) {
|
||||
if (this.colourTex != null) {
|
||||
this.colourTex.free();
|
||||
@@ -76,7 +76,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
|
||||
glTextureParameterf(this.fb.getDepthTex().id, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT);
|
||||
}
|
||||
|
||||
this.initDepthStencil(sourceFB, this.fb.framebuffer.id, viewport.width, viewport.height);
|
||||
this.initDepthStencil(sourceFB, this.fb.framebuffer.id, viewport.width, viewport.height, viewport.width, viewport.height);
|
||||
|
||||
return this.fb.getDepthTex().id;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finish(Viewport<?> viewport, int sourceFrameBuffer) {
|
||||
protected void finish(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
|
||||
this.finalBlit.bind();
|
||||
if (this.useEnvFog) {
|
||||
float start = viewport.fogParameters.environmentalStart();
|
||||
|
||||
@@ -205,6 +205,9 @@ public class VoxyRenderSystem {
|
||||
int oldFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING);
|
||||
int boundFB = oldFB;
|
||||
|
||||
int[] dims = new int[4];
|
||||
glGetIntegerv(GL_VIEWPORT, dims);
|
||||
|
||||
//var target = DefaultTerrainRenderPasses.CUTOUT.getTarget();
|
||||
//boundFB = ((net.minecraft.client.texture.GlTexture) target.getColorAttachment()).getOrCreateFramebuffer(((GlBackend) RenderSystem.getDevice()).getFramebufferManager(), target.getDepthAttachment());
|
||||
if (boundFB == 0) {
|
||||
@@ -224,7 +227,7 @@ public class VoxyRenderSystem {
|
||||
|
||||
|
||||
//The entire rendering pipeline (excluding the chunkbound thing)
|
||||
this.pipeline.runPipeline(viewport, boundFB);
|
||||
this.pipeline.runPipeline(viewport, boundFB, dims[2], dims[3]);
|
||||
|
||||
|
||||
TimingStatistics.main.stop();
|
||||
|
||||
Reference in New Issue
Block a user