forked from 1b-agent/opencadstudio-upstream
The single-batch arena required a set with no mesh/solid edges, so any drawing with a 3D solid or mesh (this one: 1693 mesh-edge wires of 12200) disqualified the WHOLE set — every edit fell back to build_wire_buffers re-uploading ~265 MB (4.4M instances), stalling ~1s per edit on a shared-memory GPU. Split the resident set into a regular-2D arena and a mesh-edge arena (the wires that need the draw loops mesh-edge skip/black treatment), one WireArena each, passed as &[&WireModel] subsets (no clone). Both patch incrementally; the mesh arena carries is_3d_mesh_edge so the existing draw loop handles it. A changed handle absent from an arenas subset is a no-op for it, so each edit touches only the batch it belongs to. Result: the wire block drops from ~300ms + a 265 MB GPU upload to ~2ms. Two correctness points folded in from adversarial review: - mesh-edge wires are stamped draw_depth 0 (matching WireGpu::from_run) so their hidden back edges dont peek through the shaded fill; the mesh arena also always bails on append (all its wires share depth 0, so relocation would reorder coincident edges). - buffers are capped at wgpus 256 MB limit — a batch larger than one buffer returns None so the caller chunks it via the batched path (fixes a create_buffer panic on the 355 MB regular batch). Still behind OCS_WIRE_GPU_PATCH (default off). OCS_PERF prints the per-edit wire timing + outcome. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>