Allow selecting GPU from env

This commit is contained in:
Joe Neeman 2023-01-21 14:29:23 -06:00
parent 9ba85075d4
commit 338bd30870
3 changed files with 8 additions and 7 deletions

View file

@ -15,6 +15,7 @@ pollster = "0.2.5"
# for picosvg
roxmltree = "0.13"
clap = { version = "4.1.0", features = ["derive"] }
env_logger = "0.10.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
vello = { path = "../../", features = ["hot_reload"] }

View file

@ -225,6 +225,7 @@ enum UserEvent {
fn main() {
let args = Args::parse();
env_logger::init();
#[cfg(not(target_arch = "wasm32"))]
{
use winit::{dpi::LogicalSize, window::WindowBuilder};

View file

@ -96,13 +96,12 @@ impl RenderContext {
/// Creates a compatible device handle id.
async fn new_device(&mut self, compatible_surface: Option<&Surface>) -> Option<usize> {
let adapter = self
.instance
.request_adapter(&RequestAdapterOptions {
compatible_surface,
..Default::default()
})
.await?;
let adapter = wgpu::util::initialize_adapter_from_env_or_default(
&self.instance,
wgpu::Backends::PRIMARY,
compatible_surface,
)
.await?;
let features = adapter.features();
let limits = Limits::default();
let (device, queue) = adapter