fmt: run clippy

This commit is contained in:
chyyran 2022-12-01 19:16:13 -05:00
parent 1665770615
commit f92dc5cae6
13 changed files with 18 additions and 20 deletions

View file

@ -32,6 +32,8 @@ librashader provides both a Rust API under the `librashader` crate, and a C API.
The librashader C API is best used by linking statically with `librashader_ld`, which implements a loader that dynamically
loads the librashader (`librashader.so` or `rashader.dll`) implementation in the search path.
Note that the Rust crate requires nightly Rust to build.
## Compatibility
librashader implements the entire RetroArch shader pipeline and is highly compatible with existing shaders,

View file

@ -53,8 +53,8 @@ fn preprocess(
let file_name = file_name.file_name().and_then(|f| f.to_str()).unwrap_or("");
for (line_no, line) in lines.enumerate() {
if line.starts_with("#include ") {
let include_file = line["#include ".len()..].trim().trim_matches('"');
if let Some(include_file) = line.strip_prefix("#include ") {
let include_file = include_file.trim().trim_matches('"');
if include_file.is_empty() {
return Err(PreprocessError::UnexpectedEol(line_no));
}

View file

@ -87,12 +87,12 @@ pub(crate) fn parse_pragma_meta(source: impl AsRef<str>) -> Result<ShaderMeta, P
}
}
if line.starts_with("#pragma format ") {
if let Some(format_string) = line.strip_prefix("#pragma format ") {
if format != ImageFormat::Unknown {
return Err(PreprocessError::DuplicatePragmaError(line.to_string()));
}
let format_string = line["#pragma format ".len()..].trim();
let format_string = format_string.trim();
format = ImageFormat::from_str(format_string)?;
if format == ImageFormat::Unknown {

View file

@ -30,8 +30,8 @@ pub(crate) fn process_stages(source: &str) -> Result<ShaderOutput, PreprocessErr
let mut output = ShaderOutput::default();
for line in source.lines() {
if line.starts_with("#pragma stage ") {
let stage = line["#pragma stage ".len()..].trim();
if let Some(stage) = line.strip_prefix("#pragma stage ") {
let stage = stage.trim();
active_stage = ActiveStage::from_str(stage)?;
continue;
}

View file

@ -1,8 +1,4 @@
use crate::error::ShaderReflectError;
use crate::reflect::semantics::{
Semantic, TextureBinding, TextureSemantics, TextureSizeMeta, UniqueSemantics, VariableMeta,
};
use rustc_hash::FxHashMap;
use semantics::ShaderSemantics;
/// Reflection via spirv-cross.

View file

@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
librashader-common = { path = "../librashader-common", features = ["d3d11"], version = "0.1.0-alpha.1" }
librashader-presets = { path = "../librashader-presets", version = "0.1.0-alpha.1" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.0-alpha.1" }
librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.1" }
librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.1", features = ["standalone"] }
librashader-runtime = { path = "../librashader-runtime", version = "0.1.0-alpha.1" }
thiserror = "1.0.37"
spirv_cross = "0.23.1"

View file

@ -571,7 +571,7 @@ impl FilterChain {
// try to hint the optimizer
assert_eq!(last.len(), 1);
for pass in last {
if let Some(pass) = last.iter_mut().next() {
source.filter = pass.config.filter;
pass.draw(
passes_len - 1,
@ -587,8 +587,6 @@ impl FilterChain {
&source,
viewport.into(),
)?;
// diverge so we don't need to clone output.
break;
}
std::mem::swap(&mut self.output_framebuffers, &mut self.feedback_framebuffers);

View file

@ -16,7 +16,7 @@ impl FilterChainParameters for FilterChain {
}
fn get_parameter(&self, parameter: &str) -> Option<f32> {
self.common.config.parameters.get::<str>(parameter.as_ref()).map(|f| *f)
self.common.config.parameters.get::<str>(parameter.as_ref()).copied()
}
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {

View file

@ -40,7 +40,10 @@ impl Texture {
#[derive(Debug, Clone)]
pub(crate) struct LutTexture {
// The handle to the Texture2D must be kept alive.
#[allow(dead_code)]
pub handle: ID3D11Texture2D,
#[allow(dead_code)]
pub desc: D3D11_TEXTURE2D_DESC,
pub image: Texture,
}

View file

@ -118,8 +118,7 @@ pub fn d3d_compile_shader(source: &[u8], entry: &[u8], version: &[u8]) -> error:
if cfg!(feature = "debug-shader") {
D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION
} else {
D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION
0
},
0,
&mut blob,

View file

@ -15,7 +15,7 @@ description = "RetroArch shaders for all."
librashader-common = { path = "../librashader-common", features = ["opengl"], version = "0.1.0-alpha.1" }
librashader-presets = { path = "../librashader-presets", version = "0.1.0-alpha.1" }
librashader-preprocess = { path = "../librashader-preprocess", version = "0.1.0-alpha.1" }
librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.1" }
librashader-reflect = { path = "../librashader-reflect", version = "0.1.0-alpha.1", features = ["standalone"] }
librashader-runtime = { path = "../librashader-runtime" , version = "0.1.0-alpha.1" }
spirv_cross = "0.23.1"
rustc-hash = "1.1.0"

View file

@ -517,7 +517,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
// try to hint the optimizer
assert_eq!(last.len(), 1);
for pass in last {
if let Some(pass) = last.iter_mut().next() {
source.filter = pass.config.filter;
source.mip_filter = pass.config.filter;

View file

@ -59,7 +59,7 @@ impl <T: GLInterface> FilterChainParameters for FilterChainImpl<T> {
}
fn get_parameter(&self, parameter: &str) -> Option<f32> {
self.common.config.parameters.get::<str>(parameter.as_ref()).map(|f| *f)
self.common.config.parameters.get::<str>(parameter.as_ref()).copied()
}
fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {