Skip to content

Fontations glyph rasterization backend WIP#4872

Closed
nicoburns wants to merge 4571 commits into
0.67from
fontations
Closed

Fontations glyph rasterization backend WIP#4872
nicoburns wants to merge 4571 commits into
0.67from
fontations

Conversation

@nicoburns

Copy link
Copy Markdown

This is a work-in-progress implementation of a wr_glyph_rasterizer backend that uses skrifa and vello_cpu for rasterization.

badboy and others added 30 commits April 7, 2025 20:39
…en,mach-reviewers,ahal

Vendoring happens in the next commit

Differential Revision: https://phabricator.services.mozilla.com/D241958
…r=chutten,supply-chain-reviewers,mach-reviewers,ahal

Split out, because the upgrades are split into multiple commits, but we
require a single vendoring to avoid duplicated packages.

Differential Revision: https://phabricator.services.mozilla.com/D241959
…ompositing r=gfx-reviewers,nical

Support for this with native compositing will be added by follow up patches.

Differential Revision: https://phabricator.services.mozilla.com/D244264
…ring for 0.2.0 release) r=nical

Additionally that makes its `euclid` and `app_units` dependencies optional.

Differential Revision: https://phabricator.services.mozilla.com/D244909
…ussianBlur filters to avoid panic r=gfx-reviewers,nical

Differential Revision: https://phabricator.services.mozilla.com/D244698
…ilyCompiledShader::get_internal. r=gw

This lets us remove some arguments. We were discarding the timings from initialization anyway.

Differential Revision: https://phabricator.services.mozilla.com/D245168
…r list. r=gw

This makes it easy to deinit them all.
It comes at the cost of one array index lookup on every use of a shader.

Having a list will also make it easier to do the precaching asynchronously.

Differential Revision: https://phabricator.services.mozilla.com/D245171
…alls to device.create_program. r=gw

This avoids keeping the thread blocked for too long in case the
call to glProgramBinary is slow. Slow glProgramBinary has been
observed with the Xclipse GPU driver.

Differential Revision: https://phabricator.services.mozilla.com/D245174
…ure's parent clip. r=gw

Currently if all children of a picture share a clip, the clip is hoisted out of the children to be applied to the picture as a composite mode. This prevents the clip from being backed into the picture which snapshots rely on.
This patch works around this by enforcing that the clip root of a snapshotted picture is always the parent clip node of the picture's clip. The intent is to always discard parent clips when rendering the snapshot, while never hoisting child clips out of the snapshot.

Differential Revision: https://phabricator.services.mozilla.com/D245086
We're not likely to run into unwinding problems on other OSes.

I was seeing 5% of time being spent in the timing code when profiling
MotionMark on ARM macOS.

Differential Revision: https://phabricator.services.mozilla.com/D245582
…tributionDistribution.js. CLOSED TREE

Backed out changeset ab33904d0edb (bug 1955429)
Backed out changeset abdbe82d2cc1 (bug 1955429)
Backed out changeset eba2fd65a5cf (bug 1955429)
Backed out changeset e0aa301f9301 (bug 1955429)
…D TREE

Backed out changeset 8793ee7ac873 (bug 1955429)
Backed out changeset e1cf811b7274 (bug 1955429)
Backed out changeset 79bf1547f82b (bug 1955429)
Backed out changeset c451dfbfb59f (bug 1955429)
…'s parent clip. r=gw

Currently if all children of a picture share a clip, the clip is hoisted out of the children to be applied to the picture as a composite mode. This prevents the clip from being backed into the picture which snapshots rely on.
This patch works around this by enforcing that the clip root of a snapshotted picture is always the parent clip node of the picture's clip. The intent is to always discard parent clips when rendering the snapshot, while never hoisting child clips out of the snapshot.

Differential Revision: https://phabricator.services.mozilla.com/D245086
…es . CLOSED TREE

Backed out changeset c559fb92573e (bug 1957880)
Backed out changeset 79ae9de06c34 (bug 1957880)
Backed out changeset 18ffb81884ca (bug 1957880)
Backed out changeset 5561a18254dd (bug 1957880)
…ition r=jgilbert,gfx-reviewers,ahale

This also adds the plumbing for implementing the rounded compositor
clip in CoreAnimation and SWGL compositors, though they will be
implemented in follow up patches.

Differential Revision: https://phabricator.services.mozilla.com/D245166
…@ widget/tests/test_bug343416.xhtml CLOSED TREE

Backed out changeset 3fd7b7cba0ff (bug 1955429)
Backed out changeset d771f40c809c (bug 1955429)
Backed out changeset 98fe0042de25 (bug 1955429)
Backed out changeset f239ffd8098f (bug 1955429)
Backed out changeset a49202330c21 (bug 1955429)
…'s parent clip. r=gw

Currently if all children of a picture share a clip, the clip is hoisted out of the children to be applied to the picture as a composite mode. This prevents the clip from being backed into the picture which snapshots rely on.
This patch works around this by enforcing that the clip root of a snapshotted picture is always the parent clip node of the picture's clip. The intent is to always discard parent clips when rendering the snapshot, while never hoisting child clips out of the snapshot.

Differential Revision: https://phabricator.services.mozilla.com/D245086
…e-element-right-and-left-of-viewport-partially-onscreen-old.html CLOSED TREE
…'s parent clip. r=gw

Currently if all children of a picture share a clip, the clip is hoisted out of the children to be applied to the picture as a composite mode. This prevents the clip from being backed into the picture which snapshots rely on.
This patch works around this by enforcing that the clip root of a snapshotted picture is always the parent clip node of the picture's clip. The intent is to always discard parent clips when rendering the snapshot, while never hoisting child clips out of the snapshot.

Differential Revision: https://phabricator.services.mozilla.com/D245086
orium and others added 28 commits September 11, 2025 22:47
…n WebRender. r=gfx-reviewers,lsalzman" for causing build bustages mismatched_lifetime_syntaxes related

This reverts commit 42b9723.
…r=gfx-reviewers,lsalzman,nical

Fix a few minor issues when using WR debugger with Gecko:

 - Handle client side namespace allocation mode
 - Handle when server address is already bound by another WR instance
 - Enable debugger by default in Gecko (still disabled by default by Cargo feature)

Differential Revision: https://phabricator.services.mozilla.com/D264891
…each gradient type. r=lsalzman

That will let us gradually enable it.

Differential Revision: https://phabricator.services.mozilla.com/D260791
…from gradient stops directly. r=gfx-reviewers,gw

This patch adds a new quad gradient gradient shaders that can render linear, radial and conic gradients. The main improvements is that the new shader does not approximate gradient stops with a table, which removes an entire class of shader precision issues.
The extra correctness comes at a cost in run-time performance. The fragment shader now has to traverse the array of gradient stop offsets to find which pair affect each pixel, using a potentially large number of gpu buffer reads (depending on the number of stops).

To alleviate some of the performance impact, the first four stops are always passed via varyings. In addition the new shader has a fast path for gradients with no more than two gradient stops: in this configuration, all of the data needed by the fragment shader is passed via varying, which yields significant speedups over reading them from the gpu buffer for each fragment.
The slow path performs a linear search in the gradient stop offsets to find the pair affecting the current pixel. This starts fairly cheap for 4 stops or less as the first 4 stops are also provded via varyings in the slow path, and gets more expensive for each new quadruplet of gradient stops. The assumption here that the vast majority of gradients use less than 8 stops.
In the slow path, once the pair of gradient stop offsets has been computed, the color pair is read from the gpu buffer.

The new shader is disabled by default. Followup work before it can be enabled include:
 - implementing the swgl fast paths,
 - switching to a more effective search algorithm when the number of gradient stops is very high,
 - wiring up dithering.

Differential Revision: https://phabricator.services.mozilla.com/D257734
The code path is still behind a pref, disabled by default.

The new span shader is based on the existing one with a few notable
differences:
 - The gradient stop pair is fetched via an incremental linear search
   instead of using a table. Since the search is incremental from one
   pixel to the next, it's typically pretty cheap and has not shown up
   in profiles in my initial testing so far.
 - This version does not have a loop to merge contiguous stops.
 - the structure of the inner loop is a bit different: The existing span
   shader advances in SIMD-aligned blocks and has a scalar path for
   partially covered blocks. The new version removes the scalar part
   using the vectorized code to also handle partially covered blocks
   with extra pixels masked out. The inner loop that handles a gradient
   stop pair still operates in SIMD-sized increment, but isn't aligned
   anymore.

Differential Revision: https://phabricator.services.mozilla.com/D259113
…iewers,gw

This change simplifies the followup patch that will implement a tree traversal of stop offsets.

Differential Revision: https://phabricator.services.mozilla.com/D264068
…-reviewers,gw

This patch changes the gradient stop search on the GPU from a linear search to a tree traversal. This drastically reduces the number of gpu buffer reads when there is a lot of gradient stops. An added benefit is that the linear search required non-uniform loop control flow which SWGL currently does not handle (loop that can be exited by some lanes before others). The loop of the tree traversal is uniform which lets SWGL produce correct code.

The tree traversal requires laying out the stops in the gpu buffer in a specific way.

However, the hand-rolled SWGL gradient span shaders benefit enormously from doing an incremental linear search so we keep the linear order of the stops offsets when we know that a span shader will be used.

Differential Revision: https://phabricator.services.mozilla.com/D264069
… it in the precise gradient shader. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D265227
…ilio

Generated with clang-format version 19.1.7 (taskcluster-ImeD-jyDRx-_6soViZ_luw)

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D266586
…dius. r=lsalzman

- There were a few leftover comments referring to the merge step which is not needed in this version of the shader.
- Removed a few unused variables also orphaned by the absence of the merge step.
- Renamed radius into startRadius

Differential Revision: https://phabricator.services.mozilla.com/D266689
…n shader. r=gfx-reviewers,lsalzman

This is already covered by wrench tests and makes them pass with the new (currently preffed off) code path.

Differential Revision: https://phabricator.services.mozilla.com/D266690
… span shader. r=lsalzman

The code was incorrectly assuming that one could simply update dotPos and dotPosDelta for partial chunks by dividing by the chunk size and multiplying by the number of pixels in the partial chunk. That's true for dotPosDelta but not for dotPos where there is a compounding effect with each iteration feeding back into the next in a way that makes things non-linear. There has to be a more elegant solution but after many failed attempts I ended up expressing it in terms of a single-pixel step applied multiple times depending on the number of pixels in the partial chunk. It should be pretty fast still and this way the math looks similar to the whole-chunk steps.

In addition, the patch rounds endT up so that we go all the way to the next pixel that is in a different stop pair rather than stopping one pixel before. This removes a lot of unnecessary partial chunks. Before that, we would round endT down which meant that in the next sub-span we would still be in the same gradient stop pair and advance by a pixel before stepping into the next stop pair.

Differential Revision: https://phabricator.services.mozilla.com/D266691
This is only run on Linux currently in Gecko, so we do the same
thing downstream.
This is still used by Servo.
Also derive Deserialize and Serialize for serde, not just for the
capture and replay features.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Changes made:

    - Update webrender and in-repo crates that are dependencies of
    webrender to version 0.68

    - Update these crates to use workspace depency versions similar to
      stylo#249 (seeing as the feedback on that change was positive).

I have not bothered updating the versions of the other in-repo crates
that are not dependencies of webrender (e.g. wrench and crates that are
used by wrench like swgl) as we don't need to publish those and thus
their version numbers don't matter, and I figured it would keep the diff
a little smaller. But it would be easy to update those too if we wanted
to.

Signed-off-by: Nico Burns <nico@nicoburns.com>
Signed-off-by: Nico Burns <nico@nicoburns.com>
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.