perf(decompress): release compressed staging after submit, not for the resource's life
The compressed Mesh::Build / ImageVulkan::Update paths kept their host-visible `compressedStaging` (holding the GDeflate streams) alive for the whole life of the mesh/image, pinning host-visible memory long after the single GPU decompress that reads it has retired. Release it via VulkanBuffer::DeferredClear() right after recording the decompress. The recorded vkCmdDecompressMemoryEXT still references compressedStaging.address, so it must outlive the submit — exactly what the fence-keyed deletion queue (#101/#102) guarantees: it retires the allocation only after framesInFlight frames have elapsed, by which point the submit's fence has cleared. Between Builds/Updates the handle is null; the next call's Resize re-creates it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3e0a38fafb
commit
8a32f0d545
3 changed files with 33 additions and 9 deletions
|
|
@ -77,12 +77,13 @@ export namespace Crafter {
|
|||
// Lifetime contract matches vertexBuffer/indexBuffer: must stay
|
||||
// alive until the build submitted on `cmd` completes.
|
||||
VulkanBuffer<RTAabb, true> aabbBuffer;
|
||||
// Lives until the cmd buffer issued by the compressed Build path
|
||||
// completes execution. Kept as a member so the recorded
|
||||
// vkCmdDecompressMemoryEXT references valid memory until the queue
|
||||
// submit signals — caller must not re-Build or destroy the Mesh
|
||||
// before that submit's fence is signaled (same contract as the
|
||||
// existing uncompressed path).
|
||||
// Transient host-visible staging for the compressed Build path. Kept as
|
||||
// a member only so the recorded vkCmdDecompressMemoryEXT has a stable
|
||||
// address to reference; the compressed Build releases it via
|
||||
// DeferredClear() right after recording the decompress, so it is freed
|
||||
// by the fence-keyed deletion queue (#101/#102) once that submit's frame
|
||||
// has cleared — no longer pinned for the mesh's life. Between Builds the
|
||||
// handle is null; the next Build's Resize re-creates it.
|
||||
VulkanBuffer<std::byte, true> compressedStaging;
|
||||
VkAccelerationStructureGeometryTrianglesDataKHR blasData;
|
||||
VkAccelerationStructureGeometryKHR blas;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue