startup: count a failed buffer copy as the null cause ring_full and refuse the draw; report upload ring statistics #2856
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2864"
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 R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T14:42:30Z.
Part of #870
Fixes #2863
What this unblocks: a translated draw whose buffer copy fails for lack of upload-ring space is refused and counted as
ring_full, instead of running with a silent null binding that reads zeros; the render totals now show how full the ring is.What changed
NullCause::ring_full(sixth slot) andBindingFacts::ring_failedinsrc/startup_stubs/null_binding_cause.h; thex2w-render totalsline printsring_full Nafterdimension N.src/startup_stubs/d3d12_draw.inl: at the frame-copy site and the odd-size padded-stream site of the buffer binding, a readable range whose copy failed refuses the draw and countsring_full(first six logged). Unreadable or empty descriptors stay null as before.src/startup_stubs/d3d12_xs_device.cpp:x2w-render upload ring: reserved N MiB in N reservations, refusals N, capacity N MiBevery 300 frames.tests/startup_null_cause_labels_check.cpp: six causes,ring_fullcases, totals-line text.Why it is correct
A binding that could be read but not copied is not "nothing bound": drawing with it feeds the shader zeros in place of the title's data. Refusing the draw keeps the frame consistent and the count says why.
What stays as it was
Null bindings for entries, tokens, wrappers and dimensions, and unreadable buffer ranges, keep their causes and behaviour.
Source: Microsoft D3D12 documentation,
ID3D12Device::CreateShaderResourceViewandD3D12_BUFFER_SRV(a buffer view reads zeros only when its resource is unbound); this change is an accounting and refusal rule in our own stand-in, repo codesrc/startup_stubs/d3d12_draw.inl.Verification
x86_64-w64-mingw32-g++ -std=c++17 -Isrc tests/startup_null_cause_labels_check.cppunder wine: pass (17 cases);--mutate buffer-token: fails.tests/startup_null_views_check.cpp: mingw syntax check ok.d3d12_xs_device.cppwith clang for mingw: no error in the changed code.^(startup_null|startup_indirect_translated)): dev 23/23 and release 23/23 (15 passed, 8 hardware tests skipped).ring_failedtoring_fullrule dropped): killed on Win2025 (startup_null_cause_labelsexpected the sixth cause) and on Linux with g++ (4 of 17 cases fail).Real-hardware testing: @Makto94 - thanks for the help.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T14:57:16Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
166b62a714ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T14:51:55Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
166b62aℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T14:57:17Z.
Code review location:
src/startup_stubs/d3d12_draw.inl; line 2627When a formatted buffer has a readable range but
frame_copy()fails because the upload ring is exhausted, the precedingif (!have && formatted.entry)returns before this new check. Those draws are reported asformatted buffer refused (unresolved buffer)and never incrementring_full, so formatted-buffer copy failures remain absent from the new cause counter. Handle or count the readable copy failure before that early return, and cover this combination in a regression check.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T15:37:57Z.
Review: APPROVED
Good fix. This cleanly addresses the silent null binding problem (#2863):
When the guest memory is readable but the upload ring is full, the draw is now refused and counted as ring_full instead of silently binding null (zeros). This is the right behavior a null binding would produce incorrect rendering that is much harder to diagnose.
Changes reviewed:
Minor note: The volatile LONG64 / volatile LONG for stats counters works fine with Interlocked operations. If you add a consumer (e.g., a telemetry hook) that reads all four stats at once, consider snapshotting them under a lock for consistency across the log line. Not blocking.
Looks good to merge. This unblocks #870 and is a prerequisite for #2847 (upload ring reuse builds on proper refusal semantics).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T15:12:46Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T15:12:45Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
07222b46ca69ec819147a3ff65bd07ffdc41bb7f:--preset dev): build ofd3d12_xs_device_obj d3d12_xs_shim startup_null_cause_labels_check startup_null_views_checkok;ctest --preset dev -R '^startup_null_cause_labels'2/2 passed.--preset release): same targets build ok;ctest --preset release -R '^startup_null_cause_labels'2/2 passed.Fix in this head: a formatted buffer whose range is readable but whose frame copy fails (upload ring full) now counts
ring_fullbefore the early return, so it is no longer reported only as "unresolved buffer".AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T15:12:46Z.
Code review location:
src/startup_stubs/d3d12_draw.inl; line 2627Fixed in
07222b46c. The formatted-buffer early return now countsring_fullwhen the range is readable andframe_copy()failed, before refusing the draw. Commands run:g++ -std=c++17 -Isrc tests/startup_null_cause_labels_check.cpp(PASS, 17 cases),cmake -S . -B /tmp/cm-2864 -DDXC_EXECUTABLE=/bin/true(rc 0),git diff --check, and Win2025 dev+releasectest -R '^startup_null_cause_labels'2/2 each at this head. Note: the call-site ordering lives in the Windows-only draw path, so the existing classifier test covers thering_fulllabel and totals but cannot exercise this branch directly.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T16:11:24Z.
Review: COMMENTED
Tested on Windows hardware and read the diff. The full suite and the startup run used
166b62a7. After07222b46landed, I rebuilt and reran the 34 fixtures below on it: 34/34 passed.Environment: Windows 11 build 26300.9974, MSVC 19.44.35230, Windows SDK 10.0.26100, NVIDIA GeForce RTX 4090 driver 610.88 (32.0.16.1088), WARP and hardware backends, D3D12 debug layer not enabled.
Fixtures
34/34 passed. That covers your gate regex on WARP and hardware (the hardware variants ran rather than skipped), plus the
gate/gate-ringfixtures,upload_reservationand all sixstartup_slot133_heap_capcases.Full suite, in two passes so the hardware tests don't contend for the GPU:
The first pass passed 1752/1752 with 22 capability skips (77). The second ran 690 tests: 688 passed, including 8 capability skips, and 2 failed:
pixel_aot_cvt_flr_rpi_hardwaretimed out at 60 s under-j 4and passed when rerun alone (26.6 s). This is contention.compute_store_aot_mac_f32_hardwarealso fails when run alone:mac_f32: mad() fusion probe read back neither model alone: {'fused': False, 'unfused': False}. The probe comes from #2844, which is now on main. The run doesn't touch the startup stand-in, so it is unrelated to this PR. I'll report it separately.Startup run from #2837 (on this PR alone, so the ring still caps at 256 MiB)
I used a release build and
run.ps1 -Render -Translate -FakeUser -GpuMirror -ContinueAsserts 1000, 180 s, with A pressed every 5 s from 50 s. The new lines do what the PR says:On
7256cecfthe same run counted those failures asbuffernull bindings. Here they are named and the draws are refused. Ring refusals (9,088) exceedring_full(7,038) because texture uploads and index copies also reserve from the ring, and those failures are not counted here (see 3).From reading the diff
07222b46. Such a draw now countsring_fullbefore the early return. It also still counts informatted-load draws refused, and the log line still saysformatted buffer refused (unresolved buffer). A reader adding the two totals would count it twice, and the log names the wrong cause. Saying "upload ring" in that log line whenreadable_rangeis set would fix the second.BindingFacts::ring_failedis only used by the test. Both runtime sites callcount_null_binding(NullCause::ring_full)directly. No runtime code setsring_failedor reaches the new classifier rule. The mutant in the description, which drops thering_failed→ring_fullrule, therefore only shows that the unit test checks the classifier. It doesn't cover the draw path. Either route the two sites throughclassify_null_bindingwithring_failedset, or drop the field and test the call sites.frame_copy(indices_ok && frame_copy(...)), the root-SRVupload_from_titleand the texturereserve_upload_ringcalls can also fail on ring space without touchingring_full. Textures are #2855. If the index path is in scope, it would explain part of the gap between refusals andring_fullabove.reserved N MiBis cumulative andcapacityis current, so once #2847 or #2849 lands,reservedwill passcapacityroutinely. Labelling it "reserved since start" would avoid misreading.git merge-treereports conflicts with both #2847 and #2849 ind3d12_draw.inlandd3d12_xs_device.cpp. Both rewritereserve_upload_ring, and #2847 also changesframe_copy. Whichever lands second will need the counters moved into the new reservation code.Points 1–4 come from reading the code. I did not force a formatted-buffer or index-buffer ring failure.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T17:56:29Z.
Merged origin/main (GPU upload ring) into this branch: new head
65802fcd0a.Conflicts in
src/startup_stubs/d3d12_draw.inlandsrc/startup_stubs/d3d12_xs_device.cppresolved keeping both sides: main'sreserve_upload_ring(self, ...)/frame_copy(self, ...)signatures and chunk reuse stay; the ring_full null-binding count and the reserved/capacity/refusal counters sit on top of every reservation path (including the new reuse pass).Verification:
git diff --check origin/main...HEAD: cleancmake -S . -B /tmp/cm-2864 -DDXC_EXECUTABLE=/bin/true: rc=0g++ -std=c++17 -Isrc tests/startup_null_cause_labels_check.cpp: PASS (17 cases)65802fcd(x2w_pipe.py win2025 2864 --regex 'startup_null_cause_labels|upload_reservation|startup_slot133_heap_cap' --keep-release): dev 100% passed out of 9; release 7/9 passed plus 2 skipped for capability (debug1 layer cases, not a pass).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T19:54:26Z.
Review: COMMENTED
I tried to review
65802fcdover currentmain454fc0ed. The trial merge conflicts in one hunk ofsrc/startup_stubs/d3d12_xs_device.cpp, the 300-frame log block:main(#2920,e04217f4) addedbuilder gate refused %ld/compute_builder_gate_refusalsto thex2w-render compute dispatchesline.x2w-render upload ringline just above the old form of that line.The fix looks mechanical: keep the new upload ring line, then
main's compute dispatches line with the builder gate count. Since thenmainhas also taken #2949 (98e4a2ee, opt-in release of upload ring chunks at a fenced submit). It would be worth checking thatreservedandrefusalsstill mean what the body says once chunks can be released early.I'll review it once it is updated with
main.This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:28:16Z.
Updated with
main: pushedf01ad4d1d. The one conflict is resolved as you suggested (upload ring line kept, then the compute dispatches line with the builder gate count). With the opt-in early chunk release,reservedcounts successful reservations including recycled chunks (it can exceed capacity), andrefusalscounts allocation failures;docs/experiments.mdsays so.Not yet re-run on Windows after the merge.
Commands run locally:
python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,cmake -S . -B <tmp> -DDXC_EXECUTABLE=/bin/true,public_guard.py.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T21:47:17Z.
Verification: head
f01ad4d1dafter the main merge and the latest fixes.Environment: Windows Server 2025 (build 26100), MSVC 14.44, D3D12 WARP and the hardware adapter, dev and release legs in parallel.
Commands (the same selection in both legs):
Result: 6/6 passed in both legs.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:49:18Z.
Review: APPROVED
Re-reviewed
f01ad4d1merged over currentmain14d56502. The merge is clean andgit diff --cached --checkis clean. Thedevice.cpplog-block conflict from my comment on65802fcdis resolved: the totals line keeps main's fields and addsring_fullafterdimension.What the change does at the draw sites.
ring_full. One site is the frame-copy binding, the other the odd-size padded stream. Each releasesdraw_lockbeforereturn false, like the existing formatted-load refusal.bytesat 16 MiB before either site (d3d12_draw.inl, the "16 MiB copy cap" block).reserve_upload_ring's size-based refusal (bytes > max_upload_ring_bytes / 4, 64 MiB) is never reached from here, soring_fullalways means the ring had no space.reserve_upload_ring, andrefusalson its final refusal.What I ran. I did a full build in
devandrelease, then ran15/15 and 10/10 pass in both presets, with no skips. These include
startup_null_cause_labelsand its_buffer_token_control.Mutants. For each, I rebuilt in
devand ran the 15 non-hardware tests:classify_null_bindingdrops thering_failedrulestartup_null_cause_labels)if (readable_range && !have)→if (false))if (readable_range && !target)→if (false))Restored and rebuilt afterwards;
git diff --quietis clean.Non-blocking.
ring_fullline and a refused draw.BindingFacts::ring_failedis never set by the runtime. Both sites callcount_null_binding(NullCause::ring_full)directly, andcount_bufferdoesn't set the new field. So the new cases instartup_null_cause_labelspin a rule the draw path doesn't go through. Routing the two sites throughcount_bufferwithring_failed = truewould make the label test cover them. Otherwise, a comment saying the field exists only for the classification test would help the next reader.Verdict: approve on
f01ad4d1.Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs.
CI:
Build and test on Windows,Assemble and translate gfx1013 fixturesandRun platform-independent Python checks on Linuxpass onf01ad4d1.This reply was AI-assisted.