d3d12: the title-texture upload ring gives back large idle buffers, and counts as staging (RT-TITLE-UPLOAD-TRIM) #2463
Closed
kawaii-shakal wants to merge 6 commits from
upstream-pr/2463 into main
pull from: upstream-pr/2463
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
ProjectLeonida/mandy!2463
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2463"
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 ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-27T12:26:38Z.
Claimed in the coordination issue as: RT-TITLE-UPLOAD-TRIM
Overlaps #2021 (the same header, a different change): the two conflict only in
runtime/CMakeLists.txt, whereeach registers a test; whichever lands second keeps both lines.
What and why
TitleImageUpload(runtime/shims/d3d12_title_image_upload.h) is a ring of four slots. Each slot grew to thelargest whole-image upload that went through it and kept that buffer until the device was destroyed. The buffers
are host-visible, so on a discrete GPU they are system RAM: after a burst of large textures (a cutscene's, say)
up to four of the largest stayed allocated for the rest of the run. The ring's memory was also not named in the
mem probe, so it showed up as
other.trim(), called from the periodic title-texture pass (refresh_title_textures) under atry_lock, frees aslot whose buffer is over
LEONIDA_TITLE_UPLOAD_KEEP_MB(4) and that has not been used forLEONIDA_TITLE_UPLOAD_IDLE_MS(2000), once its last transfer has completed. Completion is read withvkGetSemaphoreCounterValue; the pass never waits for the GPU, and a slot whose value can't be read stays.LEONIDA_TITLE_UPLOAD_IDLE_MS=0keeps the old behaviour, for A/B runs.memory_breakdownstaging owner, so[rt] mem-probe breakdownshows it as staging.The
registered image backingline now also says how many buffers were released.runtime/src/title_upload_trim.h, tested bytitle_upload_trim_test: idle limit and size floor,a transfer still running, an empty slot, a clock read before the last use, 0 = off, malformed and huge values.
runtime/README.mdanddocs/d3d12_vulkan.mddescribe the two variables.Tested
ctest117 of 117, with the new test.trim()andcapacity()on a fakedevice (
-Wall -Wextra, no warnings from these files).1,091 targets, including
d3d12_vulkan_device.cpp. Its tests under Wine 9.0 with Xvfb on Mesa lavapipe: 464 of490 pass; the 26 that fail fail the same way on main (checked by building main's two files in the same tree).
LEONIDA_MEM_PROBE=1through acutscene and after it, with
LEONIDA_TITLE_UPLOAD_IDLE_MS=0and with the default, comparing thestagingpartof the breakdown line and the buffer size on the
registered image backingline.AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly.docs/design.md. (n/a: no translator change)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-27T12:37:10Z.
Native Windows check on
d14a81479. The Windows-onlyd3d12_vulkan_device.cppcompiled with MSVC 19.44 andgta6rt.exelinked in Release. The stocktitle_upload_trimCPU test andd3d12_mapped_plane_asyncRTX 4090 test both passed.I also measured the ring through the production refresh path on Windows 11, RTX 4090, NVIDIA 616.64. I adapted the test's mapped-plane fixture locally to upload four 4096×2048 R8 textures, each filled with a different byte. I disabled host image copy on the test device to exercise staging. Each copy completed and its full 8 MiB readback matched before the next upload. After 10.5 s idle, an empty queue submission triggered the next refresh and let the regular memory probe print the counters.
LEONIDA_TITLE_UPLOAD_IDLE_MS=0A fifth 8 MiB upload with a new fill byte passed full GPU readback in both processes. Khronos validation was enabled and reported zero errors. This checks retention, release and reuse of the staging ring with synthetic textures. The 32 MiB is the ring-capacity difference for this fixture.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:20:35Z.
Code review location:
runtime/shims/d3d12_title_image_upload.h; line 97Because
write()rotatesslots_strictly round-robin (next_ = (next_ + 1) % kSlots),prepare()retains any existing buffer whensize <= slot.capacity, andslot.last_used_ns = now_ns()is updated unconditionally on every upload regardless ofbytes, steady small uploads (<=keep_bytes) at even 2-3 uploads/second touch all 4 slots within every 2 s window.After a burst of large textures (e.g. 64 MiB cutscene uploads) grows all 4 slots, ongoing small uploads will continuously reset
last_used_nson every oversized slot so none of the 4 large buffers is ever released bytrim(). Tracking when a slot last carried an upload larger thankeep_bytes(or avoiding stampinglast_used_nswhenbytes <= settings.keep_bytesandslot.capacity > settings.keep_bytes) would let oversized slots actually be reclaimed under steady small-texture traffic.Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:20:35Z.
Code review location:
runtime/shims/d3d12_title_image_upload.h; line 38Minor: calling
std::getenvtwice as sibling arguments tosettings_from(...)relies on the second call not overwriting the buffer returned by the first (the C/C++ standard allows a single static buffer; safe on MSVC UCRT today, easy to avoid by reading/copying the first value or usingGetEnvironmentVariableA/getenv_s).Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:20:35Z.
Review: COMMENTED
Reviewed and tested at
d14a81479(merged cleanly ontomainec91d695c).The trim policy header (
runtime/src/title_upload_trim.h), non-blocking timeline check intransfer_done(), atomiccapacity()/trimmed()counters, andConsumer::stagingaccounting are clean and pass CPU and GPU tests. Two notes inline:write()rotatesslots_round-robin and stampsslot.last_used_ns = now_ns()on every upload regardless of size, so steady small uploads (<= 4 MiB) every ~0.5 s keep resettinglast_used_nson all 4 oversized slots and preventtrim()from reclaiming them.std::getenv(...)calls in one argument list intrim().Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note
VK_LAYER_KHRONOS_validationis not installed locally so Vulkan validation layers did not run):title_upload_trim(CPU): passedd3d12_existing_heapandd3d12_host_prefix(GPU): 2/2 passedscripts/check_no_game_data.pyandgit diff --check: cleanAI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by djrolfes on 2026-11-27T15:26:27Z.
Independent Linux/Wine + NVIDIA check at head
d14a81479(merged cleanly ontoorigin/mainec91d695cin a local integration stack alongside#2467,#2470,#2469,#2461,#2126,#2091, and two local V# patches).7.2.15,wine-11.22,clang-cl+xwincross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver620.73.04, Ryzen 7 5800X, 32 GB RAM. No game files.gta6rtandtitle_upload_trim_testcross-compiled cleanly withclang-cl+xwin;title_upload_trimpassed (4.39 s) under Wine.capacity()/trimmed()counters and non-blockingvkGetSemaphoreCounterValuecheck intransfer_done()before releasing idle slots look clean.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-27T16:28:09Z.
@lixonik thanks, both were right. Changed by Claude Code (AI-assisted) in
07326dfb:write()no longer stamps a slot on every upload. Only an upload overLEONIDA_TITLE_UPLOAD_KEEP_MBcounts(
title_upload_trim::counts_as_use), so small uploads going round the ring no longer keep a large buffer froma burst alive; a small one fits the buffer
trim()leaves behind.title_upload_trim_testhas the case youdescribed: 1 MiB uploads every 0.5 s after a 64 MiB one, and the slot is released 2 s after the large one.
title_upload_trim::settings_from_env, which copies each value before the next read(
_dupenv_son Windows, so the CRT's getenv deprecation warning is gone too).Tested: Linux
ctest117/117; Windows build cross-compiled with clang-cl 21 and xwin (gta6rt,title_upload_trim_test), the test passing under Wine 9.0.@ecox982745 @djrolfes the change is small but it touches what you measured: a re-run of your adapted fixture on
this head would confirm the four buffers still go.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-27T16:53:09Z.
Note on #2464, which came out after this PR: it lists
runtime/shims/d3d12_title_image_upload.hamong the filesthe performance rewrite owns. @aslan2142 if the rewrite covers the upload ring, feel free to close this or take
the change into it; the rule and its test (
src/title_upload_trim.h,title_upload_trim_test) are separate filesand can move as they are. The measured effect is in ecox982745's comment above.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T20:10:56Z.
Review: APPROVED
Re-reviewed
07326dfb8and re-tested:write()now only updatesslot.last_used_nswhentitle_upload_trim::counts_as_use(bytes, trim_settings())is true (bytes > keep_bytes), so steady small uploads rotating through the ring no longer keep oversized buffers alive indefinitely while in-flight transfers remain protected by the timeline semaphore check intrim().title_upload_trim::settings_from_env()reads both environment variables viaenv_copy()(_dupenv_son Windows, ownedstd::stringcopy on POSIX), avoiding siblingstd::getenvpointer aliasing and MSVC C4996 warnings.VK_LAYER_KHRONOS_validationnot installed locally):title_upload_trim: passed (0.02 s).d3d12_mapped_plane_async: passed (0.21 s).Looks good to merge (maintainers can weigh overlap with #2464 perf work on
d3d12_title_image_upload.h).AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:32Z.
Reviewed at head
07326dfb8on Windows 11 (MSVC 202219.44).Verification
title_upload_trim_testandgta6rt.title_upload_trim_test: ok.Notes (non-blocking)
d3d12_title_image_upload.h:93-98,160-299;title_upload_trim.h:53-77;d3d12_vulkan_device.cpp:15661-15668) all look solid.d3d12_title_image_upload.h:37-47,160-172;title_upload_trim.h:80-85): The periodic trim evaluatestransfer_done(d, slot)(pollingvkGetSemaphoreCounterValue) for every non-empty slot even when size/age already disqualify it. Checking size and age first — and querying the shared timeline at most once if any candidate qualifies — avoids redundant Vulkan calls under both locks during steady small uploads.Approve.
AI-assisted review + local MSVC verification.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:23:23Z.
#2463 | head
c9e75ba74a(merged cleanly with mainadfb3821a2— no conflicts on currentmain) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(title_upload_trim|memory_breakdown|d3d12_mapped_plane_async)$" --output-on-failure(LEONIDA_VK_VALIDATION=1,LEONIDA_MEM_PROBE=1,LEONIDA_FSDRAW_PROBE=1,LEONIDA_TITLE_UPLOAD_IDLE_MS=1,LEONIDA_TITLE_UPLOAD_KEEP_MB=0) | red mutation: forcingtitle_upload_trim::release()inruntime/src/title_upload_trim.htoreturn falsefailstitle_upload_trimatline 33: tt::release(64 * kMiB, t0, t0 + 2000 * kMs, true, s)| green on PR+main:3/3CTests (title_upload_trim,memory_breakdown, andd3d12_mapped_plane_asynclogging[rt] mem-probe: registered image backing: ... staged fills 1, 0.001 s, buffer 0.0 MiB (0 released idle)) pass in1.02 son RTX 3090 with0Khronos validation errors;test_docs_encoding.py&test_docs_repo_paths.py(6/6 OK) andcheck_no_game_data.py(0violations) pass | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:29:02Z.
Review: COMMENTED
Static audit of
c9e75ba74. No builds or GPU runs were performed for this review.runtime/test/title_upload_trim_test.cpp:29— The policy test supplies the completion flag, leaving the production timeline check atruntime/shims/d3d12_title_image_upload.h:164untested. If an oversized slot reaches the idle threshold with a copy still pending, accepting a successful counter query below the slot's ticket would free the source buffer early and leave the policy test green. Please add a ring-level test with a fake Vulkan counter that returns below the ticket and then reaches it. Check that the first trim retains the buffer and capacity, and the second frees the allocation exactly once and decrements capacity.The upload ring records the ticket when the primary copy submission succeeds, before submitting waits on the consumer queues. The refresh path takes the registry mutex before trying the upload mutex, and slot mutation stays under the upload mutex. Teardown joins the fill worker and waits for device idle before releasing the ring. The memory probe records staging allocations by handle and erases them on free, including cleanup after bind or map failure. Ring capacity is added only after mapping succeeds and subtracted by the shared release path. The policy test is registered in
runtime/CMakeLists.txtand exercises the MSVC and POSIX environment-reading branches on their respective platforms.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-30T08:37:05Z.
Thanks, both addressed in
15531782:runtime/test/title_upload_ring_trim_test.cppdrivesTitleImageUpload::trimitself over a fake device whosevkGetSemaphoreCounterValue,vkDestroyBufferandvkFreeMemorycount their calls (a test-only friend seeds a submitted slot). With the counter below the slot's ticket the first trim keeps the buffer andcapacity(); with it at the ticket the second frees buffer and memory exactly once,capacity()drops to 0 andtrimmed()is 1, and a third frees nothing. A counter read that fails (VK_ERROR_DEVICE_LOST) or a missing entry point keeps the buffer, and each slot goes by its own ticket.trim()now checks size and age first, so a slot they keep costs no counter read under the locks; the test counts the reads.Built with clang-cl 21 + xwin (the flags the CMake target gets) and run under Wine: 3/3 pass; with the
reached < slot.valuecomparison removed fromtransfer_done()it fails 3/3 at the first-trim check. Not built with MSVC here. Merges cleanly into maine236b19c.AI-assisted (Claude Code); I ran the builds and checked the results.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T09:04:29Z.
Native Windows follow-up on
15531782. I merged it locally intodcba958e5(tree1bee9a100) and built the unmodified test targets with MSVC 19.44 in Release.title_upload_ring_trim,title_upload_trim, andmemory_breakdowneach passed 3/3. The new ring test uses a fake Vulkan device. It covers the below-ticket hold, the exactly-once free at the ticket, counter lookup failures, and independent slot tickets.d3d12_mapped_plane_asyncalso passed 3/3 on the RTX 4090 (NVIDIA 616.64, Windows 11) with Khronos Vulkan validation 1.4.369 enabled and no diagnostics. This was the stock synthetic GPU smoke test. Ring trimming itself was verified by the CPU fixture above.AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T09:38:53Z.
Independent live-ring check of
15531782merged ontomain4014af7fe. CachyOS, clang++ 23.1.5, RTX 4070 SUPER (NVIDIA 620.73.04) and Radeon 610M/Raphael (RADV 26.3.1), Khronos validation 1.4.363. The three stock CPU fixtures (title_upload_ring_trim,title_upload_trim,memory_breakdown) also passed.I used a test-only friend to call the production ring's
prepare,submitandtrimpaths with real Vulkan resources. The ring allocated and mapped an 8 MiB source and submitted a copy to a coherent readback buffer. I added an unsignalled timeline wait to that submission sotrim()ran while the transfer was pending. I set the slot's last-use timestamp to zero to select an already-idle slot without sleeping.With trim on (
KEEP_MB=4,IDLE_MS=1), the real counter was0against ticket1and the first trim kept all 8 MiB. I opened the gate, waited for ticket1, and all 8,388,608 bytes matched. The next trim dropped capacity to zero and counted one release. An extra trim kept that count at one.With
LEONIDA_TITLE_UPLOAD_IDLE_MS=0, the same transfer and full readback passed. The ring kept all 8 MiB and counted zero releases until normal teardown.Measured: 3/3 repetitions for each mode on each GPU, 12/12 total with zero validation diagnostics. This exercises the real map, submission timeline and release path using a synthetic buffer copy. The fixture supplies the command and idle timestamp.
AI-assisted: yes (OpenAI Codex).
Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-30T13:16:48Z.
Main's rewrite of
d3d12_title_image_upload.h(variable slots with best-fit, batched uploads, GPU detile, fromfix/rendering-correctness) replaces the four-slot ring this PR trims, so it no longer merges. Does the new ring still want idle large slots given back? If so I'll port the trim (release a slot overLEONIDA_TITLE_UPLOAD_KEEP_MBthat is idle and whose ticket the timeline has reached, staging accounting, and the fake-device ring test) onto it; if the rewrite covers this or it isn't wanted, I'll close this one.Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-30T14:10:03Z.
I checked the variable-slot uploader on
mainf44904d21to see what it retains today. Native Windows 11, MSVC 19.44 Release, RTX 4090 (NVIDIA 616.64) and Khronos Vulkan validation 1.4.369. I reused the earlier synthetic fixture, which forces staging and checks every byte of four sequential 4096×2048 R8 image readbacks. After 10.5 s idle, I submitted and fenced an empty command list, then did a fifth upload and readback.Both runs reported four staged fills and 8 MiB of staging capacity still held after the idle submission, with zero live slot-70 or slot-133 backing at that point. The fifth upload matched in full, and both runs had zero validation errors. The earlier fixture on the four-slot ring with trimming off retained 32 MiB. Best-fit reuse reduced retention for this sequential case. The new ring still kept its idle allocation.
This confirms retained staging on the merged uploader. The fixture only exercises a sequential stream, so it leaves the multi-slot burst and in-game tradeoff open. AI-assisted with OpenAI Codex (GPT-6.2 Sol).
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:44:48Z.
Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.Pull request closed