diff --git a/contrib/screen-13-hot/src/lib.rs b/contrib/screen-13-hot/src/lib.rs index 8cd13ab..aac85c1 100644 --- a/contrib/screen-13-hot/src/lib.rs +++ b/contrib/screen-13-hot/src/lib.rs @@ -81,7 +81,7 @@ fn compile_shader( context: path .parent() .map(|path| path.to_path_buf()) - .unwrap_or_else(PathBuf::new), + .unwrap_or_default(), }) } } diff --git a/examples/shader-toy/build.rs b/examples/shader-toy/build.rs index 676774c..c1a32b5 100644 --- a/examples/shader-toy/build.rs +++ b/examples/shader-toy/build.rs @@ -178,7 +178,7 @@ fn read_shader_source(path: impl AsRef) -> String { context: path .parent() .map(|path| path.to_path_buf()) - .unwrap_or_else(PathBuf::new), + .unwrap_or_default(), }) } } diff --git a/src/driver/shader.rs b/src/driver/shader.rs index cdd25d5..42d26a3 100644 --- a/src/driver/shader.rs +++ b/src/driver/shader.rs @@ -940,13 +940,7 @@ impl Shader { for spec in &spec_info.map_entries { config.specialize( spec.constant_id, - spec_info.data[spec.offset as usize..spec.offset as usize + spec.size] - .try_into() - .map_err(|err| { - error!("Unable to specialize spirv: {err}"); - - DriverError::InvalidData - })?, + spec_info.data[spec.offset as usize..spec.offset as usize + spec.size].into(), ); } } diff --git a/src/event_loop.rs b/src/event_loop.rs index 554170f..db31522 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -507,33 +507,33 @@ impl EventLoopBuilder { /// Helper function to automatically select the best UNORM format. pub fn linear_surface_format(formats: &[vk::SurfaceFormatKHR]) -> Option { - for swapchain in formats.iter().copied() { - if matches!( - swapchain.format, - vk::Format::R8G8B8A8_UNORM | vk::Format::B8G8R8A8_UNORM - ) { - return Some(swapchain); - } - } - - None + formats + .iter() + .find(|&&vk::SurfaceFormatKHR { format, .. }| { + matches!( + format, + vk::Format::R8G8B8A8_UNORM | vk::Format::B8G8R8A8_UNORM + ) + }) + .copied() } /// Helper function to automatically select the best sRGB format. pub fn srgb_surface_format(formats: &[vk::SurfaceFormatKHR]) -> Option { - for swapchain in formats.iter().copied() { - if swapchain.color_space != vk::ColorSpaceKHR::SRGB_NONLINEAR { - continue; - } - - if matches!( - swapchain.format, - vk::Format::R8G8B8A8_SRGB | vk::Format::B8G8R8A8_SRGB - ) { - return Some(swapchain); - } - } - - None + formats + .iter() + .find( + |&&vk::SurfaceFormatKHR { + color_space, + format, + }| { + matches!(color_space, vk::ColorSpaceKHR::SRGB_NONLINEAR) + && matches!( + format, + vk::Format::R8G8B8A8_SRGB | vk::Format::B8G8R8A8_SRGB + ) + }, + ) + .copied() } } diff --git a/src/graph/resolver.rs b/src/graph/resolver.rs index 9f484e6..76242ec 100644 --- a/src/graph/resolver.rs +++ b/src/graph/resolver.rs @@ -73,13 +73,13 @@ impl Resolver { fn allow_merge_passes(lhs: &Pass, rhs: &Pass) -> bool { let lhs_pipeline = lhs .execs - .get(0) + .first() .map(|exec| exec.pipeline.as_ref()) .filter(|pipeline| matches!(pipeline, Some(ExecutionPipeline::Graphic(_)))) .flatten(); let rhs_pipeline = rhs .execs - .get(0) + .first() .map(|exec| exec.pipeline.as_ref()) .filter(|pipeline| matches!(pipeline, Some(ExecutionPipeline::Graphic(_)))) .flatten();