Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it invalid to call CommandEncoder::finish in a prepare callback function #3116

Closed
ACGNnsj opened this issue Jun 27, 2023 · 2 comments
Closed

Comments

@ACGNnsj
Copy link

ACGNnsj commented Jun 27, 2023

I‘m a newer to egui, so I tried to follow other's examples. And I found that the function item type of CallbackFn::prepare had been changed. Here's a new parameter of type &mut CommandEncoder and a new return type Vec<wgpu::CommandBuffer>.
I tried to invoke CommandEncoder::finish but failed, because the CommandEncoder in the closure is a mutable reference which can't be moved by CommandEncoder::finish.
I have to steal the ownership from the reference or edit CommandEncoder::finish to make it work.
If it's allowed to call CommandEncoder::finish here, CommandEncoder should be changed to value type I think.

@emilk
Copy link
Owner

emilk commented Sep 18, 2023

NOTE: @Wumpf rewrote this recently in #3253

@Wumpf
Copy link
Collaborator

Wumpf commented Sep 18, 2023

didn't see this ticket so far, don't think the mechanism has changed there much
@ACGNnsj the command encoder you get in is the one that is later on used to record egui render passes, as such you're not allowed to finish it inside of prepare since it is still used later. However, you can create new command encoders (or pass them in), finish those and return the resulting CommandBuffer. These command buffers will be executed prior to the egui command encoder but in the same wgpu::Queue::submit call which can make things quite a bit more efficient.

@Wumpf Wumpf closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants