diff --git a/implementations/Crafter.Graphics-UI-WebGPU.cpp b/implementations/Crafter.Graphics-UI-WebGPU.cpp index e7cac71..865bb19 100644 --- a/implementations/Crafter.Graphics-UI-WebGPU.cpp +++ b/implementations/Crafter.Graphics-UI-WebGPU.cpp @@ -177,7 +177,12 @@ void UIRenderer::Dispatch(GraphicsCommandBuffer /*cmd*/, const GraphicsComputeSh // data at the recorded offset, look up the GPU handle in the heap, // and assemble a list of handles in the same order the JS bridge // expects (matching shader.customBindings). - std::vector handles; + // Reuse one vector across dispatches: custom compute runs per-frame, so a + // fresh malloc+free each call is pure churn. thread_local keeps it valid + // even if dispatches ever cross threads; its capacity grows to the high + // water mark once and is reused thereafter. + thread_local std::vector handles; + handles.clear(); handles.reserve(shader.customBindings.size()); const std::uint8_t* p = static_cast(push); for (const auto& b : shader.customBindings) {