From 8d5ef65dcb3e447148a21f042f2570bc0a9a9730 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Fri, 20 Nov 2020 23:33:10 -0330 Subject: [PATCH 1/2] Temporarily use `BackendBit::PRIMARY` in examples `BackendBit::all()` allows GL/surfman to be used on macOS which appears to prevent rendering with Metal (e.g. hello-triangle displays an empty window). surfman will be removed in later versions of gfx, which will allow us to switch back to `BackendBit::all()` in the examples. --- examples/hello-compute/main.rs | 2 +- examples/hello-triangle/main.rs | 2 +- examples/hello-windows/main.rs | 2 +- examples/hello/main.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/hello-compute/main.rs b/examples/hello-compute/main.rs index 5ff78246b..4472562a9 100644 --- a/examples/hello-compute/main.rs +++ b/examples/hello-compute/main.rs @@ -21,7 +21,7 @@ async fn run() { async fn execute_gpu(numbers: Vec) -> Vec { // Instantiates instance of WebGPU - let instance = wgpu::Instance::new(wgpu::BackendBit::all()); + let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); // `request_adapter` instantiates the general connection to the GPU let adapter = instance diff --git a/examples/hello-triangle/main.rs b/examples/hello-triangle/main.rs index 8cd6a9867..06b5f5ea5 100644 --- a/examples/hello-triangle/main.rs +++ b/examples/hello-triangle/main.rs @@ -6,7 +6,7 @@ use winit::{ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu::TextureFormat) { let size = window.inner_size(); - let instance = wgpu::Instance::new(wgpu::BackendBit::all()); + let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); let surface = unsafe { instance.create_surface(&window) }; let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { diff --git a/examples/hello-windows/main.rs b/examples/hello-windows/main.rs index d165f3f68..af0e98c48 100644 --- a/examples/hello-windows/main.rs +++ b/examples/hello-windows/main.rs @@ -67,7 +67,7 @@ async fn run( viewports: Vec<(Window, wgpu::Color)>, swapchain_format: wgpu::TextureFormat, ) { - let instance = wgpu::Instance::new(wgpu::BackendBit::all()); + let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); let viewports: Vec<_> = viewports .into_iter() .map(|(window, color)| ViewportDesc::new(window, color, &instance)) diff --git a/examples/hello/main.rs b/examples/hello/main.rs index 55618875f..faeee7520 100644 --- a/examples/hello/main.rs +++ b/examples/hello/main.rs @@ -1,7 +1,7 @@ /// This example shows how to describe the adapter in use. async fn run() { #[cfg_attr(target_arch = "wasm32", allow(unused_variables))] - let adapter = wgpu::Instance::new(wgpu::BackendBit::all()) + let adapter = wgpu::Instance::new(wgpu::BackendBit::PRIMARY) .request_adapter(&wgpu::RequestAdapterOptions::default()) .await .unwrap(); From 4fafceb30a09f96076b4e335bbc76da460b8501f Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Sat, 21 Nov 2020 00:07:57 -0330 Subject: [PATCH 2/2] Fix typo --- examples/hello-triangle/main.rs | 2 +- examples/hello-windows/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/hello-triangle/main.rs b/examples/hello-triangle/main.rs index 06b5f5ea5..c4ddb58a4 100644 --- a/examples/hello-triangle/main.rs +++ b/examples/hello-triangle/main.rs @@ -15,7 +15,7 @@ async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu:: compatible_surface: Some(&surface), }) .await - .expect("Failed to find an appropiate adapter"); + .expect("Failed to find an appropriate adapter"); // Create the logical device and command queue let (device, queue) = adapter diff --git a/examples/hello-windows/main.rs b/examples/hello-windows/main.rs index af0e98c48..f73a4b8aa 100644 --- a/examples/hello-windows/main.rs +++ b/examples/hello-windows/main.rs @@ -79,7 +79,7 @@ async fn run( compatible_surface: viewports.first().map(|desc| &desc.surface), }) .await - .expect("Failed to find an appropiate adapter"); + .expect("Failed to find an appropriate adapter"); // Create the logical device and command queue let (device, queue) = adapter