Added global shader debug printf util
This commit is contained in:
@@ -80,6 +80,7 @@ public class VoxelCore {
|
||||
|
||||
public void renderSetup(Frustum frustum, Camera camera) {
|
||||
this.renderer.setup(camera);
|
||||
PrintfDebugUtil.tick();
|
||||
}
|
||||
|
||||
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("SCS: " + Arrays.toString(this.world.getLoadedSectionCacheSizes()));
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.cortex.voxy.client.core.rendering;
|
||||
|
||||
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.rendering.building.BuiltSection;
|
||||
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 net.minecraft.client.render.Camera;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.lwjgl.opengl.ARBDirectStateAccess.glGetNamedFramebufferAttachmentParameteri;
|
||||
|
||||
@@ -22,6 +22,7 @@ public class HierarchicalOcclusionTraverser {
|
||||
private final GlBuffer requestBuffer;
|
||||
|
||||
private final GlBuffer nodeBuffer;
|
||||
private final GlBuffer uniformBuffer = new GlBuffer(1024);
|
||||
|
||||
private final HiZBuffer hiZBuffer = new HiZBuffer();
|
||||
|
||||
@@ -79,5 +80,6 @@ public class HierarchicalOcclusionTraverser {
|
||||
this.requestBuffer.free();
|
||||
this.hiZBuffer.free();
|
||||
this.nodeBuffer.free();
|
||||
this.uniformBuffer.free();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user