-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 WGPU_BACKEND environment variable #789
Conversation
Running after setting through |
Is an environment variable the proper way to introduce this kind of configuration? Should it always be a user choice? |
I think the ideal situation is the compiled iced program, you can choose their own internal rendering back-end, just need to restart the program can switch back-end, but it seems difficult to achieve. Environment variables make it easy for developers to specify which backend should be used for the compiled version, but users have no choice. |
I would say yes: sometimes because of a driver issue with some backend, sometimes just for testing. At any rate I did something similar (though |
If by user you mean the end-user of an In doing so, we would allow developers to create a "backend fallback strategy", This would allow any developer to add a pub enum GlowBackend{
Modern,
Compatibility,
Legacy,
}
pub enum Backend{
#[cfg(feature="wgpu")]
Wgpu(wgpu::BackendBit),
#[cfg(feature="glow")]
Glow(GlowBackend)
} Maybe we should move this to a discussion? |
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.
I have changed the implementation details a bit, but the result for users should be the same.
Specifically, I have introduced a from_env
method to the Settings
of our renderers, instead of coupling the environment variable to Compositor::new
.
Thanks! I think we can merge this.
@derezzedex Backend fallback is in the roadmap, but I believe it solves a different kind of use case. |
Fixes #787. Related to #207.
Inspired by Bevy’s source code.
You can explicitly specify the render backend when you run your app by setting the WGPU_BACKEND environment variable. If this environment variable does not exist, the default is the wgpu::BackendBit::PRIMARY.
If you use cargo with version 1.52 or later, you can easily set your environment variables.
First create a folder called
.cargo
in your project directory, then create aconfig.toml
file in the.cargo
folder:before:
. ├── Cargo.lock ├── Cargo.toml └── src └── main.rs
after:
. ├── Cargo.lock ├── .cargo │ └── config.toml ├── Cargo.toml └── src └── main.rs
.cargo/config.toml
:Specific configuration method can be seen here.