perf(rt): allocate TLAS instance buffer in BAR/VRAM, not system RAM (#65) #105
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!105
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-65"
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
The TLAS instance buffer is rebuilt/refit every frame and is co-written by both CPU and GPU: the compute shader writes the transform field in place for
transformOwnedByGpuelements, and the CPU loop writes the other fields. AllocatedHOST_VISIBLE | HOST_COHERENT(system RAM), both GPU accesses crossed PCIe — the compute write of the transform, and the AS build's read of the whole instance.This upgrades the request to
HOST_VISIBLEwith a best-effortDEVICE_LOCALpreference (BAR/VRAM), keeping the single shared, persistently-mapped buffer. No staging, no copy, no extra barrier:A whole-buffer staging copy was deliberately not used: it would clobber the GPU-written transforms in this in-place co-write design.
Correctness
GetMemoryTypefalls back to plainHOST_VISIBLE(the previous behaviour) on GPUs without resizable BAR.HOST_COHERENTdropped from the required set — the combined type may not be coherent. The existingFlushDevice(cmd, ...)already establishes host→build visibility and gates its flush-skip on the chosen type's flags (#60), so a non-coherent BAR type still flushes correctly. The barrier is never removed.primitiveCount × 64 B≈ 6 MB even at 100k instances.metadataBuffergets the same upgrade separately in #75.Testing
crafter-build test— 19/19 pass. TheTLASHighWaterMarkhardware test (real RT device + validation layers) is extended to assert the instance buffer's chosen memory type matches theHOST_VISIBLE | prefer-DEVICE_LOCALrequest and lands on aDEVICE_LOCALtype where one is reachable. Confirmed on the test GPU: the buffer is now placed in aDEVICE_LOCALBAR type with zero validation errors (the latter covers the dropped-HOST_COHERENTflush path).Resolves #65
🤖 Generated with Claude Code