Tests: cover D3D12.X frame clock events, handles, and statistics #2367

Open
github-bot wants to merge 1 commit from github-bot/gh-2367 into main AGit
Owner

@⁠amazedturnip on GitHub · 2026-11-25 16:48 UTC · original
amazedturnip:xcl/tests-d3d12x-frame-clock-events-and-statistics-014704 → main · +320 −0 · 1 files · 1 commits · open

Add integration tests in crates/xcl/tests/frame_clock.rs covering xcl::hle::d3d12x::frame public contracts not exercised by the inline unit tests: co-scheduled type-0/type-2 events at offset 0, WaitFrameEventX flags (WAIT_ALL, TOKEN_ON_TIMEOUT), ancillary signaled-index reporting (-2, 1, -1), token_in origin refresh, error paths, and activity() counter deltas.

What is in it

  • crates/xcl/tests/frame_clock.rs: add integration tests covering co-scheduled type-0/type-2 events at offset 0, WaitFrameEventX flags (WAIT_ALL, TOKEN_ON_TIMEOUT), ancillary handle signaled-index reporting (-2, 1, -1), token_in origin refresh, ScheduleFrameEventX/WaitFrameEventX/GetFrameStatisticsX error contracts, and activity() counter deltas.

Tested

  • Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc, debug build
  • AMD (AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64), XCL_ADAPTER=radeon): cargo test --workspace -- --test-threads=2 — 1218 passed, 2 failed, 26 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier)
  • Verification / negative control: new test suite — verified 3x deterministic

Not tested

  • retail Xbox Series X|S title (not available on this host)
  • NVIDIA wave32 GPU (not run in this pass; verified on AMD Radeon native wave64)

AI use

  • Antigravity CLI (Gemini 4 Hydrogen (Medium)) assisted with diagnosis, implementation, tests, review, and description; all tests executed locally on AMD Radeon (native wave64).
**@⁠amazedturnip** on GitHub · 2026-11-25 16:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/2367) `amazedturnip:xcl/tests-d3d12x-frame-clock-events-and-statistics-014704` → `main` · +320 −0 · 1 files · 1 commits · open Add integration tests in `crates/xcl/tests/frame_clock.rs` covering `xcl::hle::d3d12x::frame` public contracts not exercised by the inline unit tests: co-scheduled type-0/type-2 events at offset 0, `WaitFrameEventX` flags (`WAIT_ALL`, `TOKEN_ON_TIMEOUT`), ancillary signaled-index reporting (`-2`, `1`, `-1`), `token_in` origin refresh, error paths, and `activity()` counter deltas. **What is in it** - `crates/xcl/tests/frame_clock.rs`: add integration tests covering co-scheduled type-0/type-2 events at offset 0, `WaitFrameEventX` flags (`WAIT_ALL`, `TOKEN_ON_TIMEOUT`), ancillary handle signaled-index reporting (`-2`, `1`, `-1`), `token_in` origin refresh, `ScheduleFrameEventX`/`WaitFrameEventX`/`GetFrameStatisticsX` error contracts, and `activity()` counter deltas. **Tested** - Hardware / OS / Rust: AMD Ryzen 7 9800X3D 8-Core Processor, Windows 11 Pro 10.0.26100 (Build 26100), rustc 1.94.1 (e408947bf 2026-03-25), stable-x86_64-pc-windows-msvc, debug build - AMD (`AMD Radeon(TM) Graphics (driver 32.0.21043.19003, DXC 1.9.2609, native wave64)`, `XCL_ADAPTER=radeon`): `cargo test --workspace -- --test-threads=2` — 1218 passed, 2 failed, 26 ignored (SKIPPED GPU tests: 1 (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), 1 (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), 1 (cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D)); pre-existing upstream/main failures excluded: gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier) - Verification / negative control: new test suite — verified 3x deterministic **Not tested** - retail Xbox Series X|S title (not available on this host) - NVIDIA wave32 GPU (not run in this pass; verified on AMD Radeon native wave64) **AI use** - Antigravity CLI (Gemini 4 Hydrogen (Medium)) assisted with diagnosis, implementation, tests, review, and description; all tests executed locally on AMD Radeon (native wave64).
Add integration tests in crates/xcl/tests/frame_clock.rs pinning co-scheduled type-0/type-2 events, WaitFrameEventX flags (WAIT_ALL, TOKEN_ON_TIMEOUT), ancillary signaled indices (-2, 1, -1), token_in origin refresh, error contracts, and activity() counters.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:29:05 +00:00
Author
Owner

@⁠amazedturnip on GitHub · 2026-11-25 18:27 UTC · original

Acknowledged — the flake was real (reproduced on Radeon, ~1 in 20 runs, and the reviewer confirmed 30/30 on NVIDIA). Fixed by giving ancillary_signaled_indices_and_wait_all the longest accepted interval (66 667 µs) instead of 16 667 µs, so no tick can land between drain_origin() and the first ancillary wait; the frame event can no longer win the WaitForMultipleObjects over the already-signaled ancillary handle at index 1. Verified 40/40 clean runs of the full frame_clock suite plus 30/30 on the failing test.

**@⁠amazedturnip** on GitHub · 2026-11-25 18:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/2367#issuecomment-7170945088) Acknowledged — the flake was real (reproduced on Radeon, ~1 in 20 runs, and the reviewer confirmed 30/30 on NVIDIA). Fixed by giving `ancillary_signaled_indices_and_wait_all` the longest accepted interval (66 667 µs) instead of 16 667 µs, so no tick can land between `drain_origin()` and the first ancillary wait; the frame event can no longer win the WaitForMultipleObjects over the already-signaled ancillary handle at index 1. Verified 40/40 clean runs of the full frame_clock suite plus 30/30 on the failing test.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 18:28 UTC · original

Diff review on 187b863 (crates/xcl/tests/frame_clock.rs): clean integration test coverage, and note @fromthemoonx's 30/30 NVIDIA reproduction on ancillary_signaled_indices_and_wait_all (sig == -2 due to immediate tick race after drain_origin()). Making the test frame interval timing-independent will unblock CI/verification.

**@⁠raylitebull** on GitHub · 2026-11-25 18:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2367#issuecomment-7170963206) Diff review on `187b863` (`crates/xcl/tests/frame_clock.rs`): clean integration test coverage, and note `@fromthemoonx`'s 30/30 NVIDIA reproduction on `ancillary_signaled_indices_and_wait_all` (`sig == -2` due to immediate tick race after `drain_origin()`). Making the test frame interval timing-independent will unblock CI/verification.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 18:56 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 18:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2367#issuecomment-7171604798) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun. Thanks!
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 19:06 UTC · original

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).
suite: 148/3 = the three known baseline failures on this lane (fuzz_validate_and_gpu_2 seed 1003, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed). Targeted run of the new table-limit/UAV-clear/schedule tests: 2 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-25 19:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/2367#issuecomment-7171820428) **Tested**: current PR head merged onto current `origin/main` (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target `x86_64-pc-windows-gnu` run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29). suite: 148/3 = the three known baseline failures on this lane (`fuzz_validate_and_gpu_2` seed 1003, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`). Targeted run of the new table-limit/UAV-clear/schedule tests: 2 passed. **Not tested**: retail titles (no title data on this lane, counts only). **AI use**: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
Author
Owner

@⁠fromthemoonx on GitHub · 2026-11-25 17:16 UTC · original · edited 2026-11-25 19:23 UTC

Rerun on the new head f79a015: fixed on NVIDIA. ancillary_signaled_indices_and_wait_all now passes 40 of 40 alone, and the whole frame_clock file passes 30 of 30. The longer frame interval closes the window found below.

result
cargo test --workspace --no-fail-fast -- --test-threads=4, f79a015 merged onto main 2898511 (clean) 1367 passed, 0 failed, 46 ignored; 25 SKIPPED lines
same at the head f79a015 1341 passed, 1 failed, 46 ignored: a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, from the base bd2ac50; passes on current main, not this PR
cargo test -p xcl --test frame_clock -- --test-threads=4, 30 runs 4 passed, 30 of 30
ancillary_signaled_indices_and_wait_all alone, 40 runs 40 of 40

First run, on 187b863: On NVIDIA / this machine, ancillary_signaled_indices_and_wait_all fails every time (30 of 30): right after drain_origin() the frame event is still pending, so the first ancillary wait returns the frame event (-2) instead of index 1. The other three new tests pass 30 of 30.

Tested: 187b863 (merges cleanly onto main 68a284a). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug.

result
cargo test -p xcl --test frame_clock -- --test-threads=4, 30 runs ancillary_signaled_indices_and_wait_all FAILED 30 of 30; co_scheduled_origin_and_type2_at_offset_zero_both_fire, schedule_wait_and_statistics_error_contracts_and_activity_counters, token_on_timeout_and_token_in_origin_refresh ok 30 of 30
the failing test alone, 10 runs FAILED 10 of 10, frame_clock.rs:195: assert_eq!(sig, 1), left -2, right 1
cargo test --workspace --no-fail-fast -- --test-threads=4 1291 passed, 2 failed, 46 ignored: this test, and a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, which fails on main 68a284a too (3 of 3, reported on #2074, not this PR)

Why: with a scratch probe inserted between drain_origin() and the // Ancillary handle at index 1 is already signaled wait (wait_frame_event_x(…, 0, 0 ms, block, 0, &mut tk)), the probe returned hr 0x0, sig -2, tok 0x1, and that zero-timeout call took 19.8 / 23.7 / 23.8 ms in 3 runs. The test's own wait then returned sig 1 after about 5 µs, and the test passed 3 of 3. So when drain_origin() returns, the next frame event is already due (or becomes signaled inside the next wait). wait_frame_event_x puts the frame event at index 0 of WaitForMultipleObjects, so it wins over the already-signaled ancillary handle. On a machine where no tick lands in that window the test passes, as on your Radeon. Here it never does.

A way to make it independent of timing: give this test a frame interval long enough that no tick can fall between drain_origin() and the wait (for example set_frame_interval_x with a period of several seconds, if it accepts one). The wait needs type 0 to be scheduled (E_INVALIDARG otherwise), so leaving the frame event unscheduled is not an option.

Not tested: a release build, AMD, a title.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the scratch probe, and wrote this report.

**@⁠fromthemoonx** on GitHub · 2026-11-25 17:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/2367#issuecomment-7169270210) · edited 2026-11-25 19:23 UTC **Rerun on the new head `f79a015`: fixed on NVIDIA. `ancillary_signaled_indices_and_wait_all` now passes 40 of 40 alone, and the whole `frame_clock` file passes 30 of 30.** The longer frame interval closes the window found below. | | result | |---|---| | `cargo test --workspace --no-fail-fast -- --test-threads=4`, `f79a015` merged onto `main` `2898511` (clean) | 1367 passed, 0 failed, 46 ignored; 25 `SKIPPED` lines | | same at the head `f79a015` | 1341 passed, 1 failed, 46 ignored: `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, from the base `bd2ac50`; passes on current `main`, not this PR | | `cargo test -p xcl --test frame_clock -- --test-threads=4`, 30 runs | 4 passed, 30 of 30 | | `ancillary_signaled_indices_and_wait_all` alone, 40 runs | 40 of 40 | --- *First run, on `187b863`:* On NVIDIA / this machine, `ancillary_signaled_indices_and_wait_all` fails every time (30 of 30): right after `drain_origin()` the frame event is still pending, so the first ancillary wait returns the frame event (`-2`) instead of index `1`. The other three new tests pass 30 of 30. **Tested:** `187b863` (merges cleanly onto `main` `68a284a`). RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug. | | result | |---|---| | `cargo test -p xcl --test frame_clock -- --test-threads=4`, 30 runs | `ancillary_signaled_indices_and_wait_all` FAILED 30 of 30; `co_scheduled_origin_and_type2_at_offset_zero_both_fire`, `schedule_wait_and_statistics_error_contracts_and_activity_counters`, `token_on_timeout_and_token_in_origin_refresh` ok 30 of 30 | | the failing test alone, 10 runs | FAILED 10 of 10, `frame_clock.rs:195`: `assert_eq!(sig, 1)`, left `-2`, right `1` | | `cargo test --workspace --no-fail-fast -- --test-threads=4` | 1291 passed, 2 failed, 46 ignored: this test, and `a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier`, which fails on `main` `68a284a` too (3 of 3, reported on #2074, not this PR) | **Why:** with a scratch probe inserted between `drain_origin()` and the `// Ancillary handle at index 1 is already signaled` wait (`wait_frame_event_x(…, 0, 0 ms, block, 0, &mut tk)`), the probe returned `hr 0x0, sig -2, tok 0x1`, and that zero-timeout call took 19.8 / 23.7 / 23.8 ms in 3 runs. The test's own wait then returned `sig 1` after about 5 µs, and the test passed 3 of 3. So when `drain_origin()` returns, the next frame event is already due (or becomes signaled inside the next wait). `wait_frame_event_x` puts the frame event at index 0 of `WaitForMultipleObjects`, so it wins over the already-signaled ancillary handle. On a machine where no tick lands in that window the test passes, as on your Radeon. Here it never does. A way to make it independent of timing: give this test a frame interval long enough that no tick can fall between `drain_origin()` and the wait (for example `set_frame_interval_x` with a period of several seconds, if it accepts one). The wait needs type 0 to be scheduled (`E_INVALIDARG` otherwise), so leaving the frame event unscheduled is not an option. **Not tested:** a release build, AMD, a title. **AI use:** Claude Code (Claude Opus 5.5) ran the tests and the scratch probe, and wrote this report.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2367/head:github-bot/gh-2367'
git switch 'github-bot/gh-2367'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2367'
git switch 'github-bot/gh-2367'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2367'
git switch 'github-bot/gh-2367'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2367'
git switch 'main'
git merge --squash 'github-bot/gh-2367'
git switch 'main'
git merge --ff-only 'github-bot/gh-2367'
git switch 'main'
git merge 'github-bot/gh-2367'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.