Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.20.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/net/coderbot/iris/mixin/shadows/MixinLevelRenderer.java
  • Loading branch information
IMS212 committed Oct 4, 2023
2 parents 3f7fa53 + fc97fab commit bef7c67
Show file tree
Hide file tree
Showing 34 changed files with 198 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ body:
id: logs
attributes:
label: Log output
description: 'Please upload a client log file by dragging and dropping it into this section. Usually this is found at `.minecraft/logs/latest.log`. If you are not sure how to find `.minecraft`, please see this article: https://minecraft.fandom.com/wiki/.minecraft#Locating_.minecraft. Please do not upload a compressed (`.log.gz`) file, they are very difficult for us to read when viewing issue reports. The log file instantly tells us important information like the versions of any other installed mods or if there are errors so it is very very important that you include it in your report.'
description: 'Please upload a client log file by dragging and dropping it into this section. Usually this is found at `.minecraft/logs/latest.log`. If you are not sure how to find `.minecraft`, please see this article: https://minecraft.wiki/w/.minecraft#Locating_.minecraft. Please do not upload a compressed (`.log.gz`) file, they are very difficult for us to read when viewing issue reports. The log file instantly tells us important information like the versions of any other installed mods or if there are errors so it is very very important that you include it in your report.'
- type: input
id: minecraft-version
attributes:
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/incompatible-mods.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See https://github.com/VazkiiMods/Botania/issues/3912

Similarly to Botania, ComputerCraft uses custom shader programs for high-performance monitor rendering. Unfortunately, this doesn't work with Iris shader programs.

The ComputerCraft: Restitched developers have implemented specific workarounds when using shader packs with OptiFine, but have not done so for Iris.
The CC: Tweaked devs have made the renderer switch to VBO mode with shaders enabled, so there should be no issue.

See: https://github.com/cc-tweaked/cc-restitched/issues/1

