From 2b77800ed9aa6be7fee73087ab896cff004fc6f0 Mon Sep 17 00:00:00 2001 From: mcrcortex <{ID}+{username}@users.noreply.github.com> Date: Sat, 13 Apr 2024 11:22:14 +1000 Subject: [PATCH] Fixes --- src/main/java/me/cortex/voxy/client/Voxy.java | 3 ++- .../client/config/VoxyConfigScreenFactory.java | 5 ++++- .../voxy/common/config/Serialization.java | 13 ++----------- .../voxy/shaders/lod/gl46mesh/bindings.glsl | 17 +++++++++++++++-- .../voxy/shaders/lod/gl46mesh/cmdgen.comp | 2 ++ .../assets/voxy/shaders/lod/gl46mesh/quads.vert | 5 ++++- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/Voxy.java b/src/main/java/me/cortex/voxy/client/Voxy.java index 7fb667ad..75c66b22 100644 --- a/src/main/java/me/cortex/voxy/client/Voxy.java +++ b/src/main/java/me/cortex/voxy/client/Voxy.java @@ -4,6 +4,8 @@ import me.cortex.voxy.client.core.VoxelCore; import me.cortex.voxy.client.saver.ContextSelectionSystem; import me.cortex.voxy.client.terrain.WorldImportCommand; import me.cortex.voxy.common.config.Serialization; +import me.cortex.voxy.common.storage.compressors.ZSTDCompressor; +import me.cortex.voxy.common.storage.config.StorageConfig; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.fabricmc.loader.api.FabricLoader; @@ -16,7 +18,6 @@ public class Voxy implements ClientModInitializer { static { ModContainer mod = (ModContainer) FabricLoader.getInstance().getModContainer("voxy").orElseThrow(NullPointerException::new); VERSION = mod.getMetadata().getVersion().getFriendlyString(); - Serialization.init(); } diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java index f8b04712..9be36c7d 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java @@ -14,13 +14,16 @@ import net.minecraft.text.Text; import java.util.List; public class VoxyConfigScreenFactory implements ModMenuApi { - private static final VoxyConfig DEFAULT = new VoxyConfig(); + private static VoxyConfig DEFAULT; @Override public ConfigScreenFactory getModConfigScreenFactory() { return parent -> buildConfigScreen(parent, VoxyConfig.CONFIG); } private static Screen buildConfigScreen(Screen parent, VoxyConfig config) { + if (DEFAULT == null) { + DEFAULT = new VoxyConfig(); + } ConfigBuilder builder = ConfigBuilder.create() .setParentScreen(parent) .setTitle(Text.translatable("voxy.config.title")); diff --git a/src/main/java/me/cortex/voxy/common/config/Serialization.java b/src/main/java/me/cortex/voxy/common/config/Serialization.java index 49beb9ae..60426f37 100644 --- a/src/main/java/me/cortex/voxy/common/config/Serialization.java +++ b/src/main/java/me/cortex/voxy/common/config/Serialization.java @@ -22,7 +22,7 @@ import java.util.stream.Stream; public class Serialization { public static final Set> CONFIG_TYPES = new HashSet<>(); - public static final Gson GSON; + public static Gson GSON; private static final class GsonConfigSerialization implements TypeAdapterFactory { private final String typeField = "TYPE"; @@ -90,14 +90,7 @@ public class Serialization { } } - static { - try { - Class.forName(CompressorConfig.class.getName()); - Class.forName(StorageConfig.class.getName()); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - + public static void init() { String BASE_SEARCH_PACKAGE = "me.cortex.voxy"; Map, GsonConfigSerialization> serializers = new HashMap<>(); @@ -205,6 +198,4 @@ public class Serialization { throw new RuntimeException(e); } } - - public static void init() {} } diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/bindings.glsl b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/bindings.glsl index 212918ab..f222c5a6 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/bindings.glsl +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/bindings.glsl @@ -1,3 +1,16 @@ +struct Frustum { + vec4 planes[6]; +}; + +layout(binding = 0, std140) uniform SceneUniform { + mat4 MVP; + ivec3 baseSectionPos; + int sectionCount; + Frustum frustum; + vec3 cameraSubPos; + uint frameId; +}; + struct BlockModel { uint faceData[6]; uint flagsA; @@ -30,8 +43,8 @@ layout(binding = 0) uniform sampler2D blockModelAtlas; #ifndef Quad #define Quad ivec2 #endif -layout(binding = 1, std430) readonly restrict buffer QuadBuffer { -Quad quadData[]; +layout(binding = 1, std430) readonly restrict buffer GeometryBuffer { + Quad geometryPool[]; }; layout(binding = 2, std430) restrict buffer DrawBuffer { diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/cmdgen.comp b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/cmdgen.comp index 1116463d..05c1c4d3 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/cmdgen.comp +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/cmdgen.comp @@ -1,4 +1,6 @@ #version 450 +#extension GL_ARB_gpu_shader_int64 : enable + #define MESHLET_ACCESS writeonly #import #import diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert index 2bf78806..41741980 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.vert @@ -1,4 +1,6 @@ #version 450 +#extension GL_ARB_gpu_shader_int64 : enable + #define MESHLET_ACCESS readonly #define QUADS_PER_MESHLET 126 //There are 16 bytes of metadata at the start of the meshlet @@ -6,8 +8,9 @@ #import #import #import +#define GEOMETRY_FMT Quad -uvec2 meshletPosition; +GEOMETRY_FMT meshletPosition; Quad quad; bool setupMeshlet() { gl_CullDistance[0] = 1;