Skip to content

Commit

Permalink
Merge branch '1.19.1' into 1.19.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/net/coderbot/iris/pipeline/ShadowRenderer.java
#	src/main/resources/iris.accesswidener
#	src/main/resources/mixins.iris.json
  • Loading branch information
IMS212 committed Oct 4, 2023
2 parents c98ce70 + 05dd395 commit 3576efa
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 4 deletions.
30 changes: 30 additions & 0 deletions src/main/java/net/coderbot/iris/compliance/ComplianceVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.coderbot.iris.compliance;

import net.coderbot.iris.Iris;

public enum ComplianceVersion {
NO_COMPLIANCE,
v1;

public int getInternalComplianceLevel() {
switch (this) {
case NO_COMPLIANCE -> {
return 0;
}
case v1 -> {
return 1;
}
default -> throw new IllegalStateException("Impossible, compliance is not existing? " + this.name());
}
}

public static ComplianceVersion getComplianceLevel(String compliance) {
try {
int complianceL = Integer.parseInt(compliance);
return ComplianceVersion.valueOf("v" + complianceL);
} catch (IllegalArgumentException e) {
Iris.logger.warn("Unknown compliance: " + compliance + "; defaulting to NONCOMPLIANT.");
return NO_COMPLIANCE;
}
}
}
5 changes: 5 additions & 0 deletions src/main/java/net/coderbot/iris/gl/BooleanStateExtended.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package net.coderbot.iris.gl;

