Skip to content

Commit

Permalink
Backport DH support from Iris 1.6.11 into Oculus (Use PixelBuilder sh…
Browse files Browse the repository at this point in the history
…adow fix for DH)
  • Loading branch information
henrikx committed Feb 27, 2024
1 parent a5958d6 commit 714ead3
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 4 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ loom {
"mixins.oculus.optimized-stitching.json",
"oculus-batched-entity-rendering.mixins.json",
"mixins.oculus.compat.sodium.json",
"mixins.oculus.compat.json"
"mixins.oculus.compat.json",
"mixins.iris.compat.dh.json"
]
}
mixin.defaultRefmapName = "oculus-mixins-refmap.json"
Expand Down Expand Up @@ -59,6 +60,8 @@ dependencies {

modRuntimeOnly "curse.maven:lazydfu-460819:3249059"

implementation "maven.modrinth:distanthorizons:2.0.1-a-1.16.5"

implementation(shadow(project(path: ":glsl-relocated", configuration: "bundledJar"))) {
transitive = false
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/coderbot/iris/compat/dh/DHCompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.coderbot.iris.compat.dh;

import net.coderbot.iris.gl.framebuffer.GlFramebuffer;

public class DHCompat {
private GlFramebuffer fb;

public int getFramebuffer() {
return fb.getId();
}

public void setFramebuffer(GlFramebuffer fb) {
this.fb = fb;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package net.coderbot.iris.compat.dh.mixin;

import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import net.minecraftforge.fml.loading.FMLLoader;

import java.util.List;
import java.util.Set;

/**
* Non-critical mixin config plugin, just disables mixins if Distant Horizons isn't present,
* since otherwise the log gets spammed with warnings.
*/
public class IrisDHCompatMixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {

}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return FMLLoader.getLoadingModList().getModFileById("distanthorizons") != null;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.coderbot.iris.compat.dh.mixin;

import com.seibel.distanthorizons.core.render.renderer.shaders.DhApplyShader;
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
import net.coderbot.iris.Iris;
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = DhApplyShader.class, remap = false)
public class MixinDHApplyShader {
@Redirect(method = "onRender", at = @At(value = "INVOKE", target = "Lcom/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IMinecraftRenderWrapper;getTargetFrameBuffer()I"))
private int changeFB(IMinecraftRenderWrapper instance) {
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
if (pipeline.getDHCompat() != null) {
return pipeline.getDHCompat().getFramebuffer();
} else {
return instance.getTargetFrameBuffer();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Set;
import java.util.function.IntFunction;
import java.util.function.Supplier;

import net.coderbot.iris.compat.dh.DHCompat;
import net.coderbot.iris.colorspace.ColorSpace;
import net.coderbot.iris.colorspace.ColorSpaceComputeConverter;
import net.coderbot.iris.colorspace.ColorSpaceConverter;
Expand Down Expand Up @@ -164,6 +164,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
private PackDirectives packDirectives;
private ColorSpace currentColorSpace;

private DHCompat dhCompat;

public DeferredWorldRenderingPipeline(ProgramSet programs) {
Objects.requireNonNull(programs);

Expand All @@ -179,6 +181,8 @@ public DeferredWorldRenderingPipeline(ProgramSet programs) {
this.oldLighting = programs.getPackDirectives().isOldLighting();
this.updateNotifier = new FrameUpdateNotifier();

this.dhCompat = new DHCompat();

this.packDirectives = programs.getPackDirectives();

RenderTarget mainTarget = Minecraft.getInstance().getMainRenderTarget();
Expand Down Expand Up @@ -436,6 +440,8 @@ public DeferredWorldRenderingPipeline(ProgramSet programs) {
return builder.build();
};

dhCompat.setFramebuffer(renderTargets.createGbufferFramebuffer(ImmutableSet.of(), new int[] { 0 }));

this.sodiumTerrainPipeline = new SodiumTerrainPipeline(this, programs, createTerrainSamplers,
shadowRenderer == null ? null : createShadowTerrainSamplers, createTerrainImages,
shadowRenderer == null ? null : createShadowTerrainImages);
Expand Down Expand Up @@ -531,6 +537,11 @@ public float getSunPathRotation() {
return sunPathRotation;
}

@Override
public DHCompat getDHCompat() {
return dhCompat;
}

private RenderCondition getCondition(WorldRenderingPhase phase) {
if (isRenderingShadow) {
return RenderCondition.SHADOW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.OptionalInt;

import com.mojang.blaze3d.platform.GlStateManager;

import net.coderbot.iris.compat.dh.DHCompat;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
Expand Down Expand Up @@ -193,4 +193,9 @@ public float getSunPathRotation() {
// No sun tilt
return 0;
}

@Override
public DHCompat getDHCompat() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;
import java.util.OptionalInt;

import net.coderbot.iris.compat.dh.DHCompat;
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import net.coderbot.iris.gbuffer_overrides.state.RenderTargetStateListener;
Expand Down Expand Up @@ -54,4 +54,6 @@ public interface WorldRenderingPipeline {
boolean allowConcurrentCompute();

float getSunPathRotation();

DHCompat getDHCompat();
}
13 changes: 13 additions & 0 deletions src/main/resources/mixins.iris.compat.dh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8",
"plugin": "net.coderbot.iris.compat.dh.mixin.IrisDHCompatMixinPlugin",
"package": "net.coderbot.iris.compat.dh.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"MixinDHApplyShader"
],
"injectors": {
"defaultRequire": 1
}
}

4 comments on commit 714ead3

@IMS212
Copy link

@IMS212 IMS212 commented on 714ead3 Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skull emoji

@henrikx
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad!

@henrikx
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IMS212 Don't mean to burden you with random mod compatibility issues, however I was wondering if maybe you would know anything about this kind of log spam?

[22:03:05] [Render thread/INFO] [minecraft/GlDebugTextUtils]: OpenGL debug message, id=1000, source=API, type=ERROR, severity=HIGH, message=glUniform2i has generated an error (GL_INVALID_OPERATION)
[22:03:05] [Render thread/INFO] [minecraft/GlDebugTextUtils]: OpenGL debug message, id=1000, source=API, type=ERROR, severity=HIGH, message=glUniform2i has generated an error (GL_INVALID_OPERATION)

This is happening with the fork of Complementary which was made for Iris 1.6.11. Basically, the shaders work fine until after a few minutes when suddenly Computercraft Consoles (the UI, not the monitors) become transparent.

I was just wondering if there were any fixes you have made in newer versions of Iris which come to mind? If so then I could also backport those fixes to see if they fix my issue :)

@IMS212
Copy link

@IMS212 IMS212 commented on 714ead3 Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can’t really help with that; the whole pipeline was written to be 1.18 exclusive.

Please sign in to comment.