Repository navigation
startup: lower the binary16 BVH box node - #3032
Conversation
|
I am preparing an AI-assisted backport patch from x2w-microlift for three independently reproducible FP32 corrections: encoded descriptor base is in 256-byte units (keep the upper base byte), unsorted hits preserve original child slots (existing One separate FP16-specific point from RDNA2 ISA Table 49: size encodes the number of nodes minus one, so a single-unit binary16 node at offset == size, including size zero/offset zero, is valid. The current two-unit bounds check and shared size-zero refusal need adjustment for box16. I will keep the standalone FP32 patch source-built/title-neutral and avoid runtime binding changes. |
tedin7
left a comment
There was a problem hiding this comment.
Review of head c7a23a1 (a merge of main on top of the code I read; the PR-only diff is the same 3 files) (comment only).
Read the diff of tools/startup/gfx2hlsl.py (85 lines): kind-4 (binary16) box nodes are now lowered through x2w_bvh_box16_slot / x2w_bvh_intersect_box16, with a 64-byte node alignment check (offset & 0x3f), the same descriptor-size rule in 64-byte units, miss compaction, and a separate path for unsorted boxes (the sort network is not reused, with the reason in a comment). The six half values per child are read as f16tof32 and the box32 maths is reused, which is exact.
The check has what a lowering needs: startup_gfx2hlsl_bvh_dispatch_warp / _hardware run the generated HLSL on a node buffer and compare the readback with the CPU reference(...) for both box32 and box16 cases (including the half-node cases), plus the translator-level startup_gfx2hlsl_bvh.
Ran locally (Linux; no dxc here, so the dispatch part skips): python3 -B tests/startup_gfx2hlsl_bvh_check.py: all ok.
- Mutation A: the
lo.zhalf read changed fromh1toh2in the HLSL helper: the Linux part does NOT catch it (HLSL maths only runs in the dispatch test); only the WARP dispatch can. - Mutation B: accepted kinds reduced to
(5,): the translator control fails (StopIteration, no box16 call).
No defect found. It only lacks a Windows receipt on this head: ctest -R "startup_gfx2hlsl_bvh" (dev + release).
AI-assisted; commands listed were executed locally.
|
Windows receipt on Hardware adapter: AMD Radeon RX 9060 XT ( The translator controls and both DXC compiles pass in dev and release. No code changes since the head you reviewed; this is only the requested Windows receipt. |
|
The focused FP32 correction is available in #3040 now. It also checks the 48-bit node-address end-exclusive bound. Portable CPU model/translator checks passed; GPU dispatch remains unverified on this host. |
|
#3040 has landed on |
Adopt the FP32 BVH descriptor unit decode, 48-bit end-exclusive bound, positional unsorted results and positive-infinity miss keys for both box kinds. Binary16 fixtures are packed as half values and share the independent model; dev and release WARP and RX 9060 XT dispatch pass 21 cases plus six mutants.
|
Merged The binary16 path now shares the #3040 semantics:
The combined check writes four FP32 nodes, four binary16 nodes and 21 rays, and compares the 1232-byte readback. Binary16 bounds are packed as Windows receipt on
The earlier Windows receipt predates the #3040 changes; this one is on the new head. |
|
Merged |
|
Windows checks #8206 completed successfully on |
R0Y00
left a comment
There was a problem hiding this comment.
The new descriptor boundary rule treats the encoded size as the number of 64-byte units. The PR's manifest docs specify (size + 1) * 64, consistent with the AMD RDNA 2 ISA, Table 49, which defines the field as a count minus one.
Reproduced on aa5c9013 integrated over 4a6302eb. Import translate_program from tests/startup_gfx2hlsl_bvh_check.py and call it with (node, word2) equal to (0x04, 0), (0x05, 1), and (0x0c, 1). All three currently refuse. In order, these are a binary16 box in a one-unit span, an FP32 box in a two-unit span, and a binary16 box in the last unit of a two-unit span. Each accepts if the advertised extent grows by one unit. In particular, the FP32 case (0x05, 1) was accepted before this PR.
Please use the same decoded extent in the Python guard and both emitted HLSL helpers, including the descriptor validity guard for size=0. Add exact-fit positives and neighboring too-short negatives. For example, at offset zero the FP32 positive is size=1 and the negative is size=0. Also check the upper bound against the decoded extent. This is relevant to the boundary check carried by stacked #3105.
|
Additional test receipt for the reviewed |
Size 0 is a one-unit span, so a binary16 node at offset zero accepts it and an FP32 node needs size 1 at offset zero. Use the decoded extent in the Python guard and both HLSL helpers, with exact-fit, too-short, upper-bound and boundary-dispatch controls.
|
Fixed on
Controls added: exact fits The same rule is carried to the triangle helper in #3105 ( |
|
Windows checks #8235 completed successfully on |
|
All three review points are addressed on |
|
Merged |
|
@R0Y00 the descriptor boundary fix has been on |
R0Y00
left a comment
There was a problem hiding this comment.
Re-reviewed current head d2eeb68c. The decoded count-minus-one extent is now consistent across Python and both HLSL helpers. Exact-fit box16 at offset zero and in the final unit, and exact-fit box32 at offset zero, all translate. The neighboring too-short cases and the above-4-GiB extent are refused. This supersedes my earlier changes-requested review on aa5c9013.
Built offscreen_check in Debug and Release /O2, on cf3df832 plus #3153 and this exact #3032 head (tree 0720ecb04d9db50f7f00a02789ba73336006956a). Ran ctest --test-dir <build> --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_bvh'. Each build passed 3/3 with zero skips, including the WARP and hardware dispatches, four descriptor extent readbacks and the existing mutations. The pure Python and DXC controls also passed on cf3df832 plus #3032 alone. Windows 26200.9974, Microsoft Basic Render Driver WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, SDK/DXC 10.0.26100.0, D3D12 debug layer enabled without diagnostics. Hosted Windows, Linux and gfx1013 checks also passed.
What changed
This is the binary16 slice of
image_bvh_intersect_ray, stacked on the merged FP32 box slice (#2922) and the corrected FP32 semantics from #3040.binary16values at bytes 16..63.f16tof32and reuses the slab test, extent clip, inactive-box rule, descriptor validation and sort rules of the FP32 helper.0xfffffffffor holes, and sorted misses use a positive-infinity key.x2w_bvh_intersect_box16for kind 4 and keeps the samesrv <i> bvh base 0x<base> size 0x<size>manifest line.The node layout follows Mesa 25.1.0 RADV's
radv_bvh_box16_node(MIT). No game files or captures are included.Tests
The combined check writes four FP32 nodes, four binary16 nodes and 21 rays and compares the 1232-byte readback. Binary16 bounds are packed as
binary16and read by the independenttests/gfx1030_bvh_box/bvh_model.py; one bound at 1.1 rounds to 1.099609375 so a ray extent between the two values provesf16tof32is used. Six mutants cover miss filling (box32 and box16), unsorted compaction with a box16 witness, the finite miss key, the low-byte base check and the high-byte base handling.Decoded-extent controls: exact fits
(0x04, 0),(0x05, 1)and(0x0c, 1); too-short(0x05, 0)and(0x0c, 0); the largest extent0x03ffffff; and the above-4-GiB0x04000000. A separate boundary dispatch checks box16 size 0 at offset zero (hit), box16 at offset 64 with size 0 (miss), box32 at offset 128 with size 3 (hit) and size 2 (miss).Passed on
d2eeb68c, dev and release:startup_gfx2hlsl_bvh: pass, both DXC compiles ok.startup_gfx2hlsl_bvh_dispatch_warp: pass, 21/21 cases, 6/6 controls and 4/4 boundary cases on Microsoft Basic Render Driver1414:008c, driver10.0.26100.10068.startup_gfx2hlsl_bvh_dispatch_hardware: pass, 21/21 cases, 6/6 controls and 4/4 boundary cases on AMD Radeon RX 9060 XT1002:7590, driver32.0.32029.2010.The branch is merged with current
main63a30dc1. Windows checks #8252 is green.Limits
This is a translator slice. It does not bind the node buffer on a D3D12 device or establish title behavior. The runtime manifest loader does not yet consume the
bvhbaseline, so a real dispatch is refused rather than bound at a wrong address.Refs #870, #1268, #2922, #3040.
AI-assisted.