D3D12.X: XCL_OVERLAY draws fps / stats into the shown frame #450
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!450
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@ryosen0 on GitHub · 2026-11-24 00:29 UTC · original
ryosen0:stats-overlay→main· +361 −1 · 5 files · 2 commits · openXCL_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.
@TheHoracio on GitHub · 2026-11-24 00:46 UTC · original
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.
@upipibi on GitHub · 2026-11-24 04:36 UTC · original
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.
@ryosen0 on GitHub · 2026-11-24 04:59 UTC · original
@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.
@MesshM on GitHub · 2026-11-24 05:00 UTC · original
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.
@ryosen0 on GitHub · 2026-11-24 05:43 UTC · original
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.
@DavidM1911 on GitHub · 2026-11-25 14:15 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.