Repository navigation
rdna2spirv: an empty BVH box is a miss, not a box that spans everything - #3373
Conversation
15cdb05 to
ec3b305
Compare
ec3b305 to
fade4e4
Compare
|
Tested Method: one box32 node (four child ids, then four Empty boxes (child
NaN bounds (good box
Ray B gives the same sets of hits in a different order. Further native cases:
So on this hardware a single NaN bound doesn't cull a box the ray passes through; an all-NaN box is culled. The "NaN min.x = inactive" rule comes from RADV's software path, not from the hardware instruction.
|
|
Tested fade4e4 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass.
AI-assisted (OpenCode). |
|
Tested #3366 (
This adds an RDNA4 run of the translated code only; the native-hardware data, including the open NaN-bound question, is in the comments by TheMrBeez above. (AI-assisted test run.) |
|
Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE) with a raw hw_oracle kernel:
So the hardware culls an empty box (min > max on any one axis, or all three) and keeps a zero-thickness one, as this PR does. I ran the same 13 boxes through this PR's translation (semantic interpreter, |
|
Tested
So both PRs give the same words for #3366's min > max case on this card. NaN bounds aren't in that fixture, which is where @TheMrBeez saw the two differ.
AI-assisted (Claude Code). Synthetic test shaders only, no game files. |
|
Tested fade4e4 (merged onto main aa2988c) on RTX 3060 (Ampere), driver 617.14, Windows 11, MSVC 14.44, RelWithDebInfo: pass
AI-assisted: this check was run and written with Claude Code (Anthropic) on my machine; the numbers above are its unedited output. |
…ar/far by direction sign (SHADER-650) Native image_bvh_intersect_ray on an RX 6900 XT (gfx1030, tools/hw_oracle, 338 cases) picks each axis's near and far plane by the sign of the inverse direction, takes the inverse direction as given (0 x inf is NaN), reduces the three near and the three far t with NaN skipped (all-NaN is a miss), and sorts by max(tnear, 0) through the network (0,2) (1,3) (0,1) (2,3) (1,2). A lone NaN bound leaves its plane open and an empty box misses without a separate check, so #3373's empty-box test is folded into this rule. The translator now matches all 338 measured cases (main 43). cs_bvh/cs_bvh32 and vk_compute_test expect the scene's NaN box at t = 0, as native gfx1030 returns. tests/semantic/test_image_bvh_box_hw.py holds 241 of the measured cases. docs/design.md Ray tracing row updated; the descriptor base is measured too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SHADER-635 (@zneel's finding). The translated
image_bvh_intersect_rayslab test had no empty-box check: when a box child has min > max on an axis, the interval it derives covers that axis and can overlap the ray, so an inactive element is returned as a hit (and sorted among the real ones).tools/xdxr_bvh.py's_box_testculls it first, so the CPU reference and the translated instruction disagreed.The fix ORs ordered
min > maxchecks on all three axes into the box's hit condition and negates it, so an empty box is a miss. Ordered comparisons leave NaN bounds out of the empty-box decision, as the old code did; NaN-box behaviour is SHADER-650 and is not changed here.tests/semantic/test_image_bvh_box.py(new): synthetic box32 and box16 nodes run through the translator and the mini interpreter; an inverted box whose z slab overlaps the ray, an inverted single axis, a zero-thickness box that must still hit, and an empty child before a real hit. Without the fix the inverted boxes come back in the four child words as hits.Tests:
python -m unittest discover -s tests/semantic -p "test_image_bvh_*.py"— 11 OK;python -I tests/test_xdxr_bvh.py— 33 OK (reference unchanged); four docs tests OK. No game files, no GPU.AI-assisted.