notes and tweeks

This commit is contained in:
mcrcortex
2025-05-06 20:33:21 +10:00
parent 7a4e01faab
commit 6087dba91b
7 changed files with 27 additions and 9 deletions

View File

@@ -415,6 +415,10 @@ public class ModelFactory {
} }
metadata |= fullyOpaque?(1L<<(48+6)):0; metadata |= fullyOpaque?(1L<<(48+6)):0;
boolean canBeCorrectlyRendered = true;//This represents if a model can be correctly (perfectly) represented
// i.e. no gaps
this.metadataCache[modelId] = metadata; this.metadataCache[modelId] = metadata;
uploadPtr += 4*6; uploadPtr += 4*6;
@@ -629,6 +633,10 @@ public class ModelFactory {
return res; return res;
} }
public int[] _unsafeRawAccess() {
return this.idMappings;
}
public int getModelId(int blockId) { public int getModelId(int blockId) {
int map = this.idMappings[blockId]; int map = this.idMappings[blockId];
if (map == -1) { if (map == -1) {

View File

@@ -282,7 +282,7 @@ public class HierarchicalOcclusionTraverser {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, NODE_QUEUE_SINK_BINDING, this.scratchQueueB.id); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, NODE_QUEUE_SINK_BINDING, this.scratchQueueB.id);
//Dont need to use indirect to dispatch the first iteration //Dont need to use indirect to dispatch the first iteration
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_COMMAND_BARRIER_BIT); glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_COMMAND_BARRIER_BIT|GL_BUFFER_UPDATE_BARRIER_BIT);
glDispatchCompute(firstDispatchSize, 1,1); glDispatchCompute(firstDispatchSize, 1,1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_COMMAND_BARRIER_BIT); glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT|GL_COMMAND_BARRIER_BIT);

View File

@@ -80,7 +80,7 @@ public class UploadStream {
public void commit() { public void commit() {
glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT|GL_BUFFER_UPDATE_BARRIER_BIT);
//Execute all the copies //Execute all the copies
for (var entry : this.uploadList) { for (var entry : this.uploadList) {
glCopyNamedBufferSubData(this.uploadBuffer.id, entry.target.id, entry.uploadOffset, entry.targetOffset, entry.size); glCopyNamedBufferSubData(this.uploadBuffer.id, entry.target.id, entry.uploadOffset, entry.targetOffset, entry.size);

View File

@@ -12,14 +12,17 @@ import static org.lwjgl.util.zstd.Zstd.*;
public class ZSTDCompressor implements StorageCompressor { public class ZSTDCompressor implements StorageCompressor {
private static final Cleaner CLEANER = Cleaner.create(); private static final Cleaner CLEANER = Cleaner.create();
private record Ref(long ptr) {} private record Ref(long ptr) {}
private static Ref createCleanableCompressionContext() { private static Ref createCleanableCompressionContext() {
long ctx = ZSTD_createCCtx(); long ctx = ZSTD_createCCtx();
var ref = new Ref(ctx); var ref = new Ref(ctx);
CLEANER.register(ref, ()->ZSTD_freeCCtx(ctx)); CLEANER.register(ref, ()->ZSTD_freeCCtx(ctx));
return ref; return ref;
} }
private static Ref createCleanableDecompressionContext() { private static Ref createCleanableDecompressionContext() {
long ctx = ZSTD_createDCtx(); long ctx = ZSTD_createDCtx();
nZSTD_DCtx_setParameter(ctx, ZSTD_d_experimentalParam3, 1);//experimental ZSTD_d_forceIgnoreChecksum
var ref = new Ref(ctx); var ref = new Ref(ctx);
CLEANER.register(ref, ()->ZSTD_freeDCtx(ctx)); CLEANER.register(ref, ()->ZSTD_freeDCtx(ctx));
return ref; return ref;

View File

@@ -27,6 +27,7 @@ void main() {
vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0)); vec2 uv = mod(uv, vec2(1.0))*(1.0/(vec2(3.0,2.0)*256.0));
vec2 texPos = uv + baseUV; vec2 texPos = uv + baseUV;
//vec4 colour = solidColour; //vec4 colour = solidColour;
//TODO: FIXME, need to manually compute the mip colour
vec4 colour = texture(blockModelAtlas, texPos, ((flags>>1)&1u)*-5.0);//TODO: FIXME mipping needs to be fixed so that it doesnt go cross model bounds vec4 colour = texture(blockModelAtlas, texPos, ((flags>>1)&1u)*-5.0);//TODO: FIXME mipping needs to be fixed so that it doesnt go cross model bounds
//Also, small quad is really fking over the mipping level somehow //Also, small quad is really fking over the mipping level somehow
if ((flags&1u) == 1 && colour.a <= 0.25f) { if ((flags&1u) == 1 && colour.a <= 0.25f) {

View File

@@ -21,6 +21,8 @@ uint getCurrentNode() {
return nodeQueueSource[gl_GlobalInvocationID.x]; return nodeQueueSource[gl_GlobalInvocationID.x];
} }
//TODO: limit the size/writing out of bounds
uint nodePushIndex = -1; uint nodePushIndex = -1;
void pushNodesInit(uint nodeCount) { void pushNodesInit(uint nodeCount) {
//Debug //Debug

View File

@@ -78,14 +78,18 @@ void enqueueSelfForRender(in UnpackedNode node) {
if (renderQueueIndex < renderQueueMaxSize) { if (renderQueueIndex < renderQueueMaxSize) {
lastRenderFrame[getId(node)] = frameId; lastRenderFrame[getId(node)] = frameId;
if (!isEmptyMesh(node)) { if (!isEmptyMesh(node)) {
renderQueue[atomicAdd(renderQueueIndex, 1)] = getMesh(node); uint renderIndex = atomicAdd(renderQueueIndex, 1);
#ifdef IS_DEBUG if (renderIndex < renderQueueMaxSize) {
debugRenderNodeQueue[atomicAdd(debugRenderNodeQueueIndex, 1)] = node.nodeId; renderQueue[renderIndex] = getMesh(node);
#endif
#ifdef HAS_STATISTICS #ifdef IS_DEBUG
atomicAdd(renderCounts[node.lodLevel], 1); debugRenderNodeQueue[atomicAdd(debugRenderNodeQueueIndex, 1)] = node.nodeId;
#endif #endif
#ifdef HAS_STATISTICS
atomicAdd(renderCounts[node.lodLevel], 1);
#endif
}
} }
} }
} }