Skip to content

Commit

Permalink
Improved performance of Iris compatibility interface
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Mar 4, 2023
1 parent 986d254 commit 6add0a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {

include(implementation("com.github.LlamaLad7:MixinExtras:0.1.1"))
annotationProcessor "com.github.LlamaLad7:MixinExtras:0.1.1"
include(implementation("net.lenni0451:Reflect:1.1.0"))
}

loom {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties | check these on https://fabricmc.net/versions.html
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.12
loader_version=0.14.15

# Mod Properties
mod_version = 1.1.9
mod_version = 1.1.10
maven_group = net.raphimc
archives_base_name = ImmediatelyFast
20 changes: 3 additions & 17 deletions src/main/java/net/raphimc/immediatelyfast/compat/IrisCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package net.raphimc.immediatelyfast.compat;

import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
import net.lenni0451.reflect.accessor.FieldAccessor;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.VertexFormat;
import net.raphimc.immediatelyfast.ImmediatelyFast;
Expand All @@ -40,23 +41,8 @@ public static void init() {
final Class<?> immediateStateClass = Class.forName("net.coderbot.iris.vertices.ImmediateState");
final Class<?> extendingBufferBuilderClass = Class.forName("net.coderbot.iris.vertices.ExtendingBufferBuilder");

final MethodHandle isRenderingLevelMH = lookup.findStaticGetter(immediateStateClass, "isRenderingLevel", boolean.class);
isRenderingLevel = () -> {
try {
return (boolean) isRenderingLevelMH.invokeExact();
} catch (Throwable e) {
throw new RuntimeException(e);
}
};

final MethodHandle renderWithExtendedVertexFormatMH = lookup.findStaticSetter(immediateStateClass, "renderWithExtendedVertexFormat", boolean.class);
renderWithExtendedVertexFormat = (value) -> {
try {
renderWithExtendedVertexFormatMH.invokeExact(value);
} catch (Throwable e) {
throw new RuntimeException(e);
}
};
isRenderingLevel = FieldAccessor.makeGetter(BooleanSupplier.class, null, immediateStateClass.getDeclaredField("isRenderingLevel"));
renderWithExtendedVertexFormat = FieldAccessor.makeSetter(BooleanConsumer.class, null, immediateStateClass.getDeclaredField("renderWithExtendedVertexFormat"));

final MethodHandle iris$beginWithoutExtendingMH = lookup.findVirtual(extendingBufferBuilderClass, "iris$beginWithoutExtending", MethodType.methodType(void.class, VertexFormat.DrawMode.class, VertexFormat.class));
final CallSite iris$beginWithoutExtendingCallSite = LambdaMetafactory.metafactory(lookup, "accept", MethodType.methodType(TriConsumer.class), MethodType.methodType(void.class, Object.class, Object.class, Object.class), iris$beginWithoutExtendingMH, iris$beginWithoutExtendingMH.type());
Expand Down

0 comments on commit 6add0a8

Please sign in to comment.