Skip to content

Commit

Permalink
cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
attackgoat committed Dec 29, 2023
1 parent aafa1f0 commit 884cc36
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion contrib/screen-13-hot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn compile_shader(
context: path
.parent()
.map(|path| path.to_path_buf())
.unwrap_or_else(PathBuf::new),
.unwrap_or_default(),
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/shader-toy/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn read_shader_source(path: impl AsRef<Path>) -> String {
context: path
.parent()
.map(|path| path.to_path_buf())
.unwrap_or_else(PathBuf::new),
.unwrap_or_default(),
})
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/driver/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}
}
Expand Down
48 changes: 24 additions & 24 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,33 +507,33 @@ impl EventLoopBuilder {

/// Helper function to automatically select the best UNORM format.
pub fn linear_surface_format(formats: &[vk::SurfaceFormatKHR]) -> Option<vk::SurfaceFormatKHR> {
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<vk::SurfaceFormatKHR> {
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()
}
}
4 changes: 2 additions & 2 deletions src/graph/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 884cc36

Please sign in to comment.