-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Allocate exact descriptor count, populate in one go. #47200
[Impeller] Allocate exact descriptor count, populate in one go. #47200
Conversation
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 |
…engine into descriptor_simplification
if (!encoder->Track(texture) || | ||
!encoder->Track(sampler.GetSharedSampler())) { | ||
return false; | ||
} |
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.
TODO: we're currently calling track twice on each texture.
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.
FWIW, tracking the same resource multiple times is safe.
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.
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", |
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.
Nit: binding_helpers_vk
?
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
const std::shared_ptr<CommandEncoderVK>& encoder, | ||
const std::vector<Command>& commands); | ||
|
||
std::vector<vk::DescriptorSet> AllocateAndBindDescriptorSets( |
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.
Ooh, the overload is unfortunate. Trying to figure out how we can dry up this code. But perhaps I am overthinking it.
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.
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
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.
Yeah, I was going to suggest reworking it but realized thats going to be non-trivial. Later, if at all.
if (!encoder->Track(texture) || | ||
!encoder->Track(sampler.GetSharedSampler())) { | ||
return false; | ||
} |
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.
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( |
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.
This weakens the error reporting ability of this API though. An empty vector isn't the same as a vector with nullopt elements.
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.
Yeah, I think this should be something like a status_or
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.
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( |
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.
Lets document what an empty vector would mean. Ideally, this would be a vector of optional elements.
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.
What would a std::nullopt descriptor set imply?
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.
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 {}; |
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.
Maybe a validation log here saying the pool could not be allocated.
…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
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.