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 Oct 22, 2023

Rather than doing a guess and check, since we have all of our cmds already stored we can add up the binding counts and allocate the exact descriptor size and populate them in one call.

Also makes render_pass and compute_pass share more (though not all) code.

@jonahwilliams
Copy link
Contributor Author

I did this work as part of an investigation into whether or not we could use dynamic uniform buffers. What I found is that would be difficult as the dynamic descriptor API requires the uniform buffers to have equal sizing - meaning we'd need to adjust our headers and maintain some additional tooling to synchronize that. Given that descriptors updates dont consitute a huge overhead today, I settled for a refactor to clarify the code, remove extra allocations, and remove duplication across compute_pass and render_pass

Comment on lines 30 to 33
if (!encoder->Track(texture) ||
!encoder->Track(sampler.GetSharedSampler())) {
return false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: we're currently calling track twice on each texture.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW, tracking the same resource multiple times is safe.

@chinmaygarde chinmaygarde changed the title [Impeller] allocate exact descriptor count, populate in one go. [Impeller] Allocate exact descriptor count, populate in one go. Oct 23, 2023
@jonahwilliams jonahwilliams marked this pull request as ready for review October 23, 2023 18:05
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Other than the confusion about error handling in AllocateDescriptorSets, lgtm.

"android_hardware_buffer_texture_source_vk.h",
"barrier_vk.cc",
"barrier_vk.h",
"binding_helpers.cc",
Copy link
Member

Choose a reason for hiding this comment

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

Nit: binding_helpers_vk?

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

const std::shared_ptr<CommandEncoderVK>& encoder,
const std::vector<Command>& commands);

std::vector<vk::DescriptorSet> AllocateAndBindDescriptorSets(
Copy link
Member

Choose a reason for hiding this comment

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

Ooh, the overload is unfortunate. Trying to figure out how we can dry up this code. But perhaps I am overthinking it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could make this a template monstrosity but I think lets take the win for now from sharing BindTexture/BindBuffer. Long term, I think we fix this by breaking apart Command/ComputeCommand and storing the encoding data more generically

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I was going to suggest reworking it but realized thats going to be non-trivial. Later, if at all.

Comment on lines 30 to 33
if (!encoder->Track(texture) ||
!encoder->Track(sampler.GetSharedSampler())) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, tracking the same resource multiple times is safe.

size_t command_count) {
if (pools_.empty()) {
pool_size_ = command_count;
std::vector<vk::DescriptorSet> DescriptorPoolVK::AllocateDescriptorSets(
Copy link
Member

Choose a reason for hiding this comment

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

This weakens the error reporting ability of this API though. An empty vector isn't the same as a vector with nullopt elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think this should be something like a status_or

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated these to status_or. not totally in love with the existing status enums, and the messages feel a bit redundant witht the validation logs.

std::optional<vk::DescriptorSet> AllocateDescriptorSet(
const vk::DescriptorSetLayout& layout,
size_t command_count);
std::vector<vk::DescriptorSet> AllocateDescriptorSets(
Copy link
Member

Choose a reason for hiding this comment

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

Lets document what an empty vector would mean. Ideally, this would be a vector of optional elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would a std::nullopt descriptor set imply?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind. I thought it was a DescriptorSetUnique. Following this up by making it a status or (or just leave it be) is fine.

auto new_pool =
CreatePool(strong_device->GetDevice(), sampler_count, buffer_count);
if (!new_pool) {
return {};
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a validation log here saying the pool could not be allocated.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 24, 2023
@auto-submit auto-submit bot merged commit d6a48e9 into flutter:main Oct 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 24, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Oct 24, 2023
…137180)

flutter/engine@602b513...d6a48e9

2023-10-24 [email protected] [Impeller] Allocate exact descriptor count, populate in one go. (flutter/engine#47200)
2023-10-24 [email protected] [Impeller] Curve components in stroke path use start directions as their initial offsets (flutter/engine#46203)
2023-10-24 [email protected] Roll Fuchsia Mac SDK from OUWiWfUxyMyDOlEfA... to YqSO1OByhoexFJSCr... (flutter/engine#47273)
2023-10-24 [email protected] [Impeller] Enable MSAA for OpenGLES: Take 2. (flutter/engine#47030)
2023-10-24 [email protected] Manual roll Dart SDK from 901e92d10627 to 360370ff93b0 (3 revisions) (flutter/engine#47271)
2023-10-24 [email protected] Roll Dart SDK from 901e92d10627 to 360370ff93b0 (3 revisions) (flutter/engine#47269)

Also rolling transitive DEPS:
  fuchsia/sdk/core/mac-amd64 from OUWiWfUxyMyD to YqSO1OByhoex

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
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants