Repository navigation
tests: model the console BVH node set - #2921
Conversation
Add a pure-Python model of image_bvh_intersect_ray for FP32 and binary16 box nodes and triangle nodes. The model covers descriptor and node pointer decoding, box extent clipping, stable nearest-first sorting, watertight triangle tests and the mode-1 numerator results. The model-only witness set has 315 literal cases: 231 node cases (66 FP32 box, 46 binary16 box, 119 triangle) and 84 pointer cases. They cover hits, misses, ties, shared edges, negative zero, NaN, zero directions, disabled children, f16 rounding and permutations. The HIP kernel, the code object and the existing five-ray native case are unchanged. Model-only: python -B tests/gfx1030_bvh_box/check.py --model-only Result: model_witness_cases=315 node=231 pointer=84 mismatches=0
|
Added |
KelboLive
left a comment
There was a problem hiding this comment.
PR #2921 by @lambirou -- tests: model the console BVH node set
What works
- Solid foundational work establishing the 0x100 linear layout in gfx10_layout.h with careful derivation from AMD addrlib
- The linear_mode = 0 constant elegantly extends block_log2() to accept mode 0 without changing the tiled modes switch logic
- supports() check is correct: mode == linear_mode bypasses the block_log2 >= 12 requirement since linear has no tail
- Test infrastructure is excellent -- linear_order_control (expected failure with largest mip first), linear_addrlib (338K element addresses), and the unpadded negative control all add strong coverage
- Documentation accurately restates addrlib's linear mode algorithm in clear, testable terms
Issues
- supports() currently allows block-compressed formats (BC1-BC7) in linear mode via the fallthrough -- BC formats are block-based and don't have linear row semantics; consider gating them out explicitly like 1D does in #2929
- The check script in startup_address_console_check.py builds linear backing bytes from addrlib equations. This is correct but the linear path could break if the hardcoded equations drift from addrlib; a comment linking to the Mesa commit that derives these equations would help
Recommendations
- Good discipline in including the negative control (unpadded rows test) to verify the 256-byte pitch requirement
- Consider adding a TODO or assert in supports() that blocks linear mode for BC formats until explicitly validated against addrlib
Overall
A well-researched, well-tested implementation. The linear layout extension is cleanly separated from tiled modes. Minor concern about BC format handling in linear mode, but the existing refusal behavior is safe. Ready for merge.
R0Y00
left a comment
There was a problem hiding this comment.
Reviewed c59a56f2453ce73196c3a80a54a7f38e9770ded0. I ran python -B tests/gfx1030_bvh_box/check.py --model-only in the integration tree for current main. All 315 model witnesses matched (231 node and 84 pointer cases), and the reversed-sort and zero-fill controls both produced the expected mismatch. The CPU model and source-linked formulas are clearly scoped. Native gfx1030 execution was outside this check. Required Windows CI passed.
|
Independent Linux/Python result on Environment
Commands and raw outputThe counts reproduce, and the new fragment does reach CI before merge: the What the 315 cases pinI injected 23 one-line mutants of 19 of the 21 non-equivalent mutants fail the run: 18 through a named witness mismatch, and M19 through One branch the set never observes
A triangle that hits with a negative dominant component separates the two. Node: kind 0, byte 60 = The same triangle at The other three survivors
What this fixture ties to hardware, and what it does not
Limits
AI-assisted. |
What changed
This adds a pure-Python CPU model of the console BVH node test,
image_bvh_intersect_ray/image_bvh64_intersect_ray, and extends the existing gfx1030 fixture with a model-only witness set.The model covers:
0xfffffffffor misses and absent children.{t_num, t_denom, I_num, J_num}in the triangle return mode,+inf/1/0/0on a miss.(pointer >> 3) << 6from the 40-bit descriptor base in 256-byte units, and the 64-bit absolute form.The node formats and box test follow Mesa RADV's public software emulation (MIT); the triangle test is the watertight formulation RADV uses. No game files or raw captures are included.
Tests
Output:
The 315 cases cover 66 FP32 boxes, 46 binary16 boxes, 119 triangles and 84 pointer decodings, including hits, misses, ties, shared edges, negative zero, NaN vertices, zero direction, disabled children, vertex permutations and the ID byte's high bits. The existing five-ray FP32 assertions still pass.
tests/docs_links_check.pypasses (546 links). The native five-ray GPU fixture was not run here: LLVM 15, LLD 15 and the HIP runtime are unavailable on this host. The HIP kernel and assembly are unchanged.Limits
The model is a reference for a translator, not a translation. Native gfx1030 readback remains pending, and the triangle return mode 0 is outside this slice.
Refs #870, #1268.
AI-assisted.