"""image_bvh64_intersect_ray on triangle nodes: the vertex slots each node type reads and the barycentric remap byte. One pixel shader per case runs the instruction on a hand-built 64-byte triangle node and exports the four result words. The node holds a unit quad in slots 0..3, v0 (0,0,0) v1 (1,0,0) v2 (0,1,0) v3 (1,1,0), and a fifth vertex in slot 4 (words 12..14). The ray starts at (x, y, -1) and runs along +z, so t = 1 and k = |d.z|^3 = 1. The result is the hardware's (t*det, det, b_i*det, b_j*det), so dividing by .y gives (t, -, b_i, b_j), and on a miss (copysign(inf, det), det, b_i*det, b_j*det) with the weights of the triangle's plane (docs/design.md, Ray tracing row; measured on RDNA2, tests/semantic/test_image_bvh_tri_hw.py). det is twice the projected area with the sign of the winding: -1 for TRI0..TRI2, wound like v0 v1 v2, and +0.5 for TRI3, wound the other way. Until the measurement the expected words here were the normalised (t/|det|, sign(det), b_i/|det|, b_j/|det|) and a miss (inf, 1, 0, 0); the slots, the remap selectors and the quotients checked are the same. Expected rules (docs/design.md, Ray tracing row; docs/bvh.md 7a): TRI0 reads slots (0,1,2), TRI1 (1,3,2), TRI2 (2,3,4) and TRI3 (2,4,0). Byte `type` of the word at +60 holds two selectors: bits [1:0] for the first weight and [3:2] for the second, where 0/1/2 name the triangle's vertex 0/1/2. The weights below are written by hand and checked against a plain-Python solve of the 2x2 system. The descriptor dword0 is 0x10: the base in 256-byte units (0x1000). The GPU measured this nonzero base against the CPU walker on the real-BVH first call, so this case also pins the `<< 8`, not a masked byte address. python -m unittest tests/semantic/test_image_bvh_tri.py -v """ import re import struct import unittest from support import mrt0_words, translate_lines INF = float("inf") SLOTS = [(0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), (0.5, 2, 0)] NODE = 0x1040 # descriptor base 0x10 (256-byte units) = 0x1000; node id 0x08 | type -> +0x40 def f2u(x): return struct.unpack("