Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/fspx.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ program whose kind 0 is too short for word 4 keeps the code heuristic.
SGPRs (`s[0:1]`, `s4`..`s15`), `M0`, `VCC`, `EXEC` (including inactive lanes across 64 threads) and `SCC` (both 0
and 1) unchanged, and execution resumes cleanly at `+36` bytes. So they are hardware no-ops on RDNA2.
- `tools/fspx_unpack.py` disassembles from the end of the prologue.
- **A 24-byte variant**: some programs of the pipeline library in `shaders.rpf` (`tools/shader_library.py`) carry
only the first two of those words, at words 0 and 3, and their code starts at word 6. `code_range` takes that
form only when both words are literal-bearing VOP3 opcode-0x180 words of the shape `tools/fspx_prologue_probe.py`
checks (second dword `& 0xFFFE0100 == 0x03FE0100`); a program whose words 0, 3 and 6 are all prologue words keeps
the 36-byte form. Counted on the 1.0.2.1 library with an opcode-only check (#583): 50 of 2,684 programs; read
from word 0 they never decode, and with the 24-byte start all 50 disassemble with 0 invalid words and 49
translate and pass `spirv-val` (the other stops at `s_sethalt`). `tests/test_fspx_unpack.py`
(`test_short_prologue`) covers the form and the stricter check.
- **Target.** The programs use `v_dot4_i32_i8` (1,458 times) and `v_dot4c_i32_i8` (25,813 times), which fits the
provider's name (`FSR4_Int8`). `llvm-mc` (LLVM 23.1.5) decodes them for `gfx1011`, `gfx1012`, `gfx1030`, `gfx1031`,
`gfx1033`, `gfx1034` and `gfx1036`, but not for `gfx1010`, `gfx1013` (the target `shader_disasm.py` uses for the
Expand Down
14 changes: 14 additions & 0 deletions tests/test_fspx_unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ def test_code_range(self):
self.assertEqual(fspx_unpack.code_range(program(with_prologue=False)), (0, 12 + 4))
self.assertEqual(fspx_unpack.code_range(program(endpgm=False))[1], None)

def test_short_prologue(self):
# The 24-byte prologue of some pipeline-library programs: hash carriers at words 0 and 3 only, each a VOP3
# opcode-0x180 word with a literal in the form tools/fspx_prologue_probe.py checks, then the code at word 6.
carrier = struct.pack("<III", 0xD5800000, 0x03FE0100, 0x12345678)
code = carrier * 2 + V_MOV * 3 + ENDPGM
self.assertEqual(fspx_unpack.code_range(code), (24, 24 + 12 + 4))
# Only word 0 is a carrier: no prologue.
self.assertEqual(fspx_unpack.code_range(carrier + V_MOV * 6 + ENDPGM)[0], 0)
# Opcode-0x180 words whose second dword is not the literal form: no short prologue.
loose = struct.pack("<III", 0xD5800000, 0x03FF0000, 0x12345678)
self.assertEqual(fspx_unpack.code_range(loose * 2 + V_MOV * 3 + ENDPGM)[0], 0)
# The 36-byte form still wins when word 6 is a prologue word too.
self.assertEqual(fspx_unpack.code_range(program())[0], 36)

def test_unaligned_endpgm_bytes_are_not_the_end(self):
code = prologue() + b"\0\0" + ENDPGM + b"\0\0" + V_MOV + ENDPGM
start, end = fspx_unpack.code_range(code)
Expand Down
Loading