Skip to content

bazel: enable Blender 3D-viewer targets on every supported-PDK design - #4235

Merged
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:blender-3d-viewer
May 18, 2026
Merged

maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:blender-3d-viewer

Conversation

@oharboe

@oharboe oharboe commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two pieces, bundled because they only make sense together:

  1. Bump bazel-orfs from `ce6efd9` to `3a5ddd7` (~80 commits of
    upstream main). Pulls in the `orfs_blender()` rule + the
    layerstack-trim heuristic in `render_gds.py` for browser-loadable
    GLB+HTML viewers. The previously vendored
    `//bazel:0001-orfs_design-add-user_sources.patch` is now upstream
    as of bazel-orfs `5b65b4e`, so it goes away.

  2. Flip `blender = True` once in `flow/designs/design.bzl`'s
    `design()` funnel. Every design routes through this single line;
    designs whose PDK has no BlenderGDS stackup (asap7, nangate45, ...)
    silently no-op via the upstream `blender_supports_pdk` predicate.

A small vendored patch on `render_gds.py` works around a real bug in
the BlenderGDS addon (`UnboundLocalError: pdk_info` inside
`import_gdsii`'s custom-config branch); routing the trimmed layerstack
YAML through `addon.PDK_CONFIGS[pdk]['config_path']` instead of
`gdsii_use_custom_config = True` avoids the bug. TODO: upstream the
fix in aesc-silicon/BlenderGDS and drop this patch.

Targets emitted per design

For each design + supported PDK, `orfs_blender()` emits 5 targets:

```
{name}_gds # orfs_gds; runs klayout to produce 6_final.gds
{name}_gen # runs Blender headless to save a .blend scene
{name} # bazelisk run -> hermetic Blender on the saved scene
{name}_html_gen # exports glTF + base64-embeds into HTML template
{name}_html # bazelisk run -> xdg-open on the HTML viewer
```

All tagged `manual` so wildcard builds don't pull in Blender or the
BlenderGDS addon.

End-to-end on microwatt sky130hd

```
render_gds.py [layerstack-trimmed] kept=[nwell, met3, met4, via4, met5]
render_gds.py [gdsii-imported] meshes=7 polygons=2,313,779 VmRSS=2.6 GB
render_gds.py [gltf-exported] glb=123,236,008 bytes
render_gds.py [html-written] out=165,271,042 bytes
Build completed successfully, 2 total actions
Elapsed time: 71.263s
```

123 MB GLB / 158 MB HTML on disk — well inside any browser tab's
working memory. The trim heuristic drops the densest interconnect /
contact / lower-metal layers (mcon, licon, li1, met1, via, via2, via3)
which carry most of the polygon count but read as featureless noise at
zoom levels that fit a 10mm² chip on a laptop screen.

gcd-class designs already fit under the addon's full default
layerstack, so the preset is a no-op for them.

Usage

```
bazelisk run //flow/designs/sky130hd/gcd:gcd_final_blender_html
```

opens the resulting model-viewer page in the default browser via
`xdg-open`.

Test plan

  • `bazelisk build //flow/designs/sky130hd/microwatt:microwatt_final_blender_html`
    succeeds end-to-end (`Build completed successfully`).
  • `bazelisk query //flow/designs/sky130hd/gcd:all` shows the 5
    `gcd_final_blender*` targets (sky130hd is supported).
  • `bazelisk query //flow/designs/asap7/gcd:all` shows none of them
    (asap7 has no BlenderGDS stackup — silent skip).
  • `bazelisk query 'tests(//flow/designs/sky130hd/gcd:all)'` returns
    only `gcd_test` — `tags = ["manual"]` keeps the blender targets
    out of `bazelisk test //...` wildcards.

🤖 Generated with Claude Code

…orkaround

Two pieces, bundled because they only make sense together:

  1. Bump bazel-orfs ce6efd9 -> 3a5ddd7 (~80 commits of upstream main).
     This pulls in the orfs_blender() rule plus the layerstack-trim
     `_LAYER_PRESETS` heuristic in render_gds.py.  The previously
     vendored //bazel:0001-orfs_design-add-user_sources.patch is now
     upstream as of 5b65b4e so it goes away.

  2. Flip `blender = True` once in flow/designs/design.bzl's design()
     funnel so every design routes through the same blender-supported
     branch.  Designs whose PDK has no BlenderGDS stackup (asap7,
     nangate45, ...) silently no-op via the upstream
     `blender_supports_pdk` predicate.

A small vendored patch on render_gds.py works around a real bug in
the BlenderGDS addon (`UnboundLocalError: pdk_info` inside
import_gdsii's custom-config branch); routing the trimmed YAML
through `addon.PDK_CONFIGS[pdk]['config_path']` instead of
`gdsii_use_custom_config = True` avoids the bug.  TODO: upstream the
fix to aesc-silicon/BlenderGDS and drop this patch.

End-to-end on sky130hd/microwatt (a 562 MB merged GDS), the trim
heuristic produces a 123 MB GLB and a 158 MB self-contained HTML
viewer in ~71 s of wall time once synth/place/route are cached.
gcd-class designs already fit under the addon's full default
layerstack so the preset is a no-op for them.

Usage:

  bazelisk run //flow/designs/sky130hd/gcd:gcd_final_blender_html

opens the resulting model-viewer page in the default browser via
xdg-open.

Signed-off-by: Øyvind Harboe <oyvind@ascenium.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe requested a review from maliberty May 18, 2026 04:43

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the bazel-orfs dependency commit and replaces an existing patch with a new one that addresses an UnboundLocalError in render_gds.py by monkey-patching PDK_CONFIGS. Additionally, it enables Blender targets by default for all designs. Feedback recommends exposing the blender setting as a parameter in the design macro to provide more flexibility for individual designs to opt-out.

Comment thread flow/designs/design.bzl Resolved
@oharboe

oharboe commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

@oharboe

oharboe commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty pr-merge works, so ignore pr-head, right?

@maliberty

Copy link
Copy Markdown
Member

Needs a yosys upgrade in MODULE.bazel, waiting for a bazel bcr yosys/abc versions to land

So not ready to merge?

@oharboe

oharboe commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

Needs a yosys upgrade in MODULE.bazel, waiting for a bazel bcr yosys/abc versions to land

So not ready to merge?

It is good to merge. It works for those designs that don't have the kogge stone bug in yosys.

@maliberty
maliberty merged commit 037e697 into The-OpenROAD-Project:master May 18, 2026
7 of 8 checks passed
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.

2 participants