A card counts as small at fifteen places with six different cut-offs, so VRAM rules disagree about what a small card is #1511
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot#1511
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Type: correctness · Area: renderer, VRAM policy · Part of: #1493
TL;DR
Whether a card is "small" is decided at fifteen places on main, with six cut-offs between 4.5 and 8.5 GiB, on three different quantities (the card, the driver's allowance, the PC's RAM). Three of the fifteen are copies, and one PC can be small for one rule and not for another. The static budgets for textures and mirrors also add up to 93 to 97% of an assumed allowance on 4, 6, 8 and 16 GB cards. The counters are under way in #1339; I propose one function that classifies a card once, and a game-free test that prints the table and fails when two rules disagree.
Breakdown
device_policy.h, that turns (card, allowance, RAM, integrated) into one class, and every rule asks it. Where two cut-offs differ on purpose, the function keeps both and names the reason. (2) A game-free table test. (3) Count first: take the by-class counters from #1339 and do not repeat them here.Evidence
Where a card is tested, on main (
310e7c9df). "Allowance" is what the driver lets the game use; "card" is the device-local heap.mirror_budget.h:12:32); texture budget at most 2.2 GB (texture_budget.h:33, 45)device_policy.h:110vk_memory.cpp:3693vk_memory.cpp:5327device_policy.h:143vk_texture.cpp:2187device_policy.h:156device_policy.h:162texture_budget.h:28texture_budget.h:29, 44astc_bc_policy.h:13upscaler_rows.h:266device_policy.h:571vram_compact.h:18device_policy.h:167-168,vk_vma.cpp:65, 103), floor and damping (vram_compact.h:47, 112, 119, 150,device_policy.h:186)auto_settings.h:64, 86mirror_budget.h(a quarter; 256 MB on small cards) above code that returns a third on any card up to 6.5 GiB (vk_memory.cpp:3687-3693).device_policy.h:159-161is about a laptop card (an RTX 4050 Laptop with 5.7 GB).vk_vma.cpp:69and 32 MB in code (:77); the hold line is "85" atvk_texture.cpp:5032and 80 in code (:5037).texture_frame(vk_texture.cpp:4780-5568, 789 lines) still stacks the rules bymin(): the budget by card, the dynamic floor (:5011-5016), the 90% rule (:5021), the hold and reserve lines (:5037-5049), the 97% count line (:5067), driver refusals (:5077), Windows commit (:5097) and Linux pressure (:5125). That is the nine rules of the research.The static budgets, computed from main's own formulas (
texture_budget.h dedicated_bytes,device_policy.h mirror_budget), with the allowance assumed 90% of the card (7,378 of 8,192 MB was seen in #130) and plenty of RAM:Not in those columns: render targets, shadows (about 300 MB), upscaler and frame generation images, streams, and the driver's own. The research reports found, from 393 player logs attached to bug reports (so biased toward trouble): on the 8 GB class (83 logs, 8,616 lines) 13.2% of the VRAM lines were past 97% of the allowance, and the driver's count was about 0.95 GB above the allocator's blocks (median; 2.0 GB at p90; 6,307 samples). Method: the research's
field_vramandfield_gapscripts over the downloaded logs.The ledger half, so nobody redoes it: #1339 (open, draft) adds
mem_account.h, a registry of pools with their VRAM and RAM bytes, and onevk: budget:line with anunaccountedfigure. On an RTX 3090 that figure fell from 426 MB to about 280 MB once every allocator buffer was counted. It counts only; its arbiter, which does change behaviour, is a separate commit. For the shared rule, the same PR adds a seventh predicate (six_gb_cardinmirror_budget.h) and removes row 3's copy; rows 2 and 4 to 15 are untouched.Allocation sites, for what a ledger can still miss: outside
vk_vma.cppthere are 73 in 15 files (grep count). Five are directvkAllocateMemorycalls:vk_coopmat.cpp:135,vk_draw.cpp:4880,vk_memory.cpp:274, 520andvk_texture.cpp:4158. The other 68 callcreate_image,create_buffer,create_device_buffer,create_buffer_cachedoralloc_sparse_block(one of them,vk_fsr4.cpp:337, is a driver hook, not a site). The upscaler libraries allocate on our device and stay unaccounted.Proposed change
card_class(card, allowance, ram, integrated)) and have rows 1 to 15 call it. Start with an enum that holds the six existing cut-offs, so no number moves.How we would test it
tests/test_device_policy.py, which already runsdevice_policy()on made-up PCs of 4, 6, 8 and 24 GB. Print the class each rule used for each card from 4 to 24 GB and the sum of the static budgets against the allowance. Fail when two rules disagree, and when the sum passes the chosen bound.RX_VK_TEST_VRAM_MBandRX_VK_TEST_ALLOWED_MBset to 4, 6, 8, 12 and 16 GB, the log'svk: policy:lines are identical on main and on the branch. This proves no number moved; it makes no speed claim.Related
vk: budget:line and the arbiter. The forge shows it as not mergeable with main today.RX_VK_TEST_VRAM_MB, the switch the in-game check uses.New on this forge; not opened on GitHub.
Possibly related, for context: