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

[Impeller] Descriptor pool incremental allocation. #49686

Merged
merged 9 commits into from
Jan 12, 2024

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Jan 10, 2024

This returns descriptor set allocation to the previously used strategy of incrementally allocating descriptors and maintaing a vec of pools. This is required to remove deferred command encoding as part of flutter/flutter#140804

There are some potential further improvements: we may be able to share the descriptor pool across a frame, which would reduce allocation time slightly.

size_t write_offset = 0u;

auto& pipeline_descriptor = command.pipeline->GetDescriptor();
auto& desc_set =
Copy link
Member Author

Choose a reason for hiding this comment

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

missing the & on this meant we were always copying the descriptor set layouts read from the pipeline descriptor 🤦

@@ -27,6 +28,12 @@ class RenderPassVK final : public RenderPass {
std::weak_ptr<CommandBufferVK> command_buffer_;
std::string debug_label_;
bool is_valid_ = false;

mutable std::array<vk::DescriptorImageInfo, kMaxBindings> image_workspace_;
Copy link
Member Author

Choose a reason for hiding this comment

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

These don't have to be mutable once we remove the deferred encoding.

Copy link
Member Author

Choose a reason for hiding this comment

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

But in the short term we could make this method not const.

@jonahwilliams
Copy link
Member Author

Friendly ping :)

@jonahwilliams
Copy link
Member Author

After taking a closer look I found a few places where we made extra shared_ptr copies, so i've updated this to fix them.

auto-submit bot pushed a commit that referenced this pull request Jan 12, 2024
Part of flutter/flutter#140804

Migrate the rest of the commands in impeller to use the new API. Hide RenderPass::AddCommand. On subsequent changes I will be able to begin making some of these methods virtual so we can add more direct pass through. Though the vulkan backend will be blocked on changes to descriptor sets: #49686
@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 12, 2024

writes.push_back(write_set);
write_workspace[write_offset++] = write_set;
Copy link
Member

@chinmaygarde chinmaygarde Jan 12, 2024

Choose a reason for hiding this comment

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

A somewhat hypothetical issue but there are no guards around writes past the end of the buffer. Debugging memory corruptions might get hairy. Perhaps write_workspace[std::max(write_offset++, write_workspace.size() - 1u)] = <blah>;. Or do a bounds check and propagate the error. Here and elsewhere.

write_set.descriptorType = vk::DescriptorType::eInputAttachment;
write_set.pImageInfo = &image_workspace[image_offset - 1];

write_workspace[write_offset++] = write_set;
Copy link
Member

Choose a reason for hiding this comment

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

Other than the writes past the end. This reads so much less scarier. Rather than depending on the correct reserve call to ensure that the push_back doesn't cause a reallocation and invalid pointer.

@auto-submit auto-submit bot merged commit 0f410dd into flutter:main Jan 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 12, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 12, 2024
…141489)

flutter/engine@418c9e9...b8e5d47

2024-01-12 [email protected] [Impeller] move TrackedObjectsVK to separate file. (flutter/engine#49773)
2024-01-12 [email protected] Add gclient_variables back for linux_license and fix the excluded files (flutter/engine#49775)
2024-01-12 [email protected] [Impeller] Descriptor pool incremental allocation. (flutter/engine#49686)
2024-01-12 [email protected] Relands: Refactors RBE support (flutter/engine#49660)
2024-01-12 [email protected] [Impeller] finish migration to new render pass API. (flutter/engine#49740)
2024-01-12 [email protected] [Impeller] remove Buffer type and associated abstractions. (flutter/engine#49702)
2024-01-12 [email protected] Remove `gclient_variables` from `linux_license.json` (flutter/engine#49766)

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],[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
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
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants