From 4f02eca7c9c92dd2771ba59ecad73aff44217529 Mon Sep 17 00:00:00 2001 From: mcrcortex <{ID}+{username}@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:33:08 +1000 Subject: [PATCH] Beans2 --- .../rendering/Gl46HierarchicalRenderer.java | 9 ++++---- .../HierarchicalOcclusionRenderer.java | 11 ++++++---- .../rendering/hierarchical/NodeManager.java | 22 +++++++++++-------- .../shaders/lod/hierarchical/traversal.comp | 4 ++-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46HierarchicalRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46HierarchicalRenderer.java index 4ed65fa2..5cad9f51 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46HierarchicalRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46HierarchicalRenderer.java @@ -66,6 +66,7 @@ public class Gl46HierarchicalRenderer implements IRenderInterface NODE_MSK || ((childPtr!=NODE_MSK&&childPtr!=EMPTY_MESH_ID)&&count < 1)) { + if (childPtr > NODE_MSK || ((childPtr!=NODE_MSK)&&count < 1)) { throw new IllegalArgumentException(); } long val = this.localNodeData[node*3+1]; @@ -235,8 +235,11 @@ public class NodeManager { for (int i = 0; i < count; i++) { int requestOp = MemoryUtil.memGetInt(ptr + i*4L); int node = requestOp&NODE_MSK; - System.out.println("Got request for node: " + node); - + //System.out.println("Got request for node: " + node); + if (WorldEngine.getLevel(this.getNodePos(node)) == 0) { + System.err.println("Got a request for node at level 0: " + node + " pos: " + this.getNodePos(node)); + continue; + } if (this.isLeafNode(node)) { //If its a leaf node and it has a request, it must need the children if (this.getNodeMesh(node) == -1) { @@ -444,12 +447,15 @@ public class NodeManager { } if (cnt == 0) { //This means that every child node didnt have a mesh, this is not good - throw new IllegalStateException("Every child node empty for node at " + request.position); + //throw new IllegalStateException("Every child node empty for node at " + request.position); + System.err.println("Every child node empty for node at " + request.position); + //this.setChildPtr(request.nodeId, baseIdx, 0); } else { //Set the ptr this.setChildPtr(request.nodeId, baseIdx, cnt); + this.pushNode(request.nodeId); } - this.pushNode(request.nodeId); + } private final IntArrayList nodeUpdates = new IntArrayList(); @@ -469,11 +475,9 @@ public class NodeManager { flags |= this.isEmptyNode(id)?2:0; flags |= Math.max(0, this.getNodeChildCnt(id)-1)<<2; - //TODO: PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK PUT BACK - //int a = this.getNodeMesh(id)|((flags&0xFF)<<24); - int a = id|((flags&0xFF)<<24); + int a = this.getNodeMesh(id)|((flags&0xFF)<<24); int b = this.getNodeChildPtr(id)|(((flags>>8)&0xFF)<<24); - System.out.println("Setting mesh " + this.getNodeMesh(id) + " for node " + id); + //System.out.println("Setting mesh " + this.getNodeMesh(id) + " for node " + id); MemoryUtil.memPutInt(dst, a); dst += 4; MemoryUtil.memPutInt(dst, b); dst += 4; } diff --git a/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal.comp b/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal.comp index 654f9979..a8ce0cda 100644 --- a/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal.comp +++ b/src/main/resources/assets/voxy/shaders/lod/hierarchical/traversal.comp @@ -1,7 +1,7 @@ #version 460 core //TODO: make this better than a single thread -layout(local_size_x=1, local_size_y=1) in; +layout(local_size_x=32, local_size_y=1) in; #import #line 7 @@ -90,7 +90,7 @@ layout(binding = 2, std430) restrict buffer QueueData { void addRequest(inout UnpackedNode node) { if (!hasRequested(node)) { - printf("LOG: Request %d %d %d %d", node.nodeId, node.flags, node.meshPtr, node.childPtr); + printf("Request %d %d %d %d", node.nodeId, node.flags, node.meshPtr, node.childPtr); //TODO: maybe try using only 1 variable and it being <0 being bad if (requestQueueIndex < requestQueueMaxSize) { //Mark node as having a request submitted to prevent duplicate submissions