Skip to content
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

[Impeller] Migrate all ColorSourceContents to use a shared rendering routine. #50261

Merged
merged 16 commits into from
Feb 14, 2024

Conversation

bdero
Copy link
Member

@bdero bdero commented Feb 1, 2024

This is going to be our "in" for performing StC in all the ColorSourceContents when necessary.

No semantic change.

  • SolidColor
  • LinearGradient
  • ConicalGradient
  • RadialGradient
  • SweepGradient
  • Image
  • RuntimeEffect

@bdero bdero self-assigned this Feb 1, 2024
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@bdero
Copy link
Member Author

bdero commented Feb 1, 2024

Pushing up before doing the full refactor to see those goldens. This might end up living in ColorSourceContents instead of its own TU.

@bdero
Copy link
Member Author

bdero commented Feb 6, 2024

I refactored this to live in ColorSourceContents. Would like to land this before distributing to the rest of the relevant contents.

@johnmccutchan
Copy link
Contributor

test-exempt: refactor

template <typename VertexShaderT>
bool DrawPositionsAndUVs(
Rect texture_coverage,
Matrix effect_transform,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Matrix effect_transform,
const Matrix& effect_transform,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

RenderPass& pass,
const PipelineBuilderMethod& pipeline_builder,
typename VertexShaderT::FrameInfo frame_info,
const BindFragmentCallback& bind_pipeline_callback) const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative suggestion, make color source contents have a virtual BindFragmentCallback method and make this call it. If we have to pass a closure for non trivial cases then its going to end up closing over the entire contents anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good approach. Done.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhh actually applying this to my follow-up patch is a painful because we have multiple rendering branches for all of the gradients that need different binding behavior.

In all of the use cases we can capture the things we need by reference, and my understanding is that assigning a lambda to a stack std::function shouldn't heap allocate as long as the set of captures is reasonably small.

One sec, gonna check this...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The different gradients are basically different content classes though
if the contents is less verbose with this change it would make more sense to split them in two IMO.

Copy link
Member Author

@bdero bdero Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Briefly discussed offline, we can just switch this out later if necessary / ends up being too annoying. Some legit concerns over expanding our use of std::function, like annoying stack traces, compiler differences, etc.

bool DrawPositions(const ContentContext& renderer,
const Entity& entity,
RenderPass& pass,
const PipelineBuilderMethod& pipeline_builder,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, can pipeline_builder be a virtual method on ColorSourceContents?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bdero bdero force-pushed the bdero/colorsourcecontents-utils branch from c297203 to 19b60ea Compare February 8, 2024 02:46
@bdero bdero force-pushed the bdero/colorsourcecontents-utils branch from 1861b24 to 9b882af Compare February 8, 2024 22:02
Comment on lines 142 to 144
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
pipeline_callback(options);
pass.SetPipeline(pipeline);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either move into SetPipeline or inline the call to avoid the additional shared_ptr release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oopsies, done.

auto geometry_result =
GetGeometry()->GetPositionBuffer(renderer, entity, pass);

return DrawGeometry<VertexShaderT>(geometry_result, renderer, entity, pass,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return DrawGeometry<VertexShaderT>(geometry_result, renderer, entity, pass,
return DrawGeometry<VertexShaderT>(std::move(geometry_result), renderer, entity, pass,

geometry_result contains shared_ptrs in the buffer views, should be moved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

auto geometry_result = GetGeometry()->GetPositionUVBuffer(
texture_coverage, effect_transform, renderer, entity, pass);

return DrawGeometry<VertexShaderT>(geometry_result, renderer, entity, pass,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return DrawGeometry<VertexShaderT>(geometry_result, renderer, entity, pass,
return DrawGeometry<VertexShaderT>(std::move(geometry_result), renderer, entity, pass,

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@bdero bdero changed the title [Impeller] Add shared ColorSourceContents render routine. [Impeller] Migrate ColorSourceContents to use a shared rendering routine. Feb 10, 2024
@bdero bdero changed the title [Impeller] Migrate ColorSourceContents to use a shared rendering routine. [Impeller] Migrate all ColorSourceContents to use a shared rendering routine. Feb 10, 2024
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #50261 at sha 9cad64c

@bdero
Copy link
Member Author

bdero commented Feb 10, 2024

Okay, let's see how those goldens turn out, but all the color sources are done.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #50261 at sha bd03152

@bdero
Copy link
Member Author

bdero commented Feb 13, 2024

Oh, the changed goldens are gone!

@bdero bdero force-pushed the bdero/colorsourcecontents-utils branch from bd03152 to fa205f4 Compare February 13, 2024 18:52
@bdero bdero force-pushed the bdero/colorsourcecontents-utils branch from fa205f4 to ccd8718 Compare February 13, 2024 18:53
@bdero
Copy link
Member Author

bdero commented Feb 13, 2024

I force pushed like a bad boy but let's see what happens.

Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #50261 at sha ccd8718

@jonahwilliams
Copy link
Member

It looks like this is failing on the tests added for #45308

@bdero
Copy link
Member Author

bdero commented Feb 13, 2024

Yup. Only for Vulkan though, which is peculiar.

@bdero
Copy link
Member Author

bdero commented Feb 13, 2024

Something funky is going on with this test. No fragment stage uniforms are getting bound for either Vulkan or Metal.

@bdero
Copy link
Member Author

bdero commented Feb 13, 2024

nvm, it is binding a struct.

@bdero
Copy link
Member Author

bdero commented Feb 13, 2024

This was a silly ordering bug. RuntimeEffectContents forms descriptor sets based on the uniforms while adding the bindings. It's fine to resolve the pipeline after the bind callback.

@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 14, 2024
@auto-submit auto-submit bot merged commit fa2eb89 into flutter:main Feb 14, 2024
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 14, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 14, 2024
…143425)

flutter/engine@215d55f...0849250

2024-02-14 30870216+gaaclarke@users.noreply.github.com [Impeller] replaces golden file count with a golden diff file (flutter/engine#50621)
2024-02-14 bdero@google.com [Impeller] Migrate all ColorSourceContents to use a shared rendering routine. (flutter/engine#50261)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jsimmons@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
No open projects
Status: 🤔 Needs Triage
3 participants