Commit Graph

5 Commits

Author SHA1 Message Date
6a16ac1436 FSPX lookup: a kind-0 state key next to the code key; ambiguous programs are refused (RT-99 review)
Review on #1911: two containers with the same kind-6 program and different kind-0 entries (32x1x1 and 64x1x1)
translate to different modules but got the same fspx_code_sha256, so both resolved to the same pipeline.

- tools/fspx_unpack.py writes the kind-0 entry as fspx/<name>.state; tools/shader_meta.py records its SHA-256 as
  fspx_state_sha256 next to fspx_code_sha256.
- make_game.py: entries with the same code and state keys must have identical modules, otherwise the FSPX step fails
  naming both programs and drops the index. The same code key with other state keys is allowed.
- runtime: a container or bare payload (kinds 0 and 6 present) matches the code key and then the state key; no match
  is E_INVALIDARG. A bare kind-6 program (slot 67, no kind 0) takes the code key's entries when their modules are
  identical, and is refused with E_INVALIDARG and an "ambiguous" log line when they differ.
- Tests: the review case in tests/test_fspx_shaders_stage.py, shader_library_test and d3d12_fspx_compute_test.
- docs/fspx.md: the two keys and the ambiguous case.

On 1.0.2.1 the 29 kind-6 programs are distinct, so nothing resolved wrongly before: 17 translated entries, 17
distinct code keys, 17 distinct (code, state) pairs, all 17 found from the container and from the bare program.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:28:07 -05:00
7886972a6b Merge upstream main
# Conflicts:
#	docs/d3d12_command_objects.md
2026-11-22 09:48:41 -05:00
088447e117 FSPX programs: translated by the shaders stage, found at run time by their kind-6 bytes (RT-99)
The FidelityFX DLL creates its compute pipelines from FSPX programs (docs/fspx.md): through slot 67 with the bare
kind-6 program, then through slot 62 with the DXBC container whose ACCC part holds the payload. Both ended in
E_INVALIDARG: the layer took only FSSM bytecode, the build never translated the DLL and the index had no key for it.

- make_game.py: the shaders stage unpacks the package's DLL with tools/fspx_unpack.py --disasm into
  <work>/shaders/fspx and translates it into <work>/shaders/spirv/fspx, with the same wave64 mode and fallback
  flags. The step is redone as a whole when the DLL, its tools, llvm-mc or the flags change (fspx_build.json,
  written last) and never makes the game's shaders run again.
- tools/shader_meta.py: an entry of a program without an FSSM blob gets fspx_code_sha256, the SHA-256 of
  fspx/<name>.code.
- runtime/src/shader_library.h: the library also loads <dir>/fspx/index.json and finds entries by
  fspx_code_sha256. compute_program() takes an FSSM program as before, the kind-6 bytes of an ACCC container or of a
  bare FSPX payload, and a bare kind-6 program recognized by its prologue; the directory is parsed with the DLL
  reader's rules and bounds-checked, so a malformed one is refused.
- create_compute: looks the program up by the key of its kind and uses those bytes as the code base.
- Tests: shader_library_test (parsing, malformed directories, lookup, the fspx folder), d3d12_fspx_compute_test
  (PSOs from both forms, a dispatch each, refused inputs) and tests/test_fspx_shaders_stage.py.
- Docs: the lookup in docs/fspx.md; slots 62 and 67 in d3d12_command_objects.md and d3d12_vulkan.md. The size the
  slot-67 description carries at +0x30 is kind 6's own size, read from the DLL's code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:22:54 -05:00
7ffe3a93b4 Translator: v_dot4_i32_i8 and v_dot4c_i32_i8, confirmed on RDNA2 hardware
The 29 FSPX programs of the upscaler DLL use the two signed-byte dot products 27,271 times, all in 13 programs,
and the translator had neither. The rule: the sum of the four products of the sign-extended bytes of two dwords,
plus the third source (v_dot4_i32_i8) or the destination's old value (v_dot4c_i32_i8), modulo 2^32.

Confirmed on gfx1036 with raw kernels through tools/hw_oracle: 10 operand sets, both instructions, both source
orders of the accumulating one. Two modifiers were measured and are refused: clamp saturates to a signed 32-bit
value, and op_sel 2 with op_sel_hi 5 (the 89 words llvm-mc does not decode) exchanges the 16-bit halves of the
second source. The measured words are the tables of tests/semantic/test_alu_dot4_i8.py.

With tools/fspx_unpack.py on version 1.0.2.1: 17 of the 29 programs translate and pass spirv-val, 13 before.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 08:41:38 -05:00
07918ddae6 docs: fspx.md, the FSPX format and what translates
The directory as the DLL's reader (RVA 0x1a20) and pipeline function
(RVA 0x4aa0) use it, with device slot 67's descriptor; kind 0 field by
field, each with how far it was checked (thread-group size measured
against PSV0 in 29/29; wave size, RSRC1 and RSRC2 inferred from the code);
the 36-byte prologue carrying kind 7's hash (29/29); why --mcpu gfx1030;
the 89 VOP3P words llvm-mc rejects; and the per-program translation
status: 13 of 29 translate and pass spirv-val, the 13 that use dot4 do not.
2026-11-22 13:42:04 +01:00