-
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
Add egui_wgpu crate #1564
Add egui_wgpu crate #1564
Conversation
exciting news! |
That was quick - thanks @LU15W1R7H ❤️ |
bce4daa
to
60df946
Compare
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.
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 <[email protected]>
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch; will fix
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.
fixed in d76d055
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.
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-wgpu
as an official backend ofeframe
. This adds feature flagsglow
andwgpu
toeframe
, 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.rs
too much, and instead create aegui_wpgu::winit::Painter
wrapper around it, abstracting all wgpu-specific code away fromeframe
.eframe
now has two very similar-lookingrun_glow
andrun_wgpu
.Closes #1555 #1561
Name
egui-wgpu
is 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