refactor: Removing structureID, keep structure anchor as id

This commit is contained in:
2026-11-12 15:51:05 +01:00
parent a39256a0f1
commit c31f3a9bc3
23 changed files with 1417 additions and 806 deletions
+14 -10
View File
@@ -17,8 +17,9 @@ The durable system is:
- `src/voxel_cache/shaders/*.wgsl` — runtime-specialised cache shaders.
- `src/gpu/*` — radix sort, top-K, indirect dispatch, compaction.
- `shaders/*.slang` — render-side ray marching, compiled ahead of time.
- `src/voxel_cache/tables.rs` + `src/terrain.rs` — structure tables and the
toroidal world wrapper.
- `src/voxel_cache/tables.rs` + `src/terrain.rs` — structure tables
(`FixedStructureTable`, the freelist-backed `DynamicStructureTable`, and the
shared `StructureTableCore`) and the toroidal world wrapper.
> **Temporary code:** `src/main.rs` and `src/producers.rs` are a playground/test
> harness built alongside the cache. They contain hardcoded parameters and
@@ -84,14 +85,16 @@ Do not change these casually; they are contracts between Rust, WGSL, and Slang.
10. **Eviction order:** timestamp-major (least recently used first), depth-minor
(deepest first). The depth pass runs descending and the timestamp pass runs
stable so equal timestamps keep the deepest-first order.
11. **Identity is not placement.** `StructureId` is stable tree identity
(monotonic per producer, never reused for another anchor). `StructureAnchor`
is the opaque, table-defined content identity (toroidal table: world
position + version). `TableSlot` is table-private placement and may change
freely. Root identity is `(ProducerId, StructureId, StructureAnchor)`; the
slot travels only as attachment metadata. Request keys, `LocationPage`,
`RequestInformation`, and `InsertionParent` must not treat the slot as
identity.
11. **Identity is not placement.** `StructureAnchor` is the opaque, table-defined
content identity and the *only* structure identity (toroidal table: world
position + version). A table must never expose two live slots with the same
anchor, and an anchor must keep naming the same content if it leaves and
later re-enters; bump the version word when content generation changes for
the same coordinates. `TableSlot` is table-private placement and may change
freely. Root identity is `(ProducerId, StructureAnchor)`; the slot travels
only as attachment metadata (`RequestMeta`, `InsertionParent`). Request keys,
`LocationPage`, `RequestInformation`, `RequestMeta`, and `InsertionParent`
must not treat the slot as identity.
## Where to look for common tasks
@@ -103,6 +106,7 @@ Do not change these casually; they are contracts between Rust, WGSL, and Slang.
| Change eviction | `src/voxel_cache/eviction.rs`, `src/voxel_cache/shaders/eviction.wgsl`, `src/voxel_cache/shaders/insertion.wgsl` |
| Change insertion semantics | `src/voxel_cache.rs` (`insert`), `src/voxel_cache/pipelines.rs`, `src/voxel_cache/shaders/insertion.wgsl`, `write_pointers.wgsl` |
| Change world/chunk lookup | `src/voxel_cache/tables.rs`, `src/terrain.rs`, `shaders/toroidal_structure_table.slang` |
| Add/change slot allocation or table growth | `src/voxel_cache/tables.rs` (`DynamicStructureTable`, `SlotAllocator`, `StructureTableCore`) |
| Change structure identity / anchors | `src/voxel_cache/schema.rs` (`StructureAnchor`, wire structs), `src/production/request_queue.rs`, `src/voxel_cache/tables.rs`, `src/voxel_cache/shaders/common.wgsl`, fixed-table shaders |
| Change ray marching/LOD | `shaders/voxel.slang`, `shaders/voxel_cache.slang`, `shaders/lod_policies.slang` |
| Add a producer | `src/producers.rs` (interface), `src/main.rs` (`fullfill_request`), [`docs/pipeline-and-producers.md`](./docs/pipeline-and-producers.md) |