More and more working?

This commit is contained in:
mcrcortex
2024-09-23 03:02:18 +10:00
parent 7eaa8483b8
commit ad7660e4d6
4 changed files with 24 additions and 12 deletions

View File

@@ -120,6 +120,7 @@ public class VoxelCore {
matrices.pop(); matrices.pop();
var projection = computeProjectionMat();//RenderSystem.getProjectionMatrix(); var projection = computeProjectionMat();//RenderSystem.getProjectionMatrix();
//var projection = RenderSystem.getProjectionMatrix();
var viewport = this.renderer.getViewport(); var viewport = this.renderer.getViewport();
viewport viewport
@@ -135,6 +136,8 @@ public class VoxelCore {
} }
//TODO: use the raw depth buffer texture instead //TODO: use the raw depth buffer texture instead
//int boundDepthBuffer = glGetNamedFramebufferAttachmentParameteri(boundFB, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); //int boundDepthBuffer = glGetNamedFramebufferAttachmentParameteri(boundFB, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
//TODO:FIXME!!! ??
this.postProcessing.setup(MinecraftClient.getInstance().getFramebuffer().textureWidth, MinecraftClient.getInstance().getFramebuffer().textureHeight, boundFB); this.postProcessing.setup(MinecraftClient.getInstance().getFramebuffer().textureWidth, MinecraftClient.getInstance().getFramebuffer().textureHeight, boundFB);
this.renderer.renderFarAwayOpaque(viewport); this.renderer.renderFarAwayOpaque(viewport);

View File

