vello_cpu/vello_hybrid: use rect fast paths for rect fills and clips - #114
Merged
Merged
Conversation
When the shape passed to fill, push_clip_layer or push_layer is a Rect (Shape::as_rect), call fill_rect / push_clip_rect instead of converting it to a path, so the sparse strip renderers can use their rectangle fast paths.
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
vello_cpu and vello_gpu 0.3 have rectangle fast paths (
fill_rect,push_clip_rect; see linebender/vello#1916, #1924, #1926). AnyRender never used them, because every shape went throughshape.into_path(..)and thenfill_path/push_clip_path/push_clip_layer.All three sparse-strip painters (vello_cpu, vello_hybrid, and vello_hybrid's WebGL painter) now check
Shape::as_rect():vello_cpu
push_clip_layerno longer always pushes an isolated clip layer:push_clip_path/pop_clip, copies the clip into each batch, and rasterizes the clip on the main thread. In multi-threaded mode that costs more than the layer it saves. The check isRenderContext::is_multi_threaded()rather than themultithreadingfeature, because vello_cpu falls back to single-threaded whennum_threadsis 0.VelloCpuScenePaintergains a smalllayer_stackto choose betweenpop_layerandpop_clip.push_layerstill passes its clip topush_layeras a path, because opacity and blend need a layer anyway.stroke_recthas no fast path.Vello itself falls back to paths for skewed or rotated transforms. A new vello_cpu unit test,
rect_clips_and_fills, covers a rect clip nested inside a rect-clipped layer.Benchmark
paint_benchcpu backend through Blitz, 1366×768@2x, 8-core VM. Each figure is the median of 4 runs of 60 frames, on a synthetic page of 600 roundedoverflow: hiddenboxes (non-rect clips):push_clip_pathpush_clip_pathMulti-threaded therefore keeps the layer. Real pages (bbc, google, github, servo) showed no clear change, because their clips are almost all rects.
Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/45dbc6c083354777aaa43442ce8ef8ab
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/45dbc6c083354777aaa43442ce8ef8ab?variant=devin-insiders
Requested by: @nicoburns