D3D12.X: XCL_OVERLAY draws fps / stats into the shown frame #445
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/450"
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 ryosen0 on 2026-11-24T00:29:41Z.
XCL_OVERLAY=1draws a small stats panel into the top-left corner of the frame XCL shows: the title's fps and frame time, draws and dispatches per second, the process's commit and the adapter's video memory, refreshed once a second. Off unless asked for.What is in it
hle/overlay.rs: the sample-to-text formatting, a 5x7 bitmap font (only the characters the lines use) and the panel rendered on the CPU into BGRA/RGBA pixels matching the back buffer's format, rows padded to a 256-byte pitch. 5 unit tests.present.rs: after the game-image copy, the panel is copied from a small upload buffer into the back buffer at (8, 8) on XCL's own command list - part of the image, so it survives the flip-model swap chain and shows in screenshots and recordings. (A child window was tried first: the flip presentation draws over it - it never appears.) No extra window, no GDI, no input taken, none of the title's resources touched. 8-bit back buffers only; 10-bit / fp16 frames draw nothing.host.rslogs one line when enabled;README.mddocuments the variable.cd41749fixes the two problems upipibi found by reading the copy: the copy locations cloned intoManuallyDrop(one leaked back-buffer reference per overlay frame —ResizeBuffersthen fails — and every recreated panel buffer stayed alive); now they borrow viatransmute_copyasreadback_copydoes. The placed footprint'sRowPitchwasw * 4, almost never a multiple ofD3D12_TEXTURE_DATA_PITCH_ALIGNMENT;overlay::panelnow pads its rows to 256 and the footprint uses the samepanel_row_pitch. Testspanel_rows_are_at_a_256_byte_pitchandpanel_row_pitch_is_256_alignedfail without the change.Tested
cargo test --workspace --no-fail-fast -- --test-threads=1on093f600: 709 passed, 0 failed, 41 ignored; 2 GPU SKIPPED (no wave64 on this adapter).XCL_OVERLAY=1(panel visible, verified by PrintWindow capture in the earlier round): clean exit, steady 60 presents / 2 s.Regression run
Main at the branch's merge-base (
e50836b, current main — includes #762 translated cache, #713 full symbols, #771 Discord invite):This PR (
093f600, rebased ontoe50836b; only a README conflict with #762's bullet, both bullets kept):Not tested
ResizeBuffers/ mode change with the overlay on (the leak fix removes the known blocker; no runtime resize repro was run). The debug-layer rejection of the unaligned pitch was not reproduced on this machine (Graphics Tools not installed); the alignment fix is verified by the unit tests and code reading.AI use
GPT-6.2 Astra (API model selector) in DSH wrote the code and the fixes, ran the builds, tests and runs, and wrote this description; the human contributor watched the runs and reviewed the change. The two fixes follow upipibi's read-only review, credited in the commit message.
Imported from ivall/xcl. Originally posted by TheHoracio on 2026-11-24T00:46:30Z.
Test report on AMD RDNA3: RX 7800 XT (16 GB, wave32 and wave64), driver 32.0.32015.7029, Ryzen 7 9800X3D, Windows 11 Pro 10.0.26300, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug build. No retail data was used.
Tested: the PR head
057eabdas it is (on its base2997c9a).cargo build --workspace, thencargo test --workspace --no-fail-fast -- --test-threads=4: 680 passed, 0 failed, 41 ignored, no SKIPPED tests.hle::overlaytests pass:every_character_the_lines_produce_has_a_glyph,lines_show_the_rate_over_the_interval,panel_is_opaque_with_green_text_in_the_formats_channel_order,zero_frames_is_zero_fps_not_a_division_by_zero.Not tested: the overlay drawn on screen (
XCL_OVERLAY=1on a title), a regression run, a release build, the head merged onto currentmain.AI use: Claude Code ran the commands and drafted this comment; the runs are real runs on the hardware above.
upstream-sync referenced this pull request2026-11-24 07:05:16 +00:00
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T04:36:55Z.
Two problems in the overlay copy at
bac87c3, found by reading the code (not run):1. A reference leaks on every overlay frame, and
ResizeBuffersthen fails (present.rs:744,:749)pResource: ManuallyDrop::new(Some(bb.clone()))AddRefs the back buffer, and theManuallyDropmeans that reference is never released. The same happens to the overlay buffer at:749. The other copy locations in this file usetransmute_copy(:559,:905-906) to avoid exactly this. WhileXCL_OVERLAYis on, every back buffer gains one reference per frame. DXGI'sResizeBuffersfails while any back-buffer reference is outstanding, so the first resize or mode change after the overlay has drawn makesensure_swapchainfail, and the window stops presenting. Every recreated overlay buffer (the panel changes width with its text) also stays alive. Usingtransmute_copy(&bb)/transmute_copy(tex), as at:905, fixes both.2.
RowPitchisn't 256-aligned (present.rs:754)RowPitch: w * 4withw = 16 + 12 * cols(overlay.rspanel) gives64 + 48 * colsbytes, which is almost never a multiple ofD3D12_TEXTURE_DATA_PITCH_ALIGNMENT(256). A placed footprint needs a 256-aligned pitch; the debug layer (XCL_D3D12_DEBUG=1) rejects the copy, and behaviour without it is undefined (NVIDIA tolerates it). Padding each row inpanel()/overlay_copytoalign_up(w * 4, 256)fixes it.Also on merge order: besides #674, this PR conflicts textually in
present.rswith #711, #732, #733, #604, #555, #615, #734 and #735 (each of those merges cleanly intomain).AI-assisted (Claude Code), read-only review.
Imported from ivall/xcl. Originally posted by ryosen0 on 2026-11-24T04:59:25Z.
@upipibi both findings confirmed in the code and fixed in
cd41749— thank you, the reference leak was real and exactly as you described:ManuallyDrop::new(Some(bb.clone()))/(tex.clone())→transmute_copy(&bb)/transmute_copy(tex), the same pattern asreadback_copyat:905. One leaked back-buffer reference per overlay frame (and every recreated panel buffer alive) is gone.overlay::panelnow pads each row to(w*4).div_ceil(256)*256(transparent padding, outside the copied box), and the footprint uses the samepanel_row_pitch(w). Tests:panel_rows_are_at_a_256_byte_pitch(pixel-level, overrender_panelwith given lines — fails without the padding) andpanel_row_pitch_is_256_aligned(every font-producible width16+12*cols).Measured on the RTX 3060 Ti: full suite 691 passed, 0 failed, 41 ignored (
--test-threads=1); smoke blocks (merge-basecb868b2+ headcd41749) refreshed in the description, both steady 60 presents / 2 s. Not run: a runtimeResizeBuffersrepro with the overlay on, and the debug-layer rejection (no Graphics Tools on this machine) — both stated in Not tested.On merge order: noted, the
present.rstextual conflicts with #711/#732/#733/#604/#555/#615/#734/#735 will need a rebase after whichever lands first; happy to rebase on request.AI use: GPT-6.2 Astra (API model selector) in DSH wrote the fixes and their tests, ran the suite and smokes, and drafted this reply; the human contributor reviewed the diff before posting.
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:00:47Z.
Test run of
bac87c3db56e40969409aa873e4c817e70bab2efon AMD RDNA4. I merged it onto currentmain64b3f35locally (clean merge).Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 705 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 664 passed, 0 failed, 21 ignoredSKIPPED; theoverlaytests pass,zero_frames_is_zero_fps_not_a_division_by_zeroincluded (the overlay itself was not drawn: no title).Review: Off unless
XCL_OVERLAY=1. I did not check @upipibi's reference-leak point, which needs the copy path to run; this run only shows the suite is green on RDNA4.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by ryosen0 on 2026-11-24T05:43:02Z.
Rebased onto current main (
e50836b) — head is now093f600. The only conflict was README.md against #762's translated-cache bullet; both bullets kept.Fresh measurements on this machine (RTX 3060 Ti, Ryzen 7 9800X3D):
093f600: 709 passed, 0 failed, 41 ignored (2 GPU SKIPPED, no wave64);e50836b2417 frames / 14601 MB peak, head093f600(XCL_OVERLAY=1) 2398 frames / 14468 MB peak — both steady 60 presents / 2 s, clean exit, no device removals. Blocks in the description updated.AI use: GPT-6.2 Astra (API model selector) in DSH did the rebase, ran the suite and smokes, and drafted this comment; the human contributor reviewed the numbers before posting.
upstream-sync referenced this pull request2026-11-24 19:06:45 +00:00
upstream-sync referenced this pull request2026-11-24 22:05:13 +00:00
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:15:47Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:59Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:09:10Z.
Triage (#1607) – head
093f600No open or merged PR adds an in-frame stats overlay (#516, merged, shows fps in the window title only).
The overlay buffer is rewritten after
present_nowwaits on the previous copy's fence, so the upload buffer is not overwritten while the GPU reads it. Rebase note: main'sreal::video_memory()now returnsOption<(u64, u64, u64)>, sooverlay::textneeds updating; the PR conflicts with main. The testpanel_is_opaque_with_green_text_in_the_formats_channel_ordermostly asserts its own local constants.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.