refactor: Splitting into crates

This commit is contained in:
2026-11-15 20:36:43 +01:00
parent c13a04c8e2
commit 828806fbc8
68 changed files with 929 additions and 330 deletions
+9 -9
View File
@@ -2,7 +2,7 @@
The project uses two shader languages for two different jobs:
| | Slang (`shaders/*.slang`) | WGSL (`src/voxel_cache/shaders/*.wgsl`) |
| | Slang (`shaders/*.slang`) | WGSL (`crates/vxls-voxel-cache/src/shaders/*.wgsl`) |
|---|---|---|
| Used for | Rendering / ray marching | Cache management passes |
| Compilation | Offline via `slangc`, SPIR-V checked in | Runtime via wgpu |
@@ -10,9 +10,9 @@ The project uses two shader languages for two different jobs:
| Embedded with | `include_spirv_source!` / `include_spirv!` | `include_str!` into a generated module |
| Rust entry point | `main.rs` passthrough shader modules | `pipelines.rs`, `requests.rs`, `eviction.rs`, `tables.rs` |
> **Temporary code:** bind-group and pipeline setup in `src/main.rs` is part of
> **Temporary code:** bind-group and pipeline setup in `crates/vxls/src/main.rs` is part of
> the playground driver. Read shader contracts from the Rust cache/table
> wrappers (`src/voxel_cache/*`) and this document, not from `main.rs` alone.
> wrappers (`crates/vxls-voxel-cache/src/*`) and this document, not from `main.rs` alone.
---
@@ -48,8 +48,8 @@ them; edit the `.slang` source and rebuild.
- `shaders/out/voxel.spv` → entry `ray_march_compute`, workgroup `(16,16,1)`
- `shaders/out/gi.spv` → entry `gi`, workgroup `(16,16,1)`
- Utility shaders are loaded with ordinary `include_spirv!`:
- `shaders/out/radix_sort.spv` in `src/gpu/radix_sort.rs`
- `shaders/out/compaction.spv` in `src/gpu/buffer_compactor.rs`
- `shaders/out/radix_sort.spv` in `crates/vxls-gpu/src/radix_sort.rs`
- `shaders/out/compaction.spv` in `crates/vxls-gpu/src/buffer_compactor.rs`
- `radix_reduce.spv` is built by the Makefile but currently not referenced by
Rust source.
@@ -504,7 +504,7 @@ Do not do this casually. Required changes include:
```sh
make -C shaders # regenerates shaders/out/*.spv
cargo run # wgpu embeds the checked-in SPIR-V at compile time
cargo run -p vxls # wgpu embeds the checked-in SPIR-V at compile time
```
Because SPIR-V is embedded with `include_*!`, changing `.spv` requires a Rust
@@ -518,12 +518,12 @@ Makefile before building.
| Symptom | Location | Impact | Confidence |
|---|---|---|---|
| `voxel.slang` imports `fixed_structure_table` but never uses it. | `shaders/voxel.slang:3` | Misleads readers; increases compile surface. | High |
| `gi.slang` declares legacy bindings (`structure_pool`, `attributes_pool`, request/usage buffers, table buffers) that do not match the GI bind group Rust actually creates. | `shaders/gi.slang:17-45`, `src/main.rs:563-611` | Works only because the mismatched bindings are unused. Any real GI work will hit validation errors. | High |
| `gi.slang` declares legacy bindings (`structure_pool`, `attributes_pool`, request/usage buffers, table buffers) that do not match the GI bind group Rust actually creates. | `shaders/gi.slang:17-45`, `crates/vxls/src/main.rs:563-611` | Works only because the mismatched bindings are unused. Any real GI work will hit validation errors. | High |
| `PixelFootprintLod` demo parameters are hardcoded (100° FOV, 1080 px, threshold 2). | `shaders/voxel.slang:149` | LOD does not follow the window/FOV; resizing the window changes effective LOD. | High |
| `VoxelTraceStack` size and indexing assume `N = 4` and `chunk_power = 5`. | `shaders/voxel_cache.slang:93-96,177,189,257` | Branching/depth changes silently break tracing. | High |
| `fetch_color` / `fetch_normal` hardcode stride 64 and attribute indices 0/1. | `shaders/voxel.slang:68-79` | Cache layout changes break rendering with no compile-time error. | High |
| The child-index and child-mirror arithmetic hardcodes `4` and `16`. | `shaders/voxel_cache.slang:103-108,154-165` | Not generic over branching factor. | High |
| The toroidal tracer walks one unit cell per axis crossing with no empty-chunk skip. | `shaders/toroidal_structure_table.slang:62-101` | Cost scales with traversed grid cells, not just occupied chunks. | Medium |
| `chunk_*` immediate field naming/order differs between Rust (`width, height, alt`) and the table extent (`width, alt, height`). | `src/main.rs:1049-1062`, `shaders/voxel.slang:140` | Hidden because the demo uses 20×20×20; non-cubic extents would mismatch. | Medium |
| `chunk_*` immediate field naming/order differs between Rust (`width, height, alt`) and the table extent (`width, alt, height`). | `crates/vxls/src/main.rs:1049-1062`, `shaders/voxel.slang:140` | Hidden because the demo uses 20×20×20; non-cubic extents would mismatch. | Medium |
| `radix_reduce.spv` is built and checked in but unused. | `shaders/Makefile:1` | Confusing build artifact. | High |
| `voxel.slang` uses `groupshared VoxelTraceStack stacks[256]` but `create_shader_module_passthrough` bypasses wgpu validation. | `shaders/voxel.slang:118`, `src/main.rs:477-498` | Layout/limit errors appear as driver errors, not friendly validation messages. | Medium |
| `voxel.slang` uses `groupshared VoxelTraceStack stacks[256]` but `create_shader_module_passthrough` bypasses wgpu validation. | `shaders/voxel.slang:118`, `crates/vxls/src/main.rs:477-498` | Layout/limit errors appear as driver errors, not friendly validation messages. | Medium |