This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Document and slightly refactor ResourceManagerVK & friends.
#45474
Merged
auto-submit
merged 14 commits into
flutter:main
from
matanlurey:impeller-resource-manager-vk
Sep 7, 2023
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fe13390
Clarify that `::Create` does not enforce 1-per context. Add a test.
matanlurey 6c5721f
Tweak some naming and comments.
matanlurey f15946b
Remove unused include.
matanlurey 89f3fd4
Finish unit tests and docs.
matanlurey 5b3bde8
Merge branch 'main' into impeller-resource-manager-vk
matanlurey ca719ba
Aspirational tests were merely aspirational.
matanlurey 2c0bf22
Merge branch 'main' into impeller-resource-manager-vk
matanlurey 280fc76
Added a test that yields for resource cleanup.
matanlurey 34d07fc
Merge branch 'main' into impeller-resource-manager-vk
matanlurey 82fb32c
Thanks Aaron.
matanlurey 5ccc222
Use make_shared.
matanlurey 504853d
Go back to shared_ptr.
matanlurey 4b6dad0
Make test more resilient.
matanlurey 777ccd8
Merge branch 'main' into impeller-resource-manager-vk
matanlurey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
impeller/renderer/backend/vulkan/resource_manager_vk_unittests.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include <sys/types.h> | ||
| #include <functional> | ||
| #include <memory> | ||
| #include <utility> | ||
| #include "fml/synchronization/waitable_event.h" | ||
| #include "gtest/gtest.h" | ||
| #include "impeller/renderer/backend/vulkan/resource_manager_vk.h" | ||
|
|
||
| namespace impeller { | ||
| namespace testing { | ||
|
|
||
| // While expected to be a singleton per context, the class does not enforce it. | ||
| TEST(ResourceManagerVKTest, CreatesANewInstance) { | ||
| auto const a = ResourceManagerVK::Create(); | ||
| auto const b = ResourceManagerVK::Create(); | ||
| EXPECT_NE(a, b); | ||
| } | ||
|
|
||
| namespace { | ||
|
|
||
| // Invokes the provided callback when the destructor is called. | ||
| // | ||
| // Can be moved, but not copied. | ||
| class DeathRattle final { | ||
matanlurey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public: | ||
| explicit DeathRattle(std::function<void()> callback) | ||
| : callback_(std::move(callback)) {} | ||
|
|
||
| DeathRattle(DeathRattle&&) = default; | ||
| DeathRattle& operator=(DeathRattle&&) = default; | ||
|
|
||
| ~DeathRattle() { callback_(); } | ||
|
|
||
| private: | ||
| std::function<void()> callback_; | ||
| }; | ||
|
|
||
| } // namespace | ||
|
|
||
| TEST(ResourceManagerVKTest, ReclaimMovesAResourceAndDestroysIt) { | ||
| auto const manager = ResourceManagerVK::Create(); | ||
|
|
||
| auto waiter = fml::AutoResetWaitableEvent(); | ||
| auto dead = false; | ||
| auto rattle = DeathRattle([&waiter]() { waiter.Signal(); }); | ||
|
|
||
| // Not killed immediately. | ||
| EXPECT_FALSE(waiter.IsSignaledForTest()); | ||
|
|
||
| { | ||
| auto resource = UniqueResourceVKT<DeathRattle>(manager, std::move(rattle)); | ||
| } | ||
|
|
||
| waiter.Wait(); | ||
| } | ||
|
|
||
| } // namespace testing | ||
| } // namespace impeller | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.