[perf] WebGPU metadata flush uploads full 256 KB padded buffer every frame (RenderingElement3D-WebGPU.cpp) #130
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#130
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?
Found by an adversarially-verified performance audit (confirmed real after a skeptic pass).
Location:
implementations/Crafter.Graphics-RenderingElement3D-WebGPU.cpp:162Severity: medium · Effort: trivial · Category: memory
Problem
The metadata buffer is fixed at
kNPadded = 65536slots; onlyprimitiveCountentries are live, butmetadataBuffer.FlushDevice()wgpuWriteBuffers all 256 KB through the WASM→JS staging path every frame (~100-250× waste for a few-hundred-instance scene). The Vulkan parallel sizes toprimitiveCount, so this is WebGPU-specific.Fix
FlushDeviceRange(0, 0, primitiveCount * sizeof(uint32_t))— the existing overload that the instanceBuffer loop directly above already uses.