-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] generate mipmaps for imagefilters #49794
Changes from 7 commits
a5161bc
f74684a
b2f1c69
d6cbe11
768fbdc
068fbfc
4ae7929
ce3aeeb
2c93439
b128c28
659a0c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,6 +190,9 @@ void Canvas::Save(bool create_subpass, | |
| MipCountVisitor mip_count_visitor; | ||
| backdrop_filter->Visit(mip_count_visitor); | ||
| subpass->SetRequiredMipCount(mip_count_visitor.GetRequiredMipCount()); | ||
| current_pass_->SetRequiredMipCount( | ||
| std::max(current_pass_->GetRequiredMipCount(), | ||
| mip_count_visitor.GetRequiredMipCount())); | ||
| } | ||
| subpass->SetBlendMode(blend_mode); | ||
| current_pass_ = GetCurrentPass().AddSubpass(std::move(subpass)); | ||
|
|
@@ -725,6 +728,14 @@ void Canvas::SaveLayer(const Paint& paint, | |
| auto& new_layer_pass = GetCurrentPass(); | ||
| new_layer_pass.SetBoundsLimit(bounds); | ||
|
|
||
| if (paint.image_filter) { | ||
| MipCountVisitor mip_count_visitor; | ||
| paint.image_filter->Visit(mip_count_visitor); | ||
| new_layer_pass.SetRequiredMipCount( | ||
| std::max(mip_count_visitor.GetRequiredMipCount(), | ||
|
gaaclarke marked this conversation as resolved.
Outdated
|
||
| new_layer_pass.GetRequiredMipCount())); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new layer will always have a default required mip count. The place where the maxing needs to happen is when a layer is being appended that has a backdrop filter.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That still exists from the last PR. This covers both cases, image filter and backdrop filter. Is there a case this doesn't cover, or are you suggesting there is a singular place we can put this code instead of having it in 2 locations?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, you are saying the max needs to happen there as well? I'm not understanding the order of operations that is problematic. Can you lay it out for me?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mip count we need to use when allocating the texture is the maximum we detect for all reads. A backdrop texture is read by both subpass backdrop filters as well as the image filter that happened to be set at the time the SaveLayer was made. Inside of Save(), the RequiredMipCount of the new layer is being set to the backdrop filter's mip count. But the backdrop filter will read from the parent layer's backdrop, not the new layer's backdrop.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So when we come across a backdrop filter, we need to max the mip count with the parent pass mip count. And when an image filter is being applied via the paint state, no maxing is necessary when setting the mip count because nothing should have set the mip count yet.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yea I see, thanks. This started making the previous tests print out the "no mips" message when rendering the blur. I would like to have a way to assert that in the tests. We still have some tests that use the filter without mips (assuming they will have them at runtime) so I was a bit squishy with that. I'll see if I can find a way to assert it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay fixed. I added a logs check to make sure this doesn't regress. We don't have a better way to assert this currently. I can file an issue to make it a hard assert and migrate all the tests over. |
||
| } | ||
|
|
||
| // Only apply opacity peephole on default blending. | ||
| if (paint.blend_mode == BlendMode::kSourceOver) { | ||
| new_layer_pass.SetDelegate( | ||
|
|
||
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.
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.
done