Verify RGBA8 render-target readback from a launched D3D12 guest #59

Closed
github-bot wants to merge 1 commit from gh-pr/59/head into gh-pr/59/base
Owner

@⁠philip-roy-jones on GitHub · 2026-11-21 21:56 UTC · original
philip-roy-jones/graphics-guest-readback → main · +231 −0 · 2 files · 1 commits · closed without merging

Library / area: d3d12_xs and the mdbg title launcher. Adds a source-built x64 guest and its runner under tools/verify/.

Exports changed (exports.txt rows): None. The guest imports the existing D3D12XboxCreateDevice export from the staged d3d12_xs.dll.

Source of the behaviour: The guest uses the Scarlett command-list creation, descriptor handle, clear and copy signatures from device_wrap.rs, heap_wrap.rs and cmdlist_wrap.rs. It clears a 4×4 R8G8B8A8_UNORM target, transitions it to COPY_SOURCE, copies it into a readback buffer with a 256-byte row pitch, waits for fence value 1, then maps the four bytes at (2,1). Direct3D 12 readback documentation

Windows x64 verification

Tested with MSVC Rust 1.100.0 and Windows SDK 10.0.26100.0. The guest build uses an x64 Visual Studio developer shell.

Baseline on upstream main (0fc72956f9ff742a275534c27d9e5a7a9886a0c3)

git fetch origin main
git rev-parse HEAD origin/main FETCH_HEAD
$env:TOMBOX_DXC = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxc.exe'
cargo build --locked -p d3d12_xs
cargo test --locked -p d3d12_xs

The clean build passed with compat-common/backend_data absent. Main already gates that dependency, so the historical 28-file failure in #31 did not reproduce. The unfiltered unit suite had 408 passes, 2 failures and 37 ignored tests.

Branch (7752a682e0ac1bdf39d0c109a850aa3fbc8417a3, same SDK and DXC)

python tools/verify/run_d3d12_guest.py
dumpbin /nologo /imports target/d3d12-guest-f1_bkbkp/d3d12_guest.exe
cargo test --locked -p d3d12_xs
cargo test --locked -p d3d12_xs -- --skip centroid_bind::tests::lowered_pixel_shader_compiles_with_fxc_in_both_variants --skip pso_ext::ps::tests::per_sample_iteration_runs_the_translated_ps_once_per_sample_like_ps_iter_sample
git diff --check origin/main...HEAD

The xhost --load-only diagnostic in #12 covers DLL loading. This runner builds the DLL, the tracer and the guest, then launches a fresh guest process for each color. Both runs selected Microsoft Basic Render Driver (1414:008c) through the runtime's default adapter path. The compatibility logs recorded the same device adapter LUID (0x136f5), a wrapped command list and CopyTextureRegionX. The import table identified d3d12_xs.dll!D3D12XboxCreateDevice as the guest's only graphics import.

Guest clear Guest PID Expected RGBA Mapped RGBA at (2,1) Child EXIT_PROCESS
Red 10344 ff 00 00 ff ff 00 00 ff 0
Green 16620 00 ff 00 ff 00 ff 00 ff 0

In an isolated copy I forced the clear arguments to {1.f, 0.f, 0.f, 1.f} and reran python tools/verify/run_d3d12_guest.py. Red passed. The green guest measured ff 00 00 ff, exited 1, and the runner exited 1.

The unfiltered crate suite reproduced both baseline failures. FXC rejected uint64_t in lowered_pixel_shader_compiles_with_fxc_in_both_variants. The per-sample pixel-shader test counted 4,160 base invocations against an expected 4,096. Filtering those two tests passed 408 unit tests and both process-debug integration tests. git diff --check passed.

  • cargo test -p d3d12_xs passes (two failures on both the baseline and branch, detailed above).
  • No game or console files and no binaries included.
  • No fake success. The runner requires the mapped bytes and the child's successful exit event.
