Frame clock: a schedule change at a deadline no longer skips its events #841

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

@⁠mastrr9 on GitHub · 2026-11-24 06:39 UTC · original
mastrr9:fix/d3d12x-frame-clock-replan → main · +33 −3 · 1 files · 1 commits · open

Fixes a frame-skipping race in d3d12x::frame::clock_thread: when sleep_until finished at deadline and saw a changed schedule generation (e.g. a reschedule arriving during the unwatched 600 us spin window), the loop replanned from qpc() (now past deadline), pushing every event due at deadline (including the frame origin) a full frame interval later.

  • Tracks the reached deadline in missed and replans via replan_after(missed.take(), qpc()) (missed.min(now) - 1), so any event the new schedule still has due at that deadline fires immediately instead of being skipped for an entire interval.
  • Adds unit test a_schedule_change_at_a_deadline_does_not_skip_it.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: 228b46b3b011b15aeb2d5478f5f99a9f0f9763f7
  • cargo build --workspace: clean (only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored (new test hle::d3d12x::frame::tests::a_schedule_change_at_a_deadline_does_not_skip_it passed)
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Not tested

  • Retail title regression run (scripts/smoke.ps1) not yet run (no retail title available in this clean-room environment); opened as Draft pending a smoke run.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
**@⁠mastrr9** on GitHub · 2026-11-24 06:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/841) `mastrr9:fix/d3d12x-frame-clock-replan` → `main` · +33 −3 · 1 files · 1 commits · open Fixes a frame-skipping race in `d3d12x::frame::clock_thread`: when `sleep_until` finished at `deadline` and saw a changed schedule `generation` (e.g. a reschedule arriving during the unwatched 600 us spin window), the loop replanned from `qpc()` (now past `deadline`), pushing every event due at `deadline` (including the frame origin) a full frame interval later. - Tracks the reached `deadline` in `missed` and replans via `replan_after(missed.take(), qpc())` (`missed.min(now) - 1`), so any event the new schedule still has due at that deadline fires immediately instead of being skipped for an entire interval. - Adds unit test `a_schedule_change_at_a_deadline_does_not_skip_it`. **Tested** - Hardware/OS: NVIDIA RTX 5080 (driver `617.42` / `32.0.16.1742`), Windows 11 Pro 25H2 (`26200.9974`), `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC debug, DXC Windows SDK `10.0.26100.0`, `d3d12SDKLayers.dll` installed - Commit tested: `228b46b3b011b15aeb2d5478f5f99a9f0f9763f7` - `cargo build --workspace`: clean (only pre-existing `fetch_update` deprecation warning) - `cargo test --workspace -- --test-threads=4`: **714 passed, 0 failed, 41 ignored** (new test `hle::d3d12x::frame::tests::a_schedule_change_at_a_deadline_does_not_skip_it` passed) - `SKIPPED` GPU tests: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64` **Not tested** - Retail title regression run (`scripts/smoke.ps1`) not yet run (no retail title available in this clean-room environment); opened as Draft pending a smoke run. **AI use** - Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
The clock thread plans every type's next deadline from now - 1 and, once
it has slept to the deadline, checks that the schedule did not change
meanwhile. On a change it planned again, from now, which by then is past
the deadline, so every event due there (the origin too, whatever type
changed) moved a whole frame later. sleep_until spins the last 600 us
without watching for a change, so a title that reschedules a frame event
every frame lost about one origin in 28 at 60 Hz, and its
WaitFrameEventX waited an extra interval.

A deadline reached while the schedule changed is now planned again from
that deadline: what the new schedule has due there fires, late.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:16 +00:00
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 07:06 UTC · original

Full-suite run, since this PR has no test report yet. Tested exact head 228b46b (on its base beaa245).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: a_schedule_change_at_a_deadline_does_not_skip_it.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 07:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/841#issuecomment-7124622186) Full-suite run, since this PR has no test report yet. Tested exact head `228b46b` (on its base `beaa245`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **714 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `a_schedule_change_at_a_deadline_does_not_skip_it`. **Not tested** - AMD, a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 07:17 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head 228b46b onto main beaa245, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 707 passed, 7 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. a_schedule_change_at_a_deadline_does_not_skip_it and console_intervals_and_deadlines ok on this rig.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

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

**@⁠SlopTart** on GitHub · 2026-11-24 07:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/841#issuecomment-7124833342) Linux / AMD RDNA3 datapoint. **Merged state:** head `228b46b` onto main `beaa245`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **707 passed, 7 failed, 41 ignored**. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. `a_schedule_change_at_a_deadline_does_not_skip_it` and `console_intervals_and_deadlines` ok on this rig. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-24 19:41 UTC · original

