diff --git a/gradle.properties b/gradle.properties index 902e4d22..0ed04f46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G # check these on https://modmuss50.me/fabric.html minecraft_version=1.21 yarn_mappings=1.21+build.2 -loader_version=0.15.11 +loader_version=0.16.5 # Mod Properties mod_version = 0.1.6-alpha diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java index 6122d254..e2f3e49e 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/RenderService.java @@ -72,6 +72,7 @@ public class RenderService, J extends Vi Arrays.stream(world.getMapper().getBiomeEntries()).forEach(this.modelService::addBiome); world.getMapper().setBiomeCallback(this.modelService::addBiome); + /* final int H_WIDTH = 1; for (int x = -H_WIDTH; x <= H_WIDTH; x++) { @@ -80,8 +81,8 @@ public class RenderService, J extends Vi this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, x, y, z)); } } - } - */ + }*/ + router.watch(WorldEngine.getWorldSectionId(4, 0,0,0), 3); } public void setup(Camera camera) { diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java index 64d3367c..a101651f 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java @@ -1,12 +1,13 @@ package me.cortex.voxy.client.core.rendering.building; import me.cortex.voxy.common.util.MemoryBuffer; +import me.cortex.voxy.commonImpl.VoxyCommon; import java.util.Arrays; //TODO: also have an AABB size stored public final class BuiltSection { - public static final boolean VERIFY_BUILT_SECTION_OFFSETS = System.getProperty("voxy.verifyBuiltSectionOffsets", "true").equals("true"); + public static final boolean VERIFY_BUILT_SECTION_OFFSETS = VoxyCommon.isVerificationFlagOn("verifyBuiltSectionOffsets"); public final long position; public final int aabb; public final MemoryBuffer geometryBuffer; diff --git a/src/main/java/me/cortex/voxy/common/util/TrackedObject.java b/src/main/java/me/cortex/voxy/common/util/TrackedObject.java index 9db75b88..6c33c7a4 100644 --- a/src/main/java/me/cortex/voxy/common/util/TrackedObject.java +++ b/src/main/java/me/cortex/voxy/common/util/TrackedObject.java @@ -1,11 +1,13 @@ package me.cortex.voxy.common.util; +import me.cortex.voxy.commonImpl.VoxyCommon; + import java.lang.ref.Cleaner; public abstract class TrackedObject { //TODO: maybe make this false? for performance overhead? - public static final boolean TRACK_OBJECT_ALLOCATIONS = System.getProperty("voxy.ensureTrackedObjectsAreFreed", "true").equals("true"); - public static final boolean TRACK_OBJECT_ALLOCATION_STACKS = System.getProperty("voxy.trackObjectAllocationStacks", "true").equals("true"); + public static final boolean TRACK_OBJECT_ALLOCATIONS = VoxyCommon.isVerificationFlagOn("ensureTrackedObjectsAreFreed"); + public static final boolean TRACK_OBJECT_ALLOCATION_STACKS = VoxyCommon.isVerificationFlagOn("trackObjectAllocationStacks"); private final Ref ref; protected TrackedObject() { diff --git a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java index 31eefa64..7de164cd 100644 --- a/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java +++ b/src/main/java/me/cortex/voxy/common/world/SaveLoadSystem.java @@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.longs.LongArrayList; import me.cortex.voxy.common.util.MemoryBuffer; import me.cortex.voxy.common.util.UnsafeUtil; import me.cortex.voxy.common.world.other.Mapper; +import me.cortex.voxy.commonImpl.VoxyCommon; import org.lwjgl.system.MemoryUtil; import java.nio.ByteBuffer; @@ -13,7 +14,8 @@ import java.nio.ByteBuffer; import static org.lwjgl.util.zstd.Zstd.*; public class SaveLoadSystem { - public static final boolean VERIFY_HASH_ON_LOAD = System.getProperty("voxy.verifySectionOnLoad", "true").equals("true"); + public static final boolean VERIFY_HASH_ON_LOAD = VoxyCommon.isVerificationFlagOn("verifySectionHash"); + public static final boolean VERIFY_MEMORY_ACCESS = VoxyCommon.isVerificationFlagOn("verifyMemoryAccess"); public static final int BIGGEST_SERIALIZED_SECTION_SIZE = 32 * 32 * 32 * 8 * 2 + 8; public static int lin2z(int i) {//y,z,x @@ -86,12 +88,15 @@ public class SaveLoadSystem { public static boolean deserialize(WorldSection section, MemoryBuffer data) { long ptr = data.address; - long key = MemoryUtil.memGetLong(ptr); ptr += 8; + long key = MemoryUtil.memGetLong(ptr); ptr += 8; if (VERIFY_MEMORY_ACCESS && data.size<=(ptr-data.address)) throw new IllegalStateException("Memory access OOB"); - long metadata = MemoryUtil.memGetLong(ptr); ptr += 8; + long metadata = MemoryUtil.memGetLong(ptr); ptr += 8; if (VERIFY_MEMORY_ACCESS && data.size<=(ptr-data.address)) throw new IllegalStateException("Memory access OOB"); section.nonEmptyChildren = (byte) (metadata&0xFF); - int lutLen = MemoryUtil.memGetInt(ptr); ptr += 4; + int lutLen = MemoryUtil.memGetInt(ptr); ptr += 4; if (VERIFY_MEMORY_ACCESS && data.size<=(ptr-data.address)) throw new IllegalStateException("Memory access OOB"); + if (lutLen > 32*32*32) { + throw new IllegalStateException("lutLen impossibly large, max size should be 32768 but got size " + lutLen); + } long[] lut = new long[lutLen]; long hash = 0; if (VERIFY_HASH_ON_LOAD) { @@ -99,7 +104,7 @@ public class SaveLoadSystem { hash ^= metadata; hash *= 1242629872171L; } for (int i = 0; i < lutLen; i++) { - lut[i] = MemoryUtil.memGetLong(ptr); ptr += 8; + lut[i] = MemoryUtil.memGetLong(ptr); ptr += 8; if (VERIFY_MEMORY_ACCESS && data.size<=(ptr-data.address)) throw new IllegalStateException("Memory access OOB"); if (VERIFY_HASH_ON_LOAD) { hash *= 1230987149811L; hash += 12831; @@ -115,7 +120,7 @@ public class SaveLoadSystem { int nonEmptyBlockCount = 0; for (int i = 0; i < section.data.length; i++) { - long state = lut[MemoryUtil.memGetShort(ptr)]; ptr += 2; + long state = lut[MemoryUtil.memGetShort(ptr)]; ptr += 2; if (VERIFY_MEMORY_ACCESS && data.size<=(ptr-data.address)) throw new IllegalStateException("Memory access OOB"); nonEmptyBlockCount += Mapper.isAir(state)?0:1; section.data[z2lin(i)] = state; } @@ -131,7 +136,7 @@ public class SaveLoadSystem { } hash ^= pHash; - long expectedHash = MemoryUtil.memGetLong(ptr); ptr += 8; + long expectedHash = MemoryUtil.memGetLong(ptr); ptr += 8; if (VERIFY_MEMORY_ACCESS && data.size<(ptr-data.address)) throw new IllegalStateException("Memory access OOB"); if (expectedHash != hash) { //throw new IllegalStateException("Hash mismatch got: " + hash + " expected: " + expectedHash); System.err.println("Hash mismatch got: " + hash + " expected: " + expectedHash + " removing region"); diff --git a/src/main/java/me/cortex/voxy/common/world/WorldSection.java b/src/main/java/me/cortex/voxy/common/world/WorldSection.java index b72694b2..cf6a0af4 100644 --- a/src/main/java/me/cortex/voxy/common/world/WorldSection.java +++ b/src/main/java/me/cortex/voxy/common/world/WorldSection.java @@ -2,6 +2,7 @@ package me.cortex.voxy.common.world; import me.cortex.voxy.client.Voxy; +import me.cortex.voxy.commonImpl.VoxyCommon; import net.minecraft.util.Pair; import java.lang.invoke.MethodHandles; @@ -14,7 +15,7 @@ import java.util.concurrent.atomic.AtomicBoolean; //Represents a loaded world section at a specific detail level // holds a 32x32x32 region of detail public final class WorldSection { - public static final boolean VERIFY_WORLD_SECTION_EXECUTION = System.getProperty("voxy.verifyWorldSectionExecution", "true").equals("true"); + public static final boolean VERIFY_WORLD_SECTION_EXECUTION = VoxyCommon.isVerificationFlagOn("verifyWorldSectionExecution"); private static final VarHandle ATOMIC_STATE_HANDLE; diff --git a/src/main/java/me/cortex/voxy/commonImpl/VoxyCommon.java b/src/main/java/me/cortex/voxy/commonImpl/VoxyCommon.java index 533f0784..7312e2bd 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/VoxyCommon.java +++ b/src/main/java/me/cortex/voxy/commonImpl/VoxyCommon.java @@ -1,10 +1,8 @@ package me.cortex.voxy.commonImpl; import me.cortex.voxy.common.config.Serialization; -import me.cortex.voxy.common.thread.ServiceThreadPool; import net.fabricmc.api.EnvType; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.ModContainer; @@ -34,4 +32,11 @@ public class VoxyCommon implements ModInitializer { public static void breakpoint() { int breakpoint = 0; } + + + //This is hardcoded like this because people do not understand what they are doing + private static final boolean GlobalVerificationDisableOverride = false;//System.getProperty("voxy.verificationDisableOverride", "false").equals("true"); + public static boolean isVerificationFlagOn(String name) { + return (!GlobalVerificationDisableOverride) && System.getProperty("voxy."+name, "true").equals("true"); + } } diff --git a/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp b/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp index a1f68274..77f67305 100644 --- a/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp +++ b/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal_dev.comp @@ -8,7 +8,7 @@ layout(local_size_x=LOCAL_SIZE) in;//, local_size_y=1 void main() { uint node = getCurrentNode(); - if (node != SENTINAL_OUT_OF_BOUNDS) { + if (node != SENTINAL_OUT_OF_BOUNDS && queueIdx != 4) { printf("GID:%d, NODE %d, %d, AA, %d, %d, %d, %d", gl_GlobalInvocationID.x, node, queueIdx, nodeQueueMetadata[queueIdx].x, nodeQueueMetadata[queueIdx].y, nodeQueueMetadata[queueIdx].z, nodeQueueMetadata[queueIdx].w); pushNodesInit(1); pushNode(node);