StructureID separate from chunk 'anchor'

This commit is contained in:
2026-11-09 11:44:13 +01:00
parent e855ccd904
commit b6f4a9c432
19 changed files with 944 additions and 136 deletions
+14 -8
View File
@@ -113,8 +113,8 @@ flowchart LR
Req --> Gather[gather_requests<br/>top-K + radix sort]
TReq --> TGather[table gather_requests]
Gather --> RBuffer[(Request buffer<br/>structure_id, node_id, child)]
TGather --> TRBuffer[(Table request buffer)]
Gather --> RBuffer[(Request buffer<br/>structure_id, anchor, node_id, child)]
TGather --> TRBuffer[(Table request buffer<br/>structure_id, anchor, slot)]
RBuffer --> Host[Host fulfils requests]
TRBuffer --> Host
@@ -198,10 +198,10 @@ Consequences agents should keep in mind:
| `src/gpu/` | Radix sort, top-K, indirect dispatch, compaction helpers | Active infrastructure |
| `src/gpu_profiler/` | Timestamp profiling and memory accounting wrappers | Active infrastructure |
| `src/gi_pipeline.rs` (+ `sparse_set.rs`) | Planned GI pipeline using cache attribute sets | **Compiled but never instantiated** |
| `src/production.rs` | Producer/structure IDs and `VoxelProducer` trait | **Not declared in `main.rs`; inactive** |
| `src/production/host_production.rs` | Rayon-based `HostRequestHandler` | **Inactive** |
| `src/production/tree_locator.rs` | Compact N-tree locator encoding | **Inactive** |
| `src/production/request_queue.rs` | WIP request queue | **Untracked / WIP, inactive** |
| `src/production.rs` | Producer/structure IDs, `StructureAnchor` re-export, `VoxelProducer` trait | Compiled; durable contract |
| `src/production/host_production.rs` | Rayon-based `HostRequestHandler` | Compiled; `fullfill` still a stub |
| `src/production/tree_locator.rs` | Compact N-tree locator encoding | Compiled; inactive |
| `src/production/request_queue.rs` | Bounded, deduplicating, priority-ordered request queue | Compiled, unit-tested; not yet on the live async path |
| `src/host_production.rs` | Legacy `ChunkVoxelProducer` trait | **Inactive** |
| `src/tree.rs` | CPU N-tree prototype | **Inactive** |
| `src/sparse_tree.rs` | Packed color helper and node locator used by producers | Active via `main.rs`/`producers.rs` |
@@ -236,7 +236,13 @@ updating the stack breaks tracing.
The toroidal table is a dense 3D grid of chunk root pointers. It wraps with
`imod`, so moving the camera across a chunk boundary invalidates the departing
slab and reuses those slots for incoming chunks.
slab and reuses those slots for incoming chunks. Identity is kept separate from
placement: each slot carries a table-defined `StructureAnchor` (world position
plus a version word) and a stable `StructureId`. Anchors that stay in view keep
their id while their slot may change; anchors that leave retire their id, which
is never reused. In-flight root work carries the anchor and the latest slot, and
the GPU rejects an insertion whose anchor/id no longer matches the slot, so queue
invalidation is only a cancellation optimisation.
---
@@ -289,7 +295,7 @@ demo; the UI plots both a frame timer and a ray-march timer.
| Symptom | Location | Impact | Confidence |
|---|---|---|---|
| Location pages are sized with `size_of::<StructurePage<N>>()` (264 B at N=4) instead of `LocationPage` (8 B). | `src/voxel_cache/structure.rs:44` | ~39.6 MB allocated where ~1.2 MB is needed. | High — direct code read. |
| Location pages are sized with `size_of::<StructurePage<N>>()` (264 B at N=4) instead of `LocationPage` (28 B). | `src/voxel_cache/structure.rs:44` | ~39.6 MB allocated where ~4.2 MB is needed. | High — direct code read. |
| The host request path busy-waits on `device.poll`, making a callback design behave synchronously. | `src/main.rs` around the `loop { ... poll ... }` after request downloads | Stalls the CPU on the render thread; prevents real pipelining/streaming. | High. |
| `VoxelTraceStack` is 5 entries and indexes `stack[10 - scale_exp/2]`, assuming `N = 4` and `chunk_power = 5`. | `shaders/voxel_cache.slang:93-96,177,189,257` | Changing branching or chunk depth silently corrupts tracing. | High. |
| Slang hardcodes `64` children per node and attribute meanings (0 = packed color, 1 = 3-word normal). | `shaders/voxel_cache.slang`, `shaders/voxel.slang` | Any cache layout change must be mirrored in Slang; mismatches are not caught at compile time. | High. |