Frame clock: XCL_FRAME_PERIOD=1 holds an origin while the period's frames are unflipped #3146
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3146"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 withoutXCL_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
periodissued 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 withSetFrameIntervalX(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 / -1the_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
cargo test --workspace --no-fail-fast -- --test-threads=4on559bf786(built onmain336fddda; it merges into the currentmain7db2f391without conflict): 2124 passed, 9 failed, 48 ignored, 25SKIPPEDlines (21 no wave64, 3 #1426, 1 no heap windows).main336fdddahas (3e2etitle tests and 6 split-wave64 GPU tests, #3093:main336fdddagives 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=0andXCL_PRESS_AT=25:A.The
mainrun is on a newermainthan the PR's base (336fddda); the earlier pair (main336fddda, previous head91210968) gave 1228 and 1255 frames.Not tested
XCL_PREPARE=0.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.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T15:06:18Z.
Tested
Independently reran the pinned standalone CPU executable for
912109688ebc0bb06e7dd3dd8bb6b672dc96c39bon 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.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.Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-28T20:11:50Z.
I reproduced a frame-clock stop regression on
91210968withXCL_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 callsSetFrameIntervalX(0, 0, 0)to stop it. I ran the same test binary in two fresh processes. The runtime code matched the PR head.XCL_FRAME_PERIODunsetS_FALSEXCL_FRAME_PERIOD=1E_INVALIDARG(0x80070057)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.
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, soSetFrameIntervalX(0, 0, 0)returnedE_INVALIDARGand the clock kept running.Fixed in
559bf786, squashed into the PR's commit:periodicity_valid(len_us, periodicity)inhle/d3d12x/frame.rsaccepts any periodicity when the interval is 0, so the stop now goes through. A nonzero interval still needs a periodicity of 1–4.PERIODis stored only for a nonzero interval, so a stop that comes with an out-of-range periodicity does not overwrite it.a_zero_interval_stops_the_clock_whatever_the_periodicitycovers 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
Imported from ivall/xcl. Originally posted by Gevroska on 2026-11-29T01:49:25Z.
I reran the active-clock test on
559bf786and confirmed the fix on Windows. On the earlier head (91210968),SetFrameIntervalX(0, 0, 0)returnedE_INVALIDARGwithXCL_FRAME_PERIOD=1and left the clock running.I tested the revised head in two fresh processes, one with
XCL_FRAME_PERIODunset and one with it set to1. In each, I started a 33,333 µs clock with period 3 and consumed one frame-origin token before calling stop. Both calls returnedS_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_periodicitytest 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:36:50Z.
Triage (#1607) – head
559bf78No 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_allowstakes 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:48:58Z.
merge-check
base:
493dbd3dd0head:
559bf786ffmerge: 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_PERIODunset,PERIODstays 0 and nothing changes in behaviour, butframe.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 withXCL_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
493dbd3dvs 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 withXCL_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.
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T10:14:28Z.
merge-check
base:
1c8b551475head:
559bf786ffmerge: 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 inOnceLock) to validateSetFrameIntervalXperiodicity (1..=4whenlen_us != 0, any value whenlen_us == 0stops the clock) and hold origin releases inclock_threadwhile the newestperiodissued tokens are all still unflipped, releasing afterMAX_HELD_ORIGINS(4) consecutive holds with a capped warning (8 logs) so an unpresented token cannot wedge the clock. Lock acquisition order inframe_period_allows(ISSUEDthenFLIPPED) is clean and consistent. Non-blocking note:frame_period_allowscurrently locksISSUEDandFLIPPEDeven whenperiod == 0(once per origin tick); an earlyif 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 withXCL_FRAME_PERIOD=1enabled 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)
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-12-02T14:22:39Z.
@Foniass @Decodere thanks for the merge checks.
frame_period_allowsnow returns before taking either token-history lock when the period is 0 (the default), so the default path takes no lock (frame.rs). New testthe_default_period_check_takes_no_lock: it holdsISSUEDon the test thread and checks that the clock's check still returns, and it fails on the previous head. New head6ffaa267(rebased ontomaindf0cfef6). 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
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T14:25:24Z.
Follow-up review (head
6ffaa267, since559bf78, diff read, not a merge-check; checks red):period == 0),frame_period_allowsreturns before taking the token-history locks, andthe_default_period_check_takes_no_lockchecks it returns while another thread holdsISSUED.New: none. That test asserts
PERIODis 0, so it fails if the suite is run withXCL_FRAME_PERIODset; 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.