[perf] Per-mesh dedicated scratch buffer (VRAM waste) #66
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#66
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: Mesh / RT acceleration structures
Location:
implementations/Crafter.Graphics-Mesh.cpp:90-93, 138Impact: VRAM waste · Effort: Small (primary fix) · Not hot path (no per-frame scratch alloc)
Builds on: #101 / #102 (fence-keyed deferred-deletion queue — landed)
Problem
Per-mesh dedicated scratch buffer — one persistent DEVICE_LOCAL scratch per mesh. Real VRAM waste, but refits reuse it (no per-frame alloc). For static (
!allowUpdate) meshes — the ones that proliferate in many-mesh scenes — the scratch is dead weight the moment the build's GPU work completes.Proposed fix (primary, small — now unblocked)
Key the release on
allowUpdate(already recorded atMesh.cpp:196): forallowUpdate == falsemeshes the scratch can never be reused by a refit, so release it after the build. The old hazard — "free after build is a UAF because the GPU is still building" — is solved by the deferred-deletion queue (#102): callscratchBuffer.DeferredClear(), which retires the allocation only once the build's frame has retired past the fence. No explicitReleaseScratch()hook needed. Refit-capable (allowUpdate == true) meshes keep their scratch as today.