forked from 1b-agent/opencadstudio-upstream
fix: give the wire arena its own buffer budget
`PersistentWireArena` keeps one instance buffer for the whole resident
set and patches it in place on an edit. Sizing that against the shared
per-chunk budget caps it at 32 MiB, which is 524 288 `WireInstance`s.
A drawing with more than that fails `WireArena::build`, falls back to the
batched path, and re-uploads everything on every edit. On the 198 k-wire
reproducer -- 821 316 instances -- that shows up as:
wire 200-370ms arena-hybrid
instead of the ~12 ms `arena-patch` the same drawing reached before the
limits moved onto the shared budget.
The 32 MiB cap is right for transient chunks, where many are allocated
per frame and any one of them failing loses the frame. The arena's buffer
is a single long-lived allocation that exists precisely to avoid those
re-uploads, and it can afford more: 821 k instances is 53 MB, ~79 MB with
the arena's headroom. 128 MiB leaves it four times smaller than the
505 MiB allocation that crashed a 2 GB card, and it is allocated through
`gpu_upload`, so exhausting VRAM still degrades the frame rather than
aborting.
`OCS_GPU_CHUNK_MIB` overrides both caps, so a test can still force small
buffers everywhere.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13afc1479f
commit
19490a548b
2 files changed
+41
-7
No files matched your search
@@ -313,8 +313,10 @@ impl WireArena {
|
||||
const_bgl: &wgpu::BindGroupLayout,
|
||||
mesh_edge: bool,
|
||||
) -> Option<Self> {
|
||||
let instance_limit = super::gpu_budget::max_elements::<WireInstance>(device) as u64;
|
||||
let constant_limit = super::gpu_budget::max_storage_elements::<WireConst>(device) as u64;
|
||||
let instance_limit =
|
||||
super::gpu_budget::max_arena_elements::<WireInstance>(device) as u64;
|
||||
let constant_limit =
|
||||
super::gpu_budget::max_arena_storage_elements::<WireConst>(device) as u64;
|
||||
let ranges = handle_ranges(wires)?;
|
||||
let perf = crate::perf::enabled();
|
||||
let total_started = iced::time::Instant::now();
|
||||
@@ -971,7 +973,8 @@ impl PackedWireArena {
|
||||
depth_map: &FxHashMap<u64, [f32; 2]>,
|
||||
mesh_edge: bool,
|
||||
) -> Option<Self> {
|
||||
let packed_limit = super::gpu_budget::max_elements::<PackedWireInstance>(device) as u64;
|
||||
let packed_limit =
|
||||
super::gpu_budget::max_arena_elements::<PackedWireInstance>(device) as u64;
|
||||
let ranges = handle_ranges(wires)?;
|
||||
let max_instances: usize = wires
|
||||
.iter()
|
||||
|
||||
Reference in new issue
Block a user