fix(device): preferred mask + required-only fallback for GetMemoryType (#59) #87
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!87
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-59"
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?
Summary
Device::GetMemoryTypewas a bare first-superset match with no fallback — it threw whenever no memory type satisfied the requested property flags. Callers that combine a mandatory flag with a perf-only one (the descriptor heaps requestHOST_VISIBLE | DEVICE_LOCAL) would then fail allocation on any device without a host-visible device-local heap (i.e. no resizable BAR).The fix adds a
preferredmask distinct fromrequired:required | preferredis chosen first;required-only match instead of throwing;requiredcannot be met (no valid memory exists for the allocation).VulkanBuffer::Create/Resizegain an optional trailingpreferredPropertyFlags(defaulted, source-compatible), and the descriptor heaps now treatDEVICE_LOCALas a preference layered on mandatoryHOST_VISIBLE. On resizable-BAR hardware the first-pass match is unchanged; non-ReBAR hardware now gets a host-visible-only allocation rather than a hard failure.Correctness note
This change deliberately does not touch any flush/barrier behaviour. No coherency is assumed anywhere here —
FlushDeviceand its mandatoryHOST_WRITE→device barrier are untouched.Tests
Adds
tests/MemoryTypeFallback, a pure-CPU test (no GPU device needed) that installs syntheticDevice::memoryPropertieslayouts and exercises:typeBitsgatingrequiredstill throwingcrafter-build test→ 7 passed (MemoryTypeFallback + the 6 existing tests).Resolves #59