[perf] VulkanBuffer::Resize always destroys+reallocates #63

Closed
opened 2026-06-16 16:51:33 +02:00 by jorijnvdgraaf · 0 comments

RESOLVED. Capacity-reuse landed in #96; the destroy-and-recreate path's use-after-free is closed by the fence-keyed deferred-deletion queue (#101, merged in #102) — Resize now routes the old allocation through DeferredClear(). Both halves shipped.

Subsystem: VulkanBuffer
Location: interfaces/Crafter.Graphics-VulkanBuffer.cppm:112-117
Impact: Low · Effort: Small · Not hot path (refit paths skip Resize)

Problem

VulkanBuffer::Resize always destroys+reallocates. Every per-frame refit path is specifically engineered to skip Resize (UPDATE mode), so this is not a steady-state cost — but capacity-reuse is the safer direction.

Proposed fix

Capacity-reuse when the buffer already fits.

Correctness caveat

Fix must guard on (size-fits AND flags-match) — buffer usage flags are fixed at create. Once #40 pipelined frames, the destroy-when-it-cannot-reuse branch became a live UAF — handled by the deferred-deletion queue (#102).

> **RESOLVED.** Capacity-reuse landed in #96; the destroy-and-recreate path's use-after-free is closed by the fence-keyed deferred-deletion queue (#101, merged in #102) — `Resize` now routes the old allocation through `DeferredClear()`. Both halves shipped. **Subsystem:** VulkanBuffer **Location:** `interfaces/Crafter.Graphics-VulkanBuffer.cppm:112-117` **Impact:** Low · **Effort:** Small · Not hot path (refit paths skip Resize) ### Problem `VulkanBuffer::Resize` always destroys+reallocates. Every per-frame refit path is specifically engineered to **skip** Resize (UPDATE mode), so this is not a steady-state cost — but capacity-reuse is the safer direction. ### Proposed fix Capacity-reuse when the buffer already fits. ### Correctness caveat Fix must guard on `(size-fits AND flags-match)` — buffer usage flags are fixed at create. Once #40 pipelined frames, the destroy-when-it-cannot-reuse branch became a live UAF — handled by the deferred-deletion queue (#102).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Catcrafts/Crafter.Graphics#63
No description provided.