**@⁠philip-roy-jones** on GitHub · 2026-11-21 21:56 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/59) `philip-roy-jones/graphics-guest-readback` → `main` · +231 −0 · 2 files · 1 commits · closed without merging **Library / area:** `d3d12_xs` and the `mdbg` title launcher. Adds a source-built x64 guest and its runner under `tools/verify/`. **Exports changed (exports.txt rows):** None. The guest imports the existing `D3D12XboxCreateDevice` export from the staged `d3d12_xs.dll`. **Source of the behaviour:** The guest uses the Scarlett command-list creation, descriptor handle, clear and copy signatures from `device_wrap.rs`, `heap_wrap.rs` and `cmdlist_wrap.rs`. It clears a 4×4 `R8G8B8A8_UNORM` target, transitions it to `COPY_SOURCE`, copies it into a readback buffer with a 256-byte row pitch, waits for fence value 1, then maps the four bytes at (2,1). [Direct3D 12 readback documentation](https://learn.microsoft.com/en-us/windows/win32/direct3d12/readback-data-using-heaps) ### Windows x64 verification Tested with MSVC Rust 1.100.0 and Windows SDK 10.0.26100.0. The guest build uses an x64 Visual Studio developer shell. **Baseline on upstream main** (`0fc72956f9ff742a275534c27d9e5a7a9886a0c3`) ```powershell git fetch origin main git rev-parse HEAD origin/main FETCH_HEAD $env:TOMBOX_DXC = 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64\dxc.exe' cargo build --locked -p d3d12_xs cargo test --locked -p d3d12_xs ``` The clean build passed with `compat-common/backend_data` absent. Main already gates that dependency, so the historical 28-file failure in #31 did not reproduce. The unfiltered unit suite had 408 passes, 2 failures and 37 ignored tests. **Branch** (`7752a682e0ac1bdf39d0c109a850aa3fbc8417a3`, same SDK and DXC) ```powershell python tools/verify/run_d3d12_guest.py dumpbin /nologo /imports target/d3d12-guest-f1_bkbkp/d3d12_guest.exe cargo test --locked -p d3d12_xs cargo test --locked -p d3d12_xs -- --skip centroid_bind::tests::lowered_pixel_shader_compiles_with_fxc_in_both_variants --skip pso_ext::ps::tests::per_sample_iteration_runs_the_translated_ps_once_per_sample_like_ps_iter_sample git diff --check origin/main...HEAD ``` The `xhost --load-only` diagnostic in #12 covers DLL loading. This runner builds the DLL, the tracer and the guest, then launches a fresh guest process for each color. Both runs selected Microsoft Basic Render Driver (`1414:008c`) through the runtime's default adapter path. The compatibility logs recorded the same device adapter LUID (`0x136f5`), a wrapped command list and `CopyTextureRegionX`. The import table identified `d3d12_xs.dll!D3D12XboxCreateDevice` as the guest's only graphics import. | Guest clear | Guest PID | Expected RGBA | Mapped RGBA at (2,1) | Child EXIT_PROCESS | | --- | ---: | --- | --- | ---: | | Red | 10344 | `ff 00 00 ff` | `ff 00 00 ff` | 0 | | Green | 16620 | `00 ff 00 ff` | `00 ff 00 ff` | 0 | In an isolated copy I forced the clear arguments to `{1.f, 0.f, 0.f, 1.f}` and reran `python tools/verify/run_d3d12_guest.py`. Red passed. The green guest measured `ff 00 00 ff`, exited 1, and the runner exited 1. The unfiltered crate suite reproduced both baseline failures. FXC rejected `uint64_t` in `lowered_pixel_shader_compiles_with_fxc_in_both_variants`. The per-sample pixel-shader test counted 4,160 base invocations against an expected 4,096. Filtering those two tests passed 408 unit tests and both process-debug integration tests. `git diff --check` passed. - [ ] `cargo test -p d3d12_xs` passes (two failures on both the baseline and branch, detailed above). - [x] No game or console files and no binaries included. - [x] No fake success. The runner requires the mapped bytes and the child's successful exit event.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:08:48 +00:00
github-bot closed this pull request 2026-11-26 06:08:48 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.