refactor: Splitting into crates
This commit is contained in:
@@ -4,7 +4,7 @@ This document follows data from a GPU-emitted request to a resident cache page,
|
||||
and describes the producer interface. It also marks which producer code is
|
||||
durable and which is throwaway.
|
||||
|
||||
> **Temporary code:** `src/main.rs` and `src/producers.rs` are a playground/test
|
||||
> **Temporary code:** `crates/vxls/src/main.rs` and `crates/vxls/src/producers.rs` are a playground/test
|
||||
> harness built alongside the cache. They contain hardcoded parameters and
|
||||
> blocking workarounds. Do not treat them as stable architecture, public API, or
|
||||
> examples of intended concurrency. The `ChunkedProducer` shape and the
|
||||
@@ -141,7 +141,7 @@ corrupting the tree.
|
||||
|
||||
## 3. The durable producer shape
|
||||
|
||||
`src/producers.rs` defines:
|
||||
`crates/vxls/src/producers.rs` defines:
|
||||
|
||||
```rust
|
||||
pub trait ChunkedProducer<const N: usize>
|
||||
@@ -184,7 +184,7 @@ child instead of hardcoding color/normal.
|
||||
|
||||
### 3.1 Fulfilling a request
|
||||
|
||||
The demo's `fullfill_request` (`src/main.rs`) does:
|
||||
The demo's `fullfill_request` (`crates/vxls/src/main.rs`) does:
|
||||
|
||||
1. Decode the table-defined anchor with
|
||||
`ToroidalStructureTable::position_for_anchor` to get an absolute chunk
|
||||
@@ -212,10 +212,10 @@ chunk dimensions of 20×20×20 and a 4-ary tree.
|
||||
|
||||
Two locator implementations exist:
|
||||
|
||||
- **`NTreeNodeLocator<N>`** (`src/sparse_tree.rs`) — used by the demo. A packed
|
||||
- **`NTreeNodeLocator<N>`** (`crates/vxls/src/sparse_tree.rs`) — used by the demo. A packed
|
||||
`usize`; supports `root`, `from_usize`, `depth`, `child`, `node_location`,
|
||||
`as_usize`, `parent`, `children`.
|
||||
- **`TreeLocator<N>`** (`src/production/tree_locator.rs`) — the unwired
|
||||
- **`TreeLocator<N>`** (`crates/vxls-production/src/tree_locator.rs`) — the unwired
|
||||
production subsystem's version. Three base-N accumulators (`x`, `y`, `z`) with
|
||||
a leading `1` digit; root is `(1,1,1)`; `depth = ilog_N(x)`; `parent` divides
|
||||
each coordinate by `N`; `child` multiplies by `N` and adds the child digit.
|
||||
@@ -229,7 +229,7 @@ coordinates. Whichever is used, it must round-trip through the 32-bit
|
||||
|
||||
## 4. The current driver, step by step
|
||||
|
||||
Relevant code: `State::render` and `fullfill_request` in `src/main.rs`.
|
||||
Relevant code: `State::render` and `fullfill_request` in `crates/vxls/src/main.rs`.
|
||||
|
||||
1. **Render** writes G-buffers and request counters.
|
||||
2. **Gather** encodes both request pipelines (cache + table) into the same
|
||||
@@ -296,7 +296,7 @@ real engine.
|
||||
|
||||
---
|
||||
|
||||
## 5. Generators in `src/producers.rs`
|
||||
## 5. Generators in `crates/vxls/src/producers.rs`
|
||||
|
||||
All are fixtures. They exist to exercise the cache and should not be treated as
|
||||
stable.
|
||||
@@ -322,11 +322,11 @@ branching logic based on `depth <= 2`.
|
||||
|
||||
## 6. The production subsystem
|
||||
|
||||
`src/production.rs` and its children are compiled (`mod production;`), but the
|
||||
`crates/vxls-production/src/lib.rs` and its children are compiled (`mod production;`), but the
|
||||
demo driver in `main.rs` still uses its synchronous `fullfill_request` path. The
|
||||
production types are the durable contract; the driver is still the playground.
|
||||
|
||||
### 6.1 `src/production.rs`
|
||||
### 6.1 `crates/vxls-production/src/lib.rs`
|
||||
|
||||
Defines a more ambitious interface:
|
||||
|
||||
@@ -375,19 +375,19 @@ table keeps an anchor's identity while it stays in view and retires anchors that
|
||||
leave. An anchor must keep naming the same content if it later re-enters; bump
|
||||
its version word when content generation changes for the same coordinates.
|
||||
|
||||
### 6.2 `src/production/host_production.rs`
|
||||
### 6.2 `crates/vxls-production/src/host_production.rs`
|
||||
|
||||
`HostRequestHandler<N, P: VoxelProducer<N>>` owns a rayon `ThreadPool` and a
|
||||
producer, and is intended to fulfil requests on the CPU. Note that its
|
||||
`fullfill` method is a stub: it downloads the request buffer with an empty
|
||||
callback. `produce_requests` does the real parallel mapping.
|
||||
|
||||
### 6.3 `src/production/tree_locator.rs`
|
||||
### 6.3 `crates/vxls-production/src/tree_locator.rs`
|
||||
|
||||
`TreeLocator<N>` (described in §3.2) plus `From<StructureLocator>` /
|
||||
`Into<StructureLocator>` conversions.
|
||||
|
||||
### 6.4 `src/production/request_queue.rs`
|
||||
### 6.4 `crates/vxls-production/src/request_queue.rs`
|
||||
|
||||
A bounded, deduplicating, priority-ordered request queue. It is the durable
|
||||
answer to "the cache re-emits the same request every frame".
|
||||
@@ -429,9 +429,9 @@ Properties:
|
||||
- `ReadyItem::insertion_parent()` builds the `InsertionParent` for the insertion
|
||||
batch from the key and the latest `RequestMeta` (which carries `table_slot`).
|
||||
|
||||
The queue is unit-tested without a GPU (`cargo test production::request_queue`).
|
||||
The queue is unit-tested without a GPU (`cargo test -p vxls-production request_queue`).
|
||||
|
||||
### 6.5 `src/host_production.rs`
|
||||
### 6.5 `crates/vxls/src/host_production.rs`
|
||||
|
||||
An older, simpler trait:
|
||||
|
||||
@@ -444,13 +444,14 @@ pub trait ChunkVoxelProducer {
|
||||
It has no return value and no cache insertion types; it predates the current
|
||||
request/response pipeline.
|
||||
|
||||
### 6.6 `src/tree.rs`
|
||||
### 6.6 `crates/vxls/src/sparse_tree.rs`
|
||||
|
||||
A CPU `NTree<N>` prototype backed by a `HashMap<NTreeLocator<N>, NTreeNode<N>>`,
|
||||
A CPU `NTree<N>` prototype backed by a `HashMap<TreeLocator<N>, NTreeNode>`,
|
||||
with `constant`, `get`, `set`, array conversion, and explicit-structure export.
|
||||
Useful for understanding the tree, not used by the renderer.
|
||||
It also provides the packed `Color` helper and PLY loading. Useful for
|
||||
understanding the tree and used by the playground producers, not by the renderer.
|
||||
|
||||
### 6.7 `src/gi_pipeline.rs` + `sparse_set.rs`
|
||||
### 6.7 `crates/vxls/src/gi_pipeline.rs` + `sparse_set.rs`
|
||||
|
||||
Compiles (declared in `main.rs`) but `VoxelGiPipeline` is never instantiated. It
|
||||
adds `DontTouch` attributes for a leaf list and radiance, and a `GpuSparseSet`
|
||||
@@ -507,15 +508,15 @@ A production-ready producer should additionally:
|
||||
|
||||
| Symptom | Location | Impact | Confidence |
|
||||
|---|---|---|---|
|
||||
| The host request path busy-waits on `device.poll`; production blocks the render thread. | `src/main.rs` (`loop { ... poll ... }` in `render`) | No overlap, frame stalls, no streaming. | High |
|
||||
| `fullfill_request` hardcodes `NTreeNodeLocator<4>`, x/y/z child unpacking with `4` and `16`, and a `+5000` chunk offset. | `src/main.rs:1814-1905` | Not generic; offsets only make sense for the demo terrain. | High |
|
||||
| The demo driver is still synchronous: it downloads, produces, and inserts in one frame. The queue exists but `main.rs` does not schedule through it yet. | `src/main.rs` (`render`), `src/production/request_queue.rs` | No overlap between production and rendering in the demo. The durable contract is ready for an async scheduler. | High |
|
||||
| `page_count_buffer` is set to `request_informations.len()`, which may exceed `CacheInsertionData`'s `max_page_count` (1024) if `max_requests` is raised without resizing. | `src/main.rs` (write of `page_count_buffer`), `CacheInsertionData::new` | Buffer overrun / truncated production. | High |
|
||||
| The host request path busy-waits on `device.poll`; production blocks the render thread. | `crates/vxls/src/main.rs` (`loop { ... poll ... }` in `render`) | No overlap, frame stalls, no streaming. | High |
|
||||
| `fullfill_request` hardcodes `NTreeNodeLocator<4>`, x/y/z child unpacking with `4` and `16`, and a `+5000` chunk offset. | `crates/vxls/src/main.rs:1814-1905` | Not generic; offsets only make sense for the demo terrain. | High |
|
||||
| The demo driver is still synchronous: it downloads, produces, and inserts in one frame. The queue exists but `main.rs` does not schedule through it yet. | `crates/vxls/src/main.rs` (`render`), `crates/vxls-production/src/request_queue.rs` | No overlap between production and rendering in the demo. The durable contract is ready for an async scheduler. | High |
|
||||
| `page_count_buffer` is set to `request_informations.len()`, which may exceed `CacheInsertionData`'s `max_page_count` (1024) if `max_requests` is raised without resizing. | `crates/vxls/src/main.rs` (write of `page_count_buffer`), `CacheInsertionData::new` | Buffer overrun / truncated production. | High |
|
||||
| If `destination_indices[i] == 0xFFFFFFFF`, the producer is not told; the cache will re-request the node later. | `insertion.wgsl`, host callback | Wasted work and repeated requests; no metric for dropped pages. | High |
|
||||
| The external table insertion consumes the same eviction list as the cache insertion; if it inserts fewer roots than requested, the table has missing entries with no host-visible signal. | `VoxelCache::insert`, `fixed_table/insertion.wgsl` | Silent holes in the world. | Medium |
|
||||
| `TerrainGenerator` uses hardcoded mip factor 8 and `depth <= 2` special cases. | `src/producers.rs:207-263,330` | Not robust to different chunk resolutions. | High |
|
||||
| `BallGenerator` implements the old `Producer` trait, not `ChunkedProducer`. | `src/producers.rs:31-116` | Copying it as a template will not work with the current driver. | High |
|
||||
| The `production/` subsystem is compiled but not used by the demo driver. | `src/production.rs`, `src/production/*` | Agents may assume the queue is on the live path; it is the durable target, while `fullfill_request` is still the active playground path. | High |
|
||||
| `src/production/request_queue.rs` is new. | same | Its API may still change; `main.rs` does not depend on it yet. | Medium |
|
||||
| The demo uploads all attribute payloads with `bytemuck::cast_slice` of Rust arrays, so layout mismatches (padding, alignment) are not checked. | `src/main.rs` upload section | Silent corruption if the Rust struct layout diverges from the WGSL/Slang layout. | Medium |
|
||||
| The `+5000` offset plus `chunk_y.abs()` means negative chunk coordinates fold onto positive ones. | `src/main.rs:1785-1789` | Duplicate chunks / visual artifacts at negative y. | Medium |
|
||||
| `TerrainGenerator` uses hardcoded mip factor 8 and `depth <= 2` special cases. | `crates/vxls/src/producers.rs:207-263,330` | Not robust to different chunk resolutions. | High |
|
||||
| `BallGenerator` implements the old `Producer` trait, not `ChunkedProducer`. | `crates/vxls/src/producers.rs:31-116` | Copying it as a template will not work with the current driver. | High |
|
||||
| The `production/` subsystem is compiled but not used by the demo driver. | `crates/vxls-production/src/lib.rs`, `crates/vxls-production/src/*` | Agents may assume the queue is on the live path; it is the durable target, while `fullfill_request` is still the active playground path. | High |
|
||||
| `crates/vxls-production/src/request_queue.rs` is new. | same | Its API may still change; `main.rs` does not depend on it yet. | Medium |
|
||||
| The demo uploads all attribute payloads with `bytemuck::cast_slice` of Rust arrays, so layout mismatches (padding, alignment) are not checked. | `crates/vxls/src/main.rs` upload section | Silent corruption if the Rust struct layout diverges from the WGSL/Slang layout. | Medium |
|
||||
| The `+5000` offset plus `chunk_y.abs()` means negative chunk coordinates fold onto positive ones. | `crates/vxls/src/main.rs:1785-1789` | Duplicate chunks / visual artifacts at negative y. | Medium |
|
||||
|
||||
Reference in New Issue
Block a user