startup: lower triangle nodes in image_bvh_intersect_ray #3105
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!3105
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3105"
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 15:30 UTC · original
lambirou:startup/bvh-intersect-triangle→main· +634 −26 · 8 files · 26 commits · merged 2026-11-27 21:48 UTCWhat changed
This is the triangle-node slice of
image_bvh_intersect_ray, stacked on #3032 (binary16 box node). The triangle change is5640a903; the heada68c9bd3also merges the updated #3032 branch and currentmainso the tests run on the latest base. Rebased onto main after #3032 landed (b2f86a8d).float3vertices at bytes 0..59 and one ID dword at byte 60.iandjtwo bits each, third index(3-i-j)&3) and the Mesa RADV base vertex triple.x2w_bvh_intersect_triangle: the watertight ray/triangle test in binary32, triangle return mode 1{t, det, v, w}, and the miss{+inf, 1, 0, 0}. The instruction does not testray_extentfor triangles.size=0is a one-unit span), and the 48-bit end-exclusive bound applies. Return mode 0 and reserved bits are refused by name.-Gis, matching the runtime.Tests
The check reuses the 119 triangle witnesses in
tests/gfx1030_bvh_box/check.pyand the independent model intests/gfx1030_bvh_box/bvh_model.py(71 unique node images, 476 result words). It covers all four kinds, every ID map byte, edges and vertices, outside/behind rays, zero and negative-zero directions,t=0,extent=0, 1024x scaling both ways, degenerate/malformed nodes, and the box kinds 6 and 7.Decoded-extent controls: exact fits
(0x00, 0)and(0x08, 1), too-short(0x08, 0), largest extent0x03ffffff, above-4-GiB0x04000000, plus a boundary dispatch where a triangle at offset zero with size 0 hits and a triangle at offset 64 with size 0 misses.The dispatch passes on WARP (
1414:008c, driver10.0.26100.10068) and on an AMD Radeon RX 9060 XT (1002:7590, driver32.0.32029.2010), in dev and release, with four mutants (determinant sign, ID shift,uterm, miss words). The existing box32/box16 tests still pass 6/6 in both presets.Windows checks #8253 is green on
a68c9bd3, merged withmain63a30dc1.Limits
This is a translator slice. It does not bind the node buffer on a D3D12 device, does not execute the native gfx1030 probe, and does not establish title behavior. The runtime manifest loader does not yet consume
bvhbase. Return mode 0 is not modelled and is refused; the sort bit is ignored for triangles. Rebased after #3032 landed.Refs #870, #2921, #2922, #3032, #3040.
AI-assisted.
Review update (2026-11-27,
263604fc)JohnConnorNPC's first four requests are addressed; the stack still waits for #3032.
v18..v26) in the generated call, so swapping the threefloat3operands fails the portable check.0x0effffffandx2w_bvh_descriptor_okuses(word3 & 0xfeffffffu) == 0x80000000u. Portable and GPU dispatch cases cover both box kinds with bit 24 set; the triangle helper still requires mode 1.tests/checks/python-linux/startup_gfx2hlsl_bvh_triangle.txtputs the triangle check in the Linux job.(i,j)pairs, kinds 6 and 7 are named instance and procedural, the witnesses are identified as model-derived, and both notes are linked fromdocs/experiments.md.Receipt:
startup_gfx2hlsl_bvhdispatch 23/23 cases and all mutants on WARP and the RX 9060 XT;startup_gfx2hlsl_bvh_triangledispatch covers all 119 witnesses, four mutants and the boundary cases on both adapters;docs_links_check98 files and 591 links;run_checks_fragments_checkpasses. Windows checks #8297 is green on263604fc.Accept the 64-byte triangle node forms (kinds 0..3), decode their four ID maps and base vertex triples, and emit a watertight ray/triangle helper for return mode 1. The helper returns {t, det, v, w} and keeps the 48-bit descriptor rules. 119 CPU witnesses pass bit-for-bit on WARP and the RX 9060 XT in dev and release, with four negative mutations; the existing box tests remain green.@lambirou on GitHub · 2026-11-27 15:34 UTC · original
Head is
004fcd04, stacked on #3032.startup_gfx2hlsl_bvhpasses 6/6 in dev and release on WARP and the RX 9060 XT: box32/box16 plus 119 triangle witnesses and four mutants. Windows checks #8207 is pending. The triangle change itself is5640a903; I will retarget/ rebase after #3032 lands.@lambirou on GitHub · 2026-11-27 15:37 UTC · original
Windows checks #8207 completed successfully on
004fcd04.@lambirou on GitHub · 2026-11-27 16:08 UTC · original
Propagated the decoded-extent rule to this stacked PR on
070b12de: the triangle helper uses(offset >> 6) > word2andx2w_bvh_triangle_descriptor_okallowsword2 = 0with the same< 0x04000000upper bound.Controls: exact fits
(node 0x00, size 0)and(0x08, 1), too-short(0x08, 0), largest extent0x03ffffff, above-4-GiB0x04000000, plus a boundary dispatch where a triangle at offset zero with size 0 hits and a triangle at offset 64 with size 0 misses.startup_gfx2hlsl_bvhis 6/6 in dev and release on WARP and the RX 9060 XT. Windows checks are running on the new head.@lambirou on GitHub · 2026-11-27 16:12 UTC · original
Windows checks #8240 completed successfully on
070b12de.@lambirou on GitHub · 2026-11-27 17:31 UTC · original
Merged the updated #3032 branch and
main63a30dc1; head is nowa68c9bd3. Windows checks #8253 is green, with the same 6/6 dev+release result on WARP and the RX 9060 XT.@JohnConnorNPC on GitHub · 2026-11-27 17:44 UTC · original
Thanks for the careful slice: the witness reuse, the boundary dispatch and the mutants make this easy to follow. I ran
the Linux side at
a68c9bd3:startup_gfx2hlsl_bvh_triangle_check.py,startup_gfx2hlsl_bvh_check.pyandgfx1030_bvh_box/check.py --model-onlyall pass. DXC and GPU weren't available here. A few requests before this isready:
x2w_bvh_intersect_triangle(...)call, soonly the helper text is shared with the translator. The translator controls check the descriptor words, the node and
v32..v35, but not the
origin,directionandinv_dirarguments, which this PR wires up for the first time. WhenI swapped
directionandinv_dirin the triangle call inop_image_bvh_intersect_ray(and, separately, passed thedirection as the origin), both BVH checks stayed green. The dispatch wouldn't see it either. The fixture's v18..v26
hold distinct values, so asserting the three
float3(...)in the call line would cover it. Dispatching the translatedshader once would cover it too.
refuses box return mode 1makes a box node refuse when word 3 has bit 24set. The reference model's
descriptor()sets that bit by default, and all 66 box witnesses use it.bvh_model.intersect()reads the bit only for triangle kinds, and one T# normally covers both node types. Could boxnodes ignore bit 24, in the Python guard and in
x2w_bvh_descriptor_ok? If there's a source that requires it to be 0for boxes, a pointer to it would help.
tests/checks/python-linux/,and the
prctest preset doesn't match it. It passes on Linux without DXC, so atests/checks/python-linux/startup_gfx2hlsl_bvh_triangle.txtwould put it in the Linux job.docs/experiments/startup-gfx2hlsl-bvh-box32.mdstill starts its "Refused by name" list with "Triangle nodes(kinds 0..3)".
docs/experiments.md.may be meant.
dispatch shows the HLSL matches the model, not RDNA 2 hardware.
commits and the merges.
Happy to re-run the Linux checks on a new head.
This comment was AI-assisted.
@KelboLive on GitHub · 2026-11-27 18:54 UTC · original · approved these changes
@lambirou on GitHub · 2026-11-27 19:16 UTC · original
@JohnConnorNPC thanks for the detailed review. Points 1-4 are addressed on
263604fc; point 5 still waits for #3032.float3(F(v18), F(v19), F(v20)), float3(F(v21), F(v22), F(v23)), float3(F(v24), F(v25), F(v26))in the emitted call, so the origin, direction and inverse-direction operands are pinned independently.(vals[3] & 0x0effffff) == 0for boxes, andx2w_bvh_descriptor_okuses(word3 & 0xfeffffffu) == 0x80000000u. Portable controls plus GPU dispatch cases exercise both box kinds with bit 24 set; the triangle helper still requires mode 1.tests/checks/python-linux/startup_gfx2hlsl_bvh_triangle.txtis added, so the Linux job runs the check.(i,j)pairs per kind), names kinds 6/7 as instance and procedural, identifies the 119 witnesses as model-derived, and both notes are linked fromdocs/experiments.md.Local receipt:
startup_gfx2hlsl_bvhdispatch 23/23 plus mutants on WARP and the RX 9060 XT;startup_gfx2hlsl_bvh_trianglecovers 119 witnesses, four mutants and the boundary cases on both adapters;docs_links_check98 files/591 links;run_checks_fragments_checkpasses. Windows checks are running on this head.@lambirou on GitHub · 2026-11-27 19:18 UTC · original
Windows checks #8297 completed successfully on
263604fc.@R0Y00 on GitHub · 2026-11-27 21:20 UTC · original
#3032 is now on
mainas5b145ca9. Please rebuild this branch on currentmainwith the triangle-only delta so the squashed box16 work is not duplicated in the diff. Keep the decoded extent and 48-bit boundary controls alongside the existing triangle witnesses. I’ll recheck the new head.@lambirou on GitHub · 2026-11-27 21:42 UTC · original
#3032 landed on
mainas5b145ca9. I merged currentmain(afe70bd7) into this branch; the head is nowb2f86a8dand the PR is no longer stacked.The conflicts were limited to
tools/startup/gfx2hlsl.py,tests/startup_gfx2hlsl_bvh_check.pyand the box32 experiment note. I kept the triangle lowering plus the box return-mode controls on top of the merged box implementation. No upstream translator or test change outside the BVH section was dropped.Local checks on
b2f86a8d:startup_gfx2hlsl_bvh23/23 dispatch cases and all mutants on WARP;startup_gfx2hlsl_bvh_triangleall 119 witnesses, four mutants and the boundary cases on WARP;docs_links_check109 files and 598 links;run_checks_fragments_checkpasses. Windows checks are running on the new head.@R0Y00 on GitHub · 2026-11-27 21:47 UTC · original · approved these changes
Independently reviewed
b2f86a8dovermainat2b7ebf18. The triangle path's 64-byte records respect the decoded extent from #3032. I checked the box return-mode controls and the triangle readback, ordering, and boundary controls.I built
offscreen_checkfrom source and ranctest --test-dir <build> --no-tests=error -j1 -V -R '^startup_gfx2hlsl_bvh'in Debug and Release (/O2): 6/6 passed in each, with no skips. Both sets exercised WARP 10.0.26100.9818 and an NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.1656) on Windows 11 build 26200.9974. The D3D12 debug layer reported zero errors and warnings. Hosted Windows passed, and the hosted/O2job was skipped. The subsequentmainchange from #3177 adds a separate scene-colour reporting tool and documentation. I verified the current trial merge has identical BVH implementation and test contents.git diff --checkflags extra end-of-file blank lines in three new files. They do not affect runtime or test behavior.