d3d12(hwrt): scale BLAS budget up to 6 GiB with DXGI VRAM pressure throttling (D3D12-HWRT-BLAS-BUDGET) #3225
Closed
teamallgit wants to merge 1 commit from
upstream-pr/3225 into main
pull from: upstream-pr/3225
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!3225
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3225"
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 teamallgit on 2026-12-02T20:48:24Z.
Claimed in the coordination issue as: D3D12-HWRT-BLAS-BUDGET (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7358311451)
Fixes: #3135
What and why
d3d12/crates/leonida-gpu/src/hwrt.rspreviously clampedBLAS_BUDGET_MOSTto 1.5 GiB (1536 << 20) and only re-read the DXGI local VRAM budget every 300 frames, without throttling active BLAS or scratch/instance spares when live DXGI VRAM usage rose. On 24–32 GB GPUs (e.g. RTX 4090 / 5090), the 1.5 GiB cap caused continuous BLAS eviction and multi-second host-side rebuild stalls while driving (#3135).This change:
BLAS_BUDGET_MOSTfrom 1.5 GiB to 6 GiB (6144 << 20) so 10% of the DXGI local budget scales naturally on high-VRAM GPUs (~2.2–2.4 GiB on 24 GB cards, ~3.0–3.2 GiB on 32 GB cards) while staying unchanged on 8–16 GB cards.blas_budget_for_usage(local, used, override_bytes)(overflow-safeu128ratio checks) to tighten the BLAS budget under live DXGI VRAM pressure (>=85%-><=768 MiB,>=90%-><=512 MiB,>=95%->256 MiB) and refreshes every 60 frames (BUDGET_LOOK_FRAMES = 60).spare_limitonLeasePool<T>enforced insidegive()and updated on every budget tick (set_spare_limit()), trimming largest idle scratch/instance spares down to96 MiBat>=85%and64 MiBat>=90%(and restoring256 MiBonce pressure clears), retiring resources outside both locks.LEONIDA_HW_RT_BLAS_MB(minimum 256 MiB, overflow-safe) for explicit BLAS cache sizing and documents it ind3d12/docs/switches.md.Tested
Rebased on
main(8d82a34ae), commitbce6a5b15:cargo test --locked -p leonida-gpu --lib hwrt -- --test-threads=1— 24 passed, 0 failed (covers 6 GiB scaling,85%/90%/95%/ over-budget /local == 0boundaries,parse_blas_budget_mbedge cases, andLeasePooltrim + activegive()capping).LeasePool::give()active spare enforcement,switches.mdcount/prose alignment, and parser unit tests; all fixed and re-verified).GPUs tested: n/a (synthetic CPU-only unit tests on Windows 11; no GPU or game files required)
AI-assisted: yes (authored with Gemini in Antigravity and audited by a separate read-only reviewer subagent)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rules added)Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T20:52:02Z.
Review: COMMENTED
Source and CPU policy check on
bce6a5b1. Using the exact budget helpers with a local budget of 24,000 MiB, repeated samples one byte below and at 85% alternate the BLAS limit between 2,400 and 768 MiB and the spare limit between 256 and 96 MiB. The existing eviction path evicts toward 90% of the current BLAS limit and rebuilds a retained recipe if it is named again. Since #3135 is about repeated eviction and rebuilding, can you check what happens across repeated pressure crossings and either show the cache remains stable or add a slower recovery threshold? A single boundary test does not exercise that interaction. I ran the extracted CPU policy only, with no GPU or game workload. AI-assisted.Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T21:39:00Z.
VERIFY-3225 — Windows nativo: el presupuesto de BLAS y sus topes, con control que muerde
(this PR)b41763227= currentmainmain—merge-treeclean,git merge --no-ffcleanRan
The one failure is this machine's, unchanged all day (
views_are_made_beside_the_heap_and_copied_in, the iGPU artefact ofD3D12CreateDevice(None, ..)that #2995 addresses).Negative control (synthetic — the tests ship with the change): I made
blas_budget_for_usageignore its override argument under a test variable, rebuilt and ran →FAILED: blas_budget_tightens_under_vram_pressure_and_respects_override,assertion left == right failed: explicit LEONIDA_HW_RT_BLAS_MB override wins. The test bites.First control attempt, recorded because it was wrong: I patched the env reader (
blas_budget_override) instead of the pure function the test calls, and the test still passed — the test passes the override explicitly (Some(6144 << 20)), so the env reader is not on its path. A control that does not bite is not a control, and I moved it to the function under test.What the change says, from the test's own boundaries: the budget tightens at 85 % (768 MiB), 90 % (512 MiB) and 95 % (256 MiB) of the card's local memory, an over-budget usage is floored at 256 MiB, and an explicit
LEONIDA_HW_RT_BLAS_MBwins but never drops below that floor. Thelease_pooltest covers trimming and the active-spare limit under the same pressure.Stacked, once more
The branch carries #3204's
frame.rs(CAP_UNREAD), so merging it lands #3204 too — the fifth stacked branch tonight.What I could not test
blas_budget_for_usageand the lease pool with synthetic numbers; the GPU's own usage is not measured here.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-02T21:51:16Z.
Game run on the RTX 5090 from #3135, with this PR and without my local 6 GB override.
Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Base: upstream main
0d7a451abplus #3113, #3182 and #3204, diag build. This PR merged on top atbce6a5b15, withLEONIDA_HW_RT_BLAS_MBunset. Series X profile, 3840x2160 output, render scale 0.6667,-HardwareRT -SmoothMotion -PrecompileAll -Log, fullscreen. About 5 minutes of city driving.Tests:
cargo test -p leonida-gpu --lib hwrtgives 25 passed and 0 failed.Budget and throttling: the budget came out at 3141 MB (10 % of the card's 31.4 GB). Late in the drive,
with the card at about 24 GB in use, it was trimmed to 3034-3040 MB. Live BLAS memory peaked at about 2.5 GB.
Not one BLAS was evicted for the budget ("evicted 0 (0 MB), 0 evicted now" on every line), against continuous
eviction at the 1.5 GB cap.
time. So 3.1 GB is enough on this card for this drive.
budget stood at 3141 MB with 0.8-1.3 GB live, and the card was idle. New host pipelines were being made around
the second one, so they look unrelated to this PR, but I have not proven it. The local 6 GB run had none, on a
different drive.
From my side, this PR fixes what #3135 reported.
AI-assisted: the build, the test run, the log reading and the write-up were done with Claude Opus 5.5 (Claude
Code); the numbers are the runtime's own log lines from the run above.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:00:08Z.
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).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:25:03Z.
RUN (in game, RTX 5070 12 GB, Hardware RT, 315 s in-world gate) -- PASS on head
bce6a5b15(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-> PASSLEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --features diagnostics --lib --locked hwrt-> 24 passed, 0 failedcargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked-> PASSLive In-Game Gate (
-SeriesS -NoFrameGen, Hardware RT:LEONIDA_HW_RT=1,LEONIDA_AMBIENT=0,LEONIDA_RT_RESOLVE=1,LEONIDA_ACTIVATE_RAYS=1)315 sin world (500.0 stotal,64world samples>= 1000draws, max5,697draws)0/0/0d3d12_run_fps.py): median25.4 fps(39.4 ms; slowest tenth17.7 fps, fastest tenth26.5 fps;3000-4999draws median25.4 fpsacross54samples)hardware DXR 1.1 RT manager initialized (LEONIDA_HW_RT=1) tier=11, adaptervram_budget_mb=11176hardware RT BLAS memory: dynamic budget tracked1078..1117 MBon this 12 GB card, peak live531 MB(4,987BLAS),0evictions (0 MB),929 MBfreed past fence,39,210TLAS marks read /0lostBLAS live 5198(built 19075,refit 343974,refit->rebuild 1149,rehydrated 3312),TLAS live 5(builds 39230),AS memory 532 MB,lifted shaders 14(0software fallbacks)AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T07:01:38Z.
This pull request has a merge conflict with current
main(d9b618f10), so it can't be run in game or merged as it is. Could you merge the latestmaininto it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T09:17:57Z.
#3225rebasado y empujado:pr-3225-rebased=e7fab42a5— y el recuento no está adivinado: está calculadoEl conflicto era la línea del recuento (
main684/644, su base 683/643), pero esta vez podía derivarlo en vez de elegir:Y su PR añade una fila (
LEONIDA_HW_RT_BLAS_MB, con frase en la última columna), así que el número que toca es 685/645 — y no hizo falta creérmelo: después de insertar su fila, contar el fichero dafilas 685 · con frase 645ycoincide: True.Lo que eso cambia respecto a
#3308: allí tomé la línea demainporque su PR no añadía filas; aquí su PR sí añade una y la cabecera es una función del contenido, así que hay que recalcularla. La receta «tomar la demain» es correcta sólo cuando la PR no añade un interruptor.Los números del rebase:
Y
717contra los715demain: dos tests nuevos, medidos en el diff —hwrt.rstrae los suyos, y son de los que se pueden correr sin el juego (presupuesto de BLAS contra VRAM).Lo que no verifiqué: el comportamiento con una tarjeta real — el presupuesto de BLAS depende de la VRAM y de la presión de DXGI, y aquí sólo se prueba con lo que el test simula.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T09:24:21Z.
I independently replayed
bce6a5b15ontod9b618f1. The only merge conflict was theswitches.mdheader. Resolving it to 685 runtime names and 645 with descriptions produced a page byte-for-byte identical to what the sources generate. The full catalog checker from #3308 passed, along with all 22 catalog tests. Keeping the current main header (684/644) made that checker exit 1. This verifies the proposed documentation resolution on a local replay. GitHub still shows the original PR head as conflicting. AI-assisted with OpenAI Codex.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T18:03:25Z.
Thanks for the work on this. This pull request has a merge conflict with the current
mainand has had no new commit, comment or review for more than 5 hours, so I am closing it to keep the list of open pull requests manageable. This is not a judgement of the change. Whenever you like, merge the latestmaininto your branch, resolve the conflict, and reopen it (or open a new pull request that links this one). Please re-run the relevant tests on the new head; a reviewer will look at it when time allows, with no guarantee of timing or outcome.Generated by Claude Code
Pull request closed