Skip to content

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

Open
amazedturnip wants to merge 1 commit into
xcl-dev:mainfrom
amazedturnip:xcl/tests-d3d12x-frame-clock-events-and-statistics-014704
Open

amazedturnip wants to merge 1 commit into
xcl-dev:mainfrom
amazedturnip:xcl/tests-d3d12x-frame-clock-events-and-statistics-014704

Conversation

@amazedturnip

Copy link
Copy Markdown

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

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.
@fromthemoonx

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants