d3d12/gpu: make texture pool commit-aware and default LEONIDA_COMMIT_FLOOR on (D3D12-TEXTURE-POOL-COMMIT-FLOOR) #3201
Open
github-bot
wants to merge 1 commit from
github-bot/gh-3201 into main
AGit
pull from: github-bot/gh-3201
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3201
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3201"
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?
@Jyx0208 on GitHub · 2026-12-02 18:38 UTC · original
Jyx0208:feat/texture-pool-commit-floor→main· +129 −12 · 3 files · 1 commits · openClaimed in the coordination issue as: D3D12-TEXTURE-POOL-COMMIT-FLOOR (#2570)
What and why
Refs: #2821
Under Windows WDDM, every
D3D12_HEAP_TYPE_DEFAULT64 MiB texture heap (pool.rs) is charged 1:1 to process private bytes and system commit charge. On high-VRAM GPUs (or any host whose Windows commit headroom tightens before local VRAM reaches 88% of budget):resource::let_go_idle()kept idle textures for 10 minutes becauseLEONIDA_COMMIT_FLOORwas off by default, allowingpool.rsto sprawl up to 244+ 64 MiB texture blocks (15.6+ GiBof VRAM and system commit) and pin them via fragmentation before commit pressure triggered cleanup.pool::room()scaledSTAGINGandsmallblock spares down to1under commit pressure and0undercritical_commit(), but never applied commit headroom orcritical_commit()toTEXTURESspares (which could keep up toSPARE_KEPT = 64empty 64 MiB blocks =4 GiBwhile VRAM < 85%, and keptSPARE = 2even when commit was critical), nor didpool::texture_with_cast()guard new 64 MiB heap creation againstcritical_commit()(unlikepool::small::block()).This change:
d3d12/crates/leonida-gpu/src/pool.rs):pool::room()now computestexture_spares(limit, keep, avail_commit, critical): returns0undercritical_commit()(also stoppingRipe::now()from pre-allocating ahead blocks), caps to1below the 4 GiB commit floor, and scalesSPARE_KEPTlinearly by half of remaining commit headroom above 4 GiB so large-VRAM GPUs do not hoard up to 4 GiB of empty heaps as commit tightens.pool::texture_with_cast()returnsNonewhenresidency::critical_commit()is true instead of committing a fresh 64 MiB heap (matchingpool::small::block(), falling back cleanly to per-texture allocation).LEONIDA_COMMIT_FLOORon (d3d12/crates/leonida-gpu/src/resource.rs,d3d12/docs/switches.md):LEONIDA_COMMIT_FLOORby default (=0disables it;LEONIDA_ABstill overrides it), so idle textures out of use for >= 2.5 s and >= 60 frames are swept once available commit drops belowLEONIDA_COMMIT_FLOOR_MB(default4096 MiB) before hundreds of 64 MiB blocks fragment and lock system commit.d3d12/docs/switches.mdviatools/d3d12_switches.py --out.Tested
python -I scripts/red_green.py feat/texture-pool-commit-floor --no-fetch): exit 0 (verdict: red then green) — both new hermetic child-process tests (pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commitandresource::tests::commit_floor_defaults_on_and_zero_disables_it) fail onorigin/main(45dc41f9) and pass on this branch (703pass on both).leonida-gpuunit suite (cargo test --locked -p leonida-gpu --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws): 704 passed, 0 failed.cargo test --locked -p leonida-gpu --features diagnostics --test replay): 1 passed, 0 failed.python -I scripts/check_no_game_data.pyandpython -I tools/d3d12_switches.py --check d3d12/docs/switches.mdboth pass (exit 0).-Resolution 1440, Frame Gen 2x):a917c54d,LEONIDA_COMMIT_FLOORoff):pool.rstexture blocks grew to15,616 MB(244blocks;269made), local VRAM peaked at22,703 MB, process private bytes reached49,917 MB, available commit dropped from43,568 MBto2,212 MB(hittingcommit critical7 times before0x887A0005at 79.5 min).LEONIDA_COMMIT_FLOOR_MB=20000to exercise the floor early on 64 GB RAM):376commit-floor sweeps recycled330,946idle textures (20,578 MB) inside the initial5,056 MB(79blocks) with zero new 64 MiB texture blocks created over the remaining 7 minutes; local VRAM stabilized at11,207 MB, private bytes at37,001 MB, available commit stayed15.4–17.2 GB(0pressure warnings,0errors), frame rate23–29 fps(unchanged), texture refresh1.6 ms/frame(vs2.8 ms/framebaseline).GPUs tested: NVIDIA GeForce RTX 4090 D 48 GB (driver 616.92, Windows 11 10.0.26200).
AI-assisted: yes (Antigravity using Gemini 4 Neon for analysis, implementation, and tests; separate read-only reviewer agent using Gemini 4 Neon audited the diff, edge cases, red/green tests, and clean-room rules).
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rules changed)@x2Tweek on GitHub · 2026-12-02 19:34 UTC · original
Game-run test of this PR on a high-VRAM card: the textures are let go, but their 64 MiB blocks are not given back.
Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Series X profile, 3840x2160
output,
LEONIDA_RENDER_SCALE=0.6667, the title's upscaler,-HardwareRT -SmoothMotion -PrecompileAll -Log,LEONIDA_REAPER=0. Base: upstream main0d7a451ab(2026-12-02) plus #3113 and #3182, diag build. Candidate:the same plus this PR at
c7d0c9627. Two runs of about 5.5 minutes each: same save, then city driving. Thenumbers come from the runtime's own
copystatmemory lines and thecensusline.pool.rstextures in blockspool.rs64 MiB texture blocksWhat happens: with this PR, idle textures are let go once commit headroom falls. Here that was at about
4.5 GB left: the texture count fell from 184k to 24k within 30 s. But the 64 MiB
DEFAULTheaps holding them stayallocated. 192 blocks hold 2.1 GB of live textures, so about 10 GB is empty but still charged. As a result, private
bytes and commit kept their trend, and the card's memory did not drop either.
What would help: a pass that releases (or compacts into) empty or nearly empty texture blocks once their
textures are gone, or a cap on block count driven by the same commit floor. Without it, on a 32 GB card the floor
frees texture objects but not the memory this PR targets.
The runs were not the same route, so I do not compare frame rates between them (27.8 vs 19.4 fps median; the
second drive was busier).
Logs (scrubbed of paths) available on request.
AI-assisted: the measurements and the write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the
runtime's own log lines from the runs above.
@merzleckeier on GitHub · 2026-12-02 20:26 UTC · original · reviewed
Source check on
c7d0c9627for the retained-heap observation. At 3.5 GiB available commit the new policy allows at most one fully free spare whenroomsamples that value. That does not cap total blocks:Pool::reclaimonly dropsfree.whole(BLOCK)blocks and waits for returned ranges to become reusable. I verified the exact allocator and policy code in an isolated CPU harness: with three blocks and 64 KiB live in each of two, a zero-spare sweep drops only the wholly free block. The other two drop when their final ranges finish resting. The reported aggregate (2.1 GiB live in 192 blocks) therefore does not show how many whole heaps were releasable. For the next measurement, could you record the wholly free block count next to total blocks, ideally afterroomruns? That would distinguish fragmentation from a reclaim problem. Synthetic allocator test only; I did not repeat the GPU run. AI-assisted.@icdmkg2 on GitHub · 2026-12-02 20:36 UTC · original
Third-party Windows verification of #3201 (
D3D12-TEXTURE-POOL-COMMIT-FLOOR) on headc7d0c9627c7d0c962728c70551567bb9f9907d5f23253d986merged cleanly (git merge --no-ff) ontoorigin/mainb41763227.621.24(32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 1110.0.26300.9974,rustc 1.98.1.Results (MEASURED)
python -I scripts/check_no_game_data.py(all 3 touched files)0python -I tools/d3d12_switches.py --check d3d12/docs/switches.md0LEONIDA_ADAPTER=5060python -I scripts/red_green.py 3201 --mutate0(verdict: red then green) — both new child-process tests (pool::tests::room_and_texture_pool_drop_spares_and_refuse_new_blocks_under_critical_commit,resource::tests::commit_floor_defaults_on_and_zero_disables_it) went red → green;702pass on both,1only on green (ok),0failures.--mutate:pool.rs:902(critical_commit()guard intexture_with_cast) andresource.rs:2840(commit_floor_enableddefault-on) caught;pool.rs:48,:93,resource.rs:2831does not build;pool.rs:58,:62,:74(and doc comments:41,resource.rs:2816)not caught.LEONIDA_ADAPTER=5060+LEONIDA_D3D12_DEBUG=1cargo test -p leonida-gpu --features diagnostics --locked --lib -- pool:: resource::tests::commit_floor --test-threads=123 passed, 0 failed(note: runningpool::with parallel threads can trip a pre-existing globalTEXTURES.restingrace ina_texture_gives_its_piece_back_when_it_goes;--test-threads=1passes cleanly)Review notes (READ IN CODE)
texture_spares's linear scaling above the 4 GiB commit floor ((avail_commit - COMMIT_FLOOR) / (2 * BLOCK)) and the< 4 GiBcap-to-1branch have no direct pure-function unit test (--mutateonly exercises thecritical_commit()→0path). Adding a small unit test directly ontexture_spares(...)would lock down all four branches.DEFAULTblocks pinned whenever at least one live texture remains in a block; that's worth keeping in mind alongside this commit-floor change (even if compaction/reclaim stays a follow-up).AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
@fiestorra on GitHub · 2026-12-02 20:57 UTC · original
VERIFY-3201 — Windows nativo: suite sin regresiones, control sintético, y una pregunta sobre el cambio de defecto
(this PR)45dc41f95(behindmainb41763227)main—merge-treeclean,git merge --no-ffclean (switches.mdauto-merged)Ran
The one failure is this machine's, unchanged all day:
descriptor::host::tests::views_are_made_beside_the_heap_and_copied_infails identically on cleanmain(the iGPU artefact ofD3D12CreateDevice(None, ..)that #2995 addresses).A note for whoever runs this: three lines in the output read
test result: ok. 1 passed; … 763 filtered— those are the child processes a couple of tests spawn, not the suite. The suite's own line is the704 passed; 1 failed; 59 ignoredone.The PR ships its own tests in the same files, so the red side had to be built synthetically: in a copy I made
commit_floor()returnfalseunder a test variable, rebuilt, and ran —FAILED: resource::tests::commit_floor_defaults_on_and_zero_disables_it. The test bites.What I would want answered
LEONIDA_COMMIT_FLOORgoes from off to on for every user, so idle texture copies are dropped sooner (10 minutes → whatever the floor allows) unless=0orLEONIDA_AB. A commit-floor-on-by-default is a real behaviour change, and the body's evidence is a red/green run that skipsdepth_bounds_pipeline_loads_and_filters_…. Is that skip because the test is slow/flaky on the author's machine, and was the default flip measured withLEONIDA_AB(the body mentions it as an override, not as a measurement)? Without that, the default is being changed on reasoning alone.texture_spares(limit, keep, avail_commit, critical)returns 0 undercritical_commit(), andtexture_with_cast()refuses a fresh 64 MiB block rather than committing it — that is the path the#2821report is about.What I could not test
critical_commit()on a real machine: the tests drive it directly rather than through a pressured card.Written with an AI assistant.
@MoonEyes on GitHub · 2026-12-02 22:00 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@lixonik on GitHub · 2026-12-02 22:25 UTC · original
RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS on head
c7d0c9627(merged cleanly viagit merge --no-ffontomain8877be372).Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79)
python -I scripts/check_no_game_data.py-> PASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.md-> PASScargo test -p leonida-gpu --lib --locked pool::-> 22 passed, 0 failedcargo test -p leonida-gpu --lib --locked resource::-> 30 passed, 0 failedcargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-> PASSLive In-Game Gate (
-SeriesS -NoFrameGen, default env --LEONIDA_COMMIT_FLOORon by default)c7d0c9627on8877be372)315 s(443.9 s)64(5,611)0/027.0 fps(37.0 ms)21.5/28.2main(8877be372)315 s(441.9 s)63(4,338)0/027.9 fps(35.8 ms)26.1/29.6LEONIDA_COMMIT_FLOORwas active by default in the residency logs with0failed allocations and0sweeps under the floor (this host had> 40 GiBcommit headroom, so the low-commit eviction path itself was not forced during the run; commit-pressure behavior is covered by the unit tests and this run confirms clean steady-state behavior and zero regressions with default-onLEONIDA_COMMIT_FLOOR).AI-assisted: yes (Antigravity -- Gemini 4 Neon).
@Jyx0208 on GitHub · 2026-12-03 03:10 UTC · original
Thanks everyone for the thorough reviews, third-party verification, and live runs! Keeping head unchanged at
c7d0c9627so the passing in-game gate run stays valid.c7d0c9627merged ontomain8877be372(0errors,0device lost,27.0 fpsvs27.9 fpsonmain): #3201--skip depth_bounds_pipeline_loads_and_filters_drawsflag in the PR description came from the canonicalAGENTS.mdcommand (cargo test --workspace --exclude xtask --locked -- --skip depth_bounds_pipeline_loads_and_filters_draws), not from a failure on this GPU.LEONIDA_COMMIT_FLOORto default-on: while available commit is above4 GiB,commit_floor()short-circuits (0sweeps,0eviction overhead — confirmed by @lixonik's 315 s run). It only activates once commit drops below4 GiB(the same threshold whereresidencyenters commit pressure), andLEONIDA_COMMIT_FLOOR=0(orLEONIDA_AB) can still disable or A/B it.4 GiB,Pool::reclaimcan only freefree.whole(BLOCK)heaps, so scattered long-lived textures keep partially-empty blocks pinned (whereas triggering before sprawl kept our 4090 D run flat at79blocks /5.05 GB). Logging wholly-free vs total texture blocks and addressing block fragmentation / compaction belong in a focused follow-up PR perCONTRIBUTING.md(one topic per PR).scripts/red_green.py --mutateandLEONIDA_D3D12_DEBUG=1! We intentionally tested viapool::room()using existingorigin/mainsymbols rather than calling the newly introducedtexture_spares(...)directly soscripts/red_green.pycleanly evaluatesverdict: red then greeninstead ofred does not build.AI-assisted: yes (Antigravity using Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.