mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-19 20:09:39 +00:00
Fix issues that directly affects Euphoria Patches + Complementary (#1782)
This commit is contained in:
1 parent
9c45549e35
commit
865de3cbab
16 files changed
+95
-31
No files matched your search
@@ -2,16 +2,16 @@ package net.coderbot.iris.gl.buffer;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import lombok.Getter;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
public class ShaderStorageBuffer {
|
||||
protected final int index;
|
||||
protected final ShaderStorageInfo info;
|
||||
protected int id;
|
||||
@Getter protected int id;
|
||||
|
||||
public ShaderStorageBuffer(int index, ShaderStorageInfo info) {
|
||||
this.id = RenderSystem.createBuffers();
|
||||
@@ -45,16 +45,13 @@ public class ShaderStorageBuffer {
|
||||
GLStateManager.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, newId);
|
||||
|
||||
// Calculation time
|
||||
int newWidth = (int) (width * info.scaleX());
|
||||
int newHeight = (int) (height * info.scaleY());
|
||||
int finalSize = (newHeight * newWidth) * info.size();
|
||||
long newWidth = (long) (width * info.scaleX());
|
||||
long newHeight = (long) (height * info.scaleY());
|
||||
long finalSize = (newHeight * newWidth) * info.size();
|
||||
RenderSystem.bufferStorage(GL43.GL_SHADER_STORAGE_BUFFER, finalSize, 0);
|
||||
RenderSystem.clearBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, GL30.GL_R8, 0, finalSize, GL11.GL_RED, GL11.GL_BYTE, new int[]{0});
|
||||
RenderSystem.bindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, index, newId);
|
||||
id = newId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.coderbot.iris.gl.buffer;
|
||||
|
||||
public record ShaderStorageInfo(int size, boolean relative, float scaleX, float scaleY) {
|
||||
public record ShaderStorageInfo(long size, boolean relative, float scaleX, float scaleY) {
|
||||
}
|
||||
@@ -4,15 +4,18 @@ import lombok.Getter;
|
||||
import net.coderbot.iris.gl.GlResource;
|
||||
import net.coderbot.iris.gl.blending.DepthColorStorage;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
public final class Program extends GlResource {
|
||||
|
||||
|
||||
@Getter
|
||||
private final ProgramUniforms uniforms;
|
||||
|
||||
|
||||
@Getter
|
||||
private final ProgramSamplers samplers;
|
||||
|
||||
|
||||
@Getter
|
||||
private final ProgramImages images;
|
||||
|
||||
@@ -25,15 +28,16 @@ public final class Program extends GlResource {
|
||||
|
||||
DepthColorStorage.registerOwnedProgram(program);
|
||||
}
|
||||
|
||||
|
||||
public void use() {
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
GLStateManager.glUseProgram(getGlId());
|
||||
|
||||
|
||||
uniforms.update();
|
||||
samplers.update();
|
||||
images.update();
|
||||
}
|
||||
|
||||
|
||||
public static void unbind() {
|
||||
ProgramUniforms.clearActiveUniforms();
|
||||
ProgramSamplers.clearActiveSamplers();
|
||||
@@ -45,7 +49,7 @@ public final class Program extends GlResource {
|
||||
DepthColorStorage.unregisterOwnedProgram(getGlId());
|
||||
GLStateManager.glDeleteProgram(getGlId());
|
||||
}
|
||||
|
||||
|
||||
public int getProgramId() {
|
||||
return getGlId();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.coderbot.iris.compat.dh.DHCompat;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
import net.coderbot.iris.shaderpack.IrisLimits;
|
||||
import net.coderbot.iris.shaderpack.StringPair;
|
||||
import net.coderbot.iris.texture.format.TextureFormat;
|
||||
import net.coderbot.iris.texture.format.TextureFormatLoader;
|
||||
@@ -81,6 +82,9 @@ public class StandardMacros {
|
||||
define(standardDefines, "IS_ANGELICA");
|
||||
if (AngelicaConfig.defineIsIris) {
|
||||
define(standardDefines, "IS_IRIS");
|
||||
define(standardDefines, "IRIS_VERSION", "10803");
|
||||
define(standardDefines, "IRIS_HAS_TRANSLUCENCY_SORTING");
|
||||
define(standardDefines, "MAX_COLOR_BUFFERS", String.valueOf(IrisLimits.MAX_COLOR_BUFFERS));
|
||||
}
|
||||
|
||||
if (DHCompat.hasRenderingEnabled()) {
|
||||
|
||||
@@ -90,6 +90,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -517,7 +518,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
}
|
||||
if (hasSetup) {
|
||||
ComputeProgram.unbind();
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT);
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
}
|
||||
|
||||
// Terrain pipeline sampler/image factory setup follows.
|
||||
@@ -771,11 +772,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
public boolean shouldOverrideShaders() {
|
||||
return isRenderingWorld && !isRenderingFullScreenPass && !isPostChain && isMainBound;
|
||||
}
|
||||
|
||||
|
||||
public Pass getActivePassProgram() {
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
public int getActivePassProgramId() {
|
||||
if (current == null) return -1;
|
||||
final Program p = current.getProgram();
|
||||
@@ -793,10 +794,10 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
if (!isRenderingWorld || isRenderingFullScreenPass || isPostChain || !isMainBound) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final RenderCondition condition = getCondition(getPhase());
|
||||
final Pass matched = table.match(condition, inputs);
|
||||
|
||||
|
||||
beginPass(matched);
|
||||
}
|
||||
|
||||
@@ -1332,7 +1333,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
}
|
||||
if (ranSetup) {
|
||||
ComputeProgram.unbind();
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT);
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ class CeleritasTransformer {
|
||||
}
|
||||
|
||||
private static void transformShared(Transformer transformer, Parameters parameters) {
|
||||
transformer.replaceExpression("gl_TextureMatrix[0]", "mat4(1.0)");
|
||||
CoreTransformHelper.injectMatrixUniforms(transformer);
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -263,7 +264,7 @@ public class CompositeRenderer {
|
||||
}
|
||||
|
||||
if (ranCompute) {
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT);
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
}
|
||||
|
||||
Program.unbind();
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -229,7 +230,7 @@ public class FinalPassRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT);
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
|
||||
if (!finalPass.mipmappedBuffers.isEmpty()) {
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
|
||||
@@ -771,7 +771,7 @@ public class ShaderProperties {
|
||||
return;
|
||||
}
|
||||
|
||||
final int size = Integer.parseInt(parts[0]);
|
||||
final long size = Long.parseLong(parts[0]);
|
||||
|
||||
// Size < 1 means the shader dev intended to disable the buffer
|
||||
if (size < 1) {
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -208,7 +209,7 @@ public class ShadowCompositeRenderer {
|
||||
|
||||
if (ranCompute) {
|
||||
// Memory barrier for shader image access and texture fetch
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT);
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
}
|
||||
|
||||
Program.unbind();
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CameraUniforms {
|
||||
|
||||
private void update() {
|
||||
previousCameraPosition.set(currentCameraPosition);
|
||||
previousCameraPositionUnshifted = currentCameraPositionUnshifted;
|
||||
previousCameraPositionUnshifted.set(currentCameraPositionUnshifted);
|
||||
currentCameraPosition.set(getUnshiftedCameraPosition()).add(shift);
|
||||
currentCameraPositionUnshifted.set(getUnshiftedCameraPosition());
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import net.coderbot.iris.gl.uniform.UniformHolder;
|
||||
import net.coderbot.iris.pipeline.ShadowRenderer;
|
||||
import net.coderbot.iris.shaderpack.PackDirectives;
|
||||
import net.coderbot.iris.shadow.ShadowMatrices;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Matrix4fc;
|
||||
|
||||
@@ -17,8 +19,18 @@ public final class MatrixUniforms {
|
||||
private MatrixUniforms() {
|
||||
}
|
||||
|
||||
private static final Matrix4f GBUFFER_MODELVIEW_SCRATCH = new Matrix4f();
|
||||
private static Matrix4fc getGbufferModelView() {
|
||||
final Matrix4fc raw = RenderingState.INSTANCE.getModelViewMatrix();
|
||||
final Entity view = Minecraft.getMinecraft().renderViewEntity;
|
||||
if (view == null) {
|
||||
return raw;
|
||||
}
|
||||
return GBUFFER_MODELVIEW_SCRATCH.set(raw).translate(0f, view.getEyeHeight(), 0f);
|
||||
}
|
||||
|
||||
public static void addMatrixUniforms(UniformHolder uniforms, PackDirectives directives) {
|
||||
addMatrix(uniforms, "ModelView", RenderingState.INSTANCE::getModelViewMatrix);
|
||||
addMatrix(uniforms, "ModelView", MatrixUniforms::getGbufferModelView);
|
||||
// TODO: In some cases, gbufferProjectionInverse takes on a value much different than OptiFine...
|
||||
// We need to audit Mojang's linear algebra.
|
||||
addMatrix(uniforms, "Projection", RenderingState.INSTANCE::getProjectionMatrix);
|
||||
|
||||
Reference in new issue
Block a user