startup: lower the binary16 BVH box node #3032
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3032
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3032"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@lambirou on GitHub · 2026-11-27 09:08 UTC · original
lambirou:startup/bvh-intersect-box16→main· +405 −86 · 3 files · 18 commits · merged 2026-11-27 21:19 UTCWhat 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.
@chadhyatt on GitHub · 2026-11-27 09:58 UTC · original
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
box32/mixed-nosortwitness), and misses use positive infinity rather than FLT_MAX. These are shared with this FP16 extension; I would prefer to land the focused FP32 correction first and have this PR adopt the same semantics.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 on GitHub · 2026-11-27 10:07 UTC · original · reviewed
Review of head
c7a23a1b(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 throughx2w_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 asf16tof32and the box32 maths is reused, which is exact.The check has what a lowering needs:
startup_gfx2hlsl_bvh_dispatch_warp/_hardwarerun the generated HLSL on a node buffer and compare the readback with the CPUreference(...)for both box32 and box16 cases (including the half-node cases), plus the translator-levelstartup_gfx2hlsl_bvh.Ran locally (Linux; no
dxchere, so the dispatch part skips):python3 -B tests/startup_gfx2hlsl_bvh_check.py: all ok.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.(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.
@lambirou on GitHub · 2026-11-27 10:18 UTC · original
Windows receipt on
c7a23a1b(head), maine446b072:Hardware adapter: AMD Radeon RX 9060 XT (
1002:7590, driver32.0.32029.2010). Both WARP and hardware runs report all six FP32 and five binary16 dispatch cases exact; the miss-fill control also passes.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.
@chadhyatt on GitHub · 2026-11-27 10:18 UTC · original
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.
@R0Y00 on GitHub · 2026-11-27 11:30 UTC · original
#3040 has landed on
mainas1c879506. Please rebase or merge the current main into this PR and preserve the descriptor base in 256-byte units, the 48-bit end-exclusive bound, positional misses with sorting disabled, and the +infinity miss key. Please carry the focused controls into the combined box32/box16 run on the new head. The earlier Windows receipt predates those semantics.@lambirou on GitHub · 2026-11-27 14:05 UTC · original
Merged
mainate1ea515dinto this branch. Head is nowb7117d46; the Windows receipt was taken on13167033, and the only later change is a one-line correction to the node count in the experiment note.The binary16 path now shares the #3040 semantics:
uint4(c0, c1, c2, c3)in child slots, with0xfffffffffor a miss;asfloat(0x7f800000u), so the finiteFLT_MAXhit still sorts ahead.The combined check writes four FP32 nodes, four binary16 nodes and 21 rays, and compares the 1232-byte readback. Binary16 bounds are packed as
binary16bytes and 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.Windows receipt on
13167033(dev and release),ctest --preset <dev|release> --no-tests=error -R '^startup_gfx2hlsl_bvh':startup_gfx2hlsl_bvh: pass, both DXC compiles ok.startup_gfx2hlsl_bvh_dispatch_warp: pass, 21/21 cases and 6/6 controls on Microsoft Basic Render Driver1414:008c, driver10.0.26100.10068.startup_gfx2hlsl_bvh_dispatch_hardware: pass, 21/21 cases and 6/6 controls on AMD Radeon RX 9060 XT1002:7590, driver32.0.32029.2010.The earlier Windows receipt predates the #3040 changes; this one is on the new head.
@lambirou on GitHub · 2026-11-27 14:29 UTC · original
@R0Y00 the current
mainmerge and the #3040 descriptor/result semantics are onb7117d46, with the combined 21-case and 6-mutant run green on WARP and on the RX 9060 XT in dev and release. Could you take another look when you have a moment?@lambirou on GitHub · 2026-11-27 15:34 UTC · original
Merged
mainat428c08c1; head is nowaa5c9013.startup_gfx2hlsl_bvhpasses 6/6 in dev and release on WARP and the RX 9060 XT, including the combined box32/box16 dispatch. Windows checks #8206 is running. #3105 (triangle nodes) is stacked on this PR and will be retargeted after it lands.@lambirou on GitHub · 2026-11-27 15:37 UTC · original
Windows checks #8206 completed successfully on
aa5c9013.@R0Y00 on GitHub · 2026-11-27 15:43 UTC · original · requested changes
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
aa5c9013integrated over4a6302eb. Importtranslate_programfromtests/startup_gfx2hlsl_bvh_check.pyand 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 issize=1and the negative issize=0. Also check the upper bound against the decoded extent. This is relevant to the boundary check carried by stacked #3105.@R0Y00 on GitHub · 2026-11-27 15:55 UTC · original
Additional test receipt for the reviewed
aa5c9013integration (tree5556a1f577b2ce890e6a90881cb909d0ca95e753). Builtoffscreen_checkindevandrelease, then ranctest --test-dir <build> --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_bvh'. The existing translator, WARP, and RTX tests passed 3/3 in each build without skips. Existing readbacks and all six mutations passed on both adapters, with the debug layer enabled and no warnings or errors. RTX 4060 Laptop driver32.0.16.1656, Windows26200.9974, SDK/DXC10.0.26100.0. The exact-fit boundary case in the review is an additional compile probe.@lambirou on GitHub · 2026-11-27 16:08 UTC · original
Fixed on
3ac44c28. The size field is now treated as a count minus one everywhere:(node_offset >> 6) + node_units - 1 > word2refuses only when the decoded extent is too short;(offset >> 6) + 1 > word2;(offset >> 6) > word2;x2w_bvh_descriptor_okallowsword2 = 0and keeps the< 0x04000000upper bound.Controls added: exact fits
(node 0x04, size 0),(0x05, 1),(0x0c, 1); too-short(0x05, 0)and(0x0c, 0); largest extent0x03ffffffand 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). It passes on WARP and the RX 9060 XT.The same rule is carried to the triangle helper in #3105 (
070b12de).startup_gfx2hlsl_bvhis 6/6 in dev and release. Windows checks are running on the new head.@lambirou on GitHub · 2026-11-27 16:09 UTC · original
Windows checks #8235 completed successfully on
3ac44c28.@lambirou on GitHub · 2026-11-27 16:12 UTC · original
All three review points are addressed on
3ac44c28: decoded extent in the Python guard and both HLSL helpers,size=0accepted, exact-fit/too-short/upper-bound and boundary-dispatch controls added. Dev and release are 6/6 on WARP and the RX 9060 XT; CI #8235 is green. Could you re-review when you have a moment?@lambirou on GitHub · 2026-11-27 17:31 UTC · original
Merged
mainat63a30dc1; head is nowd2eeb68c. Windows checks #8252 is green, andstartup_gfx2hlsl_bvhremains 6/6 in dev and release on WARP and the RX 9060 XT.@lambirou on GitHub · 2026-11-27 20:40 UTC · original
@R0Y00 the descriptor boundary fix has been on
3ac44c28since 16:08, and the current headd2eeb68conly mergesmain; CI #8252 is green andstartup_gfx2hlsl_bvhremains 6/6 in dev and release on WARP and the RX 9060 XT. The exact-fit(0x04, 0),(0x05, 1),(0x0c, 1)cases and the neighboring too-short negatives are in the combined run. #3105 is stacked on this PR and cannot be rebased until it lands. Could you clear the stale CHANGES_REQUESTED when you get a moment?@R0Y00 on GitHub · 2026-11-27 21:18 UTC · original · approved these changes
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 onaa5c9013.Built
offscreen_checkin Debug and Release/O2, oncf3df832plus #3155 and this exact #3032 head (tree0720ecb04d9db50f7f00a02789ba73336006956a). Ranctest --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 oncf3df832plus #3032 alone. Windows26200.9974, Microsoft Basic Render Driver WARP10.0.26100.9818, RTX 4060 Laptop driver32.0.16.1656, SDK/DXC10.0.26100.0, D3D12 debug layer enabled without diagnostics. Hosted Windows, Linux and gfx1013 checks also passed.