mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
Fix some small things
* Bump nhlib dep due to crash when Iris is disabled * Use jabel for tests * use joml isIdentity * remove Integer usage
This commit is contained in:
1 parent
33de1de9c4
commit
2fc2e2e38d
9 files changed
+36
-39
No files matched your search
@@ -5,6 +5,11 @@ plugins {
|
||||
minecraft {
|
||||
extraRunJvmArguments.add("-Dangelica.enableTestBlocks=true")
|
||||
extraRunJvmArguments.add("-Dangelica.dumpClass=true")
|
||||
/* extraRunJvmArguments.addAll(
|
||||
"-Dlegacy.debugClassLoading=true",
|
||||
"-Dlegacy.debugClassLoadingFiner=true",
|
||||
"-Dlegacy.debugClassLoadingSave=true")*/
|
||||
|
||||
//extraRunJvmArguments.add("-Dangelica.redirectorLogspam=true")
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -58,7 +58,7 @@ dependencies {
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.8.18:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.8.19:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
@@ -114,6 +114,7 @@ dependencies {
|
||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||
testImplementation("org.mockito:mockito-core:3.+")
|
||||
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
|
||||
testAnnotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:1.0.1")
|
||||
|
||||
compileOnly("mega:fluidlogged-mc1.7.10:0.1.2")
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
name = "Angelica",
|
||||
version = Tags.VERSION,
|
||||
dependencies = """
|
||||
required-after:gtnhlib@[0.8.18,);\
|
||||
required-after:gtnhlib@[0.8.19,);\
|
||||
before:lwjgl3ify@[1.5.3,);\
|
||||
after:hodgepodge@[2.4.4,);\
|
||||
after:CodeChickenCore@[1.2.0,);\
|
||||
|
||||
@@ -101,7 +101,7 @@ public class DisplayListManager {
|
||||
return currentRenderingList != -1;
|
||||
}
|
||||
|
||||
static boolean isIdentity(Matrix4f m) {
|
||||
public static boolean isIdentity(Matrix4f m) {
|
||||
return (m.properties() & Matrix4f.PROPERTY_IDENTITY) != 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-13
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.glsm.recording;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.DisplayListManager;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.commands.DisplayListCommand;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -255,17 +256,6 @@ public final class CommandBufferProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a matrix is identity (within epsilon).
|
||||
*/
|
||||
public static boolean isIdentity(Matrix4f m) {
|
||||
final float eps = 1e-6f;
|
||||
return Math.abs(m.m00() - 1) < eps && Math.abs(m.m01()) < eps && Math.abs(m.m02()) < eps && Math.abs(m.m03()) < eps
|
||||
&& Math.abs(m.m10()) < eps && Math.abs(m.m11() - 1) < eps && Math.abs(m.m12()) < eps && Math.abs(m.m13()) < eps
|
||||
&& Math.abs(m.m20()) < eps && Math.abs(m.m21()) < eps && Math.abs(m.m22() - 1) < eps && Math.abs(m.m23()) < eps
|
||||
&& Math.abs(m.m30()) < eps && Math.abs(m.m31()) < eps && Math.abs(m.m32()) < eps && Math.abs(m.m33() - 1) < eps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lightweight transform optimizer for buffer-to-buffer processing.
|
||||
* Tracks accumulated MODELVIEW transform and emits MultMatrix commands when needed.
|
||||
@@ -316,7 +306,7 @@ public final class CommandBufferProcessor {
|
||||
}
|
||||
|
||||
public boolean isIdentity() {
|
||||
return CommandBufferProcessor.isIdentity(accumulated);
|
||||
return DisplayListManager.isIdentity(accumulated);
|
||||
}
|
||||
|
||||
public void markAbsoluteMatrix() {
|
||||
@@ -340,7 +330,7 @@ public final class CommandBufferProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
if (CommandBufferProcessor.isIdentity(lastEmitted)) {
|
||||
if (DisplayListManager.isIdentity(lastEmitted)) {
|
||||
out.writeMultMatrix(GL11.GL_MODELVIEW, target);
|
||||
} else {
|
||||
final Matrix4f delta = new Matrix4f(lastEmitted).invert().mul(target);
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.gtnewhorizons.angelica.glsm.recording;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.commands.DisplayListCommand;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memAddress;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memFree;
|
||||
@@ -96,8 +96,8 @@ public final class CompiledDisplayList {
|
||||
* Get counts of each command type in the buffer.
|
||||
* Used for testing to verify optimization results.
|
||||
*/
|
||||
public Map<Integer, Integer> getCommandCounts() {
|
||||
Map<Integer, Integer> counts = new HashMap<>();
|
||||
public Int2IntMap getCommandCounts() {
|
||||
Int2IntMap counts = new Int2IntOpenHashMap();
|
||||
if (commandBuffer == null || commandBuffer.limit() == 0) {
|
||||
return counts;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public final class CompiledDisplayList {
|
||||
long end = ptr + commandBuffer.limit();
|
||||
while (ptr < end) {
|
||||
int cmd = memGetInt(ptr);
|
||||
counts.merge(cmd, 1, Integer::sum);
|
||||
counts.mergeInt(cmd, 1, Integer::sum);
|
||||
ptr += getCommandSize(cmd, ptr);
|
||||
}
|
||||
return counts;
|
||||
@@ -115,8 +115,8 @@ public final class CompiledDisplayList {
|
||||
* Get the sequence of command opcodes in order.
|
||||
* Used for testing to verify command ordering.
|
||||
*/
|
||||
public List<Integer> getCommandOpcodes() {
|
||||
List<Integer> opcodes = new ArrayList<>();
|
||||
public IntList getCommandOpcodes() {
|
||||
IntList opcodes = new IntArrayList();
|
||||
if (commandBuffer == null || commandBuffer.limit() == 0) {
|
||||
return opcodes;
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ class GLSM_DisplayList_Batching_Test {
|
||||
private Set<VertexBuffer> getUniqueVBOs(DisplayListCommand[] commands) {
|
||||
Set<VertexBuffer> vbos = new HashSet<>();
|
||||
for (DisplayListCommand cmd : commands) {
|
||||
if (cmd instanceof DrawRangeCmd) {
|
||||
vbos.add(((DrawRangeCmd) cmd).sharedVbo());
|
||||
if (cmd instanceof DrawRangeCmd rangeCmd) {
|
||||
vbos.add(rangeCmd.sharedVbo());
|
||||
}
|
||||
}
|
||||
return vbos;
|
||||
|
||||
+10
-10
@@ -3,6 +3,8 @@ package com.gtnewhorizons.angelica.glsm;
|
||||
import com.gtnewhorizons.angelica.AngelicaExtension;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.CompiledDisplayList;
|
||||
import com.gtnewhorizons.angelica.glsm.recording.GLCommand;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import org.joml.Matrix4f;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -11,8 +13,6 @@ import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -68,7 +68,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
assertNotNull(compiled, "Display list should be compiled");
|
||||
|
||||
Map<Integer, Integer> counts = compiled.getCommandCounts();
|
||||
Int2IntMap counts = compiled.getCommandCounts();
|
||||
int multMatrixCount = counts.getOrDefault(GLCommand.MULT_MATRIX, 0);
|
||||
int individualTransformCount = counts.getOrDefault(GLCommand.TRANSLATE, 0)
|
||||
+ counts.getOrDefault(GLCommand.ROTATE, 0)
|
||||
@@ -122,7 +122,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
|
||||
// Verify optimization: should have Push, Pop, and collapsed MultMatrix commands
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
Map<Integer, Integer> counts = compiled.getCommandCounts();
|
||||
Int2IntMap counts = compiled.getCommandCounts();
|
||||
|
||||
int pushCount = counts.getOrDefault(GLCommand.PUSH_MATRIX, 0);
|
||||
int popCount = counts.getOrDefault(GLCommand.POP_MATRIX, 0);
|
||||
@@ -217,7 +217,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
|
||||
// Verify optimization: MultMatrix should be emitted before CallList
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
List<Integer> opcodes = compiled.getCommandOpcodes();
|
||||
IntList opcodes = compiled.getCommandOpcodes();
|
||||
|
||||
// Find positions of MultMatrix and CallList
|
||||
int multMatrixIndex = opcodes.indexOf(GLCommand.MULT_MATRIX);
|
||||
@@ -268,7 +268,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
GLStateManager.glEndList();
|
||||
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
Map<Integer, Integer> counts = compiled.getCommandCounts();
|
||||
Int2IntMap counts = compiled.getCommandCounts();
|
||||
|
||||
int multMatrixCount = counts.getOrDefault(GLCommand.MULT_MATRIX, 0);
|
||||
|
||||
@@ -356,7 +356,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
|
||||
// Verify optimization: should collapse to 1 MultMatrix
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
Map<Integer, Integer> counts = compiled.getCommandCounts();
|
||||
Int2IntMap counts = compiled.getCommandCounts();
|
||||
|
||||
int multMatrixCount = counts.getOrDefault(GLCommand.MULT_MATRIX, 0);
|
||||
|
||||
@@ -416,7 +416,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
assertNotNull(compiled, "Display list should be compiled");
|
||||
|
||||
List<Integer> opcodes = compiled.getCommandOpcodes();
|
||||
IntList opcodes = compiled.getCommandOpcodes();
|
||||
|
||||
// Find indices of key commands
|
||||
int pushIndex = opcodes.indexOf(GLCommand.PUSH_MATRIX);
|
||||
@@ -467,7 +467,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
GLStateManager.glEndList();
|
||||
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
List<Integer> opcodes = compiled.getCommandOpcodes();
|
||||
IntList opcodes = compiled.getCommandOpcodes();
|
||||
|
||||
int pushIndex = opcodes.indexOf(GLCommand.PUSH_MATRIX);
|
||||
int popIndex = opcodes.indexOf(GLCommand.POP_MATRIX);
|
||||
@@ -507,7 +507,7 @@ class GLSM_DisplayList_TransformCollapsing_Test {
|
||||
CompiledDisplayList compiled = DisplayListManager.getDisplayList(testList);
|
||||
assertNotNull(compiled, "Display list should be compiled");
|
||||
|
||||
Map<Integer, Integer> counts = compiled.getCommandCounts();
|
||||
Int2IntMap counts = compiled.getCommandCounts();
|
||||
int loadMatrixCount = counts.getOrDefault(GLCommand.LOAD_MATRIX, 0);
|
||||
|
||||
assertEquals(1, loadMatrixCount,
|
||||
|
||||
+3
-2
@@ -9,10 +9,11 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@@ -72,7 +73,7 @@ class RecordingDataStructuresTest {
|
||||
assertNotNull(compiled.getCommandBuffer(), "Command buffer should not be null");
|
||||
|
||||
// Get command counts to verify structure
|
||||
Map<Integer, Integer> counts = compiled.getCommandCounts();
|
||||
Int2IntMap counts = compiled.getCommandCounts();
|
||||
|
||||
// Should have PushMatrix and PopMatrix
|
||||
assertEquals(1, counts.getOrDefault(GLCommand.PUSH_MATRIX, 0), "Should have 1 PushMatrix");
|
||||
|
||||
Reference in new issue
Block a user