-
Notifications
You must be signed in to change notification settings - Fork 163
Add fast path for stripping rectangles #900
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An initial thought inline, I'll look more in-depth in the coming days.
Co-authored-by: Tom Churchman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most tests with rectangles call RenderContext::fill_rect
, which now uses the specialized path for rectangles. It would be good to continue exercising the general case as well.
I don't know what the best solution looks like. Perhaps performing multiple tests against the same snapshot could work, though we'd have to be robust against small rounding errors.
# Conflicts: # sparse_strips/vello_cpu/src/render.rs
I've added a few more test cases which check against the same snapshot as the rectangle case, I feel like this should already be an improvement? As you mentioned, there are few other test cases with rectangles, but there's also only so many ways to draw a rectangle. :P So I think this should already be a good coverage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This was a great read! Certainly adding a fast path for rects makes sense and I can see how it is so much faster.
edit: If it isn't clear, please don't let any of my comments block this from merging!
// and pattern fills. | ||
let (x0, x1, y0, y1) = ( | ||
rect.min_x().max(0.0) as f32, | ||
rect.max_x().min(width as f64) as f32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for min_x() == 30
, max_x() == 40
, width == 10
, this sets x0 = 30
and x1 = 10
. This propagates through to x_start
and x_end
. Later we check that x_end - x_start >= 1
, but due to wraparound, that'll be true. The end result is that we write a lot of unnecessary alpha values.
Maybe we can revisit in the future, but I'm pretty sure that for performant fine rasterization with SIMD, we will want to uphold the assumption that strips are always a multiple of 4 in width, which isn't the case with this fast path, and it might be tricky to change the PR to uphold this. So I'll close this for now. |
This re-adds my previously implemented fast path for rectangles. In my test scene with 20000 rectangles, this reduces the rendering time from around 37ms to 19ms!