GPU: cap a shader-visible sampler heap at 2,048 instead of losing it #100
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!100
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/100/head"
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?
@Luislariosss on GitHub · 2026-11-24 00:30 UTC · original
Luislariosss:fix/sampler-heap-cap→main· +125 −26 · 2 files · 1 commits · closed without mergingFixes #65.
What
HostHeap::newhad a portable-limit fallback only for view heaps, guarded by!sampler. D3D12 caps a shader-visible sampler heap atD3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE(2,048) on every resource binding tier, so a title asking for more failedCreateDescriptorHeap;HostHeap::newreturnedNone,Heap::host()cached thatNonein itsOnceLockfor the rest of the run, andState::binddropped the sampler heap fromSetDescriptorHeapswithout saying anything.Changes
PORTABLE_SAMPLERS = 2_048next toPORTABLE_VIEWS, naming the D3D12 constant.cap_for(sampler, count, extra) -> Option<(total, mirrored)>, and oneErrarm inHostHeap::newconsults it for both heap kinds. The view behaviour is unchanged (PORTABLE_VIEWStotal, mirroredPORTABLE_VIEWS - extra); a sampler heap caps at 2,048 with a warning that names the request and the cap.GPU_RANGES,kept, andfill_null. A sampler heap no longer reserves an unusedDYNAMIC-sized dynamic-slot vector (dynamic()already returns early for samplers).fill_nullsizes its null block tomin(total, BLOCK)and returns early when the total is 0.title slot past the host heapdiagnostic counts sampler and view slots separately instead of sharing one high-water mark.State::bindwarns once when a bound heap has no host heap instead of dropping it silently, and a sampler index past the host heap is not queued for a fresh copy, which could never be made.The last two are behaviour changes rather than pure additions, so they are the part worth reviewing hardest: a sampler slot past 2,048 cannot be mirrored, and queueing it for
freshonly spent work on a copy thatmirrorthen discards.Tested
The two new tests cover the cap boundary for both heap kinds: sampler at 2,048 (no cap) and 2,049 / 100,000 (capped), view under, at and over
PORTABLE_VIEWS, withextrasubtracted for views and ignored for samplers, plusu32::MAX.Not tested: the title itself. I do not have the game files, so I could not reproduce the original symptom or exercise a real heap over 2,048 entries; the change is verified against the host limit and by unit test only. Nothing here was run against
mainof this repository with a game.I did not run
cargo fmtover the tree: it already reports diffs on untouched files, and the two files here are formatted by hand to match the surrounding style.AI-assisted.
@Luislariosss on GitHub · 2026-11-24 00:33 UTC · original
For completeness, the whole workspace on this branch, not just
victory-gpu:cargo clippy --workspace --all-targetsis clean on this branch too. Still nothing here that exercises the title: the sampler heap path is covered by unit test only, as the description says.@DaviTostes on GitHub · 2026-11-24 00:48 UTC · original
Tested
f7d08ceunder Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build withcargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.victory_gputest binary: 38 passed, 3 failed; this PR's new testdescriptor::host::tests::cap_for_samplers_matches_d3d12_limitpasses under a real D3D12 implementation (vkd3d-proton).main: the indirect clamp shader (Wine'sd3dcompiler_47), the empty pipeline library (E_INVALIDARGfrom vkd3d), and #128 (VirtualQuerysees vkd3d-mapped memory asMEM_FREE, skipping the deferred texture upload).Coordination note: #74 and #86 are open for the same #65 and change the same
HostHeap::new; #86's description says it covers what #74 leaves open and that the two conflict. This PR does not mention either, so three fixes for #65 are in flight — worth converging before review time is spent on all three.No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
@Luislariosss on GitHub · 2026-11-24 00:50 UTC · original
Thanks for the Wine/vkd3d run, and for flagging the duplication - that is worth settling before review time is spent three ways. #74 is already closed, so it is #86 against this one.
I read #86 and ran it here (AMD RX 9060 XT, RDNA4, Windows 11 26200, MSVC 2022,
a80eb17c4):Where they differ
D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZESAMPLER_DYNAMIC = 256D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE2_048naming itcap_for(sampler, count, extra), pure, tested at both heap kinds' boundaries andu32::MAXState::bind, once)My reading
#86 is the better design and should be the one merged. Giving a capped sampler heap 256 dynamic slots means a table reaching past 2,048 is still made afresh, which is strictly better than my version: I only warn, and
State::bindskips the fresh path for sampler slots because it could never be made. It also uses the real constant, which I should have done.This PR has two small things #86 does not: the pure
cap_forwith its boundary tests, and the one-shot warning when a heap has no host heap at all. Both are worth folding into #86 rather than keeping a second PR alive for them.So: if @faultzonsol wants them, I will post the
cap_fortests and theState::bindwarning as a patch against #86's branch, and close this one. If you would rather take a single change under one author, close this without further comment - I will not take it personally, and the Wine result stands either way.I have not closed it yet because the choice is yours and #86 has no independent run on AMD yet. My machine can provide one (
cargo test --workspaceon this card: 229 passed) if that helps decide.AI-assisted.
@Marvisak on GitHub · 2026-11-25 00:00 UTC · original
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #1032. Same cap of oversized sampler heaps at 2,048 as #1032 in 125 lines instead of 15.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed