Fixes and tweeks for things

This commit is contained in:
mcrcortex
2025-03-24 13:49:15 +10:00
parent 8b7a3c4bb1
commit 68a17f0578
6 changed files with 40 additions and 28 deletions

View File

@@ -92,10 +92,10 @@ public class TextureUtils {
private static float u2fdepth(int depth) {
float depthF = (float) ((double)depth/((1<<24)-1));
//https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDepthRange.xhtml
// due to this and the unsigned bullshit, i believe the depth value needs to get multiplied by 2
// due to this and the unsigned bullshit, believe the depth value needs to get multiplied by 2
//Shouldent be needed due to the compute bake copy
//depthF *= 2;
depthF *= 2;
if (depthF > 1.00001f) {
System.err.println("Warning: Depth greater than 1");
depthF = 1.0f;

View File

@@ -359,6 +359,7 @@ public class RenderDataFactory45 {
if (false) {//Non fully opaque geometry
this.blockMesher.doAuxiliaryFaceOffset = false;
//Note: think is ok to just reuse.. blockMesher
this.blockMesher.axis = axis;
for (int layer = 0; layer < 32; layer++) {
@@ -400,6 +401,7 @@ public class RenderDataFactory45 {
}
this.blockMesher.finish();
}
this.blockMesher.doAuxiliaryFaceOffset = true;
}
}
}

View File

@@ -119,31 +119,37 @@ public class NodeCleaner {
this.setIds(this.freeIds, -1);
if (this.shouldCleanGeometry()) {
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
this.outputBuffer.fill(this.nodeManager.maxNodeCount-2);//TODO: maybe dont set to zero??
var gm = this.nodeManager.getGeometryManager();
int c = (int) (((((double) gm.getUsedCapacity() / gm.geometryCapacity) - 0.75) * 4 * 10) + 1);
c = 1;
for (int i = 0; i < c; i++) {
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
this.outputBuffer.fill(this.nodeManager.maxNodeCount - 2);//TODO: maybe dont set to zero??
this.sorter.bind();
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, nodeDataBuffer.id);
this.sorter.bind();
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, nodeDataBuffer.id);
//TODO: choose whether this is in nodeSpace or section/geometryId space
//
glDispatchCompute((this.nodeManager.getCurrentMaxNodeId()+SORTING_WORKER_SIZE-1)/SORTING_WORKER_SIZE, 1, 1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
//TODO: choose whether this is in nodeSpace or section/geometryId space
//
glDispatchCompute((this.nodeManager.getCurrentMaxNodeId() + SORTING_WORKER_SIZE - 1) / SORTING_WORKER_SIZE, 1, 1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
this.resultTransformer.bind();
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 0, this.outputBuffer.id, 0, 4*OUTPUT_COUNT);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, nodeDataBuffer.id);
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 2, this.outputBuffer.id, 4*OUTPUT_COUNT, 8*OUTPUT_COUNT);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, this.visibilityBuffer.id);
glUniform1ui(0, this.visibilityId);
this.resultTransformer.bind();
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 0, this.outputBuffer.id, 0, 4 * OUTPUT_COUNT);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, nodeDataBuffer.id);
glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 2, this.outputBuffer.id, 4 * OUTPUT_COUNT, 8 * OUTPUT_COUNT);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, this.visibilityBuffer.id);
glUniform1ui(0, this.visibilityId);
glDispatchCompute(1,1,1);
//glFinish();
glDispatchCompute(1, 1, 1);
//glFinish();
DownloadStream.INSTANCE.download(this.outputBuffer, 4*OUTPUT_COUNT, 8*OUTPUT_COUNT, this::onDownload);
//glFinish();
DownloadStream.INSTANCE.download(this.outputBuffer, 4 * OUTPUT_COUNT, 8 * OUTPUT_COUNT, this::onDownload);
//glFinish();
}
}
}

View File

@@ -274,8 +274,8 @@ public class TestNodeManager {
public static void main(String[] args) {
Logger.INSERT_CLASS = false;
int ITER_COUNT = 5000;
int INNER_ITER_COUNT = 100_000;
int ITER_COUNT = 50_000;
int INNER_ITER_COUNT = 500_000;
boolean GEO_REM = true;
AtomicInteger finished = new AtomicInteger();
@@ -283,7 +283,7 @@ public class TestNodeManager {
Logger.SHUTUP = true;
if (true) {
if (false) {
for (int q = 0; q < ITER_COUNT; q++) {
//Logger.info("Iteration "+ q);
if (runTest(INNER_ITER_COUNT, q, seenTraces, GEO_REM)) {

View File

@@ -22,7 +22,7 @@ void main() {
uint id = minVisIds[gl_LocalInvocationID.x];
uvec4 node = nodes[id];
uvec2 res = node.xy;
if (all(equal(node, uvec4(0)))) {//If its a empty node, TODO: DONT THINK THIS IS ACTUALLY CORRECT
if (all(equal(node, uvec4(-1)))) {//If its a empty node, TODO: DONT THINK THIS IS ACTUALLY CORRECT
res = uvec2(-1);
}
outputBuffer[gl_LocalInvocationID.x] = res;//Move the position of the node id into the output buffer
@@ -30,6 +30,6 @@ void main() {
//This is an evil hack to not spam the same node 500 times in a row
//TODO: maybe instead set this to the current frame index
// visibility[id] += 30;
visibility[id] = visibilityCounter;
visibility[id] = visibilityCounter + 60;
}

View File

@@ -18,7 +18,8 @@ layout(binding = OUTPUT_BUFFER_BINDING, std430) restrict volatile buffer Minimum
};
//Returns the id of the max value
uint atomicDerefMax(uint atId, uint id, uint value) {
uint atomicDerefMaxExchange(uint atId, uint id) {
const uint value = visiblity[id];
while (true) {
const uint existingId = minVisIds[atId];
//Check if the value is less than the dereferenced value, if its not, return our own id
@@ -26,7 +27,7 @@ uint atomicDerefMax(uint atId, uint id, uint value) {
return id;
}
//Attempt to swap, since we know we are less than the existingId
uint c = atomicCompSwap(minVisIds[atId], existingId, id);
const uint c = atomicCompSwap(minVisIds[atId], existingId, id);
//Check if we did swap, else if we failed (or got reswapped else where) recheck
//We did swap, (since the original mem contents was the existing id)
@@ -40,7 +41,7 @@ uint atomicDerefMax(uint atId, uint id, uint value) {
//TODO: optimize
void bubbleSort(uint start, uint id) {
for (uint i = start; i < OUTPUT_SIZE; i++) {
id = atomicDerefMax(i, id, visiblity[id]);
id = atomicDerefMaxExchange(i, id);
}
}
@@ -50,6 +51,9 @@ void main() {
//}
//First do a min sort/set of min OUTPUT_SIZE values of the set
uint vis = visiblity[gl_GlobalInvocationID.x];
if (vis == uint(-1)) {
return;
}
if (visiblity[minVisIds[OUTPUT_SIZE-1]] <= vis) {
return;
}