Added global shader debug printf util

This commit is contained in:
mcrcortex
2024-08-03 00:03:30 +10:00
parent 154f016a96
commit 3194f1d23e
4 changed files with 56 additions and 0 deletions

View File

@@ -80,6 +80,7 @@ public class VoxelCore {
public void renderSetup(Frustum frustum, Camera camera) { public void renderSetup(Frustum frustum, Camera camera) {
this.renderer.setup(camera); this.renderer.setup(camera);
PrintfDebugUtil.tick();
} }
private static Matrix4f makeProjectionMatrix(float near, float far) { private static Matrix4f makeProjectionMatrix(float near, float far) {
@@ -154,6 +155,8 @@ public class VoxelCore {
debug.add("I/S tasks: " + this.world.ingestService.getTaskCount() + "/"+this.world.savingService.getTaskCount()); debug.add("I/S tasks: " + this.world.ingestService.getTaskCount() + "/"+this.world.savingService.getTaskCount());
debug.add("SCS: " + Arrays.toString(this.world.getLoadedSectionCacheSizes())); debug.add("SCS: " + Arrays.toString(this.world.getLoadedSectionCacheSizes()));
this.renderer.addDebugData(debug); this.renderer.addDebugData(debug);
PrintfDebugUtil.addToOut(debug);
} }
//Note: when doing translucent rendering, only need to sort when generating the geometry, or when crossing into the center zone //Note: when doing translucent rendering, only need to sort when generating the geometry, or when crossing into the center zone

View File

@@ -0,0 +1,49 @@
package me.cortex.voxy.client.core.rendering;
import me.cortex.voxy.client.core.gl.shader.IShaderProcessor;
import me.cortex.voxy.client.core.gl.shader.PrintfInjector;
import java.util.ArrayList;
import java.util.List;
public final class PrintfDebugUtil {
public static final boolean ENABLE_PRINTF_DEBUGGING = System.getProperty("voxy.enableShaderDebugPrintf", "false").equals("true");
private static final List<String> printfQueue2 = new ArrayList<>();
private static final List<String> printfQueue = new ArrayList<>();
private static final IShaderProcessor PRINTF;
public static final PrintfInjector PRINTF_object;
static {
if (ENABLE_PRINTF_DEBUGGING) {
PRINTF_object = new PrintfInjector(50000, 10, line -> {
if (line.startsWith("LOG")) {
System.err.println(line);
}
printfQueue.add(line);
}, printfQueue::clear);
PRINTF = PRINTF_object;
} else {
PRINTF_object = null;
//Todo add a dummy processor that just removes all the printf calls
PRINTF = null;
}
}
public static void tick() {
if (ENABLE_PRINTF_DEBUGGING) {
printfQueue2.clear();
printfQueue2.addAll(printfQueue);
printfQueue.clear();
PRINTF_object.download();
}
}
public static void addToOut(List<String> out) {
if (ENABLE_PRINTF_DEBUGGING) {
out.add("Printf Queue: ");
out.addAll(printfQueue2);
}
}
}

View File

@@ -1,6 +1,7 @@
package me.cortex.voxy.client.core.rendering; package me.cortex.voxy.client.core.rendering;
import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.client.core.gl.shader.PrintfInjector;
import me.cortex.voxy.client.core.model.ModelBakerySubsystem; import me.cortex.voxy.client.core.model.ModelBakerySubsystem;
import me.cortex.voxy.client.core.rendering.building.BuiltSection; import me.cortex.voxy.client.core.rendering.building.BuiltSection;
import me.cortex.voxy.client.core.rendering.building.RenderGenerationService; import me.cortex.voxy.client.core.rendering.building.RenderGenerationService;
@@ -14,6 +15,7 @@ import me.cortex.voxy.client.core.rendering.util.UploadStream;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import net.minecraft.client.render.Camera; import net.minecraft.client.render.Camera;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.lwjgl.opengl.ARBDirectStateAccess.glGetNamedFramebufferAttachmentParameteri; import static org.lwjgl.opengl.ARBDirectStateAccess.glGetNamedFramebufferAttachmentParameteri;

View File

@@ -22,6 +22,7 @@ public class HierarchicalOcclusionTraverser {
private final GlBuffer requestBuffer; private final GlBuffer requestBuffer;
private final GlBuffer nodeBuffer; private final GlBuffer nodeBuffer;
private final GlBuffer uniformBuffer = new GlBuffer(1024);
private final HiZBuffer hiZBuffer = new HiZBuffer(); private final HiZBuffer hiZBuffer = new HiZBuffer();
@@ -79,5 +80,6 @@ public class HierarchicalOcclusionTraverser {
this.requestBuffer.free(); this.requestBuffer.free();
this.hiZBuffer.free(); this.hiZBuffer.free();
this.nodeBuffer.free(); this.nodeBuffer.free();
this.uniformBuffer.free();
} }
} }