Frame clock: XCL_FRAME_PERIOD=1 holds an origin while the period's frames are unflipped #3146

Open
KOLESNiii wants to merge 1 commit from upstream-pr/3146 into main
KOLESNiii commented 2026-11-28 13:01:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T13:01:53Z.


Status: a guess that needs evidence before it can be merged. What SetFrameIntervalX's periodicity means (how many intervals a frame may take from its origin to its flip) is reasoned from how titles call the API and from the PC's D3D12; it is not taken from any console documentation, and no title has confirmed it yet. Draft until then.

Evidence that would confirm it: the periodicity values titles pass (logged on main), and frames in flight / latency of a GPU-bound title with and without XCL_FRAME_PERIOD=1. Off by default, so it changes nothing unless set.

If you run a title that gets there, please post those lines here (not the whole log, which names your paths).

SetFrameIntervalX's periodicity (1-4) is how many intervals a frame may take from its origin to its flip, that is how far the CPU may run ahead of the display. XCL only logged it: the clock thread released origins on wall-clock alone, so a GPU-bound title could run more frames ahead than it asked for (latency, memory held by frames in flight).

With XCL_FRAME_PERIOD=1, SetFrameIntervalX keeps the periodicity (0 or over 4 is E_INVALIDARG, as on the console) and the clock holds an origin while the newest period issued tokens are all unflipped; the next origin comes a whole interval later, so the schedule keeps its phase. A zero interval stops the clock whatever periodicity comes with it (a title stops it with SetFrameIntervalX(0, 0, 0)), and does not change the stored period. After 4 held origins in a row one is released anyway (logged), so a token the title never presents does not stop the clock. Off by default until measured. PresentX with a token whose origin has not come yet does not wait; that is left for a title that shows it.

What is in it

  • crates/xcl/src/hle/d3d12x/frame.rs: +89 / -1
  • new tests: the_frame_period_bounds_the_frames_issued_and_not_flipped, a_zero_interval_stops_the_clock_whatever_the_periodicity (the zero-interval stop, reported in review by Gevroska)

