tombox-xshader: decode and translate buffer_load/store_format_d16_x and _d16_hi_x #263
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!263
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/263/head"
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?
@azerioxfr on GitHub · 2026-11-23 08:34 UTC · original
azerioxfr:xshader-mubuf-format-d16→main· +91 −2 · 3 files · 1 commits · closed without mergingLibrary / area: tombox-xshader, MUBUF typed-buffer D16 forms (
hlsl.rstyped-buffer path)Exports changed (exports.txt rows): none
Source of the behaviour: opcodes from
tests/isa_table/gfx1013.txt(MUBUF 0x80, 0x84, 0x26, 0x27). Semantics from the RDNA2 ISA, on the existing typed-buffer path, which declares the element float4 because the view format is not visible (#105).One topic, +91 / -2: 2 lines in
rdna2/mnem.rs, about 50 inhlsl.rs, the rest tests.What was missing
tests/isa_table.rslists these under "mubuf: gfx1013 opcodes not named by the decoder".The change
buffer_load_format_d16_x(0x80)f32tof16(.x)into vdst[15:0]; vdst[31:16] keptbuffer_load_format_d16_hi_x(0x26)buffer_store_format_d16_x/_hi_x(0x84 / 0x27)f16tof32of vdata[15:0] / [31:16], stored as.xThe kept half matches the other D16 loads (LDS, MUBUF byte/short, FLAT). A slot whose element type the translator infers as integer (
tbuf_ty, or an atomic uint slot) refuses the D16 forms explicitly instead of guessing a type, following your answer on #105.Left out: the multi-component forms (
_xy,_xyz,_xyzw, 0x81..0x83 / 0x85..0x87) stay unnamed. The exec harness binds the typed buffer as a single R32_FLOAT channel, so their .y/.z/.w cannot be checked bit-exact.Tests
--release, DXC 1.9.2609)buffer_mubuf_format_d16: four ops over eight values (exact in f16 and ones that need rounding); vdst preloaded with0x5a5aa5a5for the loadsmubuf_format_d16_refuses_integer_slotsbuffer_mubuf(shared harness gainsrun_buf_cases_buf)--test isa_table/--test opcodesx86_64-pc-windows-gnu)missingwith a note@omonkeyz on GitHub · 2026-11-23 14:08 UTC · original
Applied locally on main with your authorship kept (cherry-picked,
8b15fe5); the tombox-xshader suite passes in a sandbox (exec 155/155 on WARP). It ships in the next release; this PR will be closed when that is pushed. Thanks.@omonkeyz on GitHub · 2026-11-25 13:08 UTC · original
Applied on main in
8b15fe5(cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.@SchmashinPrunes on GitHub · 2026-11-24 14:34 UTC · original · requested changes
I checked this on RDNA2 silicon: a gfx1036 iGPU (Ryzen 5 9600X), ROCm/HIP 5.7.1, raw wave32 kernels, so RDNA2, not gfx1013. Each kernel ran twice with identical results, and I compared against the semantics this PR implements (my own port; I didn't run the PR's code).
buffer_load_format_d16_xdoesn't round the wayf32tof16does. I loaded 2,048 32_FLOAT elements: edge values (ties, the fp16 overflow boundary, subnormals, NaNs with payloads) plus random values. The hardware matched the rule this repo already measured for MTBUF d16 on every case (tools/rdna2-hwprobe/README.txt, hlsl/mtbuf.rs):Effect: 1,014 of the 2,048 cases differ from round-to-nearest-even. For example, on hardware:
0xb94fb51agives0x8a7d, where RNE gives0x8a7e;0xfb35c593gives0xfbff, where RNE gives0xfc00;0xffbfffffgives0xfdff, where the canonical NaN is0x7e00.The 8 values in
buffer_mubuf_format_d16don't separate the two rules: 0.1, 1000.5 and 1.0000001 give the same half either way. So the test passes with either one.Suggested fix: reuse the MTBUF d16 conversion for 32-bit float elements, and add cases that need rounding, overflow and NaN.
buffer_store_format_d16_xwidens exactly, and NaN keeps its payload; that matched on all 2,048 cases.The
_hi_xforms (0x26 / 0x27). LLVM 18 doesn't acceptbuffer_load_format_d16_hi_x/buffer_store_format_d16_hi_xfor any gfx10 target, gfx1013 included. Its disassembler reports those encodings as invalid on gfx1013, and they assemble only for GFX9. The repo's gfx1013 table lists them, so one of the two sources is wrong. I didn't run them: an unsupported DS opcode hung this GPU earlier today. It may be safer to leave 0x26/0x27 unnamed until there's a gfx101x source for them.(Measured with an AI assistant, Claude.)
Pull request closed