Repository navigation
Add egui_wgpu crate - #1564
Add egui_wgpu crate#1564
Conversation
|
exciting news! |
|
That was quick - thanks @LU15W1R7H ❤️ |
bce4daa to
60df946
Compare
s-nie
left a comment
There was a problem hiding this comment.
Works great. Thanks for integrating this so quickly!
How should we treat the feature flags for this?
If in any way possible, enabling both of them at the same time should be an option. This will let users create an app where the backend can be selected at runtime. Building with two backends might seem redundant at first, but in my experience, glow and wgpu complement each other pretty well in that one of them always works, even if the other doesn't because of platform incompatibility.
|
Love the approach with the impl FromStr for Renderer {
type Err = Box<dyn std::error::Error>;
fn from_str(name: &str) -> Result<Self, Self::Err> {
match name.to_lowercase().as_str() {
#[cfg(feature = "glow")]
"glow" => Ok(Self::Glow),
#[cfg(feature = "wgpu")]
"wgpu" => Ok(Self::Wgpu),
_ => {
let message = format!(
"Backend '{name}' is not available. Make sure that the corresponding feature is enabled."
);
Err(message.into())
}
}
}
} |
|
I believe the creation of the
The raw handle should be valid since it is part of the winit window, but the window is not guaranteed to outlive the surface. There is a proposal for making the API safe (gfx-rs/wgpu#1463) but it doesn't seem like it will be implemented any time soon. |
Co-authored-by: Sven Niederberger <73159570+s-nie@users.noreply.github.com>
|
@pjottos good catch, but hard for us to fix. I guess the best we can do is make |
|
If this looks good I will merge and also publish |
|
Looks good to me! Thanks again :) |
| tracing = "0.1" | ||
|
|
||
| # optional: | ||
| egui_glow = { version = "0.18.0", path = "../egui_glow", optional = true, default-features = false } |
There was a problem hiding this comment.
While randomly going through this Cargo.toml, there's a puffin = ["dep:puffin", "egui_glow/puffin"] that enables this optional egui_glow now whenever puffin is enabled. I think the feature is only used to emit profiling scopes in that crate, should it perhaps be updated to egui_glow?/puffin?
There was a problem hiding this comment.
Thanks! I still had a little entry for this on my TODO list (to not forget), can be crossed off now :)
Adding a new crate
egui-wgpuas an official backend ofeframe. This adds feature flagsglowandwgputoeframe, and you can enable either or both. At runtime you can select which backend to use withNativeOptions::renderer.Forked from #1561 so I can make commits. Based on Nils Hasenbanck's egui_wgpu_backend with additions by @s-nie and myself.
I decided not to touch
egui_wgpu/src/renderer.rstoo much, and instead create aegui_wpgu::winit::Painterwrapper around it, abstracting all wgpu-specific code away fromeframe.eframenow has two very similar-lookingrun_glowandrun_wgpu.Closes #1555 #1561
Name
egui-wgpuis already taken (https://crates.io/crates/egui_wgpu) by @LU15W1R7H, who was kind enough to transfer ownership of the crate name to me (just like they did foregui-winit!)Other
I haven't tested the WGPU backend on web yet