Tested

  • NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0 MSVC; tests in debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 559bf786 (built on main 336fddda; it merges into the current main 7db2f391 without conflict): 2124 passed, 9 failed, 48 ignored, 25 SKIPPED lines (21 no wave64, 3 #1426, 1 no heap windows).
  • The 9 failures are the ones main 336fddda has (3 e2e title tests and 6 split-wave64 GPU tests, #3093: main 336fddda gives 2122 passed, 9 failed, 48 ignored); the set of failing tests is identical to it.
  • cargo test -p xcl --lib -- hle::d3d12x::frame::tests: 10 passed, 0 failed.

Regression run

Both 60-second runs started from copies of the same DXIL cache, with XCL_PREPARE=0 and XCL_PRESS_AT=25:A.

xcl-smoke v1
commit: 7db2f391cefd748d47c7de63d50dd43ebb852185
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1553 (PresentX 1553)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 17206 MB
xcl-smoke v1
commit: 559bf786ffd0982a76a0975e9f163e94cf2430ba
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail game
seconds: 60
exit: 0x0
frames shown: 1262 (PresentX 1262)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15291 MB

The main run is on a newer main than the PR's base (336fddda); the earlier pair (main 336fddda, previous head 91210968) gave 1228 and 1255 frames.

Not tested

  • Full preparation. The smoke runs used XCL_PREPARE=0.
  • Behind XCL_FRAME_PERIOD=1, off by default: no measurement of latency or frames yet (a GPU-bound run is needed); the smoke run does not set it. PresentX with a token whose origin has not come does not wait; left for a title that shows it.
  • AMD and Intel GPUs; wave64 hardware (the RTX 2070 SUPER is wave32).

AI use

  • Codex (exact model name unavailable) verified earlier queued smoke results and drafted an earlier description update.
  • Claude Code, Claude Opus 5.5: the code and tests, the zero-interval fix, the test / suite runs and this description. Earlier description and runs: Claude Code, Claude Sonnet 5.5 and Claude Opus 5.5.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5540379417 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T13:01:53Z. --- **Status: a guess that needs evidence before it can be merged.** What SetFrameIntervalX's periodicity means (how many intervals a frame may take from its origin to its flip) is reasoned from how titles call the API and from the PC's D3D12; it is not taken from any console documentation, and no title has confirmed it yet. Draft until then. **Evidence that would confirm it:** the periodicity values titles pass (logged on `main`), and frames in flight / latency of a GPU-bound title with and without `XCL_FRAME_PERIOD=1`. Off by default, so it changes nothing unless set. If you run a title that gets there, please post those lines here (not the whole log, which names your paths). SetFrameIntervalX's periodicity (1-4) is how many intervals a frame may take from its origin to its flip, that is how far the CPU may run ahead of the display. XCL only logged it: the clock thread released origins on wall-clock alone, so a GPU-bound title could run more frames ahead than it asked for (latency, memory held by frames in flight). With XCL_FRAME_PERIOD=1, SetFrameIntervalX keeps the periodicity (0 or over 4 is E_INVALIDARG, as on the console) and the clock holds an origin while the newest `period` issued tokens are all unflipped; the next origin comes a whole interval later, so the schedule keeps its phase. A zero interval stops the clock whatever periodicity comes with it (a title stops it with `SetFrameIntervalX(0, 0, 0)`), and does not change the stored period. After 4 held origins in a row one is released anyway (logged), so a token the title never presents does not stop the clock. Off by default until measured. PresentX with a token whose origin has not come yet does not wait; that is left for a title that shows it. **What is in it** - `crates/xcl/src/hle/d3d12x/frame.rs`: +89 / -1 - new tests: `the_frame_period_bounds_the_frames_issued_and_not_flipped`, `a_zero_interval_stops_the_clock_whatever_the_periodicity` (the zero-interval stop, reported in review by Gevroska) **Tested** - NVIDIA RTX 2070 SUPER (driver 32.0.16.2140), AMD Ryzen 5 3600XT, Windows 11 build 26300, Rust 1.100.0 MSVC; tests in debug - `cargo test --workspace --no-fail-fast -- --test-threads=4` on `559bf786` (built on `main` `336fddda`; it merges into the current `main` `7db2f391` without conflict): 2124 passed, 9 failed, 48 ignored, 25 `SKIPPED` lines (21 no wave64, 3 #1426, 1 no heap windows). - The 9 failures are the ones `main` `336fddda` has (3 `e2e` title tests and 6 split-wave64 GPU tests, #3093: `main` `336fddda` gives 2122 passed, 9 failed, 48 ignored); the set of failing tests is identical to it. - `cargo test -p xcl --lib -- hle::d3d12x::frame::tests`: 10 passed, 0 failed. **Regression run** Both 60-second runs started from copies of the same DXIL cache, with `XCL_PREPARE=0` and `XCL_PRESS_AT=25:A`. ``` xcl-smoke v1 commit: 7db2f391cefd748d47c7de63d50dd43ebb852185 gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1553 (PresentX 1553) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 17206 MB ``` ``` xcl-smoke v1 commit: 559bf786ffd0982a76a0975e9f163e94cf2430ba gpu: NVIDIA GeForce RTX 2070 SUPER title: retail game seconds: 60 exit: 0x0 frames shown: 1262 (PresentX 1262) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 15291 MB ``` The `main` run is on a newer `main` than the PR's base (`336fddda`); the earlier pair (main `336fddda`, previous head `91210968`) gave 1228 and 1255 frames. **Not tested** - Full preparation. The smoke runs used `XCL_PREPARE=0`. - Behind `XCL_FRAME_PERIOD=1`, off by default: no measurement of latency or frames yet (a GPU-bound run is needed); the smoke run does not set it. PresentX with a token whose origin has not come does not wait; left for a title that shows it. - AMD and Intel GPUs; wave64 hardware (the RTX 2070 SUPER is wave32). **AI use** - Codex (exact model name unavailable) verified earlier queued smoke results and drafted an earlier description update. - Claude Code, Claude Opus 5.5: the code and tests, the zero-interval fix, the test / suite runs and this description. Earlier description and runs: Claude Code, Claude Sonnet 5.5 and Claude Opus 5.5. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
JJAutoCompare commented 2026-11-28 15:06:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T15:06:18Z.


Tested

Independently reran the pinned standalone CPU executable for 912109688ebc0bb06e7dd3dd8bb6b672dc96c39b on Windows 11 x64 build 26200.9974 with a Ryzen 7 3800X. The executable was built with Rust 1.100.1 (x86_64 MSVC). I verified the extracted helpers, statics, and stock control byte for byte against the Git source. The fixture uses synthetic token histories and a diagnostic-only warning macro.

frame-period-tests.exe --exact fixture::period_four_holds_releases_and_resets --test-threads=1 --nocapture
frame-period-tests.exe --exact tests::the_frame_period_bounds_the_frames_issued_and_not_flipped --test-threads=1 --nocapture

The fixture ran with XCL_VERIFY_SEED=pr3146-fixture-91210968. Both native processes exited 0. Total was 2 passed, 0 failed, 0 ignored, 0 skipped.

With period 4 and five issued tokens, a flip of the oldest token fell outside the latest four. Four calls held, incrementing the counter to 4. The fifth released and reset it to 0. In the second sequence, two calls held and a flip within the latest four triggered early release and reset. Removing that flip made the next hold start at 1. All nine calls checked the decision, held counter, period, and both histories. The separate stock test passed as a control.

Not tested

Runtime frame pacing, clock or handle behavior, concurrency, production logging, GPU behavior, retail smoke, and the workspace suite.

AI use

T3 Code through Codex (gpt-6.2-sol, high) prepared the standalone fixture, verified source and executable pins, independently reran both tests, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7241203486 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7241203486). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-28T15:06:18Z. --- **Tested** Independently reran the pinned standalone CPU executable for `912109688ebc0bb06e7dd3dd8bb6b672dc96c39b` on Windows 11 x64 build 26200.9974 with a Ryzen 7 3800X. The executable was built with Rust 1.100.1 (x86_64 MSVC). I verified the extracted helpers, statics, and stock control byte for byte against the Git source. The fixture uses synthetic token histories and a diagnostic-only warning macro. ```text frame-period-tests.exe --exact fixture::period_four_holds_releases_and_resets --test-threads=1 --nocapture frame-period-tests.exe --exact tests::the_frame_period_bounds_the_frames_issued_and_not_flipped --test-threads=1 --nocapture ``` The fixture ran with `XCL_VERIFY_SEED=pr3146-fixture-91210968`. Both native processes exited 0. Total was 2 passed, 0 failed, 0 ignored, 0 skipped. With period 4 and five issued tokens, a flip of the oldest token fell outside the latest four. Four calls held, incrementing the counter to 4. The fifth released and reset it to 0. In the second sequence, two calls held and a flip within the latest four triggered early release and reset. Removing that flip made the next hold start at 1. All nine calls checked the decision, held counter, period, and both histories. The separate stock test passed as a control. **Not tested** Runtime frame pacing, clock or handle behavior, concurrency, production logging, GPU behavior, retail smoke, and the workspace suite. **AI use** T3 Code through Codex (`gpt-6.2-sol`, high) prepared the standalone fixture, verified source and executable pins, independently reran both tests, and drafted this report.
Gevroska commented 2026-11-28 20:11:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-28T20:11:50Z.


I reproduced a frame-clock stop regression on 91210968 with XCL_FRAME_PERIOD=1. I added a Windows test that starts the clock at 33,333 µs with periodicity 3, consumes one frame-origin token, then calls SetFrameIntervalX(0, 0, 0) to stop it. I ran the same test binary in two fresh processes. The runtime code matched the PR head.

Setting Return value Clock state immediately after the call
XCL_FRAME_PERIOD unset S_FALSE Interval 0, inactive, no origin scheduled
XCL_FRAME_PERIOD=1 E_INVALIDARG (0x80070057) Interval still 33,333 µs, active, next origin still scheduled

With the option enabled, SetFrameIntervalX(0, 3, 0) still stopped the same clock. That narrows the failure to the periodicity check rejecting zero before the stop takes effect. Could the zero-interval stop be handled before that check, with a regression test that starts from an active clock?

Across four RTX 3080 title runs on nvidia-dev (54225f58), the first logged setting was 33,333 µs with periodicity 3 and flags 0. XCL logs that setting only once per process, so I can confirm the startup values. Whether the retail game calls the zero-period stop during loading is still unknown.

I used Codex with GPT-6.2 Sol to write and run the test. A separate GPT-6.2 Sol agent independently reproduced both outcomes. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7245107277 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7245107277). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-11-28T20:11:50Z. --- I reproduced a frame-clock stop regression on `91210968` with `XCL_FRAME_PERIOD=1`. I added a Windows test that starts the clock at 33,333 µs with periodicity 3, consumes one frame-origin token, then calls `SetFrameIntervalX(0, 0, 0)` to stop it. I ran the same test binary in two fresh processes. The runtime code matched the PR head. | Setting | Return value | Clock state immediately after the call | |---|---|---| | `XCL_FRAME_PERIOD` unset | `S_FALSE` | Interval 0, inactive, no origin scheduled | | `XCL_FRAME_PERIOD=1` | `E_INVALIDARG` (`0x80070057`) | Interval still 33,333 µs, active, next origin still scheduled | With the option enabled, `SetFrameIntervalX(0, 3, 0)` still stopped the same clock. That narrows the failure to the periodicity check rejecting zero before the stop takes effect. Could the zero-interval stop be handled before that check, with a regression test that starts from an active clock? Across four RTX 3080 title runs on `nvidia-dev` (`54225f58`), the first logged setting was 33,333 µs with periodicity 3 and flags 0. XCL logs that setting only once per process, so I can confirm the startup values. Whether the retail game calls the zero-period stop during loading is still unknown. I used Codex with GPT-6.2 Sol to write and run the test. A separate GPT-6.2 Sol agent independently reproduced both outcomes. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
KOLESNiii commented 2026-11-28 21:29:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T21:29:59Z.


