From 6f1d6145f555ebbe89b0cca94288990cc0368223 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 21 Aug 2020 12:31:15 -0400 Subject: [PATCH] Fix swapchain preferred format --- wgpu-core/src/device/mod.rs | 11 +++++++++++ wgpu-core/src/swap_chain.rs | 15 --------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index fbd4aca02..86716bad1 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -3262,6 +3262,17 @@ impl Global { .push(layout_id); } + pub fn device_get_swap_chain_preferred_format( + &self, + _device_id: id::DeviceId, + ) -> Result { + span!(_guard, INFO, "Device::get_swap_chain_preferred_format"); + //TODO: we can query the formats like done in `device_create_swapchain`, + // but its not clear which format in the list to return. + // For now, return `Bgra8UnormSrgb` that we know is supported everywhere. + Ok(TextureFormat::Bgra8UnormSrgb) + } + pub fn device_create_swap_chain( &self, device_id: id::DeviceId, diff --git a/wgpu-core/src/swap_chain.rs b/wgpu-core/src/swap_chain.rs index b82359ebc..76d965dfe 100644 --- a/wgpu-core/src/swap_chain.rs +++ b/wgpu-core/src/swap_chain.rs @@ -121,22 +121,7 @@ pub struct SwapChainOutput { pub view_id: Option, } -#[error("swap chain is invalid")] -#[derive(Clone, Debug, Error)] -pub struct InvalidSwapChain; - impl Global { - pub fn swap_chain_get_preferred_format( - &self, - _swap_chain_id: SwapChainId, - ) -> Result { - span!(_guard, INFO, "SwapChain::get_next_texture"); - //TODO: we can query the formats like done in `device_create_swapchain`, - // but its not clear which format in the list to return. - // For now, return `Bgra8UnormSrgb` that we know is supported everywhere. - Ok(wgt::TextureFormat::Bgra8UnormSrgb) - } - pub fn swap_chain_get_current_texture_view( &self, swap_chain_id: SwapChainId,