-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Wgpu render pass on paint callback has now static lifetime #5149
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5149-static-renderpass |
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.
nice
May I request some assistance for making ruffle-rs/ruffle#18082 work, after this change? |
@torokati44 should be fairly straight forward: Just remove the lifetimes on paint. Since all changes are strictly lessenings of previous lifetime constraints it should be working out of the box once you adjusted the callback method's signature. Let me know if you have any concrete issues and I can have a look! |
ah I see you're using the renderer directly. In that case the other thing you're missing is something similar to this https://github.com/emilk/egui/pull/5149/files#diff-1173066e54f2d90c3a1f1e737b92a1800a8aa9be5e99e8103e9aeae4832834b7R339 |
Okay, I think I got it, thank you! My issue was that I tried to call |
A very common usability issue on egui-wgpu callbacks is that `paint` can't access any data that doesn't strictly outlive the callback resources' data. E.g. if the callback resources have an `Arc` to some resource manager, you can't easily pull out resources since you statically needed to ensure that those resource references outlived the renderpass, whose lifetime was only constrained to the callback resources themselves. Wgpu 22 no longer has this restriction! Its (render/compute-)passes take care of the lifetime of any passed resource internally. The lifetime constraint is _still_ opt-out since it protects from a common runtime error of adding commands/passes on the parent encoder while a previously created pass wasn't closed yet. This is not a concern in egui-wgpu since the paint method where we have to access the render pass doesn't even have access to the encoder!
A very common usability issue on egui-wgpu callbacks is that
paint
can't access any data that doesn't strictly outlive the callback resources' data. E.g. if the callback resources have anArc
to some resource manager, you can't easily pull out resources since you statically needed to ensure that those resource references outlived the renderpass, whose lifetime was only constrained to the callback resources themselves.Wgpu 22 no longer has this restriction! Its (render/compute-)passes take care of the lifetime of any passed resource internally. The lifetime constraint is still opt-out since it protects from a common runtime error of adding commands/passes on the parent encoder while a previously created pass wasn't closed yet.
This is not a concern in egui-wgpu since the paint method where we have to access the render pass doesn't even have access to the encoder!