mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-19 11:59:40 +00:00
GLSM Extraction (#1527)
This commit is contained in:
1 parent
b179340a0f
commit
37717bd4db
189 files changed
+2198
-1365
No files matched your search
@@ -3,6 +3,7 @@ package net.coderbot.iris.gl.blending;
|
||||
import com.gtnewhorizons.angelica.glsm.states.DepthState;
|
||||
import com.gtnewhorizons.angelica.glsm.states.ColorMask;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import lombok.Getter;
|
||||
|
||||
public class DepthColorStorage {
|
||||
@@ -11,10 +12,24 @@ public class DepthColorStorage {
|
||||
@Getter
|
||||
private static boolean depthColorLocked;
|
||||
|
||||
private static final IntOpenHashSet ownedPrograms = new IntOpenHashSet();
|
||||
|
||||
public static void registerOwnedProgram(int programId) {
|
||||
ownedPrograms.add(programId);
|
||||
}
|
||||
|
||||
public static void unregisterOwnedProgram(int programId) {
|
||||
ownedPrograms.remove(programId);
|
||||
}
|
||||
|
||||
public static boolean isOwnedProgram(int programId) {
|
||||
return ownedPrograms.contains(programId);
|
||||
}
|
||||
|
||||
public static void disableDepthColor() {
|
||||
if (!depthColorLocked) {
|
||||
// Only save the previous state if the depth and color mask wasn't already locked
|
||||
ColorMask colorMask = GLStateManager.getColorMask();
|
||||
final ColorMask colorMask = GLStateManager.getColorMask();
|
||||
final DepthState depthState = GLStateManager.getDepthState();
|
||||
|
||||
originalDepthEnable = depthState.isEnabled();
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.coderbot.iris.gl.program;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.GlResource;
|
||||
import net.coderbot.iris.gl.blending.DepthColorStorage;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shaderpack.FilledIndirectPointer;
|
||||
import org.joml.Vector2f;
|
||||
@@ -34,6 +35,8 @@ public final class ComputeProgram extends GlResource {
|
||||
this.uniforms = uniforms;
|
||||
this.samplers = samplers;
|
||||
this.images = images;
|
||||
|
||||
DepthColorStorage.registerOwnedProgram(program);
|
||||
}
|
||||
|
||||
public void setWorkGroupInfo(Vector2f relativeWorkGroups, Vector3i absoluteWorkGroups, FilledIndirectPointer indirectPointer) {
|
||||
@@ -89,6 +92,7 @@ public final class ComputeProgram extends GlResource {
|
||||
|
||||
@Override
|
||||
public void destroyInternal() {
|
||||
DepthColorStorage.unregisterOwnedProgram(getGlId());
|
||||
GL20.glDeleteProgram(getGlId());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.coderbot.iris.gl.program;
|
||||
|
||||
import net.coderbot.iris.gl.GlResource;
|
||||
import net.coderbot.iris.gl.blending.DepthColorStorage;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
public final class Program extends GlResource {
|
||||
@@ -14,6 +15,8 @@ public final class Program extends GlResource {
|
||||
this.uniforms = uniforms;
|
||||
this.samplers = samplers;
|
||||
this.images = images;
|
||||
|
||||
DepthColorStorage.registerOwnedProgram(program);
|
||||
}
|
||||
|
||||
public void use() {
|
||||
@@ -32,6 +35,7 @@ public final class Program extends GlResource {
|
||||
|
||||
@Override
|
||||
public void destroyInternal() {
|
||||
DepthColorStorage.unregisterOwnedProgram(getGlId());
|
||||
GL20.glDeleteProgram(getGlId());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
|
||||
import net.coderbot.iris.gbuffer_overrides.state.RenderTargetStateListener;
|
||||
import net.coderbot.iris.gl.blending.AlphaTestOverride;
|
||||
import net.coderbot.iris.gl.blending.BlendModeOverride;
|
||||
import net.coderbot.iris.gl.blending.DepthColorStorage;
|
||||
import net.coderbot.iris.gl.blending.BufferBlendOverride;
|
||||
import net.coderbot.iris.gl.buffer.ShaderStorageBufferHolder;
|
||||
import net.coderbot.iris.gl.buffer.ShaderStorageInfo;
|
||||
@@ -738,6 +739,16 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldOverrideShaders() {
|
||||
return isRenderingWorld && !isRenderingFullScreenPass && !isPostChain && isMainBound;
|
||||
}
|
||||
|
||||
public int getActivePassProgramId() {
|
||||
if (current == null) return -1;
|
||||
final Program p = current.getProgram();
|
||||
return p != null ? p.getProgramId() : -1;
|
||||
}
|
||||
|
||||
private void matchPass() {
|
||||
if (!isRenderingWorld || isRenderingFullScreenPass || isPostChain || !isMainBound) {
|
||||
return;
|
||||
@@ -947,6 +958,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
}
|
||||
|
||||
public void use() {
|
||||
DepthColorStorage.unlockDepthColor();
|
||||
|
||||
if (isBeforeTranslucent) {
|
||||
framebufferBeforeTranslucents.bind();
|
||||
} else {
|
||||
@@ -986,6 +999,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
}
|
||||
|
||||
public void stopUsing() {
|
||||
DepthColorStorage.unlockDepthColor();
|
||||
|
||||
if (alphaTestOverride != null) {
|
||||
AlphaTestOverride.restore();
|
||||
}
|
||||
@@ -1009,6 +1024,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
DepthColorStorage.unlockDepthColor();
|
||||
BlendModeOverride.restore();
|
||||
AlphaTestOverride.restore();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.coderbot.iris.texture.pbr;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureTracker;
|
||||
import com.gtnewhorizons.angelica.client.rendering.TextureTracker;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.coderbot.iris.Iris;
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.BlendState;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfo;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureTracker;
|
||||
import com.gtnewhorizons.angelica.client.rendering.TextureTracker;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor;
|
||||
import net.coderbot.iris.gl.state.FogMode;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
|
||||
Reference in new issue
Block a user