Skip to content

perf: clash-detection broadphase + raster material tints#393

Merged
ecto merged 2 commits into
mainfrom
claude/render-clash-perf
Jul 3, 2026
Merged

perf: clash-detection broadphase + raster material tints#393
ecto merged 2 commits into
mainfrom
claude/render-clash-perf

Conversation

@ecto

@ecto ecto commented Jul 3, 2026

Copy link
Copy Markdown
Owner

What

Three renderer/eval fixes found by tracing why a large imported document never finished rendering:

  1. Clash detection broadphase (vcad-eval): evaluate_document ran a blind O(n²) pairwise BRep intersection across all scene roots. On a many-root document this dominates everything — an imported chip die (~88k roots, zero actual overlaps) sat at 84% of profile samples inside boolean_op/face_aabb and would effectively never finish (3.8 billion kernel booleans). Now: per-root AABBs computed once, sorted by min-x, sweep-and-prune — only genuinely overlapping boxes reach the kernel. AABB-disjoint pairs intersect to empty anyway, so results are identical.
  2. vcad-render skips clash detection — a static renderer never displays clash meshes (the flag existed, nothing set it).
  3. Raster path honors material tints (vcad-render --jpeg): render_jpeg_str silently dropped document material colors — hardcoded monochrome. Tinted parts now sample the same tinted shading ramp as the SVG path. Untinted parts keep the original shade byte-for-byte, and render_jpeg_solids stays monochrome, so mecheval reference images are unchanged.

Numbers

scenario before after
88k-root sky130 die (vcad-render) never finishes 5.2 s
2,000 disjoint roots (evaluate_document) minutes 0.23 s

Testing

  • New clash_broadphase integration suite: overlap still detected (incl. same-x-extent pairs and root-order independence), disjoint scenes produce zero clashes, per-pair counts, and a 2,000-root wall-clock regression bound.
  • cargo test -p vcad-eval -p vcad-render green; clippy -D warnings clean (incl. --all-features).

Found while importing a real OpenLane/sky130 GDS via #387 — the two PRs are independent but this one is what makes big imported layouts actually render.

🤖 Generated with Claude Code

ecto and others added 2 commits July 2, 2026 22:27
…es in vcad-render

Clash detection ran a blind O(n²) pairwise BRep intersection across all
scene roots. On a many-root document this dominates everything: an
imported chip die (~88k roots, zero actual overlaps) spent 84% of its
samples inside boolean_op/face_aabb and would never finish — 3.8 billion
kernel booleans.

Two fixes:
- evaluate_document: compute each root's AABB once, sort by min-x, and
  sweep — only AABB-overlapping pairs reach the kernel. AABB-disjoint
  pairs intersect to empty anyway, so results are identical. 2,000
  disjoint roots: minutes → 0.23 s.
- vcad-render: pass skip_clash_detection — a static SVG renderer never
  displays clash meshes. The 88k-root die now renders in 5.2 s.

Adds clash_broadphase integration tests (overlap detection incl. same-x
pairs and order independence, disjoint scenes, pair counts, and a
2,000-root wall-clock regression bound).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
render_jpeg_str dropped material colors on the floor — the raster path
was hardcoded monochrome for mecheval reference images. Route the
document's tints through to the shared raster impl and sample each
part's tinted shading ramp (same ramp the SVG path uses). Untinted
parts keep the original two-stop monochrome shade byte-for-byte, and
render_jpeg_solids stays monochrome, so mecheval reference renders are
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vcad-mcp Building Building Preview, Comment Jul 3, 2026 3:59am
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
mecheval Ignored Ignored Jul 3, 2026 3:59am
vcad Ignored Ignored Jul 3, 2026 3:59am
vcad-docs Ignored Ignored Jul 3, 2026 3:59am

Request Review

@ecto ecto merged commit 85cf75e into main Jul 3, 2026
12 checks passed
@chojiai

chojiai Bot commented Jul 3, 2026

Copy link
Copy Markdown

What shipped

This is an internal performance and correctness fix with no new user-facing features, but it resolves a real-world problem where large imported designs would never finish rendering.

  • Documents with many components (such as large chip layouts) now render in seconds instead of hanging indefinitely.
  • Parts with assigned material colors now appear correctly tinted in exported JPEG images, matching how they look in other views.

Plain-English summary generated by Choji from this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant