AA
This commit is contained in:
@@ -24,14 +24,10 @@ public class Voxy implements ClientModInitializer {
|
||||
}
|
||||
|
||||
|
||||
private static final ContextSelectionSystem selector = new ContextSelectionSystem();
|
||||
private static final ContextSelectionSystem SELECTOR = new ContextSelectionSystem();
|
||||
|
||||
public static VoxelCore createVoxelCore(ClientWorld world) {
|
||||
var selection = selector.getBestSelectionOrCreate(world);
|
||||
var selection = SELECTOR.getBestSelectionOrCreate(world);
|
||||
return new VoxelCore(selection);
|
||||
}
|
||||
|
||||
public static void breakpoint() {
|
||||
int breakpoint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package me.cortex.voxy.client.core.rendering.hierachical2;
|
||||
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
import me.cortex.voxy.client.core.gl.shader.Shader;
|
||||
import me.cortex.voxy.client.core.gl.shader.ShaderType;
|
||||
import me.cortex.voxy.client.core.rendering.util.HiZBuffer;
|
||||
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.UploadStream;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import static me.cortex.voxy.client.core.rendering.PrintfDebugUtil.PRINTF_object;
|
||||
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT;
|
||||
import static org.lwjgl.opengl.GL30.GL_R32UI;
|
||||
import static org.lwjgl.opengl.GL30C.GL_RED_INTEGER;
|
||||
import static org.lwjgl.opengl.GL42.glMemoryBarrier;
|
||||
import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_BARRIER_BIT;
|
||||
import static org.lwjgl.opengl.GL43.glDispatchComputeIndirect;
|
||||
import static org.lwjgl.opengl.GL45.nglClearNamedBufferSubData;
|
||||
|
||||
public class HierarchicalOcclusionTraverser {
|
||||
@@ -34,6 +36,10 @@ public class HierarchicalOcclusionTraverser {
|
||||
|
||||
private final HiZBuffer hiZBuffer = new HiZBuffer();
|
||||
|
||||
private final Shader traversal = Shader.make(PRINTF_object)
|
||||
.add(ShaderType.COMPUTE, "voxy:lod/hierarchical/traversal.comp")
|
||||
.compile();
|
||||
|
||||
|
||||
public HierarchicalOcclusionTraverser(HierarchicalNodeManager nodeManager, int requestBufferCount) {
|
||||
this.nodeManager = nodeManager;
|
||||
@@ -46,6 +52,10 @@ public class HierarchicalOcclusionTraverser {
|
||||
|
||||
}
|
||||
|
||||
private void bindings() {
|
||||
|
||||
}
|
||||
|
||||
public void doTraversal(Viewport<?> viewport, int depthBuffer) {
|
||||
//Compute the mip chain
|
||||
this.hiZBuffer.buildMipChain(depthBuffer, viewport.width, viewport.height);
|
||||
@@ -53,6 +63,9 @@ public class HierarchicalOcclusionTraverser {
|
||||
this.uploadUniform(viewport);
|
||||
UploadStream.INSTANCE.commit();
|
||||
|
||||
this.traversal.bind();
|
||||
this.bindings();
|
||||
|
||||
//Use a chain of glDispatchComputeIndirect (5 times) with alternating read/write buffers
|
||||
// TODO: swap to persistent gpu thread instead
|
||||
|
||||
@@ -89,6 +102,7 @@ public class HierarchicalOcclusionTraverser {
|
||||
}
|
||||
|
||||
public void free() {
|
||||
this.traversal.free();
|
||||
this.requestBuffer.free();
|
||||
this.hiZBuffer.free();
|
||||
this.nodeBuffer.free();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class BasicSectionGeometryManager extends AbstractSectionGeometryManager
|
||||
//Invalidate the section id
|
||||
this.invalidatedSectionIds.add(newId);
|
||||
|
||||
HierarchicalOcclusionTraverser.HACKY_SECTION_COUNT = this.allocationSet.getCount();
|
||||
//HierarchicalOcclusionTraverser.HACKY_SECTION_COUNT = this.allocationSet.getCount();
|
||||
return newId;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,17 +11,18 @@ import java.util.function.Supplier;
|
||||
// it is probably better anyway
|
||||
public class ServiceThreadPool {
|
||||
private volatile boolean running = true;
|
||||
private final Thread[] workers;
|
||||
private Thread[] workers = new Thread[0];
|
||||
private final Semaphore jobCounter = new Semaphore(0);
|
||||
|
||||
private volatile ServiceSlice[] serviceSlices = new ServiceSlice[0];
|
||||
private final AtomicLong totalJobWeight = new AtomicLong();
|
||||
private final ThreadGroup threadGroup;
|
||||
|
||||
public ServiceThreadPool(int workers) {
|
||||
public ServiceThreadPool(int threadCount) {
|
||||
this.threadGroup = new ThreadGroup("Service job workers");
|
||||
this.workers = new Thread[workers];
|
||||
for (int i = 0; i < workers; i++) {
|
||||
|
||||
this.workers = new Thread[threadCount];
|
||||
for (int i = 0; i < threadCount; i++) {
|
||||
int threadId = i;
|
||||
var worker = new Thread(this.threadGroup, ()->this.worker(threadId));
|
||||
worker.setDaemon(false);
|
||||
@@ -215,4 +216,29 @@ public class ServiceThreadPool {
|
||||
public int getThreadCount() {
|
||||
return this.workers.length;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setThreadCount(int threadCount) {
|
||||
if (threadCount == this.workers.length) {
|
||||
return;//No change
|
||||
}
|
||||
|
||||
if (threadCount < this.workers.length) {
|
||||
//Need to remove workers
|
||||
} else {
|
||||
//Need to add new workers
|
||||
}
|
||||
|
||||
this.workers = new Thread[threadCount];
|
||||
for (int i = 0; i < workers; i++) {
|
||||
int threadId = i;
|
||||
var worker = new Thread(this.threadGroup, ()->this.worker(threadId));
|
||||
worker.setDaemon(false);
|
||||
worker.setName("Service worker #" + i);
|
||||
worker.start();
|
||||
worker.setUncaughtExceptionHandler(this::handleUncaughtException);
|
||||
this.workers[i] = worker;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -16,11 +16,13 @@ public class SaveLoadSystem {
|
||||
public static final boolean VERIFY_HASH_ON_LOAD = System.getProperty("voxy.verifySectionOnLoad", "true").equals("true");
|
||||
public static final int BIGGEST_SERIALIZED_SECTION_SIZE = 32 * 32 * 32 * 8 * 2 + 8;
|
||||
|
||||
public static int lin2z(int i) {
|
||||
public static int lin2z(int i) {//y,z,x
|
||||
int x = i&0x1F;
|
||||
int y = (i>>10)&0x1F;
|
||||
int z = (i>>5)&0x1F;
|
||||
return Integer.expand(x,0b1001001001001)|Integer.expand(y,0b10010010010010)|Integer.expand(z,0b100100100100100);
|
||||
|
||||
//zyxzyxzyxzyxzyx
|
||||
}
|
||||
|
||||
public static int z2lin(int i) {
|
||||
|
||||
@@ -20,10 +20,19 @@ public class VoxyCommon implements ModInitializer {
|
||||
IS_DEDICATED_SERVER = FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER;
|
||||
|
||||
Serialization.init();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
//this.serviceThreadPool = new ServiceThreadPool(VoxyConfig.CONFIG.serviceThreads);
|
||||
|
||||
//TODO: need to have a common config with server/client configs deriving from it
|
||||
// maybe server/client extend it? or something? cause like client needs server config (at least partially sometimes)
|
||||
// but server doesnt need client config
|
||||
}
|
||||
|
||||
public static void breakpoint() {
|
||||
int breakpoint = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//TODO: increase local size
|
||||
#define LOCAL_SIZE_BITS 5
|
||||
#define LOCAL_SIZE_MSK ((1<<LOCAL_SIZE_BITS)-1)
|
||||
layout(local_size_x=(1<<LOCAL_SIZE_BITS), local_size_y=1) in;
|
||||
#define LOCAL_SIZE (1<<LOCAL_SIZE_BITS)
|
||||
layout(local_size_x=LOCAL_SIZE) in;//, local_size_y=1
|
||||
|
||||
#import <voxy:lod/hierarchical/binding_points.glsl>
|
||||
#line 7
|
||||
@@ -55,14 +56,6 @@ layout(binding = DEBUG_RENDER_NODE_INDEX, std430) restrict buffer DebugRenderNod
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
layout(binding = 2, std430) restrict buffer QueueData {
|
||||
uint tail;
|
||||
uint head;
|
||||
uint top;
|
||||
uint[] queue;
|
||||
} queue;
|
||||
*/
|
||||
#import <voxy:lod/hierarchical/transform.glsl>
|
||||
|
||||
#import <voxy:lod/hierarchical/node.glsl>
|
||||
|
||||
Reference in New Issue
Block a user