refactor: cleaner request path + raytracing code
This commit is contained in:
+20
-17
@@ -93,11 +93,12 @@ Implemented and wired into the running demo:
|
||||
- WGSL cache-management shaders, specialised at runtime with generated
|
||||
constants.
|
||||
- Procedural fixtures (`SdfGenerator`, `TerrainGenerator`, `BallGenerator`) and
|
||||
a blocking host request-fulfilment loop in `main.rs`.
|
||||
a blocking host request-fulfilment loop in `main.rs` built on `RequestQueue`,
|
||||
`Producer`/`ProducedNode`, and `CacheInsertionData::upload`.
|
||||
|
||||
Not wired in: the `production/` subsystem, `tree.rs`, the older
|
||||
`host_production.rs` trait, and `VoxelGiPipeline` (module compiles but is never
|
||||
instantiated). See the module map below.
|
||||
Not wired in: the terrain/ball fixtures, `tree.rs`, and `VoxelGiPipeline`
|
||||
(module compiles but is never instantiated). The demo uses `TreeProducer` and
|
||||
the production subsystem's queue. See the module map below.
|
||||
|
||||
---
|
||||
|
||||
@@ -147,7 +148,9 @@ Both loops share the same request-buffer implementation and host download path.
|
||||
- write position/albedo/normal G-buffers;
|
||||
- update per-page usage timestamps;
|
||||
- increment request counters for missing children.
|
||||
3. **GI pass** (`gi.slang`) — currently a stub that copies albedo.
|
||||
3. **GI / AO pass** (`gi.slang`) — reads the world-space G-buffer, traces a few
|
||||
short hemisphere rays per pixel with `any_hit` and a finite `t_max`, and
|
||||
multiplies albedo by the AO term.
|
||||
4. **Blit / UI** — copy the selected debug texture, draw egui, download a usage
|
||||
histogram for the plot.
|
||||
5. **Encode request gathering** for both the cache and the structure table
|
||||
@@ -202,10 +205,8 @@ Consequences agents should keep in mind:
|
||||
| `crates/vxls-profiler/src/` | Timestamp profiling and memory accounting wrappers | Active infrastructure |
|
||||
| `crates/vxls/src/gi_pipeline.rs` (+ `sparse_set.rs`) | Planned GI pipeline using cache attribute sets | **Compiled but never instantiated** |
|
||||
| `crates/vxls-production/src/lib.rs` | Producer ID, `StructureAnchor` re-export, `Producer`/`ProducedNode` | Compiled; durable contract |
|
||||
| `crates/vxls-production/src/host_production.rs` | Rayon-based `HostRequestHandler` | Compiled; `fullfill` still a stub |
|
||||
| `crates/vxls-production/src/tree_locator.rs` | Compact N-tree locator encoding | Compiled; inactive |
|
||||
| `crates/vxls-production/src/request_queue.rs` | Bounded, deduplicating, priority-ordered request queue | Compiled, unit-tested; not yet on the live async path |
|
||||
| `crates/vxls/src/host_production.rs` | Legacy `ChunkVoxelProducer` trait | **Inactive** |
|
||||
| `crates/vxls-production/src/tree_locator.rs` | Compact N-tree locator encoding | Active via `RequestKey::node_locator` and `TreeProducer` |
|
||||
| `crates/vxls-production/src/request_queue.rs` | Bounded, deduplicating, priority-ordered request queue | Active in the demo driver, unit-tested |
|
||||
| `crates/vxls/src/sparse_tree.rs` | CPU `NTree` prototype, packed color helper and node locator used by producers | Active via `main.rs`/`producers.rs` |
|
||||
|
||||
The workspace uses edition 2024. Crates that use const-generic expressions enable
|
||||
@@ -232,10 +233,12 @@ mantissas to derive tree levels.
|
||||
`scale_exp`, so the tree is effectively spatially indexed by float bit
|
||||
patterns. This is why the tracer can descend without explicit bounding boxes.
|
||||
|
||||
`VoxelTraceStack` in `voxel_cache.slang` is a 5-entry stack indexed by
|
||||
`10 - scale_exp/2`. That hardcodes the maximum supported depth and the
|
||||
branching factor. It also assumes `chunk_power = 5`; changing chunk depth without
|
||||
updating the stack breaks tracing.
|
||||
The trace stack is caller-owned through `ITraceStack`. The local
|
||||
implementation (`LocalTraceStack` in `voxel_tracing.slang`) is a 5-entry stack
|
||||
indexed by `10 - scale_exp/2`. That hardcodes the maximum supported depth and
|
||||
the branching factor. It also assumes `chunk_power = 5`; changing chunk depth
|
||||
without updating the stack breaks tracing. A groupshared-backed implementation
|
||||
is a front-end change and needs no trace-core edits.
|
||||
|
||||
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
|
||||
@@ -300,9 +303,9 @@ demo; the UI plots both a frame timer and a ray-march timer.
|
||||
|---|---|---|---|
|
||||
| Location pages are sized with `size_of::<StructurePage<N>>()` (264 B at N=4) instead of `LocationPage` (28 B). | `crates/vxls-voxel-cache/src/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. | `crates/vxls/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. |
|
||||
| The caller-owned trace stack (`LocalTraceStack`, or a groupshared-backed `ITraceStack`) is 5 entries and indexes `entries[10 - scale_exp/2]`, assuming `N = 4` and `chunk_power = 5`. | `shaders/voxel_tracing.slang`, `shaders/voxel_cache.slang` | 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. |
|
||||
| `gi.slang` is a stub that copies albedo and declares legacy bindings that do not match the Rust GI bind group. | `shaders/gi.slang`, `crates/vxls/src/main.rs` | Works only because the declared bindings are unused; misleading as an example. | High. |
|
||||
| `gi.slang` is a simple AO pass (4 fixed hemisphere rays, no denoiser), not a full GI solution. | `shaders/gi.slang` | Noisy, view-dependent AO; it exists as a secondary-ray smoke test. | High. |
|
||||
| `FixedStructureTable` / `ToroidalStructureTable` naming: the toroidal wrapper delegates to the fixed table, and `fixed_structure_table.slang` is imported but unused by `voxel.slang`. | `crates/vxls-terrain/src/lib.rs`, `shaders/fixed_structure_table.slang`, `shaders/voxel.slang:3` | Readers may look for toroidal logic in the wrong shader/module. | High. |
|
||||
| Several subsystems are present but not wired into the binary (see module map). | `crates/vxls-production/src/*`, `crates/vxls/src/host_production.rs`, `crates/vxls/src/gi_pipeline.rs` | Dead code can be mistaken for current architecture; it does not compile into the binary unless declared. | High. |
|
||||
| `fullfill_request` hardcodes `NTreeNodeLocator<4>` and a `+5000` chunk offset. | `crates/vxls/src/main.rs:1762-1838` | Not generic over the cache branching factor; offsets are demo-specific. | High. |
|
||||
| Several subsystems are present but not wired into the binary (see module map). | `crates/vxls/src/gi_pipeline.rs`, terrain/ball fixtures | Dead code can be mistaken for current architecture; it does not compile into the binary unless declared. | High. |
|
||||
| The demo worker thread still lives in `main.rs`, so scheduling and producer ownership are not reusable. | `crates/vxls/src/main.rs` | Production types are durable; the host service around them is playground code. | Medium. |
|
||||
|
||||
Reference in New Issue
Block a user