-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] vk::CommandPool
resets via ResourceManager
#45654
[Impeller] vk::CommandPool
resets via ResourceManager
#45654
Conversation
vk::CommandPool
is now reset off-thread using ResourceManager
vk::CommandPool
resets via ResourceManager
/// | ||
/// A single instance should be created per |ContextVK|. | ||
/// | ||
/// Every "frame", a single |CommandPoolResourceVk| is made available for each |
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.
Please make a note of the the threading restrictions you've accounted for here. Specifically, the spec says:
Command pools are externally synchronized, meaning that a command pool must not
be used concurrently in multiple threads. That includes use via recording
commands on any command buffers allocated from the pool, as well as
operations that allocate, free, and reset command buffers or the pool itself.
The things I would look for are:
- Are the commands in the command pool done executing when recycle is called?
- Does the swap and recycle happen in a thread safe manner.
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.
Ack. I did find a problem (in unit tests) and addressed them. Did you want the docs updated?
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.
It would be good to have at least 1 answered clearly in the docs. 2 is an implementation detail I am fine leaving out.
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.
Sounds good, added!
I ran into some multi-threading problems with |
I found two other sources of bugs (other than code in this PR) blocking and have fixes out:
Once those are both in I'll update to main and address @chinmaygarde's comments/re-run CI. |
I started using `CreateMockVulkanContext()` in #45654, and discovered that it was not thread-safe. This PR does a little bit of refactoring/TLC to ensure that functions and buffers can be accessed across threads (like the _real_ `ContextVK`). The attached test (_test for a test fixture, hoorah!_) fails consistently before the changes, and passes after. Note that if you try testing this with `--gtest_repeat=10000` (at least that's the threshold for me), it'll fail - that's actually due to flutter/flutter#134482 which in turn is being fixed in #45686. (Unblocks flutter/flutter#133198) --------- Co-authored-by: gaaclarke <30870216+gaaclarke@users.noreply.github.com>
|
||
buffers_to_collect_.clear(); | ||
void CommandPoolRecyclerVK::Recycle() { |
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.
Seems more like disposal than recycling?
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.
Ah fair enough. Renamed!
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.
Overall LGTM, though not to CI 😄
/// | ||
/// A single instance should be created per |ContextVK|. | ||
/// | ||
/// Every "frame", a single |CommandPoolResourceVk| is made available for each |
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.
It would be good to have at least 1 answered clearly in the docs. 2 is an implementation detail I am fine leaving out.
…ions) (#134882) Manual roll requested by zra@google.com flutter/engine@4909256...8c2203b 2023-09-16 skia-flutter-autoroll@skia.org Roll Skia from b33e0e6706b0 to 2eaaa5bf7dae (1 revision) (flutter/engine#45926) 2023-09-16 skia-flutter-autoroll@skia.org Roll Skia from a1f8fb54299a to b33e0e6706b0 (1 revision) (flutter/engine#45923) 2023-09-16 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from -_edKGA5GTkDFxVgl... to 3Tb9CQTTiBv1lb673... (flutter/engine#45922) 2023-09-16 skia-flutter-autoroll@skia.org Roll Dart SDK from 029d6d73c860 to a0ca39c63c16 (1 revision) (flutter/engine#45921) 2023-09-16 matanlurey@users.noreply.github.com [Impeller] `vk::CommandPool` resets via `ResourceManager` (flutter/engine#45654) 2023-09-16 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from wWzXsy6kx1sp8Km34... to ZhY53WD7bFJSA3xoO... (flutter/engine#45919) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from wWzXsy6kx1sp to ZhY53WD7bFJS fuchsia/sdk/core/mac-amd64 from -_edKGA5GTkD to 3Tb9CQTTiBv1 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 bdero@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…ions) (flutter#134882) Manual roll requested by zra@google.com flutter/engine@4909256...8c2203b 2023-09-16 skia-flutter-autoroll@skia.org Roll Skia from b33e0e6706b0 to 2eaaa5bf7dae (1 revision) (flutter/engine#45926) 2023-09-16 skia-flutter-autoroll@skia.org Roll Skia from a1f8fb54299a to b33e0e6706b0 (1 revision) (flutter/engine#45923) 2023-09-16 skia-flutter-autoroll@skia.org Roll Fuchsia Mac SDK from -_edKGA5GTkDFxVgl... to 3Tb9CQTTiBv1lb673... (flutter/engine#45922) 2023-09-16 skia-flutter-autoroll@skia.org Roll Dart SDK from 029d6d73c860 to a0ca39c63c16 (1 revision) (flutter/engine#45921) 2023-09-16 matanlurey@users.noreply.github.com [Impeller] `vk::CommandPool` resets via `ResourceManager` (flutter/engine#45654) 2023-09-16 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from wWzXsy6kx1sp8Km34... to ZhY53WD7bFJSA3xoO... (flutter/engine#45919) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from wWzXsy6kx1sp to ZhY53WD7bFJS fuchsia/sdk/core/mac-amd64 from -_edKGA5GTkD to 3Tb9CQTTiBv1 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 bdero@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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Fixes flutter/flutter#133198. Major changes: - `CommandPoolVK` is now created indirectly through `CommandPoolRecyclerVK`. - Via destructor, `CommandPoolVK` resets on a background thread via `ResourceManager`. - Removed all of the code trying to reuse/reset individual command buffers (no longer needed). - After every frame, the current/active command pool is recycled. --- _Tests secured._
Fixes flutter/flutter#133198.
Major changes:
CommandPoolVK
is now created indirectly throughCommandPoolRecyclerVK
.CommandPoolVK
resets on a background thread viaResourceManager
.Tests secured.