A translation-only check of the #6623 workaround's form: it fails on
main's OpSelect form (8 such selects) and passes with usel_k, on any
machine, unlike the GPU and interpreter runs that can't see the
KosmicKrisp typing.
AI-assisted: yes
Review on #7595: every NaN input in the BVH semantic tests was 0x7FC00000, so
a usel_k that dropped its mask still passed. A payload NaN in v0.x catches it
on the CPU.
AI-assisted: yes
Native image_bvh_intersect_ray / image_bvh64_intersect_ray on an RX 6800 (gfx1030, AMD 26.11.2, tools/hw_oracle,
308 single-lane rows and 896 lane results, both forms equal) returns the watertight test's raw values scaled by
k = |d[kz]|^3: a hit is k*(T, det, b_i, b_j) and a miss (copysign(inf, k*det), k*det, k*b_i, k*b_j), with the shear
taken from the direction (the supplied inverse direction is not read), t >= 0 tested and no test against t max.
Every zero comes back +0 and every NaN 0xFFC00000; a NaN anywhere in the ray, or an infinite origin, gives
(inf, 1, 0, 0). The tie rule on a zero edge function is RDNA2's own: (tx, ty) = Q - P of the edge in the sheared
frame passes when ty == 0 ? tx < 0 : sign(det) ty > 0, not RADV's.
The triangle branch now computes those words with the shear multiplied through by |d[kz]| (no division), so U, V,
W and det carry |d[kz]|^2, and fixes zero signs and NaN bits with integer selects. Every input the measurement used
is defined SPIR-V (main divided by zero on zero-area triangles and took FSign of NaN). This form gives all 1204
measured results; a shear divided by d[kz] (its zero divisor guarded) gives 1203, all but d.z = +inf, the one row
that separates the two (a fit after the runs). Box nodes and the sort network are unchanged.
test_image_bvh_tri.py expected the normalised words (t/|det|, sign(det), ...) and a miss (inf, 1, 0, 0); it now
expects det and the plane's weight numerators (TRI3 of its quad has det 0.5). One image_bvh site grows from 789 to
809 SPIR-V instructions (3825 to 3913 words).
Co-Authored-By: Claude Opus <noreply@anthropic.com>
The nonzero-base measurement falsifies the earlier mask. The game passes
ptr >> 8 in the descriptor's dword0 (0x10 for a structure at VA 0x1000), and
the |0x30 its shader ORs is only the temporary root-load address. The original
<< 8 is correct at base 0 and at 0x1000; the GPU returns the CPU walker's
children at both. This commit restores the translator and the test fixture to
main and keeps the measured result in docs/bvh.md 7b and the Ray tracing row.
The game's RT shaders build the BVH descriptor base as (ptr & ~0xFF) | 0x30: a
byte address with flags in the low bits, not the 256-byte-unit field the
emulation assumed (base40 << 8). Masking the low byte fixes the address; a
non-zero base moved every node by 256x the flags.
The semantic test now runs the masked-base case (dword0 0x1030 -> base 0x1000,
node at 0x1040) and fails under the old shift. Measured with the first real
core_bvh4 BLAS (docs/bvh.md 7b): header at VA 0, root 0x4CABC; the game RT
shadow CS returns the CPU walker's children in the same order on the RTX 2060.
image_bvh(64)_intersect_ray followed RADV's software path on triangle nodes,
which always reads vertex slots 0, 1, 2 and returns (v, w): RADV builds one
triangle per node. The hardware format packs up to four triangles per node,
and the node type picks the slots: TRI0 (0,1,2), TRI1 (1,3,2), TRI2 (2,3,4),
TRI3 (2,4,0). The type's byte of the triangle-ID word at +60 picks which two
vertex weights come back (bits [1:0] and [3:2]; 0x09 is RADV's v, w). A BVH
with paired leaves therefore traversed TRI1 against the wrong triangle.
Both rules come from AMD GPURT (CalcTriangleCompressionVertexIndices,
SwizzleBarycentrics, TRIANGLE_ID_I/J_SRC_SHIFT), and the public XDXR software
path (Read3Verts, TestXboxBvh4Leaf) agrees with it.
- tests/semantic/test_image_bvh_tri.py: every node type on a hand-built node,
every remap selector pair, the byte per type, selector 3, a zero word
- spirv_mini_interp: OpVectorExtractDynamic and GLSL.std.450 FSign, from the
specifications
- vk_compute_test "bvh": its hand-built triangle nodes now carry the 0x09
triangle ID a builder writes; expected words unchanged
- docs/design.md Ray tracing row, docs/bvh.md 7a, translator docstring
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>