Expand description
GPU.4 — grid-of-chunks upload + storage layout.
Concatenates every chunk of one roxlap-scene::Grid into a few
flat storage buffers so a single compute dispatch can outer-DDA
through chunk-space + inner-DDA into any chunk it hits.
Memory layout (post-bedrock-strip):
occupancy[meta_idx]— one chunk’s 128 KiB occupancy slice starts atmeta_idx * vsid² * OCC_WORDS_PER_COLUMNu32 words. Uniform per chunk (all chunks are vsid² × CHUNK_Z voxels).color_offsets[meta_idx]— one chunk’svsid² + 1u32 offsets start atmeta_idx * (vsid² + 1)u32 words. Uniform per chunk.colors— variable per chunk. Per-chunk base index lives inchunk_colors_base[meta_idx].chunk_occupancy— 1 bit per chunk position. Bit atmeta_idxset iff that chunk has any textured voxels. The outer DDA uses this to skip empty chunks in one step.
The meta_idx for a chunk at (chx, chy, chz) is its row-major
offset within the grid’s chunks_dims bounding box:
rel = chunk_idx - origin_chunk
meta_idx = rel.x + rel.y * chunks_dims.x + rel.z * chunks_dims.x * chunks_dims.yStructs§
- GpuGrid
Resident - GPU-resident storage for one grid’s chunks. Lives until the host drops it; in GPU.6 (edit invalidation) we’ll re-upload individual chunks via partial buffer writes.
- Grid
Upload - CPU-side aggregation of a grid’s chunks ready to upload. Host
(e.g.
roxlap-scene-demo) builds this by iterating itsroxlap-scene::Gridand callingcrate::decompress_chunkper materialised chunk.
Constants§
- GRID_
CHUNK_ Z - Z-extent of every chunk — re-export of the
CHUNK_Zconstant so hosts can budget without pullingcrate::decompressin.
Functions§
- bounding_
box_ of - Compute the smallest bounding box that contains every
(chunk_idx, _)inchunks. ReturnsNoneifchunksis empty. - ceil_
pow2 - Round
nup to the nearest power of 2.0and1both return1. Used to derive a GPU.7GridUpload::pool_dimsfrom a non-pow2chunks_dims. - occ_
words_ per_ chunk - Number of u32 words a single chunk’s per-chunk occupancy slice occupies in the concatenated grid occupancy buffer. Useful for host-side memory budgeting.