Expand Down
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 @@ -300,11 +300,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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public Vector3i getWorkGroups(float width, float height) {
if (this.absoluteWorkGroups != null) {
this.cachedWorkGroups = this.absoluteWorkGroups;
} else if (relativeWorkGroups != null) {
// TODO: This is my best guess at what Optifine does. Can this be confirmed?
// Do not use actual localSize here, apparently that's not what we want.
this.cachedWorkGroups = new Vector3i((int) Math.ceil(Math.ceil((width * relativeWorkGroups.x)) / localSize[0]), (int) Math.ceil(Math.ceil((height * relativeWorkGroups.y)) / localSize[1]), 1);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ public OptionalInt location(String name, UniformType type) {
return OptionalInt.empty();
}

// TODO: Temporary hack until custom uniforms are merged.
if ((!locations.containsKey(id) && !uniformNames.containsKey(name)) || name.equals("framemod8")) {
if ((!locations.containsKey(id) && !uniformNames.containsKey(name))) {
locations.put(id, name);
uniformNames.put(name, type);
} else {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/net/coderbot/iris/gl/shader/ProgramCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ public class ProgramCreator {
public static int create(String name, GlShader... shaders) {
int program = GlStateManager.glCreateProgram();

// TODO: This is *really* hardcoded, we need to refactor this to support external calls
// to glBindAttribLocation
GlStateManager._glBindAttribLocation(program, 11, "iris_Entity");
GlStateManager._glBindAttribLocation(program, 11, "mc_Entity");
GlStateManager._glBindAttribLocation(program, 12, "mc_midTexCoord");
GlStateManager._glBindAttribLocation(program, 13, "at_tangent");
GlStateManager._glBindAttribLocation(program, 14, "at_midBlock");

// TODO: more hardcoding for 1.17
GlStateManager._glBindAttribLocation(program, 0, "Position");
GlStateManager._glBindAttribLocation(program, 1, "UV0");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
public class IrisVideoSettings {
public static int shadowDistance = 32;

// TODO: Tell the user to check in the shader options once that's supported.
private static final Tooltip DISABLED_TOOLTIP = Tooltip.create(Component.translatable("options.iris.shadowDistance.disabled"));
private static final Tooltip ENABLED_TOOLTIP = Tooltip.create(Component.translatable("options.iris.shadowDistance.enabled"));
public static ColorSpace colorSpace = ColorSpace.SRGB;
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;
}
}
6 changes: 0 additions & 6 deletions src/main/java/net/coderbot/iris/mixin/MixinGameRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public class MixinGameRenderer {
}, at = @At("HEAD"), cancellable = true)
private static void iris$overrideTranslucentShader(CallbackInfoReturnable<ShaderInstance> cir) {
if (ShadowRenderer.ACTIVE) {
// TODO: Wrong program
override(ShaderKey.SHADOW_TERRAIN_CUTOUT, cir);
} else if (isBlockEntities() || isEntities()) {
override(ShaderKey.MOVING_BLOCK, cir);
Expand All @@ -187,7 +186,6 @@ public class MixinGameRenderer {
}, at = @At("HEAD"), cancellable = true)
private static void iris$overrideEntityCutoutShader(CallbackInfoReturnable<ShaderInstance> cir) {
if (ShadowRenderer.ACTIVE) {
// TODO: Wrong program
override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir);
} else if (HandRenderer.INSTANCE.isActive()) {
override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE, cir);
Expand Down Expand Up @@ -222,7 +220,6 @@ public class MixinGameRenderer {
}, at = @At("HEAD"), cancellable = true)
private static void iris$overrideEnergySwirlShadowShader(CallbackInfoReturnable<ShaderInstance> cir) {
if (ShadowRenderer.ACTIVE) {
// TODO: Wrong program
override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir);
} else if (HandRenderer.INSTANCE.isActive()) {
override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT : ShaderKey.HAND_TRANSLUCENT, cir);
Expand Down Expand Up @@ -253,7 +250,6 @@ public class MixinGameRenderer {
}, at = @At("HEAD"), cancellable = true)
private static void iris$overrideEntitySolidDiffuseShader(CallbackInfoReturnable<ShaderInstance> cir) {
if (ShadowRenderer.ACTIVE) {
// TODO: Wrong program
override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir);
} else if (HandRenderer.INSTANCE.isActive()) {
override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT_DIFFUSE : ShaderKey.HAND_WATER_DIFFUSE, cir);
Expand All @@ -269,7 +265,6 @@ public class MixinGameRenderer {
}, at = @At("HEAD"), cancellable = true)
private static void iris$overrideEntitySolidShader(CallbackInfoReturnable<ShaderInstance> cir) {
if (ShadowRenderer.ACTIVE) {
// TODO: Wrong program
override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir);
} else if (HandRenderer.INSTANCE.isActive()) {
override(HandRenderer.INSTANCE.isRenderingSolid() ? ShaderKey.HAND_CUTOUT : ShaderKey.HAND_TRANSLUCENT, cir);
Expand Down Expand Up @@ -302,7 +297,6 @@ public class MixinGameRenderer {
}, at = @At("HEAD"), cancellable = true)
private static void iris$overrideEntityEyesShader(CallbackInfoReturnable<ShaderInstance> cir) {
if (ShadowRenderer.ACTIVE) {
// TODO: Wrong program
override(ShaderKey.SHADOW_ENTITIES_CUTOUT, cir);
} else if (isBlockEntities()) {
override(ShaderKey.BLOCK_ENTITY, cir);
Expand Down
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
1 change: 0 additions & 1 deletion src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class MixinGui {
}
}

// TODO: Move this to a more appropriate mixin
@Inject(method = "render", at = @At("RETURN"))
public void iris$displayBigSodiumWarning(GuiGraphics guiGraphics, float pFloat1, CallbackInfo ci) {
if (Iris.isSodiumInstalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public abstract class MixinBufferBuilder extends DefaultedVertexConsumer impleme
if (format == DefaultVertexFormat.BLOCK) {
this.switchFormat(IrisVertexFormats.TERRAIN);
this.iris$isTerrain = true;
} else if (format == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
this.switchFormat(IrisVertexFormats.GLYPH);
this.iris$isTerrain = false;
} else {
this.switchFormat(IrisVertexFormats.ENTITY);
this.iris$isTerrain = false;
Expand All @@ -138,11 +141,7 @@ public abstract class MixinBufferBuilder extends DefaultedVertexConsumer impleme

@Override
public @NotNull VertexConsumer uv2(int pBufferVertexConsumer0, int pInt1) {
if (injectNormalAndUV1 && currentElement == DefaultVertexFormat.ELEMENT_UV1) {
this.putShort(0, (short) 0);
this.putShort(2, (short) 10);
this.nextElement();
}

return BufferVertexConsumer.super.uv2(pBufferVertexConsumer0, pInt1);
}

Expand All @@ -152,6 +151,9 @@ public abstract class MixinBufferBuilder extends DefaultedVertexConsumer impleme
if (format == DefaultVertexFormat.BLOCK) {
this.switchFormat(IrisVertexFormats.TERRAIN);
this.iris$isTerrain = true;
} else if (format == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
this.switchFormat(IrisVertexFormats.GLYPH);
this.iris$isTerrain = false;
} else {
this.switchFormat(IrisVertexFormats.ENTITY);
this.iris$isTerrain = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public class MixinVertexFormat {
IrisVertexFormats.TERRAIN.setupBufferState();

ci.cancel();
} else if ((Object) this == DefaultVertexFormat.NEW_ENTITY || (Object) this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
} else if ((Object) this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
IrisVertexFormats.GLYPH.setupBufferState();

ci.cancel();
} else if ((Object) this == DefaultVertexFormat.NEW_ENTITY) {
IrisVertexFormats.ENTITY.setupBufferState();

ci.cancel();
Expand All @@ -37,7 +41,11 @@ public class MixinVertexFormat {
IrisVertexFormats.TERRAIN.clearBufferState();

ci.cancel();
} else if ((Object) this == DefaultVertexFormat.NEW_ENTITY || (Object) this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
} else if ((Object) this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
IrisVertexFormats.GLYPH.clearBufferState();

ci.cancel();
} else if ((Object) this == DefaultVertexFormat.NEW_ENTITY) {
IrisVertexFormats.ENTITY.clearBufferState();

ci.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ private short resolveBlockId(BlockState state) {
if (bufferBuilder2 instanceof BlockSensitiveBufferBuilder) {
lastBufferBuilder = ((BlockSensitiveBufferBuilder) bufferBuilder2);
// All fluids have a ShadersMod render type of 1, to match behavior of Minecraft 1.7 and earlier.
// TODO: We're using createLegacyBlock? That seems like something that Mojang wants to deprecate.
lastBufferBuilder.beginBlock(resolveBlockId(fluidState.createLegacyBlock()), ExtendedDataHelper.FLUID_RENDER_TYPE, blockPos3.getX() & 0xF, blockPos3.getY() & 0xF, blockPos3.getZ() & 0xF);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ private TextureAccess createCustomTexture(CustomTextureData textureData) throws
// and we could end up holding on to a deleted texture unless we added special code to handle resource
// reloads. Re-fetching the texture from the TextureManager every time is the most robust approach for
// now.
// TODO: Should we give something else if the texture isn't there? This will need some thought
return new TextureWrapper(() -> {
AbstractTexture texture = textureManager.getTexture(textureLocation);
return texture != null ? texture.getId() : MissingTextureAtlasSprite.getTexture().getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,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 @@ -485,8 +485,6 @@ public NewWorldRenderingPipeline(ProgramSet programSet) throws IOException {
this.shadowRenderer = null;
}

// TODO: Create fallback Sodium shaders if the pack doesn't provide terrain shaders
// Currently we use Sodium's shaders but they don't support EXP2 fog underwater.
this.sodiumTerrainPipeline = new SodiumTerrainPipeline(this, programSet, createTerrainSamplers,
shadowRenderTargets == null ? null : createShadowTerrainSamplers, createTerrainImages, createShadowTerrainImages, renderTargets, flippedAfterPrepare, flippedAfterTranslucent,
shadowRenderTargets != null ? shadowRenderTargets.createShadowFramebuffer(ImmutableSet.of(), programSet.getShadow().filter(source -> !source.getDirectives().hasUnknownDrawBuffers()).map(source -> source.getDirectives().getDrawBuffers()).orElse(new int[]{0, 1})) : null, customUniforms);
Expand Down
Loading

0 comments on commit bef7c67

Please sign in to comment.