Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Nov 27, 2024

All render targets created by flutter have a single color attachment. Lets specialize that case in impeller::RenderTarget by creating a field for that attachment description instead of placing it in a hashmap.

return false;
}

#ifndef NDEBUG
Copy link
Contributor Author

@jonahwilliams jonahwilliams Nov 27, 2024

Choose a reason for hiding this comment

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

This function is actually crazy expensive and I don't think we should be running it in any modes.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

Approach is looking good to me. I'd rather see this detail abstracted away from RenderTarget's clients instead of changing its interface.

Comment on lines +131 to +143
vk::AttachmentReference color_ref;
color_ref.attachment = attachments.size();
color_ref.layout = vk::ImageLayout::eGeneral;
color_refs[0] = color_ref;
attachments.push_back(color0_.value());

if (color0_resolve_.has_value()) {
vk::AttachmentReference resolve_ref;
resolve_ref.attachment = attachments.size();
resolve_ref.layout = vk::ImageLayout::eGeneral;
resolve_refs[0] = resolve_ref;
attachments.push_back(color0_resolve_.value());
}
Copy link
Member

Choose a reason for hiding this comment

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

Please remove duplication

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Can't you use the Iterate method here to avoid the duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't the render_target, this is the internal implementation of the RenderPassBuilderVK

std::optional<vk::AttachmentDescription> color0_resolve_;
std::optional<vk::AttachmentDescription> depth_stencil_;

std::map<size_t, vk::AttachmentDescription> colors_;
Copy link
Member

Choose a reason for hiding this comment

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

We should add a comment here that colors_[0] is really at color0_.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines -93 to -94
.GetColorAttachments()
.find(0u)
Copy link
Member

Choose a reason for hiding this comment

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

Can we instead change this to .GetColorAttachment(0u). That way the way the render target is storing the first color attachment isn't being leaked to its clients.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return ColorAttachment{};
}

bool RenderTarget::HasColor0() const {
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here. Let's just make HasColorAttachment(0) look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@jonahwilliams
Copy link
Contributor Author

Approach is looking good to me. I'd rather see this detail abstracted away from RenderTarget's clients instead of changing its interface.

So the way to do that would be to remove the GetColorAttachments function that returns a map and instead have an iterator like approach. I can do that.

@gaaclarke
Copy link
Member

Approach is looking good to me. I'd rather see this detail abstracted away from RenderTarget's clients instead of changing its interface.

So the way to do that would be to remove the GetColorAttachments function that returns a map and instead have an iterator like approach. I can do that.

I don't think you need need an iterator, deleting GetColorAttachments() and adding GetColorAttachment(size_t) should be enough right?

@jonahwilliams
Copy link
Contributor Author

I don't need an iterator exactly, I just can't have a method that returns a app. I can't just have a length query because I think its possible to have combinations like color0 and color2 with color1 not set to anything.

@jonahwilliams
Copy link
Contributor Author

app -> map

@jonahwilliams
Copy link
Contributor Author

Updated so that we use a new IterateColorAttachments function to avoid making callers handle color0 as a special case.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of remaining niggles. I think this is a lot cleaner.

Comment on lines +131 to +143
vk::AttachmentReference color_ref;
color_ref.attachment = attachments.size();
color_ref.layout = vk::ImageLayout::eGeneral;
color_refs[0] = color_ref;
attachments.push_back(color0_.value());

if (color0_resolve_.has_value()) {
vk::AttachmentReference resolve_ref;
resolve_ref.attachment = attachments.size();
resolve_ref.layout = vk::ImageLayout::eGeneral;
resolve_refs[0] = resolve_ref;
attachments.push_back(color0_resolve_.value());
}
Copy link
Member

Choose a reason for hiding this comment

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

Can't you use the Iterate method here to avoid the duplication?

Comment on lines +57 to +61
// Visible for testing.
std::optional<vk::AttachmentDescription> GetColor0() const;

// Visible for testing.
std::optional<vk::AttachmentDescription> GetColor0Resolve() const;
Copy link
Member

Choose a reason for hiding this comment

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

Please make the test a friend instead of making these public (example

FML_FRIEND_TEST(testing::BufferBindingsGLESTest, BindUniformData);
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Listing out each test name seems like a pretty big step down, given that this is an internal library of an internal library.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 4, 2024
@auto-submit auto-submit bot merged commit 1f7f37e into flutter:main Dec 4, 2024
31 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2024
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Dec 4, 2024
…159805)

flutter/engine@29d6640...1f7f37e

2024-12-04 [email protected] [Impeller] avoid heap allocation in
RenderTarget object. (flutter/engine#56829)
2024-12-04 [email protected] Manual roll dart to
470117150f34d712ee6d8c4558b3c656d973f656 (flutter/engine#56915)

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 [email protected],[email protected] 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
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…ine#56829)

All render targets created by flutter have a single color attachment. Lets specialize that case in impeller::RenderTarget by creating a field for that attachment description instead of placing it in a hashmap.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants