[perf][MEDIUM] Descriptor heaps force HOST_VISIBLE|DEVICE_LOCAL with no fallback #58
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#58
Loading…
Add table
Add a link
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?
Subsystem: Device / DescriptorHeap
Location:
interfaces/Crafter.Graphics-DescriptorHeapVulkan.cppm:86-89(root causeimplementations/Crafter.Graphics-Device.cpp:814-827)Impact: MEDIUM (robustness/portability) · Effort: Small · Setup-time
Related: #59 (the fallback mechanism this needs), #89 (upload-strategy helper — generalizes the "don't over-commit the small BAR window" budget logic referenced below)
Problem
Initializeallocates 3 heap copies requestingHOST_VISIBLE|DEVICE_LOCAL.GetMemoryTypereturns the first match and throws if none exists. On a discrete non-ReBAR GPU the only such type is the ~256 MB pinned BAR heap, so the bindless heaps compete for scarce BAR memory — or the app hard-throws.Proposed fix
Make
GetMemoryTypeprefer-but-not-require DEVICE_LOCAL for host-visible heaps: tryHOST_VISIBLE|DEVICE_LOCAL, fall back to plainHOST_VISIBLE. Keep HOST_VISIBLE a hard requirement.Correctness caveat
The per-frame triplication is correct by design (each frame-slot binds its own heap copy; collapsing to one shared region is a write-after-read race — keep it). If the fallback type lacks HOST_COHERENT, correctness then depends on the existing
FlushDevice/FlushHostpaths being called.Investigated — this is already fully resolved by #59 (commit
294c137, merged via PR #87). #58 and #59 are duplicate findings from the same audit, and #59 implements the exact fix proposed here, touching the same files and lines.What is already in
master:Device::GetMemoryType(implementations/Crafter.Graphics-Device.cpp:814-843) now takes apreferredmask distinct fromrequired. It triesrequired | preferredfirst, falls back torequiredalone, and throws only when evenrequiredcannot be satisfied.HOST_VISIBLEstays a hard requirement;DEVICE_LOCALis a preference.interfaces/Crafter.Graphics-DescriptorHeapVulkan.cppm:86-93— the exact lines this issue cites) now callResize(..., VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, size, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT), i.e. host-visible required + device-local preferred. On a discrete non-ReBAR GPU they get a host-visible-only allocation instead of competing for BAR memory or hard-throwing.FlushDevice()(implementations/Crafter.Graphics-UI.cpp:69,77,304,327,344), so a fallback memory type withoutHOST_COHERENTis still safe.tests/MemoryTypeFallback) exercises selection, preference, fallback, and the unsatisfiable-required throw. It passes:crafter-build test→ 8 passed, includingMemoryTypeFallback.No code change is needed. Recommend closing this as a duplicate of #59. No PR opened (there would be no diff).