diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index 96e96e1ebc..221dfbe77e 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -76,7 +76,12 @@ async fn run_async(event_loop: EventLoop<()>, window: Window) { let mut sc_desc = wgpu::SwapChainDescriptor { usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, - format: wgpu::TextureFormat::Bgra8Unorm, + // TODO: Allow srgb unconditionally + format: if cfg!(target_arch = "wasm32") { + wgpu::TextureFormat::Bgra8Unorm + } else { + wgpu::TextureFormat::Bgra8UnormSrgb + }, width: size.width, height: size.height, present_mode: wgpu::PresentMode::Mailbox, diff --git a/wgpu/examples/hello-triangle/main.rs b/wgpu/examples/hello-triangle/main.rs index ad7a996d4c..f46954c326 100644 --- a/wgpu/examples/hello-triangle/main.rs +++ b/wgpu/examples/hello-triangle/main.rs @@ -4,7 +4,7 @@ use winit::{ window::Window, }; -async fn run(event_loop: EventLoop<()>, window: Window) { +async fn run(event_loop: EventLoop<()>, window: Window, swapchain_format: wgpu::TextureFormat) { let size = window.inner_size(); let surface = wgpu::Surface::create(&window); @@ -84,7 +84,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) { let mut sc_desc = wgpu::SwapChainDescriptor { usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, - format: wgpu::TextureFormat::Bgra8Unorm, + format: swapchain_format, width: size.width, height: size.height, present_mode: wgpu::PresentMode::Mailbox, @@ -143,7 +143,8 @@ fn main() { #[cfg(not(target_arch = "wasm32"))] { env_logger::init(); - futures::executor::block_on(run(event_loop, window)); + // Temporarily avoid srgb formats for the swapchain on the web + futures::executor::block_on(run(event_loop, window, wgpu::TextureFormat::Bgra8Unorm)); } #[cfg(target_arch = "wasm32")] { @@ -159,6 +160,10 @@ fn main() { .ok() }) .expect("couldn't append canvas to document body"); - wasm_bindgen_futures::spawn_local(run(event_loop, window)); + wasm_bindgen_futures::spawn_local(run( + event_loop, + window, + wgpu::TextureFormat::Bgra8UnormSrgb, + )); } }