Update wgpu to 0.15

This commit is contained in:
Elham Aryanpur 2023-04-12 23:38:21 +03:00 committed by Héctor Ramón Jiménez
parent adb70d232a
commit d5453c62e9
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 50 additions and 20 deletions

View file

@ -28,8 +28,8 @@ spirv = ["wgpu/spirv"]
webgl = ["wgpu/webgl"]
[dependencies]
wgpu = "0.14"
wgpu_glyph = "0.18"
wgpu = "0.15"
wgpu_glyph = "0.19"
glyph_brush = "0.7"
raw-window-handle = "0.5"
log = "0.4"

View file

@ -39,6 +39,7 @@ impl Atlas {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
view_formats: &[],
usage: wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::COPY_SRC
| wgpu::TextureUsages::TEXTURE_BINDING,
@ -247,6 +248,7 @@ impl Atlas {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
view_formats: &[],
usage: wgpu::TextureUsages::COPY_DST
| wgpu::TextureUsages::COPY_SRC
| wgpu::TextureUsages::TEXTURE_BINDING,

View file

@ -222,6 +222,7 @@ impl Targets {
sample_count,
dimension: wgpu::TextureDimension::D2,
format,
view_formats: &[],
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
});
@ -232,6 +233,7 @@ impl Targets {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format,
view_formats: &[],
usage: wgpu::TextureUsages::RENDER_ATTACHMENT
| wgpu::TextureUsages::TEXTURE_BINDING,
});

View file

@ -31,7 +31,10 @@ impl<Theme> Compositor<Theme> {
settings: Settings,
compatible_window: Option<&W>,
) -> Option<Self> {
let instance = wgpu::Instance::new(settings.internal_backend);
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: settings.internal_backend,
..Default::default()
});
log::info!("{:#?}", settings);
@ -46,7 +49,7 @@ impl<Theme> Compositor<Theme> {
#[allow(unsafe_code)]
let compatible_surface = compatible_window
.map(|window| unsafe { instance.create_surface(window) });
.and_then(|window| unsafe { instance.create_surface(window).ok() });
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
@ -63,7 +66,18 @@ impl<Theme> Compositor<Theme> {
log::info!("Selected: {:#?}", adapter.get_info());
let format = compatible_surface.as_ref().and_then(|surface| {
surface.get_supported_formats(&adapter).first().copied()
surface
.get_capabilities(&adapter)
.formats
.iter()
.filter(|format| format.describe().srgb)
.copied()
.next()
.or_else(|| {
log::warn!("No sRGB format found!");
surface.get_capabilities(&adapter).formats.first().copied()
})
})?;
log::info!("Selected format: {:?}", format);
@ -144,7 +158,9 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
) -> wgpu::Surface {
#[allow(unsafe_code)]
unsafe {
self.instance.create_surface(window)
self.instance
.create_surface(window)
.expect("Create surface")
}
}
@ -163,6 +179,7 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
width,
height,
alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
},
);
}