diff --git a/src/main/java/me/cortex/voxy/client/core/Capabilities.java b/src/main/java/me/cortex/voxy/client/core/Capabilities.java index 87548163..468ec576 100644 --- a/src/main/java/me/cortex/voxy/client/core/Capabilities.java +++ b/src/main/java/me/cortex/voxy/client/core/Capabilities.java @@ -1,6 +1,9 @@ package me.cortex.voxy.client.core; +import me.cortex.voxy.client.core.gl.shader.Shader; +import me.cortex.voxy.client.core.gl.shader.ShaderType; import org.lwjgl.opengl.GL; +import org.lwjgl.opengl.GL20C; public class Capabilities { @@ -11,6 +14,28 @@ public class Capabilities { public Capabilities() { var cap = GL.getCapabilities(); this.meshShaders = cap.GL_NV_mesh_shader && cap.GL_NV_representative_fragment_test; - this.INT64_t = cap.GL_ARB_gpu_shader_int64 || cap.GL_AMD_gpu_shader_int64; + //this.INT64_t = cap.GL_ARB_gpu_shader_int64 || cap.GL_AMD_gpu_shader_int64; + //The only reliable way to test for int64 support is to try compile a shader + this.INT64_t = testShaderCompilesOk(ShaderType.COMPUTE, """ + #version 430 + #extension GL_ARB_gpu_shader_int64 : require + layout(local_size_x=32) in; + void main() { + uint64_t a = 1234; + } + """); + } + + public static void init() { + } + + private static boolean testShaderCompilesOk(ShaderType type, String src) { + int shader = GL20C.glCreateShader(type.gl); + GL20C.glShaderSource(shader, src); + GL20C.glCompileShader(shader); + int result = GL20C.glGetShaderi(shader, GL20C.GL_COMPILE_STATUS); + GL20C.glDeleteShader(shader); + + return result == GL20C.GL_TRUE; } } diff --git a/src/main/java/me/cortex/voxy/client/core/VoxelCore.java b/src/main/java/me/cortex/voxy/client/core/VoxelCore.java index dfd356fc..32db5f19 100644 --- a/src/main/java/me/cortex/voxy/client/core/VoxelCore.java +++ b/src/main/java/me/cortex/voxy/client/core/VoxelCore.java @@ -68,6 +68,7 @@ public class VoxelCore { //Trigger the shared index buffer loading SharedIndexBuffer.INSTANCE.id(); + Capabilities.init();//Ensure clinit is called this.renderer = this.createRenderBackend(); this.viewportSelector = new ViewportSelector<>(this.renderer::createViewport); System.out.println("Renderer initialized"); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/HiZBuffer.java b/src/main/java/me/cortex/voxy/client/core/rendering/HiZBuffer.java index d2e05a03..280cb601 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/HiZBuffer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/HiZBuffer.java @@ -94,6 +94,7 @@ public class HiZBuffer { this.texture.free(); this.texture = null; glDeleteSamplers(this.sampler); + this.hiz.free(); } public int getHizTextureId() { diff --git a/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java b/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java index e793a29e..beb7fedd 100644 --- a/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java +++ b/src/main/java/me/cortex/voxy/client/saver/ContextSelectionSystem.java @@ -79,6 +79,9 @@ public class ContextSelectionSystem { } catch (Exception e) { throw new RuntimeException("Failed to deserialize the default config, aborting!", e); } + if (this.config == null) { + throw new IllegalStateException("Config is still null"); + } } public StorageBackend createStorageBackend() { diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp index 1b1a74ac..79a45420 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/meshletculler.comp @@ -63,7 +63,7 @@ void main() { PosHeader pos = geometryPool[meshletId*MESHLET_SIZE]; AABBHeader aabb = geometryPool[meshletId*MESHLET_SIZE+1]; - if (testHiZ(pos, aabb)) {//If didnt cull, insert it back into the stream + if (testHiZ(pos, aabb) || true) {//If didnt cull, insert it back into the stream meshlets[atomicAdd(drawCmd.instanceCount, 1)+fullMeshletCount] = meshletId; } } \ No newline at end of file diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.frag b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.frag index 76dd75fe..14e2362f 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.frag +++ b/src/main/resources/assets/voxy/shaders/lod/gl46mesh/quads.frag @@ -19,7 +19,7 @@ void main() { //vec4 colour = solidColour; vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0); if ((flags&1u) == 1 && colour.a <= 0.25f) { - //discard; + discard; } //Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha