-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Compute in Vulkan #42294
[Impeller] Compute in Vulkan #42294
Changes from 1 commit
efbb8b3
eab8f2c
37eaae7
f07bfd9
28d1457
2168461
9301a82
c88dd19
355eaed
14f4076
8615211
b2b37ec
becb828
45aeb3b
53220ac
454ed44
d26abf2
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 |
|---|---|---|
|
|
@@ -124,13 +124,23 @@ bool CommandEncoderVK::IsValid() const { | |
| return is_valid_; | ||
| } | ||
|
|
||
| bool CommandEncoderVK::Submit() { | ||
| bool CommandEncoderVK::Submit(SubmitCallback callback) { | ||
| // Make sure to call callback with `false` if anything returns early. | ||
| bool fail_callback = !!callback; | ||
|
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. Prefer a ScopedCleanupClosure that returns false by default. On the one success case, release the closure and invoke it with true once.
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. That's being done below.
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.
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. Oh, I think I see what you mean.
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. I thought there was some way to make this a little clearer with a second fml::ScopedCleanupClosure but I'm missing it. Maybe we can sync up offline.
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. Argh, nevermind again, I misread this and now I understand what you're saying :) |
||
| if (!IsValid()) { | ||
| if (fail_callback) { | ||
| callback(false); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // Success or failure, you only get to submit once. | ||
| fml::ScopedCleanupClosure reset([&]() { Reset(); }); | ||
| fml::ScopedCleanupClosure reset([&]() { | ||
| if (fail_callback) { | ||
| callback(false); | ||
| } | ||
| Reset(); | ||
| }); | ||
|
|
||
| InsertDebugMarker("QueueSubmit"); | ||
|
|
||
|
|
@@ -155,10 +165,16 @@ bool CommandEncoderVK::Submit() { | |
| return false; | ||
| } | ||
|
|
||
| // Submit will proceed, call callback with true when it is done and do not | ||
| // call when `reset` is collected. | ||
| fail_callback = false; | ||
|
|
||
| return fence_waiter_->AddFence( | ||
| std::move(fence), [tracked_objects = std::move(tracked_objects_)] { | ||
| // Nothing to do, we just drop the tracked | ||
| // objects on the floor. | ||
| std::move(fence), | ||
| [callback, tracked_objects = std::move(tracked_objects_)] { | ||
| if (callback) { | ||
| callback(true); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
|
|
||
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.
You missed the early return after the callback invocation on error. Thats why I prefer this stylistically too (and its drier).
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.
That doesn't work - it fires the callback too early.
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.
Ahh NVM I see.