Get surface capabilities only once in iced_wgpu
This commit is contained in:
parent
d5453c62e9
commit
b677345ac1
2 changed files with 8 additions and 8 deletions
|
|
@ -92,17 +92,16 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let needed_limits = wgpu::Limits::default();
|
let needed_limits = wgpu::Limits::default();
|
||||||
|
|
||||||
|
let capabilities = surface.get_capabilities(&adapter);
|
||||||
|
|
||||||
(
|
(
|
||||||
surface
|
capabilities
|
||||||
.get_capabilities(&adapter)
|
|
||||||
.formats
|
.formats
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|format| format.describe().srgb)
|
.filter(|format| format.describe().srgb)
|
||||||
.copied()
|
.copied()
|
||||||
.next()
|
.next()
|
||||||
.or_else(|| {
|
.or_else(|| capabilities.formats.first().copied())
|
||||||
surface.get_capabilities(&adapter).formats.first().copied()
|
|
||||||
})
|
|
||||||
.expect("Get preferred format"),
|
.expect("Get preferred format"),
|
||||||
adapter
|
adapter
|
||||||
.request_device(
|
.request_device(
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,9 @@ impl<Theme> Compositor<Theme> {
|
||||||
log::info!("Selected: {:#?}", adapter.get_info());
|
log::info!("Selected: {:#?}", adapter.get_info());
|
||||||
|
|
||||||
let format = compatible_surface.as_ref().and_then(|surface| {
|
let format = compatible_surface.as_ref().and_then(|surface| {
|
||||||
surface
|
let capabilities = surface.get_capabilities(&adapter);
|
||||||
.get_capabilities(&adapter)
|
|
||||||
|
capabilities
|
||||||
.formats
|
.formats
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|format| format.describe().srgb)
|
.filter(|format| format.describe().srgb)
|
||||||
|
|
@ -76,7 +77,7 @@ impl<Theme> Compositor<Theme> {
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
log::warn!("No sRGB format found!");
|
log::warn!("No sRGB format found!");
|
||||||
|
|
||||||
surface.get_capabilities(&adapter).formats.first().copied()
|
capabilities.formats.first().copied()
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue