Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5055432
startup: lower the FP32 box case of image_bvh_intersect_ray
lambirou Nov 26, 2026
2ec454f
startup: keep non-BVH resource manifests from reading a third field
lambirou Nov 26, 2026
34a2c5c
startup: lower binary16 box nodes in image_bvh_intersect_ray
lambirou Nov 26, 2026
c47f598
tests: compile the binary16 BVH helper with DXC
lambirou Nov 26, 2026
1fd5475
tests: dispatch the binary16 BVH helper on WARP
lambirou Nov 26, 2026
cfe00df
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
35a342d
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
94e9029
startup: keep unsorted BVH hits in child order
lambirou Nov 27, 2026
07a60ea
merge the sort-disabled BVH fix into the binary16 slice
lambirou Nov 27, 2026
6d2b778
merge main into the binary16 BVH slice
lambirou Nov 27, 2026
6459442
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
c7a23a1
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
1316703
Merge origin/main into startup/bvh-intersect-box16
lambirou Nov 27, 2026
b7117d4
docs: correct the binary16 node count in the BVH receipt
lambirou Nov 27, 2026
bf0e664
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
aa5c901
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
3ac44c2
startup: treat the BVH descriptor size as a count minus one
lambirou Nov 27, 2026
d2eeb68
Merge remote-tracking branch 'origin/main' into startup/bvh-intersect…
lambirou Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 35 additions & 24 deletions docs/experiments/startup-gfx2hlsl-bvh-box32.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# First `image_bvh_intersect_ray` slice: FP32 box nodes
# First `image_bvh_intersect_ray` slice: FP32 and binary16 box nodes

`tools/startup/gfx2hlsl.py` now lowers the 32-bit `image_bvh_intersect_ray` (RDNA 2 MIMG opcode 230) for
one node form: the 128-byte FP32 box node, kind 5. The result is four child pointers, with `0xffffffff` for a
disabled child or a missed box. The helper performs the four slab tests, clips against `ray_extent`, and sorts
hits by entry distance only when bit 31 of descriptor DWORD 1 is set. With sorting disabled each
result remains in its original child slot, including holes. Sorted misses use a positive-infinity
key so that a valid hit at `FLT_MAX` still precedes them.
the two box-node forms: the 128-byte FP32 node (kind 5) and the 64-byte binary16 node (kind 4). The result is
four child pointers, with `0xffffffff` for a disabled child or a missed box. The helper performs the four slab
tests, clips against `ray_extent`, and sorts hits by entry distance only when bit 31 of descriptor DWORD 1 is
set. With sorting disabled each result remains in its original child slot, including holes. Sorted misses use
a positive-infinity key so that a valid hit at `FLT_MAX` still precedes them.

The node layout is the one in Mesa 25.1.0 `src/amd/vulkan/bvh/bvh.h` (MIT): `children[4]` at bytes 0..15,
`coords[4][2][3]` at 16..111, and four reserved words at 112..127. The slab test follows Mesa
Expand All @@ -15,15 +15,20 @@ stages that sort the four children. A child word of `0xffffffff` is a miss even
The BVH T# fields are RDNA 2 ISA Table 49: base 39:0 (encoded in 256-byte units), reserved 54:40,
box growing 62:55, box sorting 63, size 105:64, triangle return mode 120, big page 123 and type 8 at 127:124.

The binary16 node has the same four child words at bytes 0..15 and four boxes of six binary16 values at
16..63. `f16tof32` widens each bound exactly before the same slab test. The inactive-box marker is still a NaN
in `min.x`.

## Accepted slice

- compute stage only;
- `image_bvh_intersect_ray v[4], v[11], s[4]` with the packed address form (the disassembler prints `v[16:31]`
for the eleven consumed dwords);
- a constant inline T# built by four SGPR constants, type 8, nonzero encoded base, box growing zero,
size at least one 64-byte unit and below 4 GiB, and the node inside that size;
- a constant node pointer whose low three bits are 5, 128-byte aligned and inside the 4 GiB relative
address window; the entire node must fit within the 48-bit absolute address space;
size field (a count minus one in 64-byte units) whose decoded extent covers the node (one unit
for binary16, two for FP32; `size=0` is a one-unit span) and below 4 GiB;
- a constant node pointer whose low three bits are 4 (64-byte aligned) or 5 (128-byte aligned) and inside the
same 4 GiB relative address window; the entire node must fit within the 48-bit absolute address space;
- either value of the sort bit.

The manifest names the node allocation with `srv <i> bvh base 0x<base> size 0x<size>`, using the decoded
Expand All @@ -35,7 +40,7 @@ of this change.

## Refused by name

Triangle nodes (kind 0), 16-bit box nodes (kind 4), every other node kind, `image_bvh64_intersect_ray`, A16,
Triangle nodes (kinds 0..3), every other node kind, `image_bvh64_intersect_ray`, A16,
non-sequential addresses, a pixel or vertex stage, a node pointer that is not a straight-line constant, a T#
loaded at run time, a type other than 8, nonzero box growing, an absolute (zero) base, a size that
does not cover the node, size bits above 4 GiB, a node address that wraps the 48-bit address space,
Expand All @@ -51,25 +56,31 @@ python3 -B tests/startup_gfx2hlsl_bvh_check.py

The translator check compares synthetic nodes and rays against the independently existing binary32
reference in `tests/gfx1030_bvh_box/bvh_model.py`. It checks the sort-bit negative control (word 0
changes from `0x1d` to `0x25`), the three-hit sort-disabled result with its second slot still invalid
(`0x25, 0xffffffff, 0x2d, 0x35`), and the finite `FLT_MAX` hit with infinite extent. It separately checks
the translation, full descriptor literals, and manifest for `0x1000`, `0x1008`, and a base using
the high byte of DWORD 1. The top-of-address-space witness checks a valid node ending at the
48-bit boundary and refuses a node whose start wraps to zero in the independent model, before
binding a resource or emitting a helper. The check also covers the named refusals and the actual
emitted helper's mutation sites. It compiles the translated compute shader with DXC when available;
without DXC it prints `dxc compile: skip` and does not count that compilation as a pass.
changes from `0x1d` to `0x25`), the three-hit FP32 sort-disabled result with its second slot still invalid
(`0x25, 0xffffffff, 0x2d, 0x35`), and the finite `FLT_MAX` hit with infinite extent. The binary16 fixtures
are packed as `binary16` bytes and read back through the same independent model, including a bound at 1.1
that rounds to 1.099609375 so a ray extent between the two values proves `f16tof32` is used. It separately
checks the translation, full descriptor literals, and manifest for `0x1000`, `0x1008`, and a base using
the high byte of DWORD 1, for both node kinds. The top-of-address-space witness checks a valid node ending at
the 48-bit boundary and refuses a node whose start wraps to zero in the independent model, before binding a
resource or emitting a helper. The check also covers the named refusals and the actual emitted helpers'
mutation sites. It compiles the translated compute shader with DXC when available; without DXC it prints
`dxc compile: skip` and does not count that compilation as a pass.

```text
python -B tests/startup_gfx2hlsl_bvh_check.py dispatch <dxc> <offscreen_check> warp
```

The dispatch mode compiles the same emitted helper with a `RWByteAddressBuffer` in place of the
bound `ByteAddressBuffer`, writes synthetic nodes and rays, and compares the four result DWORDs
for every case. Its negative controls remove miss filling, compact the unsorted slots, substitute
`FLT_MAX` for the infinite miss key, reintroduce the erroneous low-byte alignment check, and ignore
the high byte of the encoded base in the zero-base check. Each mutant must change its designated
witness result. This is a reproduction procedure, not a new GPU execution result.
The dispatch mode compiles both helpers with a `RWByteAddressBuffer` in place of the bound
`ByteAddressBuffer`, writes four FP32 nodes, four binary16 nodes and twenty-one rays, and compares the
four result DWORDs for every case (1232-byte readback). All eight sorted FP32 cases, three unsorted FP32
cases, eight sorted binary16 cases (including the rounded bound and both encoded bases) and two unsorted
binary16 cases pass on a Microsoft Basic Render Driver (`1414:008c`, driver `10.0.26100.10068`) and on an
AMD Radeon RX 9060 XT (`1002:7590`, driver `32.0.32029.2010`), in both the dev and release presets. Its
negative controls remove miss filling, compact the unsorted slots, substitute `FLT_MAX` for the infinite
miss key, reintroduce the erroneous low-byte alignment check, and ignore the high byte of the encoded base
in the zero-base check. Each mutant must change its designated witness result; the compact and box16
miss-fill controls use binary16 witnesses.

This is a translator slice. It does not execute the native gfx1030 probe, does not establish the
host binding of the node allocation on a D3D12 device, and does not establish any title behavior.
Loading
Loading