public interface BooleanStateExtended {
void setUnknownState();
}
2 changes: 2 additions & 0 deletions src/main/java/net/coderbot/iris/gl/IrisRenderSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ public static boolean supportsBufferBlending() {
public static void disableBufferBlend(int buffer) {
RenderSystem.assertOnRenderThreadOrInit();
GL32C.glDisablei(GL32C.GL_BLEND, buffer);
((BooleanStateExtended) GlStateManagerAccessor.getBLEND().mode).setUnknownState();
}

public static void enableBufferBlend(int buffer) {
RenderSystem.assertOnRenderThreadOrInit();
GL32C.glEnablei(GL32C.GL_BLEND, buffer);
((BooleanStateExtended) GlStateManagerAccessor.getBLEND().mode).setUnknownState();
}

public static void blendFuncSeparatei(int buffer, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/net/coderbot/iris/mixin/MixinBooleanState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package net.coderbot.iris.mixin;

import com.mojang.blaze3d.platform.GlStateManager;
import net.coderbot.iris.gl.BooleanStateExtended;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GlStateManager.BooleanState.class)
public class MixinBooleanState implements BooleanStateExtended {
@Shadow
@Final
private int state;
@Shadow
public boolean enabled;
@Unique
private boolean stateUnknown;

@Inject(method = "setEnabled", at = @At("HEAD"), cancellable = true)
private void iris$setUnknownState(boolean enable, CallbackInfo ci) {
if (stateUnknown) {
ci.cancel();
this.enabled = enable;
stateUnknown = false;
if (enable) {
GL11.glEnable(this.state);
} else {
GL11.glDisable(this.state);
}
}
}

@Override
public void setUnknownState() {
stateUnknown = true;
}
}
4 changes: 4 additions & 0 deletions src/main/java/net/coderbot/iris/mixin/MixinTweakFarPlane.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
*
* Fun.
*/

/**
* Due to shader devs moving forward with removing legacy code, I have decided to disable this Mixin. It will be stored here for reference. -IMS
*/
@Mixin(GameRenderer.class)
public class MixinTweakFarPlane {
@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private FrustumHolder createShadowFrustum(float renderMultiplier, FrustumHolder

if (isReversed) {
return holder.setInfo(new ReversedAdvancedShadowCullingFrustum(CapturedRenderingState.INSTANCE.getGbufferModelView(),
CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller), distanceInfo, cullingInfo);
CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller, new BoxCuller(halfPlaneLength * renderMultiplier)), distanceInfo, cullingInfo);
} else {
return holder.setInfo(new AdvancedShadowCullingFrustum(CapturedRenderingState.INSTANCE.getGbufferModelView(),
CapturedRenderingState.INSTANCE.getGbufferProjection(), shadowLightVectorFromOrigin, boxCuller), distanceInfo, cullingInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ public void renderAll() {
renderPass.program.use();
if (renderPass.blendModeOverride != null) {
renderPass.blendModeOverride.apply();
} else {
RenderSystem.disableBlend();
}

// program is the identifier for composite :shrug:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@
import org.joml.Vector3f;

public class ReversedAdvancedShadowCullingFrustum extends AdvancedShadowCullingFrustum {
public ReversedAdvancedShadowCullingFrustum(Matrix4f playerView, Matrix4f playerProjection, Vector3f shadowLightVectorFromOrigin, BoxCuller boxCuller) {
super(playerView, playerProjection, shadowLightVectorFromOrigin, boxCuller);
private final BoxCuller distanceCuller;

public ReversedAdvancedShadowCullingFrustum(Matrix4f playerView, Matrix4f playerProjection, Vector3f shadowLightVectorFromOrigin, BoxCuller voxelCuller, BoxCuller distanceCuller) {
super(playerView, playerProjection, shadowLightVectorFromOrigin, voxelCuller);
this.distanceCuller = distanceCuller;
}

@Override
public void prepare(double cameraX, double cameraY, double cameraZ) {
if (this.distanceCuller != null) {
this.distanceCuller.setPosition(cameraX, cameraY, cameraZ);
}
super.prepare(cameraX, cameraY, cameraZ);
}

@Override
public boolean isVisible(AABB aabb) {
if (distanceCuller != null && distanceCuller.isCulled(aabb)) {
return false;
}

if (boxCuller != null && !boxCuller.isCulled(aabb)) {
return true;
}
Expand All @@ -22,6 +37,10 @@ public boolean isVisible(AABB aabb) {

@Override
public int fastAabbTest(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
if (distanceCuller != null && distanceCuller.isCulled(minX, minY, minZ, maxX, maxY, maxZ)) {
return 0;
}

if (boxCuller != null && !boxCuller.isCulled(minX, minY, minZ, maxX, maxY, maxZ)) {
return 2;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/iris.accesswidener
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
accessWidener v1 named

accessible class com/mojang/blaze3d/platform/GlStateManager$BlendState
accessible class com/mojang/blaze3d/platform/GlStateManager$BooleanState
accessible class com/mojang/blaze3d/platform/GlStateManager$TextureState
accessible class com/mojang/blaze3d/platform/GlStateManager$ColorMask
accessible class com/mojang/blaze3d/platform/GlStateManager$DepthState
Expand Down Expand Up @@ -30,3 +31,4 @@ mutable field net/minecraft/client/renderer/ShaderInstance COLOR_MODULATOR Lcom/
accessible field net/minecraft/client/renderer/ShaderInstance uniforms Ljava/util/List;
mutable field net/minecraft/client/renderer/LevelRenderer renderBuffers Lnet/minecraft/client/renderer/RenderBuffers;
accessible class net/minecraft/client/gui/components/AbstractSelectionList$Entry
accessible field com/mojang/blaze3d/platform/GlStateManager$BooleanState enabled Z
2 changes: 1 addition & 1 deletion src/main/resources/mixins.iris.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"MixinBiome",
"MixinBiomes",
"MixinChainedJsonException",
"MixinBooleanState",
"MixinClientLanguage",
"MixinClientPacketListener",
"MixinDebugScreenOverlay",
Expand Down Expand Up @@ -47,7 +48,6 @@
"MixinShaderInstance",
"MixinTheEndPortalRenderer",
"MixinTitleScreen",
"MixinTweakFarPlane",
"MixinLightTexture",
"MixinWindow",
"MixinSystemReport",
Expand Down

0 comments on commit 3576efa

Please sign in to comment.