This commit is contained in:
mcrcortex
2024-05-07 09:48:32 +10:00
parent dba69f9470
commit abbe1c21ed
6 changed files with 33 additions and 3 deletions

View File

@@ -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;
}
}

View File

@@ -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");

View File

@@ -94,6 +94,7 @@ public class HiZBuffer {
this.texture.free();
this.texture = null;
glDeleteSamplers(this.sampler);
this.hiz.free();
}
public int getHizTextureId() {

View File

@@ -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() {

View File

@@ -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;
}
}

View File

@@ -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