-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Add a new API 'Context::WaitUntilCommandsCompleted' to ensure that commands are completed. #37704
Conversation
…mmands are completed
|
|
||
| virtual std::shared_ptr<CommandBuffer> CreateCommandBuffer() const = 0; | ||
|
|
||
| virtual bool WaitUntilCommandsCompleted() = 0; |
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 don't think this belongs on Context - you want to know when the commands from a particular buffer are completed right?
For example, should this wait for all commands from compute to finish as well?
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 tried adding a parameter to the SubmitCommands method of CommandBuffer to solve the problem. But I found that in some scenarios, developers can't call SubmitCommands themselves, or even they can't find the Command they want to wait for.
for example
engine/shell/common/snapshot_controller_impeller.cc
Lines 64 to 66 in 4464920
| std::shared_ptr<impeller::Image> image = | |
| picture.ToImage(*context, render_target_size); | |
| context->GetContext()->WaitUntilCommandsCompleted(); |
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.
@dnfield Do you have any thoughts on this example of not being able to access the specific CommandsBuffer? Thanks!
Also cc @chinmaygarde
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.
When you call EntityPass::Render from AiksContext::Render maybe there could be some parameter like a callback for when the texture is done?
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.
EntityPass::Render knows the command buffer, and the command buffer has SubmitCommands(const CompletionCallback& callback).
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.
|
Closing it since there is a better solution #37772 |
I'm working on flutter/flutter#110829, and I found that Impeller doesn't have an API to ensure that all commands are completed.
Let's take the following code as an example. In the following piece of code, we will draw the
DisplayListinto aTexturein the Raster thread, and then blit theTextureinto theCPU Bufferon the IO thread. So we need to ensure that when we do the blit operation on the IO thread, the commands about the DisplayList drawn to the Texture have been completed in the GPU.Another place where we need to use this new API is "blit texture to buffer". We need to ensure that the blit operation has been executed on the gpu before using the cpu buffer.
Pre-launch Checklist
///).