... | ... | @@ -59,30 +59,61 @@ This is very useful for Vulkan/DXR where you can have multiple acceleration stru |
|
|
|
|
|
## Triangle Node
|
|
|
|
|
|
A triangle node is a BVH node containing triangle data. I have only figured out the encoding for 1 triangle per node, but there are hints that 4 triangles per node are supported.
|
|
|
A triangle node is a BVH node containing triangle data.
|
|
|
|
|
|
| Bytes | Description |
|
|
|
|-------|------------------|
|
|
|
| 00-03 | x0 of triangle 0 |
|
|
|
| 04-07 | y0 of triangle 0 |
|
|
|
| 08-11 | z0 of triangle 0 |
|
|
|
| 12-15 | x1 of triangle 0 |
|
|
|
| 16-19 | y1 of triangle 0 |
|
|
|
| 20-23 | z1 of triangle 0 |
|
|
|
| 24-27 | x2 of triangle 0 |
|
|
|
| 28-31 | y2 of triangle 0 |
|
|
|
| 32-35 | z2 of triangle 0 |
|
|
|
| 60-63 | id of triangle 0 |
|
|
|
| 00-03 | x of vertex 0 |
|
|
|
| 04-07 | y of vertex 0 |
|
|
|
| 08-11 | z of vertex 0 |
|
|
|
| 12-15 | x of vertex 1 |
|
|
|
| 16-19 | y of vertex 1 |
|
|
|
| 20-23 | z of vertex 1 |
|
|
|
| 24-27 | x of vertex 2 |
|
|
|
| 28-31 | y of vertex 2 |
|
|
|
| 32-35 | z of vertex 2 |
|
|
|
| 36-39 | x of vertex 3 |
|
|
|
| 40-43 | y of vertex 3 |
|
|
|
| 44-47 | z of vertex 3 |
|
|
|
| 48-51 | x of vertex 4 |
|
|
|
| 52-55 | y of vertex 4 |
|
|
|
| 56-59 | z of vertex 4 |
|
|
|
| 60-63 | id of triangle 0 or IJ control |
|
|
|
|
|
|
Node pointer input for the intersect instruction:
|
|
|
|
|
|
| Bits | Description |
|
|
|
|-------|-------------|
|
|
|
| 00-01 | triangle id in node (only one triangle in node gets checked?) |
|
|
|
| 00-01 | triangle id in node |
|
|
|
| 02-02 | 0 |
|
|
|
| 03-44 | node id (offset from descriptor base is `64 * node_id`) |
|
|
|
|
|
|
Looks like triangle 1-3 of node $n$ actually overlap with triangle 0 of node $n+1$, so we can use a 64-byte 1-triangle node or a ?-byte multi-triangle node.
|
|
|
Triangle nodes can actually store up to 4 triangles using a total of 5 vertices. The triangle to vertex mapping seems fixed:
|
|
|
|
|
|
| Triangle | Vertices |
|
|
|
|----------|----------|
|
|
|
| 0 | 0, 1, 2 |
|
|
|
| 1 | 1, 3, 2 |
|
|
|
| 2 | 2, 3, 4 |
|
|
|
| 3 | 2, 4, 0 |
|
|
|
|
|
|
(The order of vertices here is such that the winding order is the same for all 4 triangles wrt positive/negative of the denominator returned by the intersect instruction)
|
|
|
|
|
|
Depending on the descriptor the instruction can either return the triangle id (or any 32-bit data really) or compute the IJ of the intersection based on the IJ control word.
|
|
|
|
|
|
The formatting is as follows:
|
|
|
|
|
|
| Triangle 0 | Bits 0-3 | Triangle 1 | bits 8-11 | Triangle 2 | Bits 16-19 | Triangle 3 | Bits 24-27 |
|
|
|
|------------|----------|------------|-----------|------------|------------|------------|------------|
|
|
|
| P012 | 9 | P123 | 6 | P234 | 9 | P024 | 4 |
|
|
|
| P021 | 6 | P132 | 9 | P243 | 6 | P042 | 1 |
|
|
|
| P102 | 8 | P213 | 4 | P324 | 8 | P204 | 6 |
|
|
|
| P120 | 2 | P231 | 1 | P342 | 2 | P240 | 9 |
|
|
|
| P201 | 4 | P312 | 8 | P423 | 4 | P402 | 2 |
|
|
|
| P210 | 1 | P321 | 2 | P432 | 1 | P420 | 8 |
|
|
|
|
|
|
It is unknown what bits 4-7, 12-15, 20-23, 28-31 do, they didn't seem to affect the results of the intersect instruction (which might give us some space for driver info to e.g. deal with winding order).
|
|
|
|
|
|
|
|
|
## Box Node - FP16
|
|
|
|
... | ... | |