Regression run on a retail title for 1fdbdb5: pass (no device removal, no crash, frames and peak commit within the check's limits).

Tested

  • RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build.
  • scripts\smoke.ps1 -Game <folder> -Seconds 60, no input, on this PR's head as it is and on main beaa245, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The main block is shared with my reports on other PRs of the same base.

main:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1466 (PresentX 1466)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15248 MB

this PR:

xcl-smoke v1
commit: 1fdbdb5f3a19e1031b1bef78687c728b420a89bd
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1455 (PresentX 1455)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15429 MB

Not tested

  • Whether the 60 s reach the code this PR changes, the world load, the test suite, current main merged in, AMD and Intel GPUs.

AI use

  • Claude Code (Claude Opus 5.5) made the runs with me present and wrote this from the script's output.
**@⁠CuteBooty** on GitHub · 2026-11-24 19:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/841#issuecomment-7142448473) Regression run on a retail title for `1fdbdb5`: **pass** (no device removal, no crash, frames and peak commit within the check's limits). **Tested** - RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build. - `scripts\smoke.ps1 -Game <folder> -Seconds 60`, no input, on this PR's head as it is and on `main` `beaa245`, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The `main` block is shared with my reports on other PRs of the same base. main: ``` xcl-smoke v1 commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2 gpu: NVIDIA GeForce RTX 3070 title: game seconds: 60 exit: 0x0 frames shown: 1466 (PresentX 1466) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15248 MB ``` this PR: ``` xcl-smoke v1 commit: 1fdbdb5f3a19e1031b1bef78687c728b420a89bd gpu: NVIDIA GeForce RTX 3070 title: game seconds: 60 exit: 0x0 frames shown: 1455 (PresentX 1455) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15429 MB ``` **Not tested** - Whether the 60 s reach the code this PR changes, the world load, the test suite, current `main` merged in, AMD and Intel GPUs. **AI use** - Claude Code (Claude Opus 5.5) made the runs with me present and wrote this from the script's output.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 05:57 UTC · original

Empirical test report (1fdbdb5f)

Tested PR #841 at 1fdbdb5f3a19e1031b1bef78687c728b420a89bd in a clean, detached checkout.

Hardware / environment

  • AMD Ryzen 7 3800X 8-Core Processor on Windows x64 (build 26200).
  • rustc 1.100.0 (0ef1bc386 2026-11-09), host x86_64-pc-windows-msvc. DXC reported 1.9.2609.5 (01b62ad47).
  • Cargo's unoptimized test profile ran with debug information and incremental compilation disabled. The focused run set XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both commands ran directly outside the Arc test harness and held no Arc GPU mutex.

Commands and results

  • cargo test --workspace --no-run compiled the workspace test executables and exited 0. This was a build-only check.
  • cargo test -p xcl --lib hle::d3d12x::frame::tests::a_schedule_change_at_a_deadline_does_not_skip_it -- --exact --nocapture exited 0. The captured log reports 1 passed, 0 failed, 0 ignored, and 693 filtered out. The case-sensitive ^SKIPPED count was 0.

Observed behavior

  • The added unit test calls next_deadline and replan_after using integer tick values. It exercises deadline planning without starting the clock thread or using D3D12.
  • With a schedule change detected three ticks after the deadline, replanning retains tick 1,666,700. Planning from the current tick in the same scenario advances one interval to tick 1,833,370. Moving an event's offset by 1,000 ticks selects tick 1,667,700. A remembered deadline ahead of the current tick yields a planning reference of now - 1.

Not tested

The full GPU workspace suite and game smoke runs were omitted. Live clock-thread timing and event delivery in a running title were outside the focused test's scope.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr841-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 05:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/841#issuecomment-7154297492) ### Empirical test report (1fdbdb5f) Tested PR #841 at `1fdbdb5f3a19e1031b1bef78687c728b420a89bd` in a clean, detached checkout. **Hardware / environment** - AMD Ryzen 7 3800X 8-Core Processor on Windows x64 (build 26200). - `rustc 1.100.0 (0ef1bc386 2026-11-09)`, host `x86_64-pc-windows-msvc`. DXC reported `1.9.2609.5 (01b62ad47)`. - Cargo's unoptimized test profile ran with debug information and incremental compilation disabled. The focused run set `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`. Both commands ran directly outside the Arc test harness and held no Arc GPU mutex. **Commands and results** - `cargo test --workspace --no-run` compiled the workspace test executables and exited 0. This was a build-only check. - `cargo test -p xcl --lib hle::d3d12x::frame::tests::a_schedule_change_at_a_deadline_does_not_skip_it -- --exact --nocapture` exited 0. The captured log reports 1 passed, 0 failed, 0 ignored, and 693 filtered out. The case-sensitive `^SKIPPED ` count was 0. **Observed behavior** - The added unit test calls `next_deadline` and `replan_after` using integer tick values. It exercises deadline planning without starting the clock thread or using D3D12. - With a schedule change detected three ticks after the deadline, replanning retains tick 1,666,700. Planning from the current tick in the same scenario advances one interval to tick 1,833,370. Moving an event's offset by 1,000 ticks selects tick 1,667,700. A remembered deadline ahead of the current tick yields a planning reference of `now - 1`. **Not tested** The full GPU workspace suite and game smoke runs were omitted. Live clock-thread timing and event delivery in a running title were outside the focused test's scope. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr841-focused.log` and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 10:27 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 10:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/841#issuecomment-7159732403) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 03:00 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 03:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/841#issuecomment-7181309166) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
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/841/head:github-bot/gh-841'
git switch 'github-bot/gh-841'

Merge

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