Repository navigation
GPU: cap a refused sampler heap and remap its past-cap tables - #74
WallasSCRIPTS wants to merge 2 commits into
Conversation
A sampler heap the host refused made HostHeap::new return None. The heap was then dropped from SetDescriptorHeaps by filter_map, which also shifts the heap indices the translated root signature expects — worse than losing the sampler slots alone. Retry with D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE (2,048) slots and report what the title asked for, what was made, and what was lost. The first 2,048 samplers keep working and the bound heap order is unchanged. The test uses u32::MAX to force the refused path on every host: a 2,049-slot heap is accepted on some drivers, including the RX 7600 here. Samplers past the cap still need a copy path: HostHeap::dynamic is view-only, so State::tables cannot remake their tables. Issue Marvisak#65 stays open for that part. Verified with cargo test -p victory-gpu (40 passed), clippy clean, and rustfmt --edition 2024 clean on the changed hunks.
Capping the heap kept the first 2,048 samplers, but State::tables could not remake a table past the cap: HostHeap::dynamic was view-only and sampler heaps had no scratch area. Those tables were simply not made. Reserve 256 slots in a sampler heap only when it had to be capped, and let dynamic()/release() use them like a view heap's. An uncapped sampler heap keeps all its slots for the title. Use saturating_add for the requested size so a title asking for u32::MAX reaches the cap instead of overflowing. Two tests cover the capped heap's scratch area and the uncapped heap's absence of one. cargo test -p victory-gpu: 41 passed, clippy clean.
|
Closing in favour of #86, which is the better design and covers the same One suggestion if it helps: the cap warning currently logs only Verified on my branch before closing: |
Relates to #65.
What
A sampler heap larger than
D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE(2,048) that the host refused made
HostHeap::newreturnNone. The genericerror arm had no fallback, unlike view heaps which cap at 1,000,000.
Losing the heap is worse than losing the slots:
draw::State::bindbuildsSetDescriptorHeapswithfilter_map(...host()), so a heap without a hostis dropped and the heap indices the translated root signature expects shift.
This PR:
asked for, what the host made, and what was lost. The heap stays bound.
HostHeap::dynamic/releaseuse them.State::tablesalready remakes atable with an entry past
host.count(), so sampler tables past the capnow take that path instead of being skipped. An uncapped sampler heap
keeps all 2,048 slots for the title.
count.saturating_add(extra)keeps a title asking foru32::MAXon the cappath rather than overflowing in a debug build.
Driver note
Some drivers accept a 2,049-slot sampler heap — the RX 7600 here does. The
test forces the refusal with
u32::MAXso the path is exercised on any host.Verification
cargo test -p victory-gpu: 41 passed, 0 failed.cargo clippy -p victory-gpu --all-targets: clean.rustfmt --edition 2024clean. The file haspre-existing formatting drift elsewhere, untouched here.
no title was run.