refactor: cleaner request path + raytracing code

This commit is contained in:
2026-11-23 11:32:16 +01:00
parent dd0e102348
commit dd5fdc13b8
20 changed files with 1427 additions and 618 deletions
+13 -10
View File
@@ -81,9 +81,10 @@ Do not change these casually; they are contracts between Rust, WGSL, and Slang.
6. **`N` is overloaded:** Rust `VoxelCache<N>` / `VoxelCacheInsertion<N>` use `N`
as the branching factor; Slang `VoxelCacheParameters<N>` uses `N` as the
attribute count. Read the surrounding type before assuming.
7. **Depth assumptions:** `VoxelTraceStack` holds 5 entries and indexes
`stack[10 - scale_exp/2]`, assuming branching 4 and `chunk_power = 5`.
Changing either breaks tracing silently.
7. **Depth assumptions:** the caller-owned trace stack (`LocalTraceStack`)
holds 5 entries and indexes `entries[10 - scale_exp/2]`, assuming branching
4 and `chunk_power = 5`. Changing either breaks tracing silently. The stack
is caller-owned; the tracer must not depend on where the front-end stores it.
8. **Generated WGSL constants:** `CHILDREN_COUNT`, `PAGE_COUNT`, and attribute
metadata are injected at runtime by `pipelines.rs`. Edit the Rust generator,
not a generated copy.
@@ -116,7 +117,8 @@ Do not change these casually; they are contracts between Rust, WGSL, and Slang.
| Add/change slot allocation or table growth | `crates/vxls-voxel-cache/src/tables.rs` (`DynamicStructureTable`, `SlotAllocator`, `StructureTableCore`) |
| Change structure identity / anchors | `crates/vxls-voxel-cache/src/schema.rs` (`StructureAnchor`, wire structs), `crates/vxls-production/src/request_queue.rs`, `crates/vxls-voxel-cache/src/tables.rs`, `crates/vxls-voxel-cache/src/shaders/common.wgsl`, fixed-table shaders |
| Change ray marching/LOD | `shaders/voxel.slang`, `shaders/voxel_cache.slang`, `shaders/lod_policies.slang` |
| Add a producer | `crates/vxls/src/producers.rs` (interface), `crates/vxls/src/main.rs` (`fullfill_request`), [`docs/pipeline-and-producers.md`](./docs/pipeline-and-producers.md) |
| Add a producer | `crates/vxls/src/producers.rs` (`TreeProducer`), `crates/vxls-production/src/producer.rs` (`Producer`/`ProducedNode`), `crates/vxls-production/src/request_queue.rs`, [`docs/pipeline-and-producers.md`](./docs/pipeline-and-producers.md) |
| Add/change a secondary-ray pass | `shaders/gi.slang` (AO), `shaders/voxel_tracing.slang` (`TraceSettings`, `ITraceStack`), `shaders/bvh.slang` (`max_t`), [`docs/shaders.md`](./docs/shaders.md#81-ao-pass-gislang) |
## Current demo configuration
@@ -125,7 +127,7 @@ VoxelCache<4> branching 64
150_000 pages
1_024 max requests
attributes: color (1 word), normal (3 words), both External
SdfGenerator<4>::new(5) chunk_power 5 => 4^5 = 1024 voxels/axis per chunk cell
TreeProducer<4> source: dragon.txt sparse tree (SdfGenerator is an unused fixture)
20 x 20 x 20 toroidal chunk extent
request buffers: 1024 (cache), 128 (structure table)
```
@@ -145,11 +147,12 @@ The full tables live in the docs. The most important ones:
fulfilment blocks the render thread.
- **Insertion can silently drop pages** (`destination_indices == 0xFFFFFFFF`)
with no signal to the producer.
- **Several modules are not wired in:** `crates/vxls-production/src/*`,
`crates/vxls/src/host_production.rs`, and `VoxelGiPipeline`. Mark them as inactive rather
than treating them as current behaviour.
- **`gi.slang` is a stub** with legacy bindings that do not match the Rust GI
bind group.
- **Several modules are not wired in:** the terrain/ball fixtures and
`VoxelGiPipeline`. Mark them as inactive rather than treating them as current
behaviour. The production request queue and durable producer types are on the
demo's live path.
- **`gi.slang` is a simple AO pass**, not full GI: a few short hemisphere rays
per pixel, no denoiser. It is a secondary-ray smoke test.
- **`fixed_structure_table.slang` is imported but unused**; the active path is
the toroidal wrapper around Rust's `FixedStructureTable`.