GPU: a sampler heap over 2,048 loses the host heap entirely #65
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?
Imported from Marvisak/VIctory. Originally posted by WallasSCRIPTS on 2026-11-24T00:04:04Z.
A sampler heap larger than
D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE(2,048) makes
HostHeap::newreturnNone. The heap is lost outrightinstead of being capped like a view heap.
Where
crates/victory-gpu/src/descriptor/host.rs,HostHeap::new:make(count + extra)withsampler = trueandcount > 2,048fails atCreateDescriptorHeap(2,048 is the sampler limit on every binding tier).!sampler, so a sampler heap goes to thegeneric
Err(e) => { warn; return None; }path.Descriptor::host()caches thatNoneforever withget_or_init.draw::State::bindbuildsSetDescriptorHeapswithfilter_map(...host()),so a heap without a host is dropped from the list. That also shifts the
heap indices the translated root signature expects, not just the missing
sampler heap.
View heaps behave differently: they cap at
PORTABLE_VIEWS(1,000,000) andkeep the title's first
PORTABLE_VIEWS - DYNAMICslots; #21 remaps roottables that reach past that cap.
Fixing it
Sampler chunks plus a copy path for a table crossing a chunk boundary would
be the complete fix; sampler tables cross more often because the chunks are
small. At minimum the failure should be reported clearly instead of
silently dropping the heap.
Found in static review while discussing #35. I have not seen a title ask
for more than 2,048 samplers; a log line with the title's sampler heap size
would confirm whether this path is live.
Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T00:12:04Z.
Checked this against
main97c78d1by code reading (no D3D12 here, so no GPU repro). The report matches the code:HostHeap::newsetsextra = if sampler { 0 } else { DYNAMIC }and the cap arm isErr(e) if !sampler && count + extra > PORTABLE_VIEWS, so a sampler heap above 2,048 falls through to the genericErr→None(crates/victory-gpu/src/descriptor/host.rs:68-100).Descriptor::hostcaches thatNonewithget_or_init(crates/victory-gpu/src/descriptor.rs:79-92).draw.rs:410buildsSetDescriptorHeapswithfilter_map(...host()), so the heap also disappears from the list and the indices shift.A smaller intermediate step than chunking, if you want the heap to survive meanwhile: mirror the view path — on failure with
sampler && count > 2048,make(2048)and keep the title's first 2,048 slots, recordingcount = 2048soGPU_RANGESandcpu(index)stay consistent. It still needs the #21-style remap once a root table reaches a slot past the cap, but it stops the whole heap (and the root heap indices) from vanishing for titles that only touch the low slots.No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Imported from Marvisak/VIctory. Originally posted by WallasSCRIPTS on 2026-11-24T00:17:25Z.
Update from #74: a sampler heap the host refuses is now capped at
D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE(2,048) instead of returningNone. That keeps the first 2,048 samplers and, importantly, keeps the heapin
SetDescriptorHeaps:draw::State::bindused to drop a hostless heap withfilter_map, shifting the heap indices the translated root signature expects.The other half is still open here.
HostHeap::dynamicis view-only, soState::tablescannot remake a sampler table with an entry past 2,048; thosetables are not made at all. A complete fix needs sampler chunks plus a copy
path for a table crossing a chunk boundary. Sampler tables cross more often
because the chunks are small.
One correction to the original report: this is driver-dependent. The RX 7600
here accepts a 2,049-slot sampler heap, so the refusal is not universal —
the test in #74 forces it with
u32::MAXso the path is exercised on anyhost.
Imported from Marvisak/VIctory. Originally posted by WallasSCRIPTS on 2026-11-24T00:23:13Z.
Follow-up to my earlier comment: the second half is now in #74 too. A capped
sampler heap reserves 256 scratch slots, and
HostHeap::dynamic/releaseuse them like a view heap's.
State::tablesalready remakes a table whoseentries reach past
host.count(), so sampler tables past the cap now takethat path instead of being skipped. An uncapped sampler heap keeps all
2,048 title slots.
What remains is only the complete chunked design if a title needs more than
2,048 samplers simultaneously — this gives it the first 1,792 plus a 256-slot
scratch area, not more addressable samplers. #65 can stay open for that, or
be closed if the cap is enough in practice; I cannot tell without a log of
the title's sampler heap size and usage.
cargo test -p victory-gpu: 41 passed; clippy clean.Imported from Marvisak/VIctory. Originally posted by WallasSCRIPTS on 2026-11-24T00:25:46Z.
Correction: #74 is closed in favour of #86, which covers the same fix with
a cleaner design — it caps at the spec limit up front rather than only when
the host refuses the larger heap, so behaviour does not depend on the
driver. #86 also gives the capped sampler heap 256 scratch slots for
State::tables, which is the second half of this issue. Please follow #86instead of my earlier comments.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:48:38Z.
Automated triage for the maintainers.
Confirmed on current
main. Incrates/victory-gpu/src/descriptor/host.rs,HostHeap::newmakes a sampler heap withcount.max(HEAP_SAMPLERS)slots and has no capped fallback: if the host refuses the size, it logsno host descriptor heapand returnsNone(the view path caps instead). The heap is then left out ofSetDescriptorHeapsindraw::State::bind_heaps(crates/victory-gpu/src/draw.rs,filter_mapoverhost()), so draws run with no sampler heap bound. As noted in the comments, whether the host refuses 2,049+ samplers depends on the driver.The pull requests linked to this issue (#86, #100) are closed without being merged, and no open pull request found carries the cap. A log line with the title's sampler heap size would show whether this path is reached in practice.
Generated by Claude Code