tombox-xshader: 32-bit tbuffer_store partial stores and snorm ties differ from RDNA2 hardware #42
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from omonkeyz/xbox-emulator. Originally posted by SchmashinPrunes on 2026-11-21T18:58:23Z.
While measuring MTBUF d16 on real RDNA2 hardware (gfx1036,
tools/rdna2-hwprobefrom #41), I found that the 32-bittbuffer_store_format_*model disagrees with the hardware in two ways. Both instructions are currently marked verified (on WARP, against the existing model).1. Partial stores write the whole element. A store with fewer components than the format writes every component; the missing ones become 0. The translator (
mtbuf.rs,len = end_bits / 8whenw < nc) writes only the stored components' bytes and leaves the rest untouched. It also refuses sub-byte formats with "writes part of a byte", which the hardware has no trouble with.Hardware, each thread storing (0.25, 0.5, 0.75, 1.0) as fp32. The output buffer starts as 0xAA bytes, so untouched bytes would show as
aa:The translator would produce
40aaaaaafor the first one, for example. Reproduce withtools/rdna2-hwprobe/partial_store32.py.2. snorm stores round halves away from zero. In the 2-bit snorm field (formats 45 and 51), ±0.5 is stored as ±1 on hardware.
pack()usesround()(nearest-even), which gives 0. Wider snorm fields have no reachable exact ties from fp32 inputs, so in practice only the 2-bit field is affected. (Measured via the d16 stores; the conversion stage is shared.)Happy to send a fix PR for both, with WARP tests built against the hardware results, if you'd like the 32-bit path to follow the hardware. I've left it alone in #41 so that PR doesn't change already-verified behaviour.
Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-22T13:20:21Z.
Fixed on main in
b72625c: partial 32-bit tbuffer stores zero-fill the element (len = format bytes), and snorm ties round away from zero. Tests: mtbuf_partial_store_zero_fills_like_rdna2 and mtbuf_snorm2_ties_round_away. Thanks for the hardware measurements!