diff options
| author | omardev29 <154835571+omardev29@users.noreply.github.com> | 2026-11-22 04:37:35 +0100 |
|---|---|---|
| committer | omardev29 <154835571+omardev29@users.noreply.github.com> | 2026-11-22 04:58:12 +0100 |
| commit | 3da355d29089fdc747483de98b62aaa43ce55e12 (patch) | |
| tree | e1decbcd51df7e877fb3726815a7b5d3f049512a /docs/d3d12_command_objects.md | |
| parent | 4a36bb19979b611f525d027f92e0fefad1626546 (diff) | |
FSR: Xbox backend descriptor, console command-list map, XMemGetWorkingSetStatistics and device slot 67
amd_fidelityfx_upscaler_xbox.dll, measured with Ghidra 12.2 (through REA)
and run by fsr_dispatch_test on PC devices (RTX 2000 Ada and WARP) behind
the Xbox-ABI proxy.
Backend descriptor: the provider's create walks the chain for type
0x01000002, {header, device} with the device at +0x10, and ends in
FFX_API_RETURN_ERROR without it (what RT-3 got with 0x0200000x). With it
the DLL creates its backend through the proxy: device slots 14, 15, 18, 19,
27, 38 and 76 and heap slot 9, at the shapes the PC order and the measured
overrides predict; slot 76 takes the seven CreateCommittedResource
arguments. No earlier test here reached slot 76 or heap slot 9.
Two runtime bugs it found:
- XMemGetWorkingSetStatistics takes (kind, stats*): all seven call sites
pass kind 0x20000001 in ECX and a stack buffer in RDX. The one-argument
shim wrote to address 0x20000001.
- Device slot 67 is a console-only compute-pipeline call (a code blob in its
desc), not the PC CreateProtectedResourceSession1 the proxy forwarded it
to. The proxy now refuses it (E_NOTIMPL).
The context: on the RTX 2000 Ada the create stops at the DLL's HRESULT
check, because the driver refuses its R9G9B9E5_SHAREDEXP texture with
ALLOW_UNORDERED_ACCESS (WARP takes it). The test reports that stop and
retries with one PC stand-in (that texture as R32_UINT). On the context it
records one ffxDispatch into a logging command list that is never executed.
The console command list, from that run and the DLL's recorder (RVA
0x59a0), the same 13 calls on both devices: slots 14, 15, 25 and 26 at
their PC positions, then SetDescriptorHeaps at 32 (PC 28, seen in the run),
SetComputeRootDescriptorTable at 35 (PC 31), ClearUnorderedAccessViewUint
at 53 (PC 49, seen in the run), ExecuteIndirect at 61 (PC 59), and
console-only methods at 85 and 141. 33 and 41 fit SetComputeRootSignature
and SetComputeRootConstantBufferView by shape; the docs mark them inferred.
The logging list forwards only measured slots. The list object also carries
a write cursor and limits (+0x18, +0x28, +0x30) the DLL writes root
arguments and dispatches through while there is room; with the cursor at
the limit every command takes the vtable. These are the fields docs section
3.4 measured in the BVH builder without a meaning.
The dispatch stops at the DLL's compute pipeline: its 29 shaders are DXBC
with an ACCC part (payload tag FSPX) and no DXIL, and the PC runtime
refuses them at slot 62; the dispatch goes on with the null pipeline and
faults, which the test reports as the documented PC limit. Its C++ `throw`
also shows the loader gap: _CxxThrowException finds no image base for a
manually mapped image.
The test's fault report gives the faulting module and RVA, the access, the
C++ throw's ThrowInfo, image base and unwound stack, and the HRESULT the
DLL formatted with the DLL frames that made the failing call.
Docs: d3d12_vulkan.md Appendix A.3 and open question 2,
d3d12_command_objects.md 3.4 and 3.5a, design.md and runtime/README.md.
Diffstat (limited to 'docs/d3d12_command_objects.md')
| -rw-r--r-- | docs/d3d12_command_objects.md | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index a064eb5bd..8dd9fcadb 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md | |||
| @@ -295,10 +295,76 @@ passes a builder-specific object that also implements the interface. The byte of | |||
| 295 | the field meanings and the method at `+0x490` are **Open**. | 295 | the field meanings and the method at `+0x490` are **Open**. |
| 296 | 296 | ||
| 297 | This is the most important compatibility finding on this page. A replacement command list that | 297 | This is the most important compatibility finding on this page. A replacement command list that |
| 298 | implements only the public GCL7/GCL8 vtable is safe for the game's own public calls, but it is | 298 | implements only the public GCL7/GCL8 vtable is **not** safe to hand to `XboxBvhBuilder`'s build path. (Section 3.5a |
| 299 | **not** safe to hand to `XboxBvhBuilder`'s build path. The helper will touch fields the public | 299 | shows it is not safe for console-compiled callers' public calls either: the console list order differs from the PC |
| 300 | order past slot 26.) The helper will touch fields the public | ||
| 300 | object does not define and call `+0x490`, which a public-only vtable does not have. | 301 | object does not define and call `+0x490`, which a public-only vtable does not have. |
| 301 | 302 | ||
| 303 | ### 3.5a The FSR DLL as a second device client | ||
| 304 | |||
| 305 | `amd_fidelityfx_upscaler_xbox.dll` is a second shipped module compiled against the console device, the second | ||
| 306 | measured client of the console **command list** after the BVH builder (section 3.3), and the first one run. It is run | ||
| 307 | by `fsr_dispatch_test` with its measured Xbox backend | ||
| 308 | descriptor ([d3d12_vulkan.md Appendix A.3](d3d12_vulkan.md)), on a PC device behind the Xbox-ABI proxy, and its | ||
| 309 | command recorder (RVA `0x59a0`) was read with Ghidra 12.2 through REA. RVAs are from image base `0x180000000`. The | ||
| 310 | run's command-list calls are the same 13, in the same order, on an RTX 2000 Ada (driver 597.06) and on WARP. | ||
| 311 | |||
| 312 | **Device.** At context creation it calls slots 14, 15, 18, 19, 27, 38 and 76 and heap slot 9, all with the shapes the | ||
| 313 | PC order and the measured overrides predict; slot 76 takes the seven `CreateCommittedResource` arguments. During | ||
| 314 | `ffxDispatch` it adds 16 `CreateRootSignature` and heap slot 10 (the recorder also has a path that calls 24 | ||
| 315 | `CopyDescriptorsSimple`, not taken in this run), plus its two compute-pipeline paths: | ||
| 316 | |||
| 317 | - **Slot 67** (call at `0x56d9`) is **not** the PC `CreateProtectedResourceSession1`: it takes `(desc, riid, out)` | ||
| 318 | with `IID_ID3D12PipelineState` and a console-only desc: the root signature at `+0x00`, two pointers into the DLL | ||
| 319 | with sizes (`0x1c` and `0x14` bytes here) at `+0x08`..`+0x20`, and a copy of a code blob at `+0x28` with its size | ||
| 320 | at `+0x30` (`0x1080` bytes here; most likely the shader's native code). The proxy used to forward it to the PC | ||
| 321 | method at the same index; it now refuses it (`E_NOTIMPL`). When it fails, the DLL takes slot 62. | ||
| 322 | - **Slot 62** (call at `0x5825`) takes the measured `(D3D12_COMPUTE_PIPELINE_STATE_DESC*, 0, 0, riid, out)`. The PC | ||
| 323 | runtime refuses the DLL's code (`E_FAIL`): it is not a PC shader. The DLL's pipeline function then returns | ||
| 324 | `0x8000000d` (`0x4b85`), but the dispatch goes on, records the null pipeline and faults (`0x65ff`), which is where a | ||
| 325 | PC device stops. | ||
| 326 | - The DLL's 29 shaders are `DXBC` containers with `SFI0`, `ISG1`, `OSG1`, `PSV0`, `RTS0`, `HASH` and `ACCC` parts | ||
| 327 | and no `DXIL`. The `ACCC` payload starts with the tag `FSPX` in all 29; the game's own native shaders are `FSSM` | ||
| 328 | inside `XBCH` ([design.md](design.md)). What `FSPX` holds, and whether the existing unpacker and translator can | ||
| 329 | take it, is open; running FSR needs that, not the executable. | ||
| 330 | |||
| 331 | **Command list.** The console list is **not** the PC order past `ResourceBarrier`. Each row is backed by the | ||
| 332 | argument shape at the call and, where marked "run", by the call seen in the run. Rows marked "inferred" fit the | ||
| 333 | shape and the shift around them, but the shape alone does not single the method out: | ||
| 334 | |||
| 335 | | Console slot (offset) | PC slot | Method | Evidence | | ||
| 336 | |---|---|---|---| | ||
| 337 | | 14 (`+0x70`) | 14 | `Dispatch` | the vtable path of the inline dispatch at `0x59a0`; the BVH builder's `Dispatch(1,1,1)` at `+0x70` | | ||
| 338 | | 15 (`+0x78`) | 15 | `CopyBufferRegion` | run: `(resource, 0, resource, …)` | | ||
| 339 | | 25 (`+0xc8`) | 25 | `SetPipelineState` | `(pipeline)` at `0x59a0` | | ||
| 340 | | 26 (`+0xd0`) | 26 | `ResourceBarrier` | run: `(1, barriers)`; the BVH builder's `+0xd0` | | ||
| 341 | | 32 (`+0x100`) | **28** | `SetDescriptorHeaps` | run: `(1, &heap)`, the heap a device-proxy descriptor heap | | ||
| 342 | | 33 (`+0x108`) | **29** | `SetComputeRootSignature` (inferred) | one pointer argument, the first call at `0x59a0` (null in the run, where pipeline creation had failed) | | ||
| 343 | | 35 (`+0x118`) | **31** | `SetComputeRootDescriptorTable` | `(index, heap GPU start + offset)` at `0x59a0` | | ||
| 344 | | 41 (`+0x148`) | **37** | `SetComputeRootConstantBufferView` (inferred) | `(index, 64-bit GPU VA from the constant allocator)` at `0x6738`; the root SRV/UAV setters take the same shape | | ||
| 345 | | 53 (`+0x1a8`) | **49** | `ClearUnorderedAccessViewUint` | run: `(GPU handle, CPU handle, resource, …)` | | ||
| 346 | | 61 (`+0x1e8`) | **59** | `ExecuteIndirect` | `(signature, 1, argument buffer, offset, null, 0)` at `0x59a0` | | ||
| 347 | | 85 (`+0x2a8`) | — | console only | run: `(stack pointer, 0, 0)`, twice per dispatch | | ||
| 348 | | 141 (`+0x468`) | — | console only | `(2, GPU VA, size, n)` at `0x65f8`: binds a buffer the DLL names `FFX_XBox_ComputeScratch` | | ||
| 349 | |||
| 350 | So the console list has four more methods than the PC list between `ResourceBarrier` (26) and `SetDescriptorHeaps` | ||
| 351 | (console 32), and two fewer between `ClearUnorderedAccessViewUint` (console 53) and `ExecuteIndirect` (console 61). | ||
| 352 | Mapping the console list as "PC plus a constant" is wrong. The BVH builder's `+0x490` (slot 146) is also past the | ||
| 353 | end of the PC list, like 141. | ||
| 354 | |||
| 355 | **The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch | ||
| 356 | call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room, | ||
| 357 | it writes the command into that buffer itself instead of calling: a root argument is a header word from the | ||
| 358 | per-root-parameter table at `+0x344` and then the value (32 bits for a descriptor table, 64 for the slot-41 GPU VA), | ||
| 359 | a dispatch four words (`0x4002c400`, or `(flag | 0x1000ba00) << 2`, then x, y, z). | ||
| 360 | It sets a flag byte at `+0x140`, stores a flag at `+0x141` from the | ||
| 361 | pipeline, and copies 32 bytes of the pipeline object (from its `+0x10`) to `+0x544`. These are the fields | ||
| 362 | section 3.4 measured in the BVH builder's helper without a meaning (`+0x18`, `+0x30`, `+0x140`, `+0x344`, `+0x544`). | ||
| 363 | **With the cursor at the limit, every command goes through the vtable**: that is how `fsr_dispatch_test` records | ||
| 364 | them, and it is the simplest contract for a layer that does not want to decode these packets. Whether the game's | ||
| 365 | executable makes the same check before writing is unknown until it is available; it is compiled against the same | ||
| 366 | console headers. | ||
| 367 | |||
| 302 | ### 3.5 What the package does not measure | 368 | ### 3.5 What the package does not measure |
| 303 | 369 | ||
| 304 | There is no shipped client for `ID3D12CommandQueue`, `ID3D12Fence`, `ID3D12CommandAllocator`, | 370 | There is no shipped client for `ID3D12CommandQueue`, `ID3D12Fence`, `ID3D12CommandAllocator`, |