Inital support for lower resolution rendering

This commit is contained in:
mcrcortex
2025-09-03 14:00:26 +10:00
parent 37323f9170
commit e2342a75dd
4 changed files with 18 additions and 15 deletions

View File

@@ -69,15 +69,15 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
this.sectionRenderer = sectionRenderer; 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 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); glDisable(GL_STENCIL_TEST);
glBindFramebuffer(GL_FRAMEBUFFER, sourceFrameBuffer); glBindFramebuffer(GL_FRAMEBUFFER, sourceFrameBuffer);
} }
public void runPipeline(Viewport<?> viewport, int sourceFrameBuffer) { public void runPipeline(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
int depthTexture = this.setup(viewport, sourceFrameBuffer); int depthTexture = this.setup(viewport, sourceFrameBuffer, srcWidth, srcHeight);
var rs = ((AbstractSectionRenderer)this.sectionRenderer); var rs = ((AbstractSectionRenderer)this.sectionRenderer);
rs.renderOpaque(viewport); rs.renderOpaque(viewport);
@@ -89,13 +89,13 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
rs.renderTranslucent(viewport); rs.renderTranslucent(viewport);
this.finish(viewport, sourceFrameBuffer); this.finish(viewport, sourceFrameBuffer, srcWidth, srcHeight);
glBindFramebuffer(GL_FRAMEBUFFER, sourceFrameBuffer); 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); 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); glBindFramebuffer(GL30.GL_FRAMEBUFFER, targetFb);

View File

@@ -90,7 +90,7 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
} }
@Override @Override
protected int setup(Viewport<?> viewport, int sourceFramebuffer) { protected int setup(Viewport<?> viewport, int sourceFramebuffer, int srcWidth, int srcHeight) {
if (this.shaderUniforms != null) { if (this.shaderUniforms != null) {
//Update the uniforms //Update the uniforms
long ptr = UploadStream.INSTANCE.uploadTo(this.shaderUniforms); long ptr = UploadStream.INSTANCE.uploadTo(this.shaderUniforms);
@@ -109,7 +109,7 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
glClear(GL_COLOR_BUFFER_BIT); 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; return this.fb.getDepthTex().id;
} }
@@ -129,8 +129,8 @@ public class IrisVoxyRenderPipeline extends AbstractRenderPipeline {
} }
@Override @Override
protected void finish(Viewport<?> viewport, int sourceFrameBuffer) { protected void finish(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
if (this.data.renderToVanillaDepth) { 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); glColorMask(false, false, false, false);
AbstractRenderPipeline.transformBlitDepth(this.depthBlit, AbstractRenderPipeline.transformBlitDepth(this.depthBlit,
this.fbTranslucent.getDepthTex().id, sourceFrameBuffer, this.fbTranslucent.getDepthTex().id, sourceFrameBuffer,

View File

@@ -54,7 +54,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
} }
@Override @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.getHeight() != viewport.height || this.colourTex.getWidth() != viewport.width) {
if (this.colourTex != null) { if (this.colourTex != null) {
this.colourTex.free(); 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); 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; return this.fb.getDepthTex().id;
} }
@@ -103,7 +103,7 @@ public class NormalRenderPipeline extends AbstractRenderPipeline {
} }
@Override @Override
protected void finish(Viewport<?> viewport, int sourceFrameBuffer) { protected void finish(Viewport<?> viewport, int sourceFrameBuffer, int srcWidth, int srcHeight) {
this.finalBlit.bind(); this.finalBlit.bind();
if (this.useEnvFog) { if (this.useEnvFog) {
float start = viewport.fogParameters.environmentalStart(); float start = viewport.fogParameters.environmentalStart();

View File

@@ -205,6 +205,9 @@ public class VoxyRenderSystem {
int oldFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING); int oldFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING);
int boundFB = oldFB; int boundFB = oldFB;
int[] dims = new int[4];
glGetIntegerv(GL_VIEWPORT, dims);
//var target = DefaultTerrainRenderPasses.CUTOUT.getTarget(); //var target = DefaultTerrainRenderPasses.CUTOUT.getTarget();
//boundFB = ((net.minecraft.client.texture.GlTexture) target.getColorAttachment()).getOrCreateFramebuffer(((GlBackend) RenderSystem.getDevice()).getFramebufferManager(), target.getDepthAttachment()); //boundFB = ((net.minecraft.client.texture.GlTexture) target.getColorAttachment()).getOrCreateFramebuffer(((GlBackend) RenderSystem.getDevice()).getFramebufferManager(), target.getDepthAttachment());
if (boundFB == 0) { if (boundFB == 0) {
@@ -224,7 +227,7 @@ public class VoxyRenderSystem {
//The entire rendering pipeline (excluding the chunkbound thing) //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(); TimingStatistics.main.stop();