Skip to content

[sparse strips] Support non-uniform corner radii in blurred rounded rectangles - #1

Closed
nicoburns wants to merge 2 commits into
mainfrom
non-uniform-blurred-rect-radii
Closed

nicoburns wants to merge 2 commits into
mainfrom
non-uniform-blurred-rect-radii

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Intended as an upstream PR to linebender/vello (opened on this fork because Devin lacks permission to open cross-fork PRs on the upstream repo). Upstream compare link: linebender/vello@main...DioxusLabs:vello:non-uniform-blurred-rect-radii

Summary

Extends the analytic blurred-rounded-rect paint in the sparse strips crates (vello_cpu, vello_hybrid, vello_common) to support a different (scalar) radius per corner, as needed for CSS box shadows on boxes with non-uniform border-radius. Elliptical corner radii remain unsupported.

Breaking API change: BlurredRoundedRectangle::radius: f32 becomes radii: RoundedRectRadii, and fill_blurred_rounded_rect on vello_cpu::RenderContext / vello_hybrid::Scene takes radii: RoundedRectRadii instead of radius: f32 (a uniform radius is r.into()).

Approach

The distance-field part of Raph's approximation folds the rect into one quadrant via abs(x)/abs(y) with a single r1/exponent. This generalizes cleanly: the encoder now precomputes (r1, exponent, recip_exponent) per corner, and the fine shaders select the active corner's parameters from the sign of the pixel's local coordinates. The field stays continuous across quadrant boundaries because along edge midlines the corner terms clamp to zero, making d independent of r1 there.

The global normalization terms keep their existing form; the scale term now uses the mean of the four corner radii (identical to before for uniform radii).

  • vello_common: per-corner [f32; 4] fields (r1, exponent, recip_exponent) on EncodedBlurredRoundedRectangle, ordered [top-left, top-right, bottom-left, bottom-right], computed per corner in encode_into.
  • vello_cpu: the SIMD fine painter selects per-lane corner parameters with two sign masks + select_f32x8; powf now takes a per-lane exponent.
  • vello_hybrid: GpuBlurredRoundedRect grows from 5 to 6 texels (two vec4s of per-corner r1/exponent; recip_exponent is computed in-shader); render.wesl picks the corner via select(0u, 1u, x >= 0.0) + select(0u, 2u, y >= 0.0).

Uniform-radius rendering is unchanged (all existing snapshots pass bit-identically). New snapshot tests cover non-uniform radii (regular, large std-dev, rotated, and inverted), passing on both the CPU and hybrid/wgpu renderers, e.g.:

non-uniform radii non-uniform radii blurred inverted

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/f0e29f278fc544ebb7a91bfeed0bcc85
Requested by: @nicoburns

@nicoburns nicoburns self-assigned this Aug 4, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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