Skip to content

Commit

Permalink
1.20.4 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Jan 26, 2025
1 parent d078f09 commit 0af4cdb
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class PostChainVRMixin {
// gui has no world renderpass
if (pass == RenderPass.GUI) {
this.vivecraft$VRPostChains.put(pass,
new PostChain(textureManager, resourceProvider, GuiHandler.GUI_FRAMEBUFFER, name));
new PostChain(textureManager, resourceManager, GuiHandler.GUI_FRAMEBUFFER, name));
continue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.vivecraft.mod_compat_vr.iris.mixin.coderbot;

import com.llamalad7.mixinextras.sugar.Local;
import net.coderbot.iris.gl.uniform.UniformHolder;
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
import org.apache.commons.lang3.tuple.Triple;
import org.joml.Matrix4fc;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.vivecraft.mod_compat_vr.shaders.ShadersHelper;

import java.util.function.Supplier;

@Pseudo
@Mixin(targets = "net.coderbot.iris.uniforms.CommonUniforms", remap = false)
public class IrisCommonUniformsMixin {
@Inject(method = "generalCommonUniforms", at = @At("TAIL"))
private static void vivecraft$addVivecraftUniforms(
CallbackInfo ci, @Local(argsOnly = true) UniformHolder uniforms)
{
for (Triple<String, ShadersHelper.UniformType, Supplier<?>> uniform : ShadersHelper.getUniforms()) {
switch (uniform.getMiddle()) {
case MATRIX4F -> uniforms.uniformMatrix(UniformUpdateFrequency.PER_FRAME, uniform.getLeft(),
() -> (Matrix4fc) uniform.getRight().get());
case VECTOR3F -> uniforms.uniform3f(UniformUpdateFrequency.PER_FRAME, uniform.getLeft(),
() -> (Vector3f) uniform.getRight().get());
case INTEGER -> uniforms.uniform1i(UniformUpdateFrequency.PER_FRAME, uniform.getLeft(),
() -> (int) uniform.getRight().get());
case BOOLEAN -> uniforms.uniform1b(UniformUpdateFrequency.PER_FRAME, uniform.getLeft(),
() -> (boolean) uniform.getRight().get());
default -> throw new IllegalStateException("Unexpected uniform type: " + uniform.getMiddle());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.vivecraft.mod_compat_vr.iris.mixin.coderbot;

import com.google.common.collect.ImmutableList;
import com.llamalad7.mixinextras.sugar.Local;
import net.coderbot.iris.helpers.StringPair;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.vivecraft.mod_compat_vr.shaders.ShadersHelper;

import java.util.ArrayList;
import java.util.List;

@Pseudo
@Mixin(targets = "net.coderbot.iris.gl.shader.StandardMacros", remap = false)
public class IrisStandardMacrosMixin {
@Shadow
private static void define(List<StringPair> defines, String key) {}

@Shadow
private static void define(List<StringPair> defines, String key, String value) {}

@Inject(method = "createStandardEnvironmentDefines", at = @At(value = "INVOKE", target = "Lnet/coderbot/iris/gl/shader/StandardMacros;define(Ljava/util/List;Ljava/lang/String;Ljava/lang/String;)V", ordinal = 0))
private static void vivecraft$addVivecraftUniforms(
CallbackInfoReturnable<ImmutableList<StringPair>> cir, @Local ArrayList<StringPair> standardDefines)
{
ShadersHelper.addMacros(
(string) -> define(standardDefines, string),
(string, value) -> define(standardDefines, string, String.valueOf(value))
);
}
}
2 changes: 2 additions & 0 deletions common/src/main/resources/vivecraft.iris.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"coderbot.IrisChunkProgramOverridesMixin",
"coderbot.IrisChunkProgramOverridesMixinSodium_0_4_11",
"coderbot.IrisChunkProgramOverridesMixinSodium_0_4_9",
"coderbot.IrisCommonUniformsMixin",
"coderbot.IrisNewWorldRenderingPipelineVRMixin",
"coderbot.IrisPipelineManagerVRMixin",
"coderbot.IrisStandardMacrosMixin",
"irisshaders.IrisChunkProgramOverridesMixin",
"irisshaders.IrisChunkProgramOverridesMixinSodium_0_5_8",
"irisshaders.IrisChunkProgramOverridesMixinSodium_0_6",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package net.coderbot.iris.gl.uniform;

import org.joml.Matrix4fc;
import org.joml.Vector3f;

import java.util.function.BooleanSupplier;
import java.util.function.IntSupplier;
import java.util.function.Supplier;

public interface UniformHolder {

UniformHolder uniform1i(UniformUpdateFrequency updateFrequency, String name, IntSupplier value);

UniformHolder uniform1b(UniformUpdateFrequency updateFrequency, String name, BooleanSupplier value);

UniformHolder uniform3f(UniformUpdateFrequency updateFrequency, String name, Supplier<Vector3f> value);

UniformHolder uniformMatrix(UniformUpdateFrequency updateFrequency, String name, Supplier<Matrix4fc> value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package net.coderbot.iris.gl.uniform;

public enum UniformUpdateFrequency {
ONCE,
PER_TICK,
PER_FRAME,
CUSTOM
}
3 changes: 3 additions & 0 deletions stubs/src/main/java/net/coderbot/iris/helpers/StringPair.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.coderbot.iris.helpers;

public class StringPair {}

0 comments on commit 0af4cdb

Please sign in to comment.