@@ -79,9 +79,9 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
//this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(0, 0,0,0)); //this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(0, 0,0,0));
//this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, 0,0,0)); //this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, 0,0,0));
final int H_WIDTH = 10; final int H_WIDTH = 1;
for (int x = -H_WIDTH; x <= H_WIDTH; x++) { for (int x = -H_WIDTH; x <= H_WIDTH; x++) {
for (int y = 0; y <= 0; y++) { for (int y = -1; y <= 0; y++) {
for (int z = -H_WIDTH; z <= H_WIDTH; z++) { for (int z = -H_WIDTH; z <= H_WIDTH; z++) {
this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, x, y, z)); this.nodeManager.insertTopLevelNode(WorldEngine.getWorldSectionId(4, x, y, z));
} }
@@ -103,7 +103,8 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
//Hieracial is not an abstract thing but //Hieracial is not an abstract thing but
// the section renderer is as it might have different backends, but they all accept a buffer containing the section list // the section renderer is as it might have different backends, but they all accept a buffer containing the section list
this.sectionRenderer.renderOpaque(viewport);
//this.sectionRenderer.renderOpaque(viewport);
//NOTE: need to do the upload and download tick here, after the section renderer renders the world, to ensure "stable" //NOTE: need to do the upload and download tick here, after the section renderer renders the world, to ensure "stable"
@@ -131,6 +132,9 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
glMemoryBarrier(GL_FRAMEBUFFER_BARRIER_BIT|GL_PIXEL_BUFFER_BARRIER_BIT); glMemoryBarrier(GL_FRAMEBUFFER_BARRIER_BIT|GL_PIXEL_BUFFER_BARRIER_BIT);
int depthBuffer = glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME); int depthBuffer = glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
if (depthBuffer == 0) {
depthBuffer = glGetFramebufferAttachmentParameteri(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME);
}
this.traversal.doTraversal(viewport, depthBuffer); this.traversal.doTraversal(viewport, depthBuffer);
this.sectionRenderer.buildDrawCallsAndRenderTemporal(viewport, this.traversal.getRenderListBuffer()); this.sectionRenderer.buildDrawCallsAndRenderTemporal(viewport, this.traversal.getRenderListBuffer());

View File

@@ -10,6 +10,7 @@ import me.cortex.voxy.client.core.rendering.util.HiZBuffer;
import me.cortex.voxy.client.core.rendering.Viewport; import me.cortex.voxy.client.core.rendering.Viewport;
import me.cortex.voxy.client.core.rendering.util.DownloadStream; import me.cortex.voxy.client.core.rendering.util.DownloadStream;
import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.client.core.rendering.util.UploadStream;
import me.cortex.voxy.common.Logger;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3f; import org.joml.Vector3f;
@@ -79,7 +80,7 @@ public class HierarchicalOcclusionTraverser {
public HierarchicalOcclusionTraverser(NodeManager2 nodeManager, int requestBufferCount) { public HierarchicalOcclusionTraverser(NodeManager2 nodeManager, int requestBufferCount) {
this.nodeManager = nodeManager; this.nodeManager = nodeManager;
this.requestBuffer = new GlBuffer(requestBufferCount*4L+1024).zero();//The 1024 is to assist with race condition issues this.requestBuffer = new GlBuffer(requestBufferCount*8L+8).zero();
this.nodeBuffer = new GlBuffer(nodeManager.maxNodeCount*16L).zero(); this.nodeBuffer = new GlBuffer(nodeManager.maxNodeCount*16L).zero();
this.maxRequestCount = requestBufferCount; this.maxRequestCount = requestBufferCount;
@@ -111,11 +112,11 @@ public class HierarchicalOcclusionTraverser {
MemoryUtil.memPutInt(ptr, viewport.height); ptr += 4; MemoryUtil.memPutInt(ptr, viewport.height); ptr += 4;
MemoryUtil.memPutInt(ptr, NodeManager.REQUEST_QUEUE_SIZE); ptr += 4; MemoryUtil.memPutInt(ptr, NodeManager.REQUEST_QUEUE_SIZE); ptr += 4;//TODO maybe these to a #define
MemoryUtil.memPutInt(ptr, (int) (this.renderList.size()/4-1)); ptr += 4;//TODO maybe move this to a #define MemoryUtil.memPutInt(ptr, (int) (this.renderList.size()/4-1)); ptr += 4;
//Screen space size for descending //Screen space size for descending
MemoryUtil.memPutFloat(ptr, 128*128); ptr += 4; MemoryUtil.memPutFloat(ptr, 64*64); ptr += 4;
} }
private void bindings() { private void bindings() {
@@ -240,8 +241,9 @@ public class HierarchicalOcclusionTraverser {
if (count < 0 || count > 50000) { if (count < 0 || count > 50000) {
throw new IllegalStateException("Count unexpected extreme value: " + count); throw new IllegalStateException("Count unexpected extreme value: " + count);
} }
if (count > (this.requestBuffer.size()>>2)-1) { if (count > (this.requestBuffer.size()>>3)-1) {
throw new IllegalStateException("Count over max buffer size, desync expected, aborting"); Logger.warn("Count over max buffer size, clamping, got count: " + count);
count = (int) ((this.requestBuffer.size()>>3)-1);
} }
if (count > this.maxRequestCount) { if (count > this.maxRequestCount) {
System.err.println("Count larger than 'maxRequestCount', overflow captured. Overflowed by " + (count-this.maxRequestCount)); System.err.println("Count larger than 'maxRequestCount', overflow captured. Overflowed by " + (count-this.maxRequestCount));

View File

@@ -27,12 +27,15 @@ void addRequest(inout UnpackedNode node) {
printf("Put node decend request"); printf("Put node decend request");
if (!hasRequested(node)) { if (!hasRequested(node)) {
if (requestQueueIndex.x < requestQueueMaxSize) { if (requestQueueIndex.x < requestQueueMaxSize) {
uint atomRes = atomicAdd(requestQueueIndex.x, 1);
if (atomRes < requestQueueMaxSize) {
//Mark node as having a request submitted to prevent duplicate submissions //Mark node as having a request submitted to prevent duplicate submissions
requestQueue[atomicAdd(requestQueueIndex.x, 1)] = getRawPos(node); requestQueue[atomRes] = getRawPos(node);
markRequested(node); markRequested(node);
} }
} }
} }
}
void enqueueChildren(in UnpackedNode node) { void enqueueChildren(in UnpackedNode node) {
uint children = getChildCount(node); uint children = getChildCount(node);