diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-22 09:22:54 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-22 09:22:54 -0500 |
| commit | 088447e117a973fc5b7ba1e7f021a91181022191 (patch) | |
| tree | 08dfd1eb35a80210ac1e6877f80d751d92a0ab8a /docs/d3d12_command_objects.md | |
| parent | 89b047cd8fab50675a43d76722a6a8a881f55dc2 (diff) | |
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>
Diffstat (limited to 'docs/d3d12_command_objects.md')
| -rw-r--r-- | docs/d3d12_command_objects.md | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index a55c3d964..9fd4027c7 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md | |||
| @@ -371,13 +371,18 @@ vtable pointer of a public object. | |||
| 371 | - **Slot 67** (call at `0x56d9`) is **not** the PC `CreateProtectedResourceSession1`: it takes `(desc, riid, out)` | 371 | - **Slot 67** (call at `0x56d9`) is **not** the PC `CreateProtectedResourceSession1`: it takes `(desc, riid, out)` |
| 372 | with `IID_ID3D12PipelineState`. The DLL's own messages name it `DeserializeComputePipelineStateX`. Its desc is the | 372 | with `IID_ID3D12PipelineState`. The DLL's own messages name it `DeserializeComputePipelineStateX`. Its desc is the |
| 373 | root signature at `+0x00`, then pointer and size pairs for the shader's `FSPX` entries: kind 0 at `+0x08`, kind 1 | 373 | root signature at `+0x00`, then pointer and size pairs for the shader's `FSPX` entries: kind 0 at `+0x08`, kind 1 |
| 374 | at `+0x18`, a copy of the kind-6 program at `+0x28`, and kind 7 at `+0x38` ([fspx.md](fspx.md)). The proxy used to | 374 | at `+0x18`, a copy of the kind-6 program at `+0x28` with its exact size at `+0x30`, and kind 7 at `+0x38` |
| 375 | forward it to the PC method at the same index; it now refuses it (`E_NOTIMPL`). When it fails, the DLL takes | 375 | ([fspx.md](fspx.md)). The proxy used to forward it to the PC method at the same index; it now refuses it |
| 376 | slot 62; its message for that failure calls the fallback "NewBE". | 376 | (`E_NOTIMPL`). When it fails, the DLL takes slot 62; its message for that failure calls the fallback "NewBE". The |
| 377 | Vulkan device's `CreateComputePipelineState` takes the bare kind-6 program from `+0x28` and finds its translated | ||
| 378 | module by `fspx_code_sha256` ([fspx.md](fspx.md), "Build and run-time lookup"), so a mapping of the description onto | ||
| 379 | that call (#1714) resolves; the mapping itself is not on `main`. | ||
| 377 | - **Slot 62** (call at `0x5825`) takes the measured `(D3D12_COMPUTE_PIPELINE_STATE_DESC*, 0, 0, riid, out)`. The PC | 380 | - **Slot 62** (call at `0x5825`) takes the measured `(D3D12_COMPUTE_PIPELINE_STATE_DESC*, 0, 0, riid, out)`. The PC |
| 378 | runtime refuses the DLL's code (`E_FAIL`): it is not a PC shader. The DLL's pipeline function then returns | 381 | runtime refuses the DLL's code (`E_FAIL`): it is not a PC shader. The DLL's pipeline function then returns |
| 379 | `0x8000000d` (`0x4b85`), but the dispatch goes on, records the null pipeline and faults (`0x65ff`), which is where a | 382 | `0x8000000d` (`0x4b85`), but the dispatch goes on, records the null pipeline and faults (`0x65ff`), which is where a |
| 380 | PC device stops. | 383 | PC device stops. The Vulkan device (`LEONIDA_D3D12=vulkan`) takes the container: it hashes the kind-6 bytes of the |
| 384 | `ACCC` part and creates the pipeline from the translated module, for the programs the build translated; others, | ||
| 385 | and a malformed `FSPX` directory, are refused with `E_INVALIDARG`. | ||
| 381 | - **Pipeline slot 11 sizes the compute scratch.** After either path succeeds (slot 67 jumps to `0x5833`), the DLL | 386 | - **Pipeline slot 11 sizes the compute scratch.** After either path succeeds (slot 67 jumps to `0x5833`), the DLL |
| 382 | calls the new pipeline's slot 11 as `(0, 0, &obj)` (`0x586d`); the public `ID3D12PipelineState` ends at slot 8, so | 387 | calls the new pipeline's slot 11 as `(0, 0, &obj)` (`0x586d`); the public `ID3D12PipelineState` ends at slot 8, so |
| 383 | this is a console-only method. On success it reads a dword through `obj`'s slot 3 (`0x5881`), multiplies it by | 388 | this is a console-only method. On success it reads a dword through `obj`'s slot 3 (`0x5881`), multiplies it by |
| @@ -391,8 +396,9 @@ vtable pointer of a public object. | |||
| 391 | - The DLL's 29 shaders are `DXBC` containers with `SFI0`, `ISG1`, `OSG1`, `PSV0`, `RTS0`, `HASH` and `ACCC` parts | 396 | - The DLL's 29 shaders are `DXBC` containers with `SFI0`, `ISG1`, `OSG1`, `PSV0`, `RTS0`, `HASH` and `ACCC` parts |
| 392 | and no `DXIL`. The `ACCC` payload starts with the tag `FSPX` in all 29; the game's own native shaders are `FSSM` | 397 | and no `DXIL`. The `ACCC` payload starts with the tag `FSPX` in all 29; the game's own native shaders are `FSSM` |
| 393 | inside `XBCH` ([design.md](design.md)). `FSPX` is a directory around an uncompressed RDNA2 program and its | 398 | inside `XBCH` ([design.md](design.md)). `FSPX` is a directory around an uncompressed RDNA2 program and its |
| 394 | dispatch state; `tools/fspx_unpack.py` unpacks it for the translator, which takes 13 of the 29 today. The 13 that | 399 | dispatch state; `tools/fspx_unpack.py` unpacks it for the translator, which takes 13 of the 29 today, and |
| 395 | use `v_dot4` instructions are not translated yet ([fspx.md](fspx.md)). | 400 | `make_game.py`'s `shaders` stage does both for the package's DLL. The 13 that use `v_dot4` instructions are not |
| 401 | translated yet ([fspx.md](fspx.md)). | ||
| 396 | 402 | ||
| 397 | **Command list.** The console list is **not** the PC order past `ResourceBarrier`. Each row is backed by the | 403 | **Command list.** The console list is **not** the PC order past `ResourceBarrier`. Each row is backed by the |
| 398 | argument shape at the call and, where marked "run", by the call seen in the run. Rows marked "inferred" fit the | 404 | argument shape at the call and, where marked "run", by the call seen in the run. Rows marked "inferred" fit the |