Implement GraphicsInformation for iced_wgpu

This commit is contained in:
Richard 2022-03-17 00:34:42 -03:00
parent e23e4b8db2
commit 83fec2f5f6
2 changed files with 14 additions and 0 deletions

View file

@ -38,6 +38,9 @@ pub trait Compositor: Sized {
height: u32,
);
/// Returns [`GraphicsInformation`] used by this [`Compositor`].
fn get_information(&self) -> GraphicsInformation;
/// Presents the [`Renderer`] primitives to the next frame of the given [`Surface`].
///
/// [`SwapChain`]: Self::SwapChain

View file

@ -9,6 +9,7 @@ use raw_window_handle::HasRawWindowHandle;
pub struct Compositor {
settings: Settings,
instance: wgpu::Instance,
adapter: wgpu::Adapter,
device: wgpu::Device,
queue: wgpu::Queue,
staging_belt: wgpu::util::StagingBelt,
@ -93,6 +94,7 @@ impl Compositor {
Some(Compositor {
instance,
settings,
adapter,
device,
queue,
staging_belt,
@ -155,6 +157,15 @@ impl iced_graphics::window::Compositor for Compositor {
);
}
fn get_information(&self) -> iced_graphics::window::GraphicsInformation {
let information = self.adapter.get_info();
iced_graphics::window::GraphicsInformation {
adapter: information.name,
backend: format!("{:?}", information.backend),
}
}
fn present<T: AsRef<str>>(
&mut self,
renderer: &mut Self::Renderer,