Pain
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package me.cortex.voxy.client.core;
|
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.GL;
|
||||||
|
import org.lwjgl.opengl.GL20C;
|
||||||
|
|
||||||
public class Capabilities {
|
public class Capabilities {
|
||||||
|
|
||||||
@@ -11,6 +14,28 @@ public class Capabilities {
|
|||||||
public Capabilities() {
|
public Capabilities() {
|
||||||
var cap = GL.getCapabilities();
|
var cap = GL.getCapabilities();
|
||||||
this.meshShaders = cap.GL_NV_mesh_shader && cap.GL_NV_representative_fragment_test;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public class VoxelCore {
|
|||||||
|
|
||||||
//Trigger the shared index buffer loading
|
//Trigger the shared index buffer loading
|
||||||
SharedIndexBuffer.INSTANCE.id();
|
SharedIndexBuffer.INSTANCE.id();
|
||||||
|
Capabilities.init();//Ensure clinit is called
|
||||||
this.renderer = this.createRenderBackend();
|
this.renderer = this.createRenderBackend();
|
||||||
this.viewportSelector = new ViewportSelector<>(this.renderer::createViewport);
|
this.viewportSelector = new ViewportSelector<>(this.renderer::createViewport);
|
||||||
System.out.println("Renderer initialized");
|
System.out.println("Renderer initialized");
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ public class HiZBuffer {
|
|||||||
this.texture.free();
|
this.texture.free();
|
||||||
this.texture = null;
|
this.texture = null;
|
||||||
glDeleteSamplers(this.sampler);
|
glDeleteSamplers(this.sampler);
|
||||||
|
this.hiz.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHizTextureId() {
|
public int getHizTextureId() {
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ public class ContextSelectionSystem {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Failed to deserialize the default config, aborting!", 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() {
|
public StorageBackend createStorageBackend() {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ void main() {
|
|||||||
PosHeader pos = geometryPool[meshletId*MESHLET_SIZE];
|
PosHeader pos = geometryPool[meshletId*MESHLET_SIZE];
|
||||||
AABBHeader aabb = geometryPool[meshletId*MESHLET_SIZE+1];
|
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;
|
meshlets[atomicAdd(drawCmd.instanceCount, 1)+fullMeshletCount] = meshletId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ void main() {
|
|||||||
//vec4 colour = solidColour;
|
//vec4 colour = solidColour;
|
||||||
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0);
|
vec4 colour = texture(blockModelAtlas, uv + baseUV, ((flags>>1)&1u)*-4.0);
|
||||||
if ((flags&1u) == 1 && colour.a <= 0.25f) {
|
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
|
//Conditional tinting, TODO: FIXME: REPLACE WITH MASK OR SOMETHING, like encode data into the top bit of alpha
|
||||||
|
|||||||
Reference in New Issue
Block a user