Make output format of iced_wgpu configurable
This commit is contained in:
parent
e680fd27e7
commit
be14aca075
11 changed files with 69 additions and 22 deletions
|
|
@ -8,6 +8,7 @@ use raw_window_handle::HasRawWindowHandle;
|
|||
pub struct Backend {
|
||||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
format: wgpu::TextureFormat,
|
||||
}
|
||||
|
||||
impl iced_native::window::Backend for Backend {
|
||||
|
|
@ -37,7 +38,14 @@ impl iced_native::window::Backend for Backend {
|
|||
|
||||
let renderer = Renderer::new(&mut device, settings);
|
||||
|
||||
(Backend { device, queue }, renderer)
|
||||
(
|
||||
Backend {
|
||||
device,
|
||||
queue,
|
||||
format: settings.format,
|
||||
},
|
||||
renderer,
|
||||
)
|
||||
}
|
||||
|
||||
fn create_surface<W: HasRawWindowHandle>(
|
||||
|
|
@ -53,7 +61,7 @@ impl iced_native::window::Backend for Backend {
|
|||
width: u32,
|
||||
height: u32,
|
||||
) -> SwapChain {
|
||||
SwapChain::new(&self.device, surface, width, height)
|
||||
SwapChain::new(&self.device, surface, self.format, width, height)
|
||||
}
|
||||
|
||||
fn draw<T: AsRef<str>>(
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ impl SwapChain {
|
|||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
surface: &wgpu::Surface,
|
||||
format: wgpu::TextureFormat,
|
||||
width: u32,
|
||||
height: u32,
|
||||
) -> SwapChain {
|
||||
SwapChain {
|
||||
raw: new_swap_chain(surface, width, height, device),
|
||||
raw: new_swap_chain(surface, format, width, height, device),
|
||||
viewport: Viewport::new(width, height),
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +39,7 @@ impl SwapChain {
|
|||
|
||||
fn new_swap_chain(
|
||||
surface: &wgpu::Surface,
|
||||
format: wgpu::TextureFormat,
|
||||
width: u32,
|
||||
height: u32,
|
||||
device: &wgpu::Device,
|
||||
|
|
@ -46,7 +48,7 @@ fn new_swap_chain(
|
|||
&surface,
|
||||
&wgpu::SwapChainDescriptor {
|
||||
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||
format,
|
||||
width,
|
||||
height,
|
||||
present_mode: wgpu::PresentMode::Vsync,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue