Compare commits

..
Author SHA1 Message Date
embeddedt ac60c01788 Delete vanilla block bounds fields 2023-12-27 09:06:16 -08:00
Caedis 9410902937 Add FalseTweaks and SmoothFont to temp incompatibilities (#70)
* Update README.MD

Add FalseTweaks to temp incompatibilities

* and add SmoothFont
2023-12-27 03:59:27 -06:00
Jason Mitchell 52776530d8 Handle GL_COMPILE separately from GL_COMPILE_AND_EXECUTE
* Should fix OpenComputer issues
2023-12-26 17:19:35 -08:00
Jason Mitchell 9cebb352ad Opt in debug
* Less stutter with buggy stuff
2023-12-26 15:12:44 -08:00
embeddedt d810eaf876 Use client world for main thread renders 2023-12-26 12:45:45 -08:00
Jason Mitchell 1a1ca32721 Update 000-report-bug.yml 2023-12-26 09:10:00 -08:00
Jason Mitchell a3d689e806 Because of course someone uses DoubleBuffer 2023-12-26 08:45:26 -08:00
embeddedt d4e22b6c0c Avoid restoring GL buffers we didn't modify 2023-12-26 07:35:29 -08:00
Jason Mitchell 7e24f6a395 Reduce stuttering on Nvidia - Track the model view and projection matrix (#56)
* Track the model view and projection matrix
* Cache ViewportState as well
* Add mixin to speedup Jabba's saveBoundTexture
2023-12-25 20:16:43 -08:00
embeddedt c8e6a6f34f Make glPushAttrib match native behavior if bypassing state manager cache 2023-12-25 17:19:59 -08:00
Jason Mitchell f7a79cf02f Switch up how we're grabbing the projection & model view matrix to avoid needing to call glGetFloat() again 2023-12-25 16:14:35 -08:00
20 changed files with 472 additions and 47 deletions

No files matched your search

+3 -3
View File
@@ -45,9 +45,9 @@ body:
- type: textarea
id: modlist
attributes:
label: Mod List
description: "List of mods, ideally a minimal reproducible set (can be retrieved from latest.log)"
placeholder: "List of mods go here"
label: Mod List or GTNH Pack Version
description: "List of mods, ideally a minimal reproducible set (can be retrieved from latest.log). If using GTNH please indicate pack version and any changed mods, not the entire modlist."
placeholder: "List of mods or GTNH Pack version goes here"
validations:
required: true
- type: checkboxes
+2
View File
@@ -9,6 +9,8 @@
* Forge Relocation - Currently non Thread Safe; safe if not in use
* ProjectRed Frames - Currently non Thread Safe; safe if not in use
* EndlessIDs - Future compat planned
* FalseTweaks - Future compat planned
* SmoothFont - Future compat planned
* RPLE - Future compat planned
# Permanent Incompatibilities
@@ -73,4 +73,9 @@ public class AngelicaConfig {
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean optimizeTextureLoading;
@Config.Comment("Optimize slow glGetInteger in Jabba w/ Nvidia Drivers")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean optimizeJabbaGetInteger;
}
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.glsm;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.glsm.states.AlphaState;
import com.gtnewhorizons.angelica.glsm.states.BlendState;
@@ -8,7 +9,9 @@ import com.gtnewhorizons.angelica.glsm.states.Color4;
import com.gtnewhorizons.angelica.glsm.states.DepthState;
import com.gtnewhorizons.angelica.glsm.states.FogState;
import com.gtnewhorizons.angelica.glsm.states.GLColorMask;
import com.gtnewhorizons.angelica.glsm.states.MatrixState;
import com.gtnewhorizons.angelica.glsm.states.TextureState;
import com.gtnewhorizons.angelica.glsm.states.ViewportState;
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
import lombok.Getter;
import net.coderbot.iris.Iris;
@@ -24,7 +27,10 @@ import net.coderbot.iris.texture.TextureInfoCache;
import net.coderbot.iris.texture.TextureTracker;
import net.coderbot.iris.texture.pbr.PBRTextureManager;
import net.minecraft.client.renderer.OpenGlHelper;
import org.joml.Matrix4d;
import org.joml.Matrix4f;
import org.joml.Vector3d;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ARBMultitexture;
import org.lwjgl.opengl.Drawable;
@@ -33,6 +39,7 @@ import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.stream.IntStream;
@@ -55,6 +62,8 @@ public class GLStateManager {
@Getter private static final AlphaState alphaState = new AlphaState();
@Getter private static final BooleanState lightingState = new BooleanState(GL11.GL_LIGHTING);
@Getter private static final BooleanState rescaleNormalState = new BooleanState(GL12.GL_RESCALE_NORMAL);
@Getter private static final MatrixState matrixState = new MatrixState();
@Getter private static final ViewportState viewportState = new ViewportState();
private static long dirty = 0;
@@ -77,7 +86,7 @@ public class GLStateManager {
private static Thread CurrentThread = MainThread;
private static boolean runningSplash = false;
private static boolean inGLNewList = false;
private static int glListMode = 0;
private static boolean hudCaching$blendEnabled;
@@ -386,11 +395,17 @@ public class GLStateManager {
}
}
public static int getBoundTexture() {
return Textures[activeTexture].binding;
}
public static void glBindTexture(int target, int texture) {
if(inGLNewList) {
// Binding a texture, while building a list, is not allowed and is a silent noop
Throwable throwable = new Throwable();
LOGGER.info("Naughty naughty, someone's making a texture binding in a display list!", throwable);
if(glListMode == GL11.GL_COMPILE ) {
if(AngelicaMod.lwjglDebug) {
// Binding a texture, while building a list, is not allowed and is a silent noop
final Throwable throwable = new Throwable();
LOGGER.info("Naughty naughty, someone's making a texture binding in a display list!", throwable);
}
return;
}
@@ -654,25 +669,26 @@ public class GLStateManager {
}
public static void glNewList(int list, int mode) {
if(inGLNewList) {
if(glListMode > 0) {
throw new RuntimeException("glNewList called inside of a display list!");
}
inGLNewList = true;
glListMode = mode;
GL11.glNewList(list, mode);
}
public static void glEndList() {
if(!inGLNewList) {
if(glListMode == 0) {
throw new RuntimeException("glEndList called outside of a display list!");
}
inGLNewList = false;
glListMode = 0;
GL11.glEndList();
}
public static void glPushAttrib(int mask) {
// TODO: Proper state tracking; but at least for now the current cases of this didn't do anything related to textures and
// just overly broadly set ALL_BITS :facepalm:
GL11.glPushAttrib(mask & ~(GL11.GL_TEXTURE_BIT));
GL11.glPushAttrib(GLStateManager.BYPASS_CACHE ? mask : (mask & ~(GL11.GL_TEXTURE_BIT)));
}
public static void glPopAttrib() {
@@ -694,4 +710,94 @@ public class GLStateManager {
public static void dirty(long dirtyFlag) {
dirty |= dirtyFlag;
}
// Matrix Operations
public static void glMatrixMode(int mode) {
matrixState.setMode(mode);
GL11.glMatrixMode(mode);
}
public static void glLoadIdentity() {
GL11.glLoadIdentity();
matrixState.identity();
}
public static void glTranslatef(float x, float y, float z) {
GL11.glTranslatef(x, y, z);
matrixState.translate(x, y, z);
}
public static void glTranslated(double x, double y, double z) {
GL11.glTranslated(x, y, z);
matrixState.translate((float) x, (float) y, (float) z);
}
public static void glScalef(float x, float y, float z) {
GL11.glScalef(x, y, z);
matrixState.scale(x, y, z);
}
public static void glScaled(double x, double y, double z) {
GL11.glScaled(x, y, z);
matrixState.scale((float) x, (float) y, (float) z);
}
public static void glMultMatrix(FloatBuffer matrix) {
GL11.glMultMatrix(matrix);
matrixState.multiply(matrix);
}
public static final Matrix4d conersionMatrix4d = new Matrix4d();
public static final Matrix4f conersionMatrix4f = new Matrix4f();
public static void glMultMatrix(DoubleBuffer matrix) {
GL11.glMultMatrix(matrix);
conersionMatrix4d.set(matrix);
conersionMatrix4f.set(conersionMatrix4d);
matrixState.multiply(conersionMatrix4f);
}
public static void glRotatef(float angle, float x, float y, float z) {
GL11.glRotatef(angle, x, y, z);
matrixState.rotate((float)Math.toRadians(angle), x, y, z);
}
public static void glRotated(double angle, double x, double y, double z) {
GL11.glRotated(angle, x, y, z);
matrixState.rotate((float)Math.toRadians(angle), (float) x, (float) y, (float) z);
}
public static void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) {
GL11.glOrtho(left, right, bottom, top, zNear, zFar);
matrixState.ortho(left, right, bottom, top, zNear, zFar);
}
public static void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar) {
GL11.glFrustum(left, right, bottom, top, zNear, zFar);
matrixState.frustum(left, right, bottom, top, zNear, zFar);
}
public static void glPushMatrix() {
GL11.glPushMatrix();
matrixState.push();
}
public static void glPopMatrix() {
GL11.glPopMatrix();
matrixState.pop();
}
private static final Matrix4f perspectiveMatrix = new Matrix4f();
private static final FloatBuffer perspectiveBuffer = BufferUtils.createFloatBuffer(16);
public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
perspectiveMatrix.identity().perspective((float)Math.toRadians(fovy), aspect, zNear, zFar);
perspectiveMatrix.get(0, perspectiveBuffer);
GL11.glMultMatrix(perspectiveBuffer);
matrixState.multiply(perspectiveMatrix);
}
public static void glViewport(int x, int y, int width, int height) {
GL11.glViewport(x, y, width, height);
viewportState.set(x, y, width, height);
}
}
@@ -0,0 +1,134 @@
package com.gtnewhorizons.angelica.glsm.states;
import org.joml.Matrix4f;
import org.joml.Matrix4fStack;
import org.lwjgl.opengl.GL11;
import java.nio.FloatBuffer;
public class MatrixState {
public MatrixMode mode = MatrixMode.NONE;
public final Matrix4fStack projectionMatrix;
public final Matrix4fStack modelViewMatrix;
public MatrixState() {
projectionMatrix = new Matrix4fStack(GL11.glGetInteger(GL11.GL_MAX_PROJECTION_STACK_DEPTH));
modelViewMatrix = new Matrix4fStack(GL11.glGetInteger(GL11.GL_MAX_MODELVIEW_STACK_DEPTH));
}
public void identity() {
switch (mode) {
case MODELVIEW -> modelViewMatrix.identity();
case PROJECTION -> projectionMatrix.identity();
default -> {
}
}
}
public void setMode(int mode) {
switch (mode) {
case GL11.GL_MODELVIEW -> this.mode = MatrixMode.MODELVIEW;
case GL11.GL_PROJECTION -> this.mode = MatrixMode.PROJECTION;
default -> this.mode = MatrixMode.NONE;
}
}
public void translate(float x, float y, float z) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.translate(x, y, z);
case PROJECTION -> projectionMatrix.translate(x, y, z);
default -> {
}
}
}
public void scale(float x, float y, float z) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.scale(x, y, z);
case PROJECTION -> projectionMatrix.scale(x, y, z);
default -> {
}
}
}
private final Matrix4f tempMatrix = new Matrix4f();
public void multiply(FloatBuffer matrix) {
tempMatrix.set(matrix);
switch (mode) {
case MODELVIEW -> modelViewMatrix.mul(tempMatrix);
case PROJECTION -> projectionMatrix.mul(tempMatrix);
default -> {
}
}
}
public void multiply(Matrix4f matrix) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.mul(matrix);
case PROJECTION -> projectionMatrix.mul(matrix);
default -> {
}
}
}
public void rotate(float angle, float x, float y, float z) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.rotate(angle, x, y, z);
case PROJECTION -> projectionMatrix.rotate(angle, x, y, z);
default -> {
}
}
}
public void ortho(double left, double right, double bottom, double top, double zNear, double zFar) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.ortho((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
case PROJECTION -> projectionMatrix.ortho((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
default -> {
}
}
}
public void frustum(double left, double right, double bottom, double top, double zNear, double zFar) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.frustum((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
case PROJECTION -> projectionMatrix.frustum((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar);
default -> {
}
}
}
public void push() {
switch (mode) {
case MODELVIEW -> modelViewMatrix.pushMatrix();
case PROJECTION -> projectionMatrix.pushMatrix();
default -> {
}
}
}
public void pop() {
switch (mode) {
case MODELVIEW -> modelViewMatrix.popMatrix();
case PROJECTION -> projectionMatrix.popMatrix();
default -> {
}
}
}
public void perspective(float fovy, float aspect, float zNear, float zFar) {
switch (mode) {
case MODELVIEW -> modelViewMatrix.perspective(fovy, aspect, zNear, zFar);
case PROJECTION -> projectionMatrix.perspective(fovy, aspect, zNear, zFar);
default -> {
}
}
}
enum MatrixMode {
NONE,
MODELVIEW,
PROJECTION
}
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.glsm.states;
import java.nio.IntBuffer;
public class ViewportState {
public int x;
public int y;
public int width;
public int height;
public void set(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public void get(IntBuffer params) {
params.put(0, x);
params.put(1, y);
params.put(2, width);
params.put(3, height);
}
}
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.loading;
import com.gtnewhorizons.angelica.transform.BlockTransformer;
import com.gtnewhorizons.angelica.transform.RedirectorTransformer;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
@@ -74,6 +75,7 @@ public class MixinCompatHackTweaker implements ITweaker {
if (FMLLaunchHandler.side().isClient()) {
// Run after Mixins, but before LWJGl3ify
Launch.classLoader.registerTransformer(RedirectorTransformer.class.getName());
Launch.classLoader.registerTransformer(BlockTransformer.class.getName());
}
return new String[0];
@@ -25,8 +25,9 @@ public enum Mixins {
ANGELICA(new Builder("Angelica").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).addMixinClasses(
"angelica.MixinEntityRenderer"
"angelica.MixinActiveRenderInfo"
,"angelica.MixinClippingHelperImpl"
,"angelica.MixinEntityRenderer"
)
),
@@ -135,6 +136,11 @@ public enum Mixins {
)
),
OPTIMIZE_JABBA_GET_INTEGER(new Builder("Optimize Jabba getInteger").setPhase(Phase.LATE)
.addTargetedMod(TargetedMod.JABBA).setSide(Side.CLIENT)
.setApplyIf(() -> AngelicaConfig.optimizeJabbaGetInteger)
.addMixinClasses("client.jabba.MixinTileEntityBaseRenderer")),
ANGELICA_TEXTURE(new Builder("Textures").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableSodium).addMixinClasses(
@@ -0,0 +1,45 @@
package com.gtnewhorizons.angelica.mixins.early.angelica;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.states.ViewportState;
import com.gtnewhorizons.angelica.rendering.RenderingState;
import net.minecraft.client.renderer.ActiveRenderInfo;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.nio.FloatBuffer;
@Mixin(ActiveRenderInfo.class)
public class MixinActiveRenderInfo {
@Shadow private static FloatBuffer modelview;
@Shadow private static FloatBuffer projection;
@Inject(method = "updateRenderInfo", at = @At(value = "TAIL"))
private static void angelica$onUpdateRenderInfo(CallbackInfo ci) {
RenderingState.INSTANCE.setProjectionMatrix(projection);
RenderingState.INSTANCE.setModelViewMatrix(modelview);
}
@Redirect(method = "updateRenderInfo", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glGetFloat(ILjava/nio/FloatBuffer;)V"), remap = false)
private static void angelica$glGetFloat(int pname, FloatBuffer params) {
if(pname == GL11.GL_MODELVIEW_MATRIX) {
GLStateManager.getMatrixState().modelViewMatrix.get(0, params);
} else if(pname == GL11.GL_PROJECTION_MATRIX) {
GLStateManager.getMatrixState().projectionMatrix.get(0, params);
} else {
GL11.glGetFloat(pname, params);
}
}
@Redirect(method = "updateRenderInfo", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glGetInteger(ILjava/nio/IntBuffer;)V"), remap = false)
private static void angelica$glGetInteger(int pname, java.nio.IntBuffer params) {
if(pname == GL11.GL_VIEWPORT) {
GLStateManager.getViewportState().get(params);
} else {
GL11.glGetInteger(pname, params);
}
}
}
@@ -0,0 +1,24 @@
package com.gtnewhorizons.angelica.mixins.early.angelica;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.nio.FloatBuffer;
@Mixin(ClippingHelperImpl.class)
public class MixinClippingHelperImpl {
@Redirect(method="init", at=@At(value="INVOKE", target="Lorg/lwjgl/opengl/GL11;glGetFloat(ILjava/nio/FloatBuffer;)V"), remap = false)
private void angelica$glGetFloat(int pname, FloatBuffer params) {
if(pname == GL11.GL_MODELVIEW_MATRIX) {
GLStateManager.getMatrixState().modelViewMatrix.get(0, params);
} else if(pname == GL11.GL_PROJECTION_MATRIX) {
GLStateManager.getMatrixState().projectionMatrix.get(0, params);
} else {
GL11.glGetFloat(pname, params);
}
}
}
@@ -21,8 +21,5 @@ public abstract class MixinEntityRenderer {
viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks,
viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks
);
RenderingState.INSTANCE.captureProjectionMatrix();
RenderingState.INSTANCE.captureModelViewMatrix();
}
}
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.mixins.early.sodium.startup;
import com.gtnewhorizons.angelica.AngelicaMod;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
import net.coderbot.iris.Iris;
@@ -19,7 +20,7 @@ public class MixinInitDebug {
}
// Temp -- move this into common debug code
Iris.identifyCapabilities();
Iris.setDebug(true);
Iris.setDebug(AngelicaMod.lwjglDebug);
}
}
@@ -0,0 +1,19 @@
package com.gtnewhorizons.angelica.mixins.late.client.jabba;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(targets = "mcp.mobius.betterbarrels.client.render.TileEntityBaseRenderer")
public class MixinTileEntityBaseRenderer {
@Redirect(method="saveBoundTexture", at=@At(value="INVOKE", target="Lorg/lwjgl/opengl/GL11;glGetInteger(I)I"), remap=false)
private int glGetInteger(int pname) {
if(pname == GL11.GL_TEXTURE_BINDING_2D) {
return GLStateManager.getBoundTexture();
} else {
return GL11.glGetInteger(pname);
}
}
}
@@ -1,5 +1,6 @@
package com.gtnewhorizons.angelica.rendering;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import lombok.Getter;
import org.joml.Matrix4f;
import org.joml.Vector3d;
@@ -26,17 +27,14 @@ public class RenderingState {
cameraPosition.set(x, y, z);
}
public void captureProjectionMatrix() {
// Not very fast, but given we're not on 3.2+ core and are still using the opengl matrix stack, we don't have much alternative
projectionBuffer.position(0);
GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionBuffer);
projectionMatrix.set(projectionBuffer);
public void setProjectionMatrix(FloatBuffer projection) {
projectionMatrix.set(projection);
projectionMatrix.get(0, projectionBuffer);
}
public void captureModelViewMatrix() {
modelViewBuffer.position(0);
GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelViewBuffer);
modelViewMatrix.set(modelViewBuffer);
public void setModelViewMatrix(FloatBuffer modelview) {
modelViewMatrix.set(modelview);
modelViewMatrix.get(0, modelViewBuffer);
}
}
@@ -0,0 +1,44 @@
package com.gtnewhorizons.angelica.transform;
import com.google.common.collect.ImmutableList;
import net.minecraft.launchwrapper.IClassTransformer;
import org.apache.commons.lang3.tuple.Pair;
import org.spongepowered.asm.lib.ClassReader;
import org.spongepowered.asm.lib.ClassWriter;
import org.spongepowered.asm.lib.tree.ClassNode;
import java.util.List;
public class BlockTransformer implements IClassTransformer {
public static final String BlockClass = "net/minecraft/block/Block";
private static final String BlockClassFriendly = BlockClass.replace('/', '.');
public static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
Pair.of("minX", "field_149759_B"),
Pair.of("minY", "field_149760_C"),
Pair.of("minZ", "field_149754_D"),
Pair.of("maxX", "field_149755_E"),
Pair.of("maxY", "field_149756_F"),
Pair.of("maxZ", "field_149757_G")
);
/**
* Delete the global vanilla bounding box fields off the Block object. {@link RedirectorTransformer}
* replaces these with a thread-safe alternative.
*/
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {
if(basicClass != null && transformedName.equals(BlockClassFriendly)) {
final ClassReader cr = new ClassReader(basicClass);
final ClassNode cn = new ClassNode();
cr.accept(cn, 0);
cn.fields.removeIf(node -> BlockBoundsFields.stream().anyMatch(pair -> node.name.equals(pair.getLeft()) || node.name.equals(pair.getRight())));
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
basicClass = cw.toByteArray();
}
return basicClass;
}
}
@@ -31,6 +31,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.gtnewhorizons.angelica.transform.BlockTransformer.*;
/**
* This transformer redirects all Tessellator.instance field accesses to go through our TessellatorManager.
* As well as redirect some GL calls to our custom GLStateManager
@@ -44,11 +46,12 @@ public class RedirectorTransformer implements IClassTransformer {
private static final String GL11 = "org/lwjgl/opengl/GL11";
private static final String GL13 = "org/lwjgl/opengl/GL13";
private static final String GL14 = "org/lwjgl/opengl/GL14";
private static final String Project = "org/lwjgl/util/glu/Project";
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
private static final String ARBMultiTexture = "org/lwjgl/opengl/ARBMultitexture";
private static final String TessellatorClass = "net/minecraft/client/renderer/Tessellator";
private static final String BlockClass = "net/minecraft/block/Block";
private static final String MinecraftClient = "net.minecraft.client";
private static final String SplashProgress = "cpw.mods.fml.client.SplashProgress";
private static final String ThreadedBlockData = "com/gtnewhorizons/angelica/glsm/ThreadedBlockData";
@@ -57,16 +60,8 @@ public class RedirectorTransformer implements IClassTransformer {
"initializeTextures", "func_77474_a"
);
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
Pair.of("minX", "field_149759_B"),
Pair.of("minY", "field_149760_C"),
Pair.of("minZ", "field_149754_D"),
Pair.of("maxX", "field_149755_E"),
Pair.of("maxY", "field_149756_F"),
Pair.of("maxZ", "field_149757_G")
);
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, TessellatorClass, BlockClass);
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, TessellatorClass, BlockClass,
Project);
private static final Map<String, Map<String, String>> methodRedirects = new HashMap<>();
private static final Map<Integer, String> glCapRedirects = new HashMap<>();
private static final List<String> TransformerExclusions = Arrays.asList(
@@ -113,6 +108,20 @@ public class RedirectorTransformer implements IClassTransformer {
.add("glPopAttrib")
.add("glShadeModel")
.add("glTexImage2D")
.add("glMatrixMode")
.add("glLoadIdentity")
.add("glTranslatef")
.add("glTranslated")
.add("glScalef")
.add("glScaled")
.add("glMultMatrix")
.add("glRotatef")
.add("glRotated")
.add("glOrtho")
.add("glFrustum")
.add("glPushMatrix")
.add("glPopMatrix")
.add("glViewport")
);
methodRedirects.put(GL13, RedirectMap.newMap().add("glActiveTexture"));
methodRedirects.put(GL14, RedirectMap.newMap().add("glBlendFuncSeparate", "tryBlendFuncSeparate"));
@@ -121,6 +130,7 @@ public class RedirectorTransformer implements IClassTransformer {
.add("func_148821_a", "tryBlendFuncSeparate"));
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
}
@Override
@@ -8,12 +8,14 @@ import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL30;
import java.util.Arrays;
import java.util.EnumSet;
public class GlStateTracker {
private static final int UNASSIGNED_HANDLE = -1;
private final int[] bufferState = new int[GlBufferTarget.COUNT];
//private final int[] bufferRestoreState = new int[GlBufferTarget.COUNT];
private final EnumSet<GlBufferTarget> mutatedBuffers = EnumSet.noneOf(GlBufferTarget.class);
private int vertexArrayState;
//private int vertexArrayRestoreState;
@@ -31,6 +33,8 @@ public class GlStateTracker {
this.bufferState[target.ordinal()] = buffer;
mutatedBuffers.add(target);
return prevBuffer != buffer;
}
@@ -47,9 +51,10 @@ public class GlStateTracker {
}
public void applyRestoreState() {
for (int i = 0; i < GlBufferTarget.COUNT; i++) {
GL15.glBindBuffer(GlBufferTarget.VALUES[i].getTargetParameter(), 0);
}
mutatedBuffers.forEach(target -> {
GL15.glBindBuffer(target.getTargetParameter(), 0);
});
mutatedBuffers.clear();
if(GlFunctions.isVertexArraySupported()) {
GL30.glBindVertexArray(0);
}
@@ -229,7 +229,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
int baseY = this.render.getOriginY();
int baseZ = this.render.getOriginZ();
BlockPos renderOffset = this.offset;
RenderBlocks rb = new RenderBlocks(slice);
RenderBlocks rb = new RenderBlocks(slice.getWorld());
for (int relY = 0; relY < 16; relY++) {
if (cancellationSource.isCancelled()) {
return;
@@ -258,7 +258,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
if (cache.getBlockRenderer().renderModel(cache.getWorldSlice(), Tessellator.instance, rb, block, meta, pos, buffers.get(pass), true, seed)) {
if (cache.getBlockRenderer().renderModel(slice.getWorld(), Tessellator.instance, rb, block, meta, pos, buffers.get(pass), true, seed)) {
bounds.addBlock(relX, relY, relZ);
}
}
@@ -355,4 +355,8 @@ public class WorldSlice implements IBlockAccess {
case UNKNOWN -> 1.0f;
};
}
public World getWorld() {
return this.world;
}
}
@@ -243,8 +243,7 @@ public class IrisRenderSystem {
public static void setupProjectionMatrix(Matrix4f matrix) {
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
PROJECTION_MATRIX_BUFFER.clear().rewind();
matrix.get(PROJECTION_MATRIX_BUFFER);
matrix.get(0, PROJECTION_MATRIX_BUFFER);
GL11.glLoadMatrix(PROJECTION_MATRIX_BUFFER);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}