refactor: Splitting into crates
This commit is contained in:
+13
-13
@@ -1,12 +1,12 @@
|
||||
# Voxel cache
|
||||
|
||||
`src/voxel_cache.rs` and `src/voxel_cache/*` implement a GPU-resident sparse
|
||||
`crates/vxls-voxel-cache/src/lib.rs` and `crates/vxls-voxel-cache/src/*` implement a GPU-resident sparse
|
||||
voxel cache. This document covers the page model, pointer encoding, public API,
|
||||
request/insertion pipelines, eviction, and the structure tables that provide
|
||||
entry points into the cache.
|
||||
|
||||
> **Temporary caller:** the public `VoxelCache` surface is intended API;
|
||||
> `src/main.rs` is only one caller and currently uses it in a blocking,
|
||||
> `crates/vxls/src/main.rs` is only one caller and currently uses it in a blocking,
|
||||
> single-threaded playground way. See [`pipeline-and-producers.md`](./pipeline-and-producers.md).
|
||||
|
||||
---
|
||||
@@ -167,7 +167,7 @@ Rust API: `CachePointer::new(Option<Option<u32>>)`.
|
||||
| `Some(None)` | `0x80000000` | subdividable, unavailable |
|
||||
| `Some(Some(p))` | `0xC0000000 \| p` | subdividable, available at page `p` |
|
||||
|
||||
WGSL helpers in `src/voxel_cache/shaders/common.wgsl`:
|
||||
WGSL helpers in `crates/vxls-voxel-cache/src/shaders/common.wgsl`:
|
||||
|
||||
- `child_pointer_empty(subdivisible)`
|
||||
- `child_pointer_subdivided(pointer)`
|
||||
@@ -602,7 +602,7 @@ root page? Structure tables answer that and emit requests when it is missing.
|
||||
|
||||
### 8.1 `FixedStructureTable`
|
||||
|
||||
`src/voxel_cache/tables.rs`.
|
||||
`crates/vxls-voxel-cache/src/tables.rs`.
|
||||
|
||||
- Backing buffer: one `CachePointer` per slot, initialised to
|
||||
`subdividable, unavailable`.
|
||||
@@ -625,7 +625,7 @@ The table is dense: allocation is `slot_count * 4` bytes for pointers plus
|
||||
|
||||
### 8.2 `ToroidalStructureTable`
|
||||
|
||||
`src/terrain.rs`. Wraps `FixedStructureTable` with a movable block of chunks.
|
||||
`crates/vxls-terrain/src/lib.rs`. Wraps `FixedStructureTable` with a movable block of chunks.
|
||||
|
||||
- `extent = (x, y, z)` chunk counts.
|
||||
- Slot index from local coordinates:
|
||||
@@ -650,7 +650,7 @@ is imported by `voxel.slang` but unused.
|
||||
|
||||
### 8.3 `DynamicStructureTable`
|
||||
|
||||
`src/voxel_cache/tables.rs`. A table whose slots are allocated and released at
|
||||
`crates/vxls-voxel-cache/src/tables.rs`. A table whose slots are allocated and released at
|
||||
runtime. It shares the GPU scaffolding with `FixedStructureTable` through the
|
||||
private `StructureTableCore`; only the host-side slot management differs.
|
||||
|
||||
@@ -758,12 +758,12 @@ Memory example at 150k pages and 2 attributes is tabulated in
|
||||
|
||||
| Symptom | Location | Impact | Confidence |
|
||||
|---|---|---|---|
|
||||
| `CacheStructure::new` allocates `location_pages` with `size_of::<StructurePage<N>>()` instead of `size_of::<LocationPage>()`. | `src/voxel_cache/structure.rs:44` | At N=4, 264 B/page instead of 8 B/page: ~39.6 MB instead of ~1.2 MB for 150k pages. No correctness issue because shaders index by `LocationPage` stride. | High |
|
||||
| `StructurePage` (Rust, `u64` mask) and `PointerPage` (WGSL, two `u32`) are duplicated layout definitions. | `src/voxel_cache/schema.rs:89-100`, `src/voxel_cache/shaders/cache_common.wgsl:3-8` | Little-endian compatible today; any field reorder breaks silently. `StructurePage` is only used for sizing. | High |
|
||||
| `request_buffer_count` is written by every invocation of `write_requests.wgsl` with the same value. | `src/voxel_cache/shaders/write_requests.wgsl:50` | Benign data race (identical writes), but unnecessary and confusing. | Medium |
|
||||
| `CacheStructure::new` allocates `location_pages` with `size_of::<StructurePage<N>>()` instead of `size_of::<LocationPage>()`. | `crates/vxls-voxel-cache/src/structure.rs:44` | At N=4, 264 B/page instead of 8 B/page: ~39.6 MB instead of ~1.2 MB for 150k pages. No correctness issue because shaders index by `LocationPage` stride. | High |
|
||||
| `StructurePage` (Rust, `u64` mask) and `PointerPage` (WGSL, two `u32`) are duplicated layout definitions. | `crates/vxls-voxel-cache/src/schema.rs:89-100`, `crates/vxls-voxel-cache/src/shaders/cache_common.wgsl:3-8` | Little-endian compatible today; any field reorder breaks silently. `StructurePage` is only used for sizing. | High |
|
||||
| `request_buffer_count` is written by every invocation of `write_requests.wgsl` with the same value. | `crates/vxls-voxel-cache/src/shaders/write_requests.wgsl:50` | Benign data race (identical writes), but unnecessary and confusing. | Medium |
|
||||
| Insertion order no longer matters: each entry is validated against its `InsertionParent` and linked statelessly. | `insertion.wgsl`, `write_pointers.wgsl`, `fixed_table/insertion.wgsl` | A producer may reorder or filter results; unchanged request order is no longer a correctness requirement. | High |
|
||||
| `CacheInsertionPass` can silently insert fewer pages than requested (`0xFFFFFFFF` destinations) with no host feedback. | `src/voxel_cache/shaders/insertion.wgsl` | Producer believes data is resident; requests may repeat or data may be missing. | High |
|
||||
| The first `VoxelCache::insert` call inserts nothing: `new_timestamp = 1`, unused pages have timestamp 0, and the guard rejects `0 >= new_timestamp - 1` (`0 >= 0`). | `src/voxel_cache.rs:248`, `src/voxel_cache/shaders/insertion.wgsl:141-146` | One-frame startup delay; any external roots submitted in the first batch are dropped and must be re-requested. | High |
|
||||
| `CacheInsertionPass` can silently insert fewer pages than requested (`0xFFFFFFFF` destinations) with no host feedback. | `crates/vxls-voxel-cache/src/shaders/insertion.wgsl` | Producer believes data is resident; requests may repeat or data may be missing. | High |
|
||||
| The first `VoxelCache::insert` call inserts nothing: `new_timestamp = 1`, unused pages have timestamp 0, and the guard rejects `0 >= new_timestamp - 1` (`0 >= 0`). | `crates/vxls-voxel-cache/src/lib.rs:248`, `crates/vxls-voxel-cache/src/shaders/insertion.wgsl:141-146` | One-frame startup delay; any external roots submitted in the first batch are dropped and must be re-requested. | High |
|
||||
| Pointer/page-count limits are implicit (`< 2^30`, total elements `< 2^32`). | `schema.rs`, `requests.rs:82-85` | Large configurations fail via asserts or truncation. | High |
|
||||
| `CacheAttributeInit::DontTouch` attributes can become stale after a page is recycled; the cache deliberately does not clear them. | `src/voxel_cache/shaders/insertion.wgsl:164-178` | Any consumer of such an attribute must tolerate garbage for recycled pages. | Medium |
|
||||
| The cache exposes `usage_timestamps()` for debugging only; timestamps are also used internally for invalidation and eviction. | `src/voxel_cache.rs:445-449` | Easy to corrupt cache behaviour by writing to that buffer. | Medium |
|
||||
| `CacheAttributeInit::DontTouch` attributes can become stale after a page is recycled; the cache deliberately does not clear them. | `crates/vxls-voxel-cache/src/shaders/insertion.wgsl:164-178` | Any consumer of such an attribute must tolerate garbage for recycled pages. | Medium |
|
||||
| The cache exposes `usage_timestamps()` for debugging only; timestamps are also used internally for invalidation and eviction. | `crates/vxls-voxel-cache/src/lib.rs:445-449` | Easy to corrupt cache behaviour by writing to that buffer. | Medium |
|
||||
|
||||
Reference in New Issue
Block a user