d3d12: give host sampler heaps every slot the shaders can reach (D3D12-GPU-SAMPLER-HEAP-2048) #2766
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2766
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/sampler-heap-2048"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: D3D12-GPU-SAMPLER-HEAP-2048 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7276016092)
What and why
Shaders clamp a sampler index to 2,047.
leonida-shaderemit/shader.rsnotes this is "not the bound heap's own count, which a title heap smaller than 2,048 would need". ButHostHeap::new(d3d12/crates/leonida-gpu/src/descriptor/host.rs) made a host sampler heap with exactly the title's count. With a title sampler heap of fewer than 2,048 samplers, an index between its count and 2,047 read past the end of the host heap. Such an index comes from a number read out of memory the host hasn't got yet, which happens while streaming.The change:
fill_nullalready makes every slot a null point sampler, so the slots past the title's count read as that.This ports ESAT's fix from the sibling VIctory tree (TaynanGT/Vice-Tay
dd67ae7, GPL-3.0).Tested
descriptor::host::tests::sampler_heaps_have_every_slot_the_shaders_can_reach: a 16-sampler title heap gets 2,048 host slots and keeps count 16, and a 2,048 one keeps 2,048. Onmain(7663c34fc) it fails (a 16-sampler heap backs 2,048 slots,left: 16,right: 2048); with the change it passes.cargo test -p leonida-gpu --lib: 573 passed, 0 failed, 52 ignored (main: 572).cargo clippy -p leonida-gpu --lib --tests: no warning in the changed lines.GPUs tested: the test makes its heaps on the local hardware D3D12 device; no game run.
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Independent check on Windows (not the author), at
e7b9959c5.cargo test --locked -p leonida-gpu --lib(shared warm target): 573 passed, 0 failed, 52 ignored in 13.9 s.Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned.
AI-assisted: yes (opencode).
Verified on Windows, for a merge (not the author). AI-assisted (Claude Code agent
oreofr-agent). RTX 4070 Laptop 8 GB, NVIDIA 621.40, Core Ultra 7 155H, Windows 11 Pro, Rust 1.98.1 pinned,cargo test --locked.Head
e7b9959c5merged into currentmain90c514437(clean), tested in one batch with #2589, #2766, #2709 and #2802 (main + all four, merged in that order, clean).if falsein place ofif sampler),sampler_heaps_have_every_slot_the_shaders_can_reachfails on this machine (it has a device, so the test checks the heaps). The mutation was reverted after the run.leonida-gpumain 589 passed / 0 failed, main + the four 598 / 0;leonida-hle242 / 0 on both.diagnostics,mimalloc, no DLSS), fresh copy of our gate data,-SeriesS -NoDlss -NoFrameGen, BAR 0, texture budget 1024, walking (keys file, 115 key changes): 330 s in the world, 0 device loss, 0 ERROR lines, no crash, clean close. Early stalls while ~169 pipelines were first made (as on main), then steady 21-23 fps (median of the last 30 fps lines 21.6), 24 GB private at the end.One run of several pull requests together covers each at its head (
docs/maintaining.md, #2797); if a merge of one of them breaksmain, the others are split out and re-run.Merging (after #2589). Head
e7b9959c5merges cleanly with main5dd6d444f(merge commit10bed9ff2).Claim: in the description, a comment in #2570 by the author (checked).
Red/green: by oreofr-agent (not the author), RTX 4070 Laptop, Windows 11: red by mutation on this head (comment above). I ran on main
86c30fcea+ #2589, #2766, #2709, #2802 (this order):cargo test --locked -p leonida-gpu599 passed, 0 failed (main alone 590/0);-p leonida-hle242/0. An independent second check (separate agent) found no blocker.In-game run: RTX 4070 Laptop 8 GB, NVIDIA 621.40, the four together at their heads on
90c514437: 330 s in the world walking, 0 device loss, 0 ERROR lines; same-scene picture against main: no visible change. Since thenmainonly gained the two CI fixes (#2825, #2827: a test-module declaration and a tool's__main__), nothing that runs in the game. Default change with no switch: every host sampler heap now has 2,048 slots (a revert undoes it).CI: green on the head (5/5) and on main (CI, No Game Data on
86c30fcea; Runtime last green oncd9fe51a9).AI-assisted: yes, Claude Code agent
oreofr-agent, merged on OreoFR's (maintainer) written instruction.finding: fill_null's null POINT samplers in past-count slots change visible pixels in GTA VI — faces go to noise
Where:
d3d12/crates/leonida-gpu/src/descriptor/host.rsfill_null(~:2451) — the 2048-slot heap frome7b9959c5.Evidence: past the title's sampler count the slots get POINT-filtered null samplers, and character faces (which sample past-count slots) render as noise; making null samplers LINEAR (local arm
LEONIDA_NULL_SAMPLER_LINEAR=1, host.rs ~:2512) brings them back — live A/B, same exe, Wine + vkd3d-proton master + RTX 4090. #2766's tests check slot counts, not what past-count sampling looks like; vkd3d's pre-#2766 default read as linear-ish and our older build proved that OK.Question for the maintainers: what should past-count slots hold — a linear-ish default, or is past-count sampling considered title error?