Repository navigation
Conversation
…oken source Device slot 80 (WaitFrameEventX, from ItsNotRexed#6935) numbered its tokens with a counter of its own, while XboxPresentation's pacer refuses any token above the ones it issued itself. A title that waits through the device and presents through the device's XboxPresentation therefore had every PresentX refused with E_INVALIDARG once its tokens ran ahead of the pacer's. leonida::FrameTokenSource is now the counter both use: a pacer takes an optional shared source (a standalone pacer still owns its own and numbers as before), the device proxy owns one and exposes it through rt::d3d12_xs::device_frame_tokens, and XboxPresentation passes a given source to its pacer. A token that was never issued is still refused. Reported by rafaelpssz in ItsNotRexed#7496.
|
Independent Windows + GPU test of Setup: Windows 11 x64, MSVC 19.44.35220 (
AI-assisted review/test. |
|
Tested
So the token-source change builds and passes on a RADV RDNA4 device as well, not only on the Windows/NVIDIA setup you tested. Caveat: the Windows-only present/pacer tests in your 9/9 are outside what this machine can run, so this is an independent second platform, not a replacement for that run. No game files used. AI-assisted (Claude Code): it built the head on that machine, ran the suite and wrote this. |
|
Tested head afb14d5 against main dde82f2 (merges clean, tree 6634c30bc). C++ — review only here; CI is the execution gate, and NO CI checks are reported on the branch. FrameTokenSource threading is sound (atomic issue/issued, standalone pacer unchanged), and your overlap self-declaration checks out — pairwise merge-tree against #2490 and #7135 is CLEAN both ways. Integration note, as your body says: on current main nobody wires device_frame_tokens into XboxPresentation, so until #2490's one-argument change lands, this alone leaves the retail refusal reachable — correct ordering, just don't let it read as the fix shipped. The negative control (device token 14 vs pacer 13 → 0x80070057 on main) is exactly the proof the finding needs. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested the device-to-presenter wiring on Arch Linux, Wine 11.20, Intel i9-10900K, RTX 3080 Ti, NVIDIA 615.78.08. This was an A/B on a private integration with #2490 and the boot dependencies, using the same local retail copy, Vulkan backend, shader inputs, and first-present readback in both runs. Title asserts were enabled.
Only aggregate results. AI-assisted with Codex. |
|
Data point from the retail 1.0.2.1 executable on Windows 11 (RTX 4090, NVIDIA 617.42, The queue's
Whichever of #2490 and this PR lands second needs that line. A mock test could create the presentation through a queue proxy, wait on the device, and present that token. Counts only, no game files. AI-assisted (Claude Code). |
|
I exercised the #2490 + #7685 integration through the production queue proxy on an RTX 5090 (616.92, Windows 11 build 26200, MSVC 19.44, Vulkan SDK 1.4.363). The fixture clears a synthetic RGBA render target, selects the newer queue layout with slot 16, then sends a token from device slot 80 to queue slot 32. The stock merge ( The production route also exposed a reference cycle because the device proxy owns the presenter and the presenter retains the proxy. Validation showed 29 leaked device objects and one surface. Having just this presenter retain the underlying device removed both teardown reports. The full presentation test still hits its existing NVIDIA sRGB validation skip. Tested integration commit. Ownership finding and claim. Synthetic inputs only. AI-assisted. |
|
Measured on the retail title with this PR stacked on #2490 (and #7880, #7286, #7111 and the other boot PRs): the queue-side PresentX path in #2490 ( Passing the shared source at that call site fixed it: state->xbox = std::make_unique<rt::d3d12::XboxPresentation>(std::move(presenter), nullptr, device->frame_tokens);With that one-argument change every PresentX returns S_OK for a 90 s run (about 100 per second). Whichever of the two lands second needs this line. I can push it to either branch if that helps. A related question for whoever owns the presenter: on: Windows 11, MSVC RelWithDebInfo, RTX 5060 Ti, LEONIDA_D3D12=vulkan, LEONIDA_SKIP_INT3=1. AI-assisted (Claude Code). |
|
@AAyberkU, @TripleJ160, thanks; both match what the PR text says: #7685 only provides the shared source, and the one line in #2490's On the window question: the separate "Leonida" window comes from #2490's AI-assisted: yes |
…esentX); includes and declarations side by side
| std::atomic<std::uint32_t> frame_latency{1}; | ||
| std::atomic<bool> frame_event_scheduled{false}; | ||
| std::atomic<std::uint64_t> frame_next_token{1}; | ||
| std::shared_ptr<leonida::FrameTokenSource> frame_tokens = std::make_shared<leonida::FrameTokenSource>(); |
There was a problem hiding this comment.
If the device proxy allocation succeeds but this new shared allocation fails, std::make_shared throws std::bad_alloc. The new (std::nothrow) DeviceProxy at line 1634 only handles failure to allocate the outer object. Its null check never runs when a member initializer throws. Before this change the token counter was an inline atomic.
That exception can escape D3D12XboxCreateDevice. The Vulkan and native D3D12 branches release their caller-owned device reference only after a failing HRESULT returns. Could the factory translate this allocation failure to E_OUTOFMEMORY while leaving *out == nullptr and the reference with the caller? A deterministic mock check could allow proxy allocation, fail just the token-source allocation, then check the HRESULT, output pointer and unchanged mock refcount. Factory · Export cleanup
Source review at afb14d56c. No runtime or allocation-failure test run. Neither GPU was exercised.
AI-assisted by GPT-6.2 Astra.
Claimed in the coordination issue: #7496 (comment), from @rafaelpssz's integration run (#7496 (comment) item 9, and #7496 (comment)), which he left as a finding; @controldebils saw the same on an RX 6900 XT (#7599 (comment)). Thanks to both.
Depends on: none (based on main only). Overlaps: #2490 (builds the per-device
XboxPresentation, which should passdevice_frame_tokens(device); a one-argument change there), #5701, #5797, #7135 (FramePacer; no shared hunks, expected to merge cleanly), #6230 (PresentX routing; doesn't touch the pacer's tokens).On its own this does not fix the retail refusal:
mainhas no caller that builds the device'sXboxPresentation, so the retailPresentXpath only exists with #2490, and #2490 must passrt::d3d12_xs::device_frame_tokens(device)to it (a one-argument change in itspresent_state_for). Until both are in, the refusal stays reachable. A local stack with #2490 and that one-argument change builds; the retail run on it has not reachedPresentXyet, so the combination is not exercised end to end; thanks to @memorypressure for pointing this out.What and why
Device slot 80 (
WaitFrameEventX, routed by #6935) handed out tokens from a counter of its own (DeviceProxy::frame_next_token), whileFramePacer::check_present_tokenrefuses any token above the ones its ownwait_frame_eventissued. The retail title waits for frame events through the device and presents throughPresentX, so once its tokens run ahead of the pacer's, everyPresentXis refused withE_INVALIDARG("never handed out"): rafaelpssz and controldebils each measured every present refused on the retail frame loop.Now both use one counter:
leonida::FrameTokenSource(frame_pacer.h): an atomic counter,issue()returns 1, 2, 3, …;issued()is the highest handed out.FramePacertakes an optional shared source; without one it owns a fresh source, so a standalone pacer numbers exactly as before. Its wait issues from the source,check_present_tokenrefuses a token aboveissued(), andtoken_source()exposes it.XboxPresentationtakes the same optional source and passes it to its pacer; existing callers are unchanged.rt::d3d12_xs::device_frame_tokens(device)returns it (null for a non-proxy). Whoever builds the device'sXboxPresentationpasses it;mainhas no such caller yet, which is the one-argument change for d3d12_xs: console-ABI command lists, upload arena, PC-list fixture path #2490 above.A token that was never issued by either path is still refused.
Tested
Windows 11, NVIDIA GeForce RTX 4070 (driver 617.42), MSVC 14.43 RelWithDebInfo, rebased on
a3f917c7e.frame_pacer_test(CPU): a pacer on a shared source accepts a token issued outside it, refusesissued() + 1, continues the shared numbering on its own wait, and accepts/refuses again after another outside issue.device_proxy_test(CPU): slot 80's tokens come fromdevice_frame_tokens(device);device_frame_tokens(nullptr)is null.xbox_present_test(GPU): the presentation is built with the device's source; a token from device slot 80 equals the pacer'stokens_issued(),PresentXwith it isS_OKand shows the frame, anddevice_token + 1isE_INVALIDARGand presents nothing.ctest -R "frame_pacer|device_proxy|xbox_present|present|boot_movie": 9/9 (d3d12_boot_movieskips withoutLEONIDA_GAME_DIR), 3 of 3 runs before the rebase and 2 of 2 after.main, the slot-80 path alone inxbox_present_testwith the old construction: after waiting through slot 80 until its token passes the pacer's (device token 14, pacer issued 13),PresentXwith it returns0x80070057(E_INVALIDARG).AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)