@Gevroska Thanks, you're right. With XCL_FRAME_PERIOD=1, the periodicity check ran before the zero-interval stop, so SetFrameIntervalX(0, 0, 0) returned E_INVALIDARG and the clock kept running.

Fixed in 559bf786, squashed into the PR's commit:

  • periodicity_valid(len_us, periodicity) in hle/d3d12x/frame.rs accepts any periodicity when the interval is 0, so the stop now goes through. A nonzero interval still needs a periodicity of 1–4.
  • PERIOD is stored only for a nonzero interval, so a stop that comes with an out-of-range periodicity does not overwrite it.
  • New test a_zero_interval_stops_the_clock_whatever_the_periodicity covers the check.

The test does not start from an active clock as you suggested. The switch is read once per process through a OnceLock, so the full path can't be driven with the option on inside the shared lib-test process. Your two-process repro covers that path.

cargo test -p xcl --lib -- hle::d3d12x::frame::tests: 10 passed, 0 failed (RTX 2070 SUPER, debug). The full suite and the smoke pair for the new head are queued.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

<!-- greyfinch-sync:ivall/xcl:comment:7246062345 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7246062345). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T21:29:59Z. --- @Gevroska Thanks, you're right. With `XCL_FRAME_PERIOD=1`, the periodicity check ran before the zero-interval stop, so `SetFrameIntervalX(0, 0, 0)` returned `E_INVALIDARG` and the clock kept running. Fixed in 559bf786, squashed into the PR's commit: - `periodicity_valid(len_us, periodicity)` in `hle/d3d12x/frame.rs` accepts any periodicity when the interval is 0, so the stop now goes through. A nonzero interval still needs a periodicity of 1–4. - `PERIOD` is stored only for a nonzero interval, so a stop that comes with an out-of-range periodicity does not overwrite it. - New test `a_zero_interval_stops_the_clock_whatever_the_periodicity` covers the check. The test does not start from an active clock as you suggested. The switch is read once per process through a `OnceLock`, so the full path can't be driven with the option on inside the shared lib-test process. Your two-process repro covers that path. `cargo test -p xcl --lib -- hle::d3d12x::frame::tests`: 10 passed, 0 failed (RTX 2070 SUPER, debug). The full suite and the smoke pair for the new head are queued. — Claude Code (Claude Opus 5.5), on behalf of the PR author
Gevroska commented 2026-11-29 01:49:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-29T01:49:25Z.


I reran the active-clock test on 559bf786 and confirmed the fix on Windows. On the earlier head (91210968), SetFrameIntervalX(0, 0, 0) returned E_INVALIDARG with XCL_FRAME_PERIOD=1 and left the clock running.

I tested the revised head in two fresh processes, one with XCL_FRAME_PERIOD unset and one with it set to 1. In each, I started a 33,333 µs clock with period 3 and consumed one frame-origin token before calling stop. Both calls returned S_FALSE, cleared the interval to zero, and left the clock inactive with no origin scheduled. With the option enabled, the stored period remained 3 after the stop.

Your new a_zero_interval_stops_the_clock_whatever_the_periodicity test also passed in both modes. All seven focused checks passed. This confirms the active-clock stop behavior I originally reported.

I used Codex with GPT-6.2 Sol to run the tests. A separate GPT-6.2 Sol agent independently repeated both active-clock cases. GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7249036345 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7249036345). Originally posted by [Gevroska](https://github.com/Gevroska) on 2026-11-29T01:49:25Z. --- I reran the active-clock test on `559bf786` and confirmed the fix on Windows. On the earlier head (`91210968`), `SetFrameIntervalX(0, 0, 0)` returned `E_INVALIDARG` with `XCL_FRAME_PERIOD=1` and left the clock running. I tested the revised head in two fresh processes, one with `XCL_FRAME_PERIOD` unset and one with it set to `1`. In each, I started a 33,333 µs clock with period 3 and consumed one frame-origin token before calling stop. Both calls returned `S_FALSE`, cleared the interval to zero, and left the clock inactive with no origin scheduled. With the option enabled, the stored period remained 3 after the stop. Your new `a_zero_interval_stops_the_clock_whatever_the_periodicity` test also passed in both modes. All seven focused checks passed. This confirms the active-clock stop behavior I originally reported. I used Codex with GPT-6.2 Sol to run the tests. A separate GPT-6.2 Sol agent independently repeated both active-clock cases. GPT-6.2 Astra drafted this comment. I reviewed and approved this comment before posting.
Foniass commented 2026-12-01 09:36:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:36:50Z.


Triage (#1607) – head 559bf78

No open or merged PR honours SetFrameIntervalX's periodicity; on main it is only logged.
frame.rs: behind the opt-in XCL_FRAME_PERIOD=1; frame_period_allows takes ISSUED then FLIPPED, and no other path nests them in the opposite order. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306953070 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7306953070). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:36:50Z. --- **Triage (#1607)** – head 559bf78 No open or merged PR honours SetFrameIntervalX's periodicity; on main it is only logged. frame.rs: behind the opt-in `XCL_FRAME_PERIOD=1`; `frame_period_allows` takes ISSUED then FLIPPED, and no other path nests them in the opposite order. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Foniass commented 2026-12-01 10:48:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:48:58Z.


merge-check
base: 493dbd3dd0
head: 559bf786ff
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+89/-1). With XCL_FRAME_PERIOD unset, PERIOD stays 0 and nothing changes in behaviour, but frame.rs ~177 takes the two token-history locks on every frame origin before it checks for period 0; checking first would make it free. The run below has a second smoke with XCL_FRAME_PERIOD=1. Findings, switch on: (1) The clock can be throttled hard. If a title's PresentX tokens never match the tokens XCL issued (token 0, for example), the clock holds 4 origins and releases 1, forever. That cuts origins to a fifth (60 Hz to 12 Hz) with only 8 warnings. It's not a full stall, but a fallback that lets go after a few unmatched frames would be safer. (2) "Flipped" means PresentX returned on the CPU (present.rs ~63), not a display flip; the description could say so. (3) The meaning of periodicity, the 1-4 range and E_INVALIDARG "as on the console" have no observation behind them (only the startup values 33,333 µs and periodicity 3 were seen, in Gevroska's comment). (4) Only the pure functions are tested; nothing drives the clock thread. Fine: off by default, no deadlock in the lock order, and the PR's checks are green.
performance: 60 s smoke of a retail title, main 493dbd3d vs this merge (cca31a81): 1670 -> 1653 frames shown (98 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17756 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with XCL_FRAME_PERIOD=1: 1671 frames shown (last presents per 2 s: 60 60 60), peak commit 17356 MB, 0 device removals, 0 crashes, and no unmatched-token warnings, so the title's PresentX tokens matched and the hold didn't throttle the clock in this run (frame interval 33,333 µs, periodicity 3).
verdict: safe to merge (off by default; checking for period 0 before taking the two token-history locks in frame.rs ~177 would make the default path free)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7308766748 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7308766748). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T10:48:58Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: 559bf786ffd0982a76a0975e9f163e94cf2430ba merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (+89/-1). With `XCL_FRAME_PERIOD` unset, `PERIOD` stays 0 and nothing changes in behaviour, but `frame.rs` ~177 takes the two token-history locks on every frame origin before it checks for period 0; checking first would make it free. The run below has a second smoke with `XCL_FRAME_PERIOD=1`. Findings, switch on: (1) **The clock can be throttled hard.** If a title's PresentX tokens never match the tokens XCL issued (token 0, for example), the clock holds 4 origins and releases 1, forever. That cuts origins to a fifth (60 Hz to 12 Hz) with only 8 warnings. It's not a full stall, but a fallback that lets go after a few unmatched frames would be safer. (2) "Flipped" means PresentX returned on the CPU (`present.rs` ~63), not a display flip; the description could say so. (3) The meaning of periodicity, the 1-4 range and E_INVALIDARG "as on the console" have no observation behind them (only the startup values 33,333 µs and periodicity 3 were seen, in Gevroska's comment). (4) Only the pure functions are tested; nothing drives the clock thread. Fine: off by default, no deadlock in the lock order, and the PR's checks are green. performance: 60 s smoke of a retail title, main 493dbd3d vs this merge (cca31a81): 1670 -> 1653 frames shown (98 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17756 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with `XCL_FRAME_PERIOD=1`: 1671 frames shown (last presents per 2 s: 60 60 60), peak commit 17356 MB, 0 device removals, 0 crashes, and no unmatched-token warnings, so the title's PresentX tokens matched and the hold didn't throttle the clock in this run (frame interval 33,333 µs, periodicity 3). verdict: safe to merge (off by default; checking for period 0 before taking the two token-history locks in `frame.rs` ~177 would make the default path free) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Decodere commented 2026-12-02 10:14:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T10:14:28Z.


merge-check
base: 1c8b551475
head: 559bf786ff
merge: clean (trial-merge commit 0198c0671b800a732bc36aa0332441c22c54b1d7, git diff --check clean)
build: cargo build --workspace ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets): 2911 passed, 0 failed, 51 ignored (+2 new tests vs main baseline). Targeted hle::d3d12x::frame::tests passed 11/11 with 0 skips, including both new tests (the_frame_period_bounds_the_frames_issued_and_not_flipped, a_zero_interval_stops_the_clock_whatever_the_periodicity). 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)).
review: Read the full merged diff (+89/-1 in crates/xcl/src/hle/d3d12x/frame.rs). Adds opt-in XCL_FRAME_PERIOD=1 (off by default, cached in OnceLock) to validate SetFrameIntervalX periodicity (1..=4 when len_us != 0, any value when len_us == 0 stops the clock) and hold origin releases in clock_thread while the newest period issued tokens are all still unflipped, releasing after MAX_HELD_ORIGINS (4) consecutive holds with a capped warning (8 logs) so an unpresented token cannot wedge the clock. Lock acquisition order in frame_period_allows (ISSUED then FLIPPED) is clean and consistent. Non-blocking note: frame_period_allows currently locks ISSUED and FLIPPED even when period == 0 (once per origin tick); an early if period == 0 { return true; } would avoid those locks on the default path. No scope creep or UB.
performance: not applicable on default path (opt-in XCL_FRAME_PERIOD=1, off by default; retail smoke with XCL_FRAME_PERIOD=1 enabled was not run in this check).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ivall/xcl:comment:7342174290 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7342174290). Originally posted by [Decodere](https://github.com/Decodere) on 2026-12-02T10:14:28Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 559bf786ffd0982a76a0975e9f163e94cf2430ba merge: clean (trial-merge commit 0198c0671b800a732bc36aa0332441c22c54b1d7, git diff --check clean) build: cargo build --workspace ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets): 2911 passed, 0 failed, 51 ignored (+2 new tests vs main baseline). Targeted hle::d3d12x::frame::tests passed 11/11 with 0 skips, including both new tests (the_frame_period_bounds_the_frames_issued_and_not_flipped, a_zero_interval_stops_the_clock_whatever_the_periodicity). 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)). review: Read the full merged diff (+89/-1 in crates/xcl/src/hle/d3d12x/frame.rs). Adds opt-in `XCL_FRAME_PERIOD=1` (off by default, cached in `OnceLock`) to validate `SetFrameIntervalX` periodicity (`1..=4` when `len_us != 0`, any value when `len_us == 0` stops the clock) and hold origin releases in `clock_thread` while the newest `period` issued tokens are all still unflipped, releasing after `MAX_HELD_ORIGINS` (4) consecutive holds with a capped warning (8 logs) so an unpresented token cannot wedge the clock. Lock acquisition order in `frame_period_allows` (`ISSUED` then `FLIPPED`) is clean and consistent. Non-blocking note: `frame_period_allows` currently locks `ISSUED` and `FLIPPED` even when `period == 0` (once per origin tick); an early `if period == 0 { return true; }` would avoid those locks on the default path. No scope creep or UB. performance: not applicable on default path (opt-in `XCL_FRAME_PERIOD=1`, off by default; retail smoke with `XCL_FRAME_PERIOD=1` enabled was not run in this check). verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)
KOLESNiii commented 2026-12-02 14:22:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T14:22:39Z.


@Foniass @Decodere thanks for the merge checks. frame_period_allows now returns before taking either token-history lock when the period is 0 (the default), so the default path takes no lock (frame.rs). New test the_default_period_check_takes_no_lock: it holds ISSUED on the test thread and checks that the clock's check still returns, and it fails on the previous head. New head 6ffaa267 (rebased onto main df0cfef6). The throttling case (tokens that never match: 1 origin in 5 while the switch is on) and the wording of "flipped" are with the PR author.

— Claude Code (Claude Opus 5.5), on behalf of the PR author

<!-- greyfinch-sync:ivall/xcl:comment:7348441626 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7348441626). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-12-02T14:22:39Z. --- @Foniass @Decodere thanks for the merge checks. `frame_period_allows` now returns before taking either token-history lock when the period is 0 (the default), so the default path takes no lock (`frame.rs`). New test `the_default_period_check_takes_no_lock`: it holds `ISSUED` on the test thread and checks that the clock's check still returns, and it fails on the previous head. New head `6ffaa267` (rebased onto `main` df0cfef6). The throttling case (tokens that never match: 1 origin in 5 while the switch is on) and the wording of "flipped" are with the PR author. — Claude Code (Claude Opus 5.5), on behalf of the PR author
Foniass commented 2026-12-02 14:25:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T14:25:24Z.


Follow-up review (head 6ffaa267, since 559bf78, diff read, not a merge-check; checks red):

  • Earlier points: unchanged otherwise; this push (a rebase) makes the default path cheaper: with the period not honoured (period == 0), frame_period_allows returns before taking the token-history locks, and the_default_period_check_takes_no_lock checks it returns while another thread holds ISSUED.

New: none. That test asserts PERIOD is 0, so it fails if the suite is run with XCL_FRAME_PERIOD set; a test-only override would avoid that.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7348518069 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3146#issuecomment-7348518069). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T14:25:24Z. --- Follow-up review (head 6ffaa267, since 559bf78, diff read, not a merge-check; checks red): - **Earlier points:** unchanged otherwise; this push (a rebase) makes the default path cheaper: with the period not honoured (`period == 0`), `frame_period_allows` returns before taking the token-history locks, and `the_default_period_check_takes_no_lock` checks it returns while another thread holds `ISSUED`. New: none. That test asserts `PERIOD` is 0, so it fails if the suite is run with `XCL_FRAME_PERIOD` set; a test-only override would avoid that. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3146:upstream-pr/3146'
git switch 'upstream-pr/3146'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3146'
git switch 'upstream-pr/3146'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3146'
git switch 'upstream-pr/3146'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3146'
git switch 'main'
git merge --squash 'upstream-pr/3146'
git switch 'main'
git merge --ff-only 'upstream-pr/3146'
git switch 'main'
git merge 'upstream-pr/3146'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3146
No description provided.