-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Reland: one descriptor pool per frame. #55960
Changes from all commits
536007a
6ab4460
8432312
d973b2c
0ae06a8
a7398b9
29c9dce
f5efff6
441daf5
1262955
a60791b
988694f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,12 @@ | |
| // found in the LICENSE file. | ||
|
|
||
| #include "impeller/renderer/backend/vulkan/context_vk.h" | ||
| #include <thread> | ||
| #include <unordered_map> | ||
|
|
||
| #include "fml/concurrent_message_loop.h" | ||
| #include "impeller/renderer/backend/vulkan/command_queue_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/descriptor_pool_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/render_pass_builder_vk.h" | ||
| #include "impeller/renderer/render_target.h" | ||
|
|
||
|
|
@@ -30,6 +33,7 @@ | |
| #include "impeller/renderer/backend/vulkan/command_pool_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/command_queue_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/debug_report_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/descriptor_pool_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/fence_waiter_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/gpu_tracer_vk.h" | ||
| #include "impeller/renderer/backend/vulkan/resource_manager_vk.h" | ||
|
|
@@ -497,8 +501,22 @@ std::shared_ptr<CommandBuffer> ContextVK::CreateCommandBuffer() const { | |
| return nullptr; | ||
| } | ||
|
|
||
| // look up a cached descriptor pool for the current frame and reuse it | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In cases where we operate on a thread pool where threads are being created and collected, thread ID reuse may cause us issues. This is just a hypothetical though. Our existing pools don't work that way. Not sure we should care.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about this some more, perhaps we should steal NSNotificationCenter from Foundation. The thread locals can add listeners (by object) to certain lifecycle events where they can collect resources when the context shuts down in addition to collection those same resources when the thread itself shuts down. In any case, what you have here should work well for our use.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you file a bug for this and describe how it would work? |
||
| // if it exists, otherwise create a new pool. | ||
| DescriptorPoolMap::iterator current_pool = | ||
| cached_descriptor_pool_.find(std::this_thread::get_id()); | ||
| std::shared_ptr<DescriptorPoolVK> descriptor_pool; | ||
| if (current_pool == cached_descriptor_pool_.end()) { | ||
| descriptor_pool = | ||
| (cached_descriptor_pool_[std::this_thread::get_id()] = | ||
| std::make_shared<DescriptorPoolVK>(weak_from_this())); | ||
| } else { | ||
| descriptor_pool = current_pool->second; | ||
| } | ||
|
|
||
| auto tracked_objects = std::make_shared<TrackedObjectsVK>( | ||
| weak_from_this(), std::move(tls_pool), GetGPUTracer()->CreateGPUProbe()); | ||
| weak_from_this(), std::move(tls_pool), std::move(descriptor_pool), | ||
| GetGPUTracer()->CreateGPUProbe()); | ||
| auto queue = GetGraphicsQueue(); | ||
|
|
||
| if (!tracked_objects || !tracked_objects->IsValid() || !queue) { | ||
|
|
@@ -517,10 +535,9 @@ std::shared_ptr<CommandBuffer> ContextVK::CreateCommandBuffer() const { | |
| tracked_objects->GetCommandBuffer()); | ||
|
|
||
| return std::shared_ptr<CommandBufferVK>(new CommandBufferVK( | ||
| shared_from_this(), // | ||
| GetDeviceHolder(), // | ||
| std::move(tracked_objects), // | ||
| GetFenceWaiter() // | ||
| shared_from_this(), // | ||
| GetDeviceHolder(), // | ||
| std::move(tracked_objects) // | ||
| )); | ||
| } | ||
|
|
||
|
|
@@ -651,6 +668,7 @@ void ContextVK::InitializeCommonlyUsedShadersIfNeeded() const { | |
| } | ||
|
|
||
| void ContextVK::DisposeThreadLocalCachedResources() { | ||
| cached_descriptor_pool_.erase(std::this_thread::get_id()); | ||
| command_pool_recycler_->Dispose(); | ||
| } | ||
|
|
||
|
|
||
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.
fence waiter is unused