perf(rt): allocate TLAS metadata buffer in BAR/VRAM, not system RAM (#75) #111
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!111
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-75"
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?
What
The TLAS
metadataBufferwas allocatedHOST_VISIBLE | HOST_COHERENT(system RAM). It is CPU-written every frame (oneuserMetadataword per element inBuildTLAS's copy loop) and read by the ray shaders as aSTORAGE_BUFFERvia device address every frame — so every per-frame shader read traversed PCIe, the same cost the sibling instance buffer paid before #65.This upgrades the request to
HOST_VISIBLEwith a best-effortDEVICE_LOCALpreference (BAR/VRAM), keeping the single persistently-mapped buffer. CPU writes go to write-combined BAR (write-only, sequential, never-read-back — the ideal load); shader reads now hit local VRAM.Correctness
DEVICE_LOCALis a preference only (depends on #59):GetMemoryTypefalls back to plainHOST_VISIBLE(the previous behaviour) on GPUs without resizable BAR.HOST_COHERENTdropped (caveat 3): the combined type may not be coherent. AFlushDevice()is added after the copy loop to make host writes available on a non-coherent type; it self-gates to a no-op on a coherent type (#60), preserving the previous behaviour wherever the type ends up coherent. The metadata buffer is not an AS build input and has no GPU co-write, so it needs neither the build-stage barrier the instance buffer takes nor a HOST→shader command barrier — the queue submit already orders host writes (made available before it) against every command in the submission, exactly as it did when the buffer wasHOST_COHERENT.Testing
TLASHighWaterMarkgains a metadata-buffer assertion block mirroring #65's instance-buffer check: the chosen memory type must equal whatGetMemoryTyperesolves for theHOST_VISIBLE | prefer-DEVICE_LOCALrequest, and must beDEVICE_LOCALwherever a host-visible device-local type is reachable. The zero-validation-errors check covers the droppedHOST_COHERENTpath. This test passes on the RTX 4090.crafter-build test: 19 of 20 green, including this PR'sTLASHighWaterMark. The one red —MeshDecompressStagingRelease— is a pre-existing failure onmaster(reproduced viagit stashon a clean tree), unrelated to this change (it testsMeshdecompress staging, this PR touches onlyRenderingElement3D). Filed as #110.Resolves #75.