feat(device): runtime upload-strategy helper PreferDirectDeviceWrite (#89) #95
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!95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-89"
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
Adds
Device::PreferDirectDeviceWrite(VkDeviceSize size), the runtime upload-strategy helper that unifies the memory-placement cluster. For a CPU-written, GPU-read buffer it decides — at runtime, fromDevice::memoryProperties— whether to:true→ allocateHOST_VISIBLE | DEVICE_LOCAL, map, write straight into device memory (no staging).false→ allocate pureDEVICE_LOCALand feed it from aHOST_VISIBLEstaging buffer +vkCmdCopyBuffer.Logic
DEVICE_LOCAL | HOST_VISIBLEtype (no resizable BAR) →false(staging mandatory).DEVICE_LOCALheap →true(staging would be pure overhead).trueonly for buffers within a per-window budget (1/8 of the window); large buffers stage so they don't exhaust the window (#58).Notes
GetMemoryType(#59): #59 selects the memory type, this selects the strategy.HOST_CACHEDand stays a separate path.VK_EXT_memory_budget-driven remaining-space check (rather than total window size) is documented as a follow-up; the extension isn't currently enabled.Testing
crafter-build test— all green (13 passed). Newtests/UploadStrategydrives the helper over synthetic ReBAR / UMA / small-window / no-BAR layouts (pure CPU, no GPU device), mirroringMemoryTypeFallback.Unblocks #65, #72, #73, #75.
Resolves #89
🤖 Generated with Claude Code
Add Device::PreferDirectDeviceWrite(size) so the memory-placement cluster (#65/#72/#73/#75) no longer re-derives where a CPU-written, GPU-read buffer should live. It picks the strategy at runtime from Device::memoryProperties: - No DEVICE_LOCAL|HOST_VISIBLE type (no resizable BAR) -> false (must stage). - ReBAR/UMA (BAR heap >= 90% of largest DEVICE_LOCAL heap) -> true: map and write directly; a staging copy would be pure overhead. - Small BAR window (BAR heap << VRAM) -> true only for buffers within a per-window budget (1/8 of the window); large buffers stage so they don't exhaust the window (#58). Complements GetMemoryType (#59): #59 picks the memory *type*, this picks the *strategy*. Upload-only — readback (#74) wants HOST_CACHED and stays separate. A VK_EXT_memory_budget-driven remaining-space check is noted as a follow-up. Tested by tests/UploadStrategy (pure CPU over synthetic ReBAR / UMA / small-window / no-BAR layouts, no GPU device needed), mirroring MemoryTypeFallback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>