Skip to content

[vello_cpu]: add WASM vello_cpu examples #1076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2025

Conversation

ajakubowicz-canva
Copy link
Contributor

@ajakubowicz-canva ajakubowicz-canva commented Jul 2, 2025

Context

To help with performance profiling and inspecting vello_cpu example renders on the browser, this PR adds a vello_cpu examples.

Run with cargo run_wasm -p wasm_cpu --release

Scenes added

We don't yet have a rendering abstraction between vello_cpu and vello_hybrid, so the example scenes are pretty similar, but not quite identical. I simplified each one to use RenderContext instead of Scene, and also made them very specific to running on the browser.

I added:

  • simple
  • tiger svg
  • cowboy image
  • text
  • clipping

No new assets are added in this PR - only existing assets in the repo are used. See the screen recording to see the scenes added.

Test plan

Note

Passing the +simd128 rustc flags spams the console with (ignoring feature) logs. This is because the run-wasm tool is built for your system architecture with the same global flags – and because it's not wasm it doesn't recognize the feature. Everything still works.

Test it by running it with cargo run_wasm -p wasm_cpu --release and test explicit SIMD by running RUSTFLAGS=-Ctarget-feature=+simd128 cargo run_wasm -p wasm_cpu --release.

Screen recording

output.mp4

@ajakubowicz-canva ajakubowicz-canva added the C-cpu Applies to the vello_cpu crate label Jul 2, 2025
@ajakubowicz-canva ajakubowicz-canva marked this pull request as ready for review July 2, 2025 04:00
Copy link
Contributor

@LaurenzV LaurenzV left a comment

Choose a reason for hiding this comment

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

I've played around with and encountered no issues, it seems to work fine, thanks! I've only skimmed the actual code and not thought about it deeply, but since most of it is ported from existing code, it should be fine!

@DJMcNab
Copy link
Member

DJMcNab commented Jul 2, 2025

Yeah - cargo run_wasm is insufficiently flexible a lot of the time. I don't really have good solutions here at the moment.

Copy link
Contributor

@taj-p taj-p left a comment

Choose a reason for hiding this comment

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

LGTM! I think once we have our rendering abstraction we can consider combining these examples

@ajakubowicz-canva ajakubowicz-canva added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@ajakubowicz-canva ajakubowicz-canva added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@ajakubowicz-canva ajakubowicz-canva force-pushed the ajakubowicz-vello_cpu-example branch from 6f407ce to 5309be3 Compare July 2, 2025 21:34
@ajakubowicz-canva ajakubowicz-canva added this pull request to the merge queue Jul 2, 2025
Merged via the queue into main with commit e7a75ec Jul 2, 2025
17 checks passed
@ajakubowicz-canva ajakubowicz-canva deleted the ajakubowicz-vello_cpu-example branch July 2, 2025 21:43
LaurenzV pushed a commit that referenced this pull request Jul 2, 2025
### Context

To help with performance profiling and inspecting vello_cpu example
renders on the browser, this PR adds a vello_cpu examples.

Run with `cargo run_wasm -p wasm_cpu --release`

### Scenes added

We don't yet have a rendering abstraction between `vello_cpu` and
`vello_hybrid`, so the example scenes are pretty similar, but not quite
identical. I simplified each one to use `RenderContext` instead of
`Scene`, and also made them very specific to running on the browser.

I added:
 - simple
 - tiger svg
 - cowboy image
 - text
 - clipping

No new assets are added in this PR - only existing assets in the repo
are used. See the screen recording to see the scenes added.

### Test plan

> [!Note]
> Passing the +simd128 rustc flags spams the console with `(ignoring
feature)` logs. This is because the run-wasm tool is built for your
system architecture with the same global flags – and because it's not
wasm it doesn't recognize the feature. Everything still works.

Test it by running it with `cargo run_wasm -p wasm_cpu --release` and
test explicit SIMD by running `RUSTFLAGS=-Ctarget-feature=+simd128 cargo
run_wasm -p wasm_cpu --release`.

### Screen recording

https://github.com/user-attachments/assets/80867362-bce5-4a9e-b303-88b2c9233972
(cherry picked from commit e7a75ec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cpu Applies to the vello_cpu crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants