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 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. loads the librashader (`librashader.so` or `rashader.dll`) implementation in the search path.
Note that the Rust crate requires nightly Rust to build.
## Compatibility ## Compatibility
librashader implements the entire RetroArch shader pipeline and is highly compatible with existing shaders, 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(""); let file_name = file_name.file_name().and_then(|f| f.to_str()).unwrap_or("");
for (line_no, line) in lines.enumerate() { for (line_no, line) in lines.enumerate() {
if line.starts_with("#include ") { if let Some(include_file) = line.strip_prefix("#include ") {
let include_file = line["#include ".len()..].trim().trim_matches('"'); let include_file = include_file.trim().trim_matches('"');
if include_file.is_empty() { if include_file.is_empty() {
return Err(PreprocessError::UnexpectedEol(line_no)); 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 { if format != ImageFormat::Unknown {
return Err(PreprocessError::DuplicatePragmaError(line.to_string())); 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)?; format = ImageFormat::from_str(format_string)?;
if format == ImageFormat::Unknown { 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(); let mut output = ShaderOutput::default();
for line in source.lines() { for line in source.lines() {
if line.starts_with("#pragma stage ") { if let Some(stage) = line.strip_prefix("#pragma stage ") {
let stage = line["#pragma stage ".len()..].trim(); let stage = stage.trim();
active_stage = ActiveStage::from_str(stage)?; active_stage = ActiveStage::from_str(stage)?;
continue; continue;
} }

View file

@ -1,8 +1,4 @@
use crate::error::ShaderReflectError; use crate::error::ShaderReflectError;
use crate::reflect::semantics::{
Semantic, TextureBinding, TextureSemantics, TextureSizeMeta, UniqueSemantics, VariableMeta,
};
use rustc_hash::FxHashMap;
use semantics::ShaderSemantics; use semantics::ShaderSemantics;
/// Reflection via spirv-cross. /// 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-common = { path = "../librashader-common", features = ["d3d11"], version = "0.1.0-alpha.1" }
librashader-presets = { path = "../librashader-presets", 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-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" } librashader-runtime = { path = "../librashader-runtime", version = "0.1.0-alpha.1" }
thiserror = "1.0.37" thiserror = "1.0.37"
spirv_cross = "0.23.1" spirv_cross = "0.23.1"

View file

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

View file

@ -40,7 +40,10 @@ impl Texture {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub(crate) struct LutTexture { pub(crate) struct LutTexture {
// The handle to the Texture2D must be kept alive.
#[allow(dead_code)]
pub handle: ID3D11Texture2D, pub handle: ID3D11Texture2D,
#[allow(dead_code)]
pub desc: D3D11_TEXTURE2D_DESC, pub desc: D3D11_TEXTURE2D_DESC,
pub image: Texture, 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") { if cfg!(feature = "debug-shader") {
D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION
} else { } else {
D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION 0
}, },
0, 0,
&mut blob, &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-common = { path = "../librashader-common", features = ["opengl"], version = "0.1.0-alpha.1" }
librashader-presets = { path = "../librashader-presets", 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-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" } librashader-runtime = { path = "../librashader-runtime" , version = "0.1.0-alpha.1" }
spirv_cross = "0.23.1" spirv_cross = "0.23.1"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"

View file

@ -517,7 +517,7 @@ impl<T: GLInterface> FilterChainImpl<T> {
// try to hint the optimizer // try to hint the optimizer
assert_eq!(last.len(), 1); assert_eq!(last.len(), 1);
for pass in last { if let Some(pass) = last.iter_mut().next() {
source.filter = pass.config.filter; source.filter = pass.config.filter;
source.mip_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> { 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> { fn set_parameter(&mut self, parameter: &str, new_value: f32) -> Option<f32> {