perf: remove large drawing stalls

Keep resident geometry and GPU resources stable across edits, MSPACE zoom, and Model/Paper switches. Add unified PERF output for tracing remaining costs.
This commit is contained in:
Hakan Seven committed 2026-07-25 13:34:48 +03:00
1 parent 2bc4c1c8f3
commit 12bf126646
26 files changed
+795 -326

No files matched your search

+8 -4
View File
@@ -21,9 +21,12 @@ pub struct Uniforms {
/// 0.0 = force opaque). Read by the wire shader so the toggle does not
/// require a retessellate.
pub transparency_enable: f32,
/// Pads the struct to 112 B (next multiple of 16) so wgpu's uniform
/// alignment rules are satisfied.
pub _pad: [f32; 2],
/// Per-viewport PSLTSCALE factor. Kept in the shared frame uniform so
/// zooming inside MSPACE changes one scalar instead of re-tessellating and
/// re-uploading every dashed wire.
pub linetype_scale: f32,
/// Pads the struct to the uniform alignment required by wgpu.
pub _pad: f32,
// ── Relative-to-eye (double-single) additions ───────────────────────────
// Appended at the end so existing field offsets are unchanged; shaders that
@@ -54,7 +57,8 @@ impl Uniforms {
lwdisplay_enable: if lwdisplay_enable { 1.0 } else { 0.0 },
flat_shade: 0.0,
transparency_enable: 1.0,
_pad: [0.0; 2],
linetype_scale: 1.0,
_pad: 0.0,
view_rot: camera.view_proj_rte(bounds),
eye_high,
_pad_eh: 0.0,
+4 -4
View File
@@ -309,7 +309,7 @@ impl WireArena {
mesh_edge: bool,
) -> Option<Self> {
let ranges = handle_ranges(wires)?;
let perf = std::env::var_os("OCS_PERF").is_some();
let perf = crate::perf::enabled();
let total_started = std::time::Instant::now();
// Reject an oversized batch before parallel emission allocates hundreds
@@ -447,7 +447,7 @@ impl WireArena {
let upload_ms = upload_started.elapsed().as_secs_f64() * 1000.0;
let const_bind_group = make_const_bg(device, const_bgl, &const_buf);
if perf {
eprintln!(
crate::perf_record!(
"[perf] arena-build-detail total={:.1}ms pack={:.1} mapped-upload={:.1} handles={} wires={} instances={} instance-bytes={} consts={}",
total_started.elapsed().as_secs_f64() * 1000.0,
pack_ms,
@@ -740,13 +740,13 @@ impl WireArena {
.collect();
}
if std::env::var_os("OCS_PERF").is_some() {
if crate::perf::enabled() {
let submitted: u64 = ranges
.iter()
.map(|(start, end)| (end - start) as u64)
.sum();
if submitted < self.inst_tail as u64 {
eprintln!(
crate::perf_record!(
"[perf] wire-cull submitted={} resident={} ranges={}",
submitted,
self.inst_tail,