refactor: cleaner request path + raytracing code
This commit is contained in:
+36
-19
@@ -75,11 +75,12 @@ struct LocationPage {
|
||||
```
|
||||
|
||||
The cache never interprets these values; they are copied from insertion data and
|
||||
returned in requests so the producer knows which node is missing. In the demo,
|
||||
`node_id` is an `NTreeNodeLocator` and `anchor` is the toroidal table's world
|
||||
position plus a version word. The anchor is the structure identity, so child
|
||||
requests inherit it from their parent page and producers never need a host-side
|
||||
identity directory. `LocationPage` is 24 bytes.
|
||||
returned in requests so the producer knows which node is missing. On the Rust
|
||||
side, `node_id` is a `StructureLocator` encoded through `TreeLocator<N>`. In the
|
||||
demo the active BVH table uses zeroed anchors; the toroidal table variant uses
|
||||
world position plus a version word. The anchor is the structure identity, so
|
||||
child requests inherit it from their parent page and producers never need a
|
||||
host-side identity directory. `LocationPage` is 24 bytes.
|
||||
|
||||
On the Rust side, `node_id` and `producer_id` are the typed
|
||||
`StructureLocator` and `ProducerId` newtypes (both `#[repr(transparent)]`
|
||||
@@ -294,7 +295,7 @@ correctness requirement.
|
||||
| `insertion_parents` | dense `InsertionParent` per entry |
|
||||
| `destination_indices` | reset to `0xFFFFFFFF` by the validation pass; the insertion pass writes the destination page for accepted entries |
|
||||
| `valid_indices` | filled by the validation pass: compacted indices of valid entries |
|
||||
| `valid_count` | host writes `0`; the validation pass fills the amount of valid entries |
|
||||
| `valid_count` | `CacheInsertionData::upload` writes `0`; the validation pass fills the amount of valid entries |
|
||||
| attribute buffers | dense per-entry attribute payloads |
|
||||
|
||||
Build the layout from a producer payload with
|
||||
@@ -302,12 +303,24 @@ Build the layout from a producer payload with
|
||||
`CacheAttributeInit::External` and come first, `extras` are appended for
|
||||
GPU-only data.
|
||||
|
||||
Upload producer voxels with `CacheInsertionData::write_attributes(&queue, voxels)`.
|
||||
It accepts a slice in `[entry][child]` order (the child order is
|
||||
`x + 4*y + 16*z`), validates that `A::LAYOUT` is an `External` prefix of the
|
||||
cache layout with matching word counts and labels, and writes one buffer per
|
||||
attribute. It returns the entry count to write to `page_count_buffer`. The
|
||||
`DontTouch` attributes after the producer prefix are left untouched.
|
||||
Upload a complete batch with
|
||||
|
||||
```rust
|
||||
let entries: Vec<InsertionEntry<N>> = ...;
|
||||
insertion.upload(&queue, &entries, &voxels)?;
|
||||
```
|
||||
|
||||
`InsertionEntry` bundles the produced page's `InsertionInformation`, its
|
||||
`InsertionParent`, and its `LocationPage`. `voxels` is a slice in
|
||||
`[entry][child]` order (child order is `x + 4*y + 16*z`) and must contain
|
||||
exactly `entries.len() * N^3` elements. `upload` writes the structure, location,
|
||||
and parent arrays, resets `valid_count`, sets `page_count`, and delegates the
|
||||
attribute payloads to `write_attributes`. It does not pre-fill
|
||||
`destination_indices`; both validation shaders reset every entry they process.
|
||||
|
||||
`write_attributes` validates that `A::LAYOUT` matches the cache layout and writes
|
||||
one buffer per attribute. The `DontTouch` attributes after the producer prefix
|
||||
are left untouched.
|
||||
|
||||
`InsertionInformation<N>` is just `children: [ChildInformation; 64]`, where each
|
||||
`ChildInformation` uses the four-state encoding below.
|
||||
@@ -441,7 +454,10 @@ collapse them.
|
||||
`&request_informations[0..count]` and `&request_meta[0..count]`.
|
||||
|
||||
The callback is asynchronous by API, but the demo blocks on it with a
|
||||
`device.poll` loop. See [`pipeline-and-producers.md`](./pipeline-and-producers.md).
|
||||
`device.poll` loop. The callback only ingests the wire requests into the
|
||||
`RequestQueue`; the demo drains produced results and uploads the insertion batch
|
||||
after both request buffers have landed. See
|
||||
[`pipeline-and-producers.md`](./pipeline-and-producers.md).
|
||||
|
||||
### 5.4 What a producer receives
|
||||
|
||||
@@ -449,10 +465,10 @@ For an **internal** request:
|
||||
|
||||
- `node_id` and `anchor` identify the **parent** node.
|
||||
- `children_index` identifies which child is missing.
|
||||
- The producer must generate that child node and emit a `LocationPage` for the
|
||||
child (typically `parent_locator.child(x, y, z)`) with the same anchor.
|
||||
- It must also emit an internal `InsertionParent` carrying the parent page,
|
||||
child index, depth, parent identity, and anchor.
|
||||
- The producer generates that child node as a `ProducedNode`. It does not emit a
|
||||
`LocationPage` or `InsertionParent`: `RequestKey::node_locator::<N>()` names
|
||||
the produced node, and `ReadyItem::insertion_entry()` derives both from the
|
||||
request key.
|
||||
|
||||
For an **external** (structure-table) request:
|
||||
|
||||
@@ -460,8 +476,9 @@ For an **external** (structure-table) request:
|
||||
table currently points.
|
||||
- `node_id` and `children_index` are 0, and `RequestMeta.page_index` is
|
||||
`0xFFFFFFFF`.
|
||||
- The producer must generate a chunk root and emit its `LocationPage` plus an
|
||||
external `InsertionParent` with `producer_id`, `anchor`, and `table_slot`.
|
||||
- The producer generates a chunk root as a `ProducedNode`; the queue derives the
|
||||
root `LocationPage` and an external `InsertionParent` with `producer_id`,
|
||||
`anchor`, and `table_slot`.
|
||||
|
||||
There is no output-order requirement. Each insertion is attached to its parent
|
||||
by its own `InsertionParent`.
|
||||
|
||||
Reference in New Issue
Block a user