From 3747e5574c2da2fb92290633d244741592afa0fc Mon Sep 17 00:00:00 2001 From: vinceh121 Date: Wed, 27 Dec 2023 01:43:13 +0100 Subject: [PATCH] fix: buffer copy for fxaa --- .../wanderer/glx/post/FxaaPostProcessEffect.java | 5 +++++ .../wanderer/desktop/glx/LWJGLFXAAShader.java | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/me/vinceh121/wanderer/glx/post/FxaaPostProcessEffect.java b/core/src/me/vinceh121/wanderer/glx/post/FxaaPostProcessEffect.java index 36db21f..e2fb19c 100644 --- a/core/src/me/vinceh121/wanderer/glx/post/FxaaPostProcessEffect.java +++ b/core/src/me/vinceh121/wanderer/glx/post/FxaaPostProcessEffect.java @@ -16,4 +16,9 @@ public FxaaPostProcessEffect(IFXAAShader shader) { public Texture process(GraphicsManager glx, Texture tex) { return this.shader.run(glx.getModelBatch().getRenderContext(), tex); } + + @Override + public boolean isInPlace() { + return false; + } } diff --git a/desktop/src/me/vinceh121/wanderer/desktop/glx/LWJGLFXAAShader.java b/desktop/src/me/vinceh121/wanderer/desktop/glx/LWJGLFXAAShader.java index 9705e8a..f82cf6b 100644 --- a/desktop/src/me/vinceh121/wanderer/desktop/glx/LWJGLFXAAShader.java +++ b/desktop/src/me/vinceh121/wanderer/desktop/glx/LWJGLFXAAShader.java @@ -3,6 +3,7 @@ import org.lwjgl.opengl.GL43; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g3d.utils.RenderContext; @@ -23,22 +24,25 @@ public LWJGLFXAAShader(final int shaderHandle, final int programHandle) { public Texture run(final RenderContext ctx, final Texture tex) { this.bind(); + final int width = Gdx.graphics.getWidth(); + final int height = Gdx.graphics.getHeight(); + final int texUnit = ctx.textureBinder.bind(tex); + final Texture texOut = new Texture(width, height, Format.RGB888); + final int texUnitOut = ctx.textureBinder.bind(texOut); + // final int texUnit = 0; // tex.bind(0); - final int width = Gdx.graphics.getWidth(); - final int height = Gdx.graphics.getHeight(); - this.setInputImage(ctx, texUnit); - this.setOutputImage(ctx, texUnit); + this.setOutputImage(ctx, texUnitOut); this.setInvResolution(width, height); this.dispatch(width / 64, height / 64, 1); // XXX divisions here should round up GL43.glMemoryBarrier(GL43.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); - return tex; + return texOut; } @Override