gl debug utils
This commit is contained in:
16
build.gradle
16
build.gradle
@@ -25,15 +25,20 @@ repositories {
|
||||
|
||||
def gitCommitHash = { ->
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
ExecResult result = exec ()->{
|
||||
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
||||
standardOutput = stdout
|
||||
ignoreExitValue = true
|
||||
}
|
||||
return stdout.toString().trim()
|
||||
}
|
||||
def buildtime = System.currentTimeSeconds()
|
||||
|
||||
if (result.getExitValue() != 0) {
|
||||
return "<UnknownCommit>";
|
||||
} else {
|
||||
return stdout.toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
def buildtime = {System.currentTimeSeconds()}
|
||||
processResources {
|
||||
inputs.properties("version": project.version, "commit": gitCommitHash, "buildtime": buildtime)
|
||||
|
||||
@@ -128,6 +133,7 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
|
||||
|
||||
@@ -141,8 +147,8 @@ dependencies {
|
||||
include(runtimeOnly "org.lwjgl:lwjgl-lmdb:$lwjglVersion:natives-linux")
|
||||
include(runtimeOnly "org.lwjgl:lwjgl-zstd:$lwjglVersion:natives-linux")
|
||||
|
||||
include(implementation 'org.rocksdb:rocksdbjni:8.10.0')
|
||||
include(implementation 'redis.clients:jedis:5.1.0')
|
||||
include(implementation('org.rocksdb:rocksdbjni:8.10.0'))
|
||||
include(implementation 'org.apache.commons:commons-pool2:2.12.0')
|
||||
//implementation 'org.rocksdb:rocksdbjni:8.10.0'
|
||||
//implementation 'redis.clients:jedis:5.1.0'
|
||||
|
||||
@@ -53,4 +53,8 @@ public class GlBuffer extends TrackedObject {
|
||||
public static long getTotalSize() {
|
||||
return TOTAL_SIZE;
|
||||
}
|
||||
|
||||
public GlBuffer name(String name) {
|
||||
return GlDebug.name(name, this);
|
||||
}
|
||||
}
|
||||
|
||||
49
src/main/java/me/cortex/voxy/client/core/gl/GlDebug.java
Normal file
49
src/main/java/me/cortex/voxy/client/core/gl/GlDebug.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package me.cortex.voxy.client.core.gl;
|
||||
|
||||
import me.cortex.voxy.client.core.gl.shader.Shader;
|
||||
|
||||
import static org.lwjgl.opengl.GL43C.*;
|
||||
|
||||
public class GlDebug {
|
||||
public static final boolean GL_DEBUG = System.getProperty("voxy.glDebug", "false").equals("true");
|
||||
|
||||
|
||||
public static void push() {
|
||||
//glPushDebugGroup()
|
||||
}
|
||||
|
||||
public static GlBuffer name(String name, GlBuffer buffer) {
|
||||
if (GL_DEBUG) {
|
||||
glObjectLabel(GL_BUFFER, buffer.id, name);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static <T extends Shader> T name(String name, T shader) {
|
||||
if (GL_DEBUG) {
|
||||
glObjectLabel(GL_PROGRAM, shader.id(), name);
|
||||
}
|
||||
return shader;
|
||||
}
|
||||
|
||||
public static GlFramebuffer name(String name, GlFramebuffer framebuffer) {
|
||||
if (GL_DEBUG) {
|
||||
glObjectLabel(GL_FRAMEBUFFER, framebuffer.id, name);
|
||||
}
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
public static GlTexture name(String name, GlTexture texture) {
|
||||
if (GL_DEBUG) {
|
||||
glObjectLabel(GL_TEXTURE, texture.id, name);
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static GlPersistentMappedBuffer name(String name, GlPersistentMappedBuffer buffer) {
|
||||
if (GL_DEBUG) {
|
||||
glObjectLabel(GL_BUFFER, buffer.id, name);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -37,4 +37,9 @@ public class GlFramebuffer extends TrackedObject {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public GlFramebuffer name(String name) {
|
||||
return GlDebug.name(name, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@ public class GlPersistentMappedBuffer extends TrackedObject {
|
||||
public long addr() {
|
||||
return this.addr;
|
||||
}
|
||||
|
||||
public GlPersistentMappedBuffer name(String name) {
|
||||
return GlDebug.name(name, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,8 @@ public class GlTexture extends TrackedObject {
|
||||
super.free0();
|
||||
glDeleteTextures(this.id);
|
||||
}
|
||||
|
||||
public GlTexture name(String name) {
|
||||
return GlDebug.name(name, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package me.cortex.voxy.client.core.gl.shader;
|
||||
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
import me.cortex.voxy.client.core.gl.GlDebug;
|
||||
import me.cortex.voxy.common.util.TrackedObject;
|
||||
import org.lwjgl.opengl.GL20C;
|
||||
|
||||
@@ -29,6 +31,9 @@ public class Shader extends TrackedObject {
|
||||
}
|
||||
|
||||
|
||||
public Shader name(String name) {
|
||||
return GlDebug.name(name, this);
|
||||
}
|
||||
|
||||
|
||||
public static Builder<Shader> make(IShaderProcessor... processor) {
|
||||
|
||||
@@ -22,9 +22,9 @@ public class ModelStore {
|
||||
public final int blockSampler = glGenSamplers();
|
||||
|
||||
public ModelStore() {
|
||||
this.modelBuffer = new GlBuffer(MODEL_SIZE * (1<<16));
|
||||
this.modelColourBuffer = new GlBuffer(4 * (1<<16));
|
||||
this.textures = new GlTexture().store(GL_RGBA8, 4, ModelFactory.MODEL_TEXTURE_SIZE*3*256,ModelFactory.MODEL_TEXTURE_SIZE*2*256);
|
||||
this.modelBuffer = new GlBuffer(MODEL_SIZE * (1<<16)).name("ModelData");
|
||||
this.modelColourBuffer = new GlBuffer(4 * (1<<16)).name("ModelColour");
|
||||
this.textures = new GlTexture().store(GL_RGBA8, 4, ModelFactory.MODEL_TEXTURE_SIZE*3*256,ModelFactory.MODEL_TEXTURE_SIZE*2*256).name("ModelTextures");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.cortex.voxy.client.core.model;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import me.cortex.voxy.client.core.gl.GlFramebuffer;
|
||||
import me.cortex.voxy.client.core.gl.GlRenderBuffer;
|
||||
import me.cortex.voxy.client.core.gl.GlTexture;
|
||||
import me.cortex.voxy.client.core.gl.shader.Shader;
|
||||
import me.cortex.voxy.client.core.gl.shader.ShaderType;
|
||||
@@ -66,7 +65,8 @@ public class ModelTextureBakery {
|
||||
private final Shader rasterShader = Shader.make()
|
||||
.add(ShaderType.VERTEX, "voxy:bakery/position_tex.vsh")
|
||||
.add(ShaderType.FRAGMENT, "voxy:bakery/position_tex.fsh")
|
||||
.compile();
|
||||
.compile()
|
||||
.name("ModelBaker");
|
||||
|
||||
private final Shader copyOutShader;
|
||||
|
||||
@@ -78,11 +78,11 @@ public class ModelTextureBakery {
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.colourTex = new GlTexture().store(GL_RGBA8, 1, width, height);
|
||||
this.depthTex = new GlTexture().store(GL_DEPTH24_STENCIL8, 1, width, height);
|
||||
this.colourTex = new GlTexture().store(GL_RGBA8, 1, width, height).name("ModelBakeryColour");
|
||||
this.depthTex = new GlTexture().store(GL_DEPTH24_STENCIL8, 1, width, height).name("ModelBakeryDepth");
|
||||
this.depthTexView = this.depthTex.createView();
|
||||
|
||||
this.framebuffer = new GlFramebuffer().bind(GL_COLOR_ATTACHMENT0, this.colourTex).bind(GL_DEPTH_STENCIL_ATTACHMENT, this.depthTex).verify();
|
||||
this.framebuffer = new GlFramebuffer().bind(GL_COLOR_ATTACHMENT0, this.colourTex).bind(GL_DEPTH_STENCIL_ATTACHMENT, this.depthTex).verify().name("ModelFramebuffer");
|
||||
|
||||
glTextureParameteri(this.depthTex.id, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT);
|
||||
glTextureParameteri(this.depthTexView.id, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
|
||||
@@ -91,7 +91,8 @@ public class ModelTextureBakery {
|
||||
.define("WIDTH", width)
|
||||
.define("HEIGHT", height)
|
||||
.add(ShaderType.COMPUTE, "voxy:bakery/buffercopy.comp")
|
||||
.compile();
|
||||
.compile()
|
||||
.name("ModelBakeryOut");
|
||||
|
||||
//This is done to help make debugging easier
|
||||
FACE_VIEWS.clear();
|
||||
|
||||
@@ -160,7 +160,7 @@ public class RenderDataFactory4 {
|
||||
int modelId = this.modelMan.getModelId(Mapper.getBlockId(block));
|
||||
long modelMetadata = this.modelMan.getModelMetadataFromClientId(modelId);
|
||||
|
||||
sectionData[i * 2] = modelId | ((long) (Mapper.getLightId(block)) << 16) | (((long) (Mapper.getBiomeId(block))) << 24);
|
||||
sectionData[i * 2] = modelId | ((long) (Mapper.getLightId(block)) << 16) | (ModelQueries.isBiomeColoured(modelMetadata)?(((long) (Mapper.getBiomeId(block))) << 24):0);
|
||||
sectionData[i * 2 + 1] = modelMetadata;
|
||||
|
||||
boolean isFullyOpaque = ModelQueries.isFullyOpaque(modelMetadata);
|
||||
@@ -221,7 +221,11 @@ public class RenderDataFactory4 {
|
||||
long nextModel = facingForward == 1 ? B : A;
|
||||
|
||||
//Example thing thats just wrong but as example
|
||||
this.blockMesher.putNext((long) facingForward | ((selfModel & 0xFFFF) << 26) | (((nextModel>>16)&0xFF) << 55));
|
||||
this.blockMesher.putNext(((long) facingForward) |//Facing
|
||||
((selfModel & 0xFFFF) << 26) | //ModelId
|
||||
(((nextModel>>16)&0xFF) << 55) |//Lighting
|
||||
((selfModel&(0x1FFL<<24))<<(46-24))//biomeId
|
||||
);
|
||||
}
|
||||
}
|
||||
this.blockMesher.endRow();
|
||||
@@ -258,7 +262,11 @@ public class RenderDataFactory4 {
|
||||
long A = this.sectionData[idx * 2];
|
||||
|
||||
//Example thing thats just wrong but as example
|
||||
this.blockMesher.putNext((long) (side == 0 ? 0L : 1L) | ((A & 0xFFFFL) << 26) | (((0xFFL) & 0xFF) << 55));
|
||||
this.blockMesher.putNext((long) (side == 0 ? 0L : 1L) |
|
||||
((A & 0xFFFFL) << 26) |
|
||||
(((0xFFL) & 0xFF) << 55) |
|
||||
((A&(0x1FFL<<24))<<(46-24))
|
||||
);
|
||||
}
|
||||
}
|
||||
this.blockMesher.endRow();
|
||||
@@ -370,8 +378,11 @@ public class RenderDataFactory4 {
|
||||
long nextModel = facingForward==1?B:A;
|
||||
|
||||
//Example thing thats just wrong but as example
|
||||
mesher.putNext((long) facingForward | ((selfModel&0xFFFF)<<26) | (((nextModel>>16)&0xFF)<<55));
|
||||
//mesher.emitQuad(y, z, 1, 1,(long) facingForward | ((selfModel&0xFFFF)<<26) | (0xFFL<<55));
|
||||
mesher.putNext(((long) facingForward) |//Facing
|
||||
((selfModel & 0xFFFF) << 26) | //ModelId
|
||||
(((nextModel>>16)&0xFF) << 55) |//Lighting
|
||||
((selfModel&(0x1FFL<<24))<<(46-24))//biomeId
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -418,7 +429,7 @@ public class RenderDataFactory4 {
|
||||
|
||||
long A = this.sectionData[(i<<5) * 2];
|
||||
|
||||
ma.putNext(0L | ((A&0xFFFF)<<26) | (((0xFFL)&0xFF)<<55));
|
||||
ma.putNext(0L | ((A&0xFFFF)<<26) | (((0xFFL)&0xFF)<<55)|((A&(0x1FFL<<24))<<(46-24)));
|
||||
} else {skipA++;}
|
||||
|
||||
if ((msk & (1<<31)) != 0) {
|
||||
@@ -426,7 +437,7 @@ public class RenderDataFactory4 {
|
||||
|
||||
long A = this.sectionData[(i*32+31) * 2];
|
||||
|
||||
mb.putNext(1L | ((A&0xFFFF)<<26) | (((0xFFL)&0xFF)<<55));
|
||||
mb.putNext(1L | ((A&0xFFFF)<<26) | (((0xFFL)&0xFF)<<55)|((A&(0x1FFL<<24))<<(46-24)));
|
||||
} else {skipB++;}
|
||||
}
|
||||
ma.skip(skipA);
|
||||
|
||||
@@ -23,8 +23,9 @@ public class HiZBuffer {
|
||||
private final Shader hiz = Shader.make()
|
||||
.add(ShaderType.VERTEX, "voxy:hiz/blit.vsh")
|
||||
.add(ShaderType.FRAGMENT, "voxy:hiz/blit.fsh")
|
||||
.compile();
|
||||
private final GlFramebuffer fb = new GlFramebuffer();
|
||||
.compile()
|
||||
.name("HiZ Builder");
|
||||
private final GlFramebuffer fb = new GlFramebuffer().name("HiZ");
|
||||
private final int sampler = glGenSamplers();
|
||||
private GlTexture texture;
|
||||
private int levels;
|
||||
@@ -42,7 +43,7 @@ public class HiZBuffer {
|
||||
// (could probably increase it to be defined by a max meshlet coverage computation thing)
|
||||
|
||||
//GL_DEPTH_COMPONENT32F //Cant use this as it does not match the depth format of the provided depth buffer
|
||||
this.texture = new GlTexture().store(GL_DEPTH24_STENCIL8, this.levels, width, height);
|
||||
this.texture = new GlTexture().store(GL_DEPTH24_STENCIL8, this.levels, width, height).name("HiZ");
|
||||
glTextureParameteri(this.texture.id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTextureParameteri(this.texture.id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTextureParameteri(this.texture.id, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class RawDownloadStream {
|
||||
private final Deque<DownloadFrame> frames = new ArrayDeque<>();
|
||||
|
||||
public RawDownloadStream(int size) {
|
||||
this.downloadBuffer = new GlPersistentMappedBuffer(size, GL_MAP_READ_BIT|GL_MAP_COHERENT_BIT);
|
||||
this.downloadBuffer = new GlPersistentMappedBuffer(size, GL_MAP_READ_BIT|GL_MAP_COHERENT_BIT).name("RawDownloadStream");
|
||||
this.allocationArena.setLimit(size);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class UploadStream {
|
||||
private final Deque<UploadData> uploadList = new ArrayDeque<>();
|
||||
|
||||
public UploadStream(long size) {
|
||||
this.uploadBuffer = new GlPersistentMappedBuffer(size,GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|GL_MAP_COHERENT_BIT);
|
||||
this.uploadBuffer = new GlPersistentMappedBuffer(size,GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|GL_MAP_COHERENT_BIT).name("UploadStream");
|
||||
this.allocationArena.setLimit(size);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package me.cortex.voxy.common.voxelization;
|
||||
|
||||
import me.cortex.voxy.common.world.other.Mapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
//16x16x16 block section
|
||||
public class VoxelizedSection {
|
||||
public int x;
|
||||
@@ -39,4 +41,9 @@ public class VoxelizedSection {
|
||||
public static VoxelizedSection createEmpty() {
|
||||
return new VoxelizedSection(new long[16*16*16 + 8*8*8 + 4*4*4 + 2*2*2 + 1]);
|
||||
}
|
||||
|
||||
public VoxelizedSection zero() {
|
||||
Arrays.fill(this.section, 0);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ public class VoxelIngestService {
|
||||
i++;
|
||||
var lighting = this.captureLightMap.remove(ChunkSectionPos.from(chunk.getPos(), i).asLong());
|
||||
if (section.isEmpty() && lighting==null) {//If the chunk section has lighting data, propagate it
|
||||
//TODO: add local cache so that it doesnt constantly create new sections
|
||||
this.world.insertUpdate(VoxelizedSection.createEmpty().setPosition(chunk.getPos().x, i, chunk.getPos().z));
|
||||
this.world.insertUpdate(SECTION_CACHE.get().zero().setPosition(chunk.getPos().x, i, chunk.getPos().z));
|
||||
} else {
|
||||
VoxelizedSection csec = WorldConversionFactory.convert(
|
||||
SECTION_CACHE.get().setPosition(chunk.getPos().x, i, chunk.getPos().z),
|
||||
|
||||
Reference in New Issue
Block a user