[perf] Per-frame whole-buffer flush of TLAS instance+metadata buffers (RenderingElement3D.cpp) #121

Closed
opened 2026-06-17 21:18:54 +02:00 by jorijnvdgraaf · 1 comment

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).

Location: implementations/Crafter.Graphics-RenderingElement3D.cpp:161-173
Severity: low · Effort: moderate · Category: memory

Problem

Both FlushDevice calls resolve to VK_WHOLE_SIZE, flushing the full high-water capacity every frame regardless of dirty bytes (steady state never calls Resize, so the span is capacity, not primitiveCount*stride). Self-gates to a no-op on HOST_COHERENT memory, so cost only materializes on non-coherent BAR/VRAM.

Fix

Use the existing ranged FlushDevice(offset, bytes) (VulkanBuffer.cppm:336) over [0, primitiveCount*stride), ideally only dirty sub-ranges.

Found by an adversarially-verified performance audit (confirmed real after a skeptic pass). **Location:** `implementations/Crafter.Graphics-RenderingElement3D.cpp:161-173` **Severity:** low · **Effort:** moderate · **Category:** memory ### Problem Both `FlushDevice` calls resolve to `VK_WHOLE_SIZE`, flushing the full high-water capacity every frame regardless of dirty bytes (steady state never calls `Resize`, so the span is capacity, not `primitiveCount*stride`). Self-gates to a no-op on HOST_COHERENT memory, so cost only materializes on non-coherent BAR/VRAM. ### Fix Use the existing ranged `FlushDevice(offset, bytes)` (`VulkanBuffer.cppm:336`) over `[0, primitiveCount*stride)`, ideally only dirty sub-ranges.
Author
Owner

Merged into #118 — the TLAS host rebuild and the whole-buffer flush act on the same instance+metadata buffers; one dirty-set drives both the copy and the ranged flush, so they're a single deliverable.

Merged into #118 — the TLAS host rebuild and the whole-buffer flush act on the same instance+metadata buffers; one dirty-set drives both the copy and the ranged flush, so they're a single deliverable.
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#121
No description provided.