Repository navigation
Conversation
…efuse the draw; report upload ring statistics
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 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
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…efore refusing the draw
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
Fix in this head: a formatted buffer whose range is readable but whose frame copy fails (upload ring full) now counts AI-assisted; commands listed were executed locally. |
KelboLive
left a comment
There was a problem hiding this comment.
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:
- NullCause::ring_full (sixth slot) correct enum extension, no existing code depends on the old index
- BindingFacts::ring_failed good separation ring failure is distinct from buffer not being bound
- draw_translated refusal path checks readable_range first, then refuses with a one-shot log. The condition ordering is correct we only treat it as ring_full if the memory was actually readable
- Upload ring stats atomic counters (InterlockedAdd64/Increment) are thread-safe for per-frame logging
- Test update correctly expects 6 causes and the ring_full label
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).
Not-Saii
left a comment
There was a problem hiding this comment.
Tested on Windows hardware and read the diff. The full suite and the startup run used 166b62a7. After 07222b46 landed, 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
ctest --preset dev --no-tests=error -R '^(startup_null|startup_indirect_translated|startup_address_console_gate|upload_reservation$|startup_slot133_heap_cap)'34/34 passed. That covers your gate regex on WARP and hardware (the hardware variants ran rather than skipped), plus the gate/gate-ring fixtures, upload_reservation and all six startup_slot133_heap_cap cases.
Full suite, in two passes so the hardware tests don't contend for the GPU:
ctest --preset dev --no-tests=error -j 20 -E '_hardware$' --timeout 600
ctest --preset dev --no-tests=error -j 4 -R '_hardware$' --timeout 600The 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:
null bindings 7038 (entry 0, buffer 0, token 0, wrapper 0, dimension 0, ring_full 7038)
translated draws 4745 (not drawn 7038)
x2w-render upload ring: reserved 256 MiB in 12119 reservations, refusals 9088, capacity 256 MiB
On 7256cecf the same run counted those failures as buffer null bindings. Here they are named and the draws are refused. Ring refusals (9,088) exceed ring_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
- Formatted buffers (the Codex point): fixed in
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.- Other ring users are not counted. The index-buffer
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. - The statistics line.
reserved N MiBis cumulative andcapacityis current, so once #2847 or #2849 lands,reservedwill passcapacityroutinely. Labelling it "reserved since start" would avoid misreading. - Conflicts.
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.
# Conflicts: # src/startup_stubs/d3d12_draw.inl # src/startup_stubs/d3d12_xs_device.cpp
|
Merged origin/main (GPU upload ring) into this branch: new head 65802fc. Conflicts in Verification:
AI-assisted; commands listed were executed locally. |
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.