d3d12_xs tests: check every detiled element and time the 1 MB detile only in optimized builds #323

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

@⁠GDAgent on GitHub · 2026-11-23 19:02 UTC · original
GDAgent:fix/d3d12-tests-detile-timing → main · +7 −1 · 1 files · 1 commits · closed without merging

What

Test only (upload.rs, detile_speed_tests). No runtime change, no exports change.

  • The 20 ms bound of upload::detile_speed_tests::one_megabyte_detiles_on_one_thread_in_a_few_ms applies only when debug_assertions are off, that is in optimized builds, where it still measures the code that ships.
  • The test now checks every destination element against the source bytes at its offset, in every build. A debug run still verifies detile_span, and an optimized run can no longer pass on wrong output (before, the test never looked at the data).

Why

The test times detile_span on a 512x512x4 surface (best of 10) and asserted < 20 ms in every build profile. In a debug build the single-thread detile takes about 6 to 16 ms, so the bound has little margin and fails when the suite runs next to other memory-heavy work. Measured on one machine, 50 runs per row, best of 10 as the test reports it:

Build, load Fails (>= 20 ms) p50 max
debug, idle 0 / 50 13.6 ms 15.8 ms
debug, memory load running beside it 5 / 50 15.1 ms 26.2 ms
release, idle 0 / 50 0.84 ms 1.2 ms
release, same memory load 0 / 50 1.4 ms 7.5 ms

Not touched: dbcount::tests::translated_pixel_shaders_with_uavs_keep_their_source, the other test that fails intermittently in full single-threaded runs. #276 fixes it.

Tests

RDNA2 gfx1032, TOMBOX_REMOVED_EXIT_MS=off, native Windows 11; not run under Proton.

  • cargo test -p d3d12_xs --lib -- --exact upload::detile_speed_tests::one_megabyte_detiles_on_one_thread_in_a_few_ms: 1 passed (debug build, 6.18 ms reported; re-run on the final commit).
  • The same test with --release: 1 passed (1.05 ms reported), measured when the change was written.
  • cargo test -p d3d12_xs --lib -- --test-threads=1: 663 passed, 5 failed, 71 ignored when the change was written; the detile test passed. The five failures are the same as on main on this GPU: three placement tests that fail here (separate PR, the GetResourceAllocationInfo one), the console-DLL fixture test (xs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs, needs a console d3d12_xs.dll), and the intermittent dbcount test that #276 fixes.
  • pr_gate.py --base origin/main: 0 problems.
  • Overlap: no open PR touches the detile test (#277 edits other parts of upload.rs).

Not verified

  • Test-only change; nothing verified in a title.
  • The timing table is from one machine and one memory-load tool; other hosts will differ.
**@⁠GDAgent** on GitHub · 2026-11-23 19:02 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/323) `GDAgent:fix/d3d12-tests-detile-timing` → `main` · +7 −1 · 1 files · 1 commits · closed without merging ## What Test only (`upload.rs`, `detile_speed_tests`). No runtime change, no exports change. - The 20 ms bound of `upload::detile_speed_tests::one_megabyte_detiles_on_one_thread_in_a_few_ms` applies only when `debug_assertions` are off, that is in optimized builds, where it still measures the code that ships. - The test now checks every destination element against the source bytes at its offset, in every build. A debug run still verifies `detile_span`, and an optimized run can no longer pass on wrong output (before, the test never looked at the data). ## Why The test times `detile_span` on a 512x512x4 surface (best of 10) and asserted `< 20 ms` in every build profile. In a debug build the single-thread detile takes about 6 to 16 ms, so the bound has little margin and fails when the suite runs next to other memory-heavy work. Measured on one machine, 50 runs per row, best of 10 as the test reports it: | Build, load | Fails (>= 20 ms) | p50 | max | |---|---:|---:|---:| | debug, idle | 0 / 50 | 13.6 ms | 15.8 ms | | debug, memory load running beside it | 5 / 50 | 15.1 ms | 26.2 ms | | release, idle | 0 / 50 | 0.84 ms | 1.2 ms | | release, same memory load | 0 / 50 | 1.4 ms | 7.5 ms | Not touched: `dbcount::tests::translated_pixel_shaders_with_uavs_keep_their_source`, the other test that fails intermittently in full single-threaded runs. #276 fixes it. ## Tests RDNA2 gfx1032, `TOMBOX_REMOVED_EXIT_MS=off`, native Windows 11; not run under Proton. - `cargo test -p d3d12_xs --lib -- --exact upload::detile_speed_tests::one_megabyte_detiles_on_one_thread_in_a_few_ms`: 1 passed (debug build, 6.18 ms reported; re-run on the final commit). - The same test with `--release`: 1 passed (1.05 ms reported), measured when the change was written. - `cargo test -p d3d12_xs --lib -- --test-threads=1`: 663 passed, 5 failed, 71 ignored when the change was written; the detile test passed. The five failures are the same as on `main` on this GPU: three placement tests that fail here (separate PR, the `GetResourceAllocationInfo` one), the console-DLL fixture test (`xs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs`, needs a console `d3d12_xs.dll`), and the intermittent `dbcount` test that #276 fixes. - `pr_gate.py --base origin/main`: 0 problems. - Overlap: no open PR touches the detile test (#277 edits other parts of `upload.rs`). ## Not verified - Test-only change; nothing verified in a title. - The timing table is from one machine and one memory-load tool; other hosts will differ.
one_megabyte_detiles_on_one_thread_in_a_few_ms asserted a 20 ms bound in
every profile. An unoptimized build needs about 13-15 ms for the 1 MB
detile on one thread, so the bound fails whenever the suite runs next to
other memory-heavy work (5 of 50 debug runs under memory load, worst
26 ms). An optimized build stays below 8 ms under the same load.

The timing bound now applies to optimized builds only, and the test
checks every element of the destination against its source offset in
all builds, so a debug run still verifies detile_span.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:18:46 +00:00
github-bot closed this pull request 2026-11-26 06:18:46 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:49 UTC · original

Applied on main in 282d358 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:49 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/323#issuecomment-7164349160) Applied on main in 282d358 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

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