Beans2
This commit is contained in:
@@ -66,6 +66,7 @@ public class Gl46HierarchicalRenderer implements IRenderInterface<Gl46Hierarchic
|
||||
}, this.printfQueue::clear);
|
||||
|
||||
private final GlBuffer renderSections = new GlBuffer(100_000 * 4 + 4).zero();
|
||||
private final GlBuffer debugNodeQueue = new GlBuffer(1000000*4+4).zero();
|
||||
|
||||
|
||||
private final DebugRenderer debugRenderer = new DebugRenderer();
|
||||
@@ -85,12 +86,12 @@ public class Gl46HierarchicalRenderer implements IRenderInterface<Gl46Hierarchic
|
||||
this.sectionSelector = new HierarchicalOcclusionRenderer(new INodeInteractor() {
|
||||
@Override
|
||||
public void watchUpdates(long pos) {
|
||||
System.err.println("Watch: " + pos);
|
||||
//System.err.println("Watch: " + pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unwatchUpdates(long pos) {
|
||||
System.err.println("Unwatch: " + pos);
|
||||
//System.err.println("Unwatch: " + pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,9 +158,9 @@ public class Gl46HierarchicalRenderer implements IRenderInterface<Gl46Hierarchic
|
||||
if (true) {//Run the hierarchical selector over the buffer to generate the set of render sections
|
||||
var i = new int[1];
|
||||
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, i);
|
||||
this.sectionSelector.doHierarchicalTraversalSelection(viewport, i[0], this.renderSections);
|
||||
this.sectionSelector.doHierarchicalTraversalSelection(viewport, i[0], this.renderSections, this.debugNodeQueue);
|
||||
|
||||
this.debugRenderer.render(viewport, this.sectionSelector.getNodeDataBuffer(), this.renderSections);
|
||||
this.debugRenderer.render(viewport, this.sectionSelector.getNodeDataBuffer(), this.debugNodeQueue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public class HierarchicalOcclusionRenderer {
|
||||
this.uniformBuffer = new GlBuffer(1024).zero();
|
||||
this.printf = printf;
|
||||
this.hierarchicalTraversal = Shader.make(printf)
|
||||
.define("IS_DEBUG")
|
||||
.add(ShaderType.COMPUTE, "voxy:lod/hierarchical/traversal.comp")
|
||||
.compile();
|
||||
}
|
||||
@@ -71,7 +72,7 @@ public class HierarchicalOcclusionRenderer {
|
||||
MemoryUtil.memPutFloat(ptr, 64*64); ptr += 4;
|
||||
}
|
||||
|
||||
public void doHierarchicalTraversalSelection(Gl46HierarchicalViewport viewport, int depthBuffer, GlBuffer renderSelectionResult) {
|
||||
public void doHierarchicalTraversalSelection(Gl46HierarchicalViewport viewport, int depthBuffer, GlBuffer renderSelectionResult, GlBuffer debugNodeOutput) {
|
||||
this.uploadUniform(viewport);
|
||||
this.nodeManager.upload();
|
||||
|
||||
@@ -94,6 +95,7 @@ public class HierarchicalOcclusionRenderer {
|
||||
|
||||
//Clear the render counter
|
||||
nglClearNamedBufferSubData(renderSelectionResult.id, GL_R32UI, 0, 4, GL_RED_INTEGER, GL_UNSIGNED_INT, 0);
|
||||
nglClearNamedBufferSubData(debugNodeOutput.id, GL_R32UI, 0, 4, GL_RED_INTEGER, GL_UNSIGNED_INT, 0);
|
||||
|
||||
{
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 0, this.uniformBuffer.id);
|
||||
@@ -102,6 +104,7 @@ public class HierarchicalOcclusionRenderer {
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, this.nodeManager.requestQueue.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, renderSelectionResult.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, this.nodeQueueB.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, debugNodeOutput.id);
|
||||
|
||||
//Bind the hiz buffer
|
||||
glBindSampler(0, this.hizSampler);
|
||||
@@ -119,19 +122,19 @@ public class HierarchicalOcclusionRenderer {
|
||||
nglClearNamedBufferSubData(this.nodeQueueA.id, GL_R32UI, 0, 4, GL_RED_INTEGER, GL_UNSIGNED_INT, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, this.nodeQueueB.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, this.nodeQueueA.id);
|
||||
glDispatchCompute(21*21*4,1,1);
|
||||
glDispatchCompute(21*21*8,1,1);
|
||||
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
|
||||
nglClearNamedBufferSubData(this.nodeQueueB.id, GL_R32UI, 0, 4, GL_RED_INTEGER, GL_UNSIGNED_INT, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, this.nodeQueueA.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, this.nodeQueueB.id);
|
||||
glDispatchCompute(21*21*8,1,1);
|
||||
glDispatchCompute(21*21*32,1,1);
|
||||
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
|
||||
nglClearNamedBufferSubData(this.nodeQueueA.id, GL_R32UI, 0, 4, GL_RED_INTEGER, GL_UNSIGNED_INT, 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, this.nodeQueueB.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, this.nodeQueueA.id);
|
||||
glDispatchCompute(21*21*8,1,1);
|
||||
glDispatchCompute(21*21*128,1,1);
|
||||
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
|
||||
nglClearNamedBufferSubData(this.nodeQueueB.id, GL_R32UI, 0, 4, GL_RED_INTEGER, GL_UNSIGNED_INT, 0);
|
||||
|
||||
@@ -192,7 +192,7 @@ public class NodeManager {
|
||||
}
|
||||
|
||||
private void setChildPtr(int node, int childPtr, int count) {
|
||||
if (childPtr > 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,14 +447,17 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final IntArrayList nodeUpdates = new IntArrayList();
|
||||
|
||||
//Invalidates the node and tells it to be pushed to the gpu next slot, NOTE: pushing a node, clears any gpu side flags
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 <voxy:lod/hierarchical/binding_points.glsl>
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user