From f3d0b2acaee6d9b526b57ad94f4ea9bae83327da Mon Sep 17 00:00:00 2001 From: chyyran Date: Fri, 11 Nov 2022 01:53:02 -0500 Subject: [PATCH] fmt: run clippy --- librashader-reflect/src/back/cross.rs | 4 +-- librashader-reflect/src/back/mod.rs | 10 +++---- librashader-reflect/src/back/targets.rs | 11 ++++---- librashader-reflect/src/reflect/cross.rs | 26 +++++++++---------- librashader-runtime-dx11/src/lib.rs | 2 +- librashader-runtime-gl/src/lib.rs | 21 +++++---------- .../invoked.timestamp | 1 - .../test-lib-librashader-presets | 1 - .../test-lib-librashader-presets.json | 1 - .../invoked.timestamp | 1 - .../lib-librashader-presets | 1 - .../lib-librashader-presets.json | 1 - 12 files changed, 31 insertions(+), 49 deletions(-) delete mode 100644 target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/invoked.timestamp delete mode 100644 target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets delete mode 100644 target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets.json delete mode 100644 target/debug/.fingerprint/librashader-presets-63cd868267815af8/invoked.timestamp delete mode 100644 target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets delete mode 100644 target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets.json diff --git a/librashader-reflect/src/back/cross.rs b/librashader-reflect/src/back/cross.rs index 28c7eac..1017b4c 100644 --- a/librashader-reflect/src/back/cross.rs +++ b/librashader-reflect/src/back/cross.rs @@ -1,9 +1,9 @@ use crate::back::targets::{CompilerBackend, FromCompilation, GLSL, HLSL}; use crate::back::CompileShader; -use crate::error::{ShaderCompileError, ShaderReflectError}; +use crate::error::ShaderReflectError; use crate::front::shaderc::GlslangCompilation; use crate::reflect::cross::{GlslReflect, HlslReflect}; -use crate::reflect::{ReflectShader, ShaderReflection}; +use crate::reflect::ReflectShader; pub type GlVersion = spirv_cross::glsl::Version; impl FromCompilation for GLSL { diff --git a/librashader-reflect/src/back/mod.rs b/librashader-reflect/src/back/mod.rs index ca0c953..7150cbd 100644 --- a/librashader-reflect/src/back/mod.rs +++ b/librashader-reflect/src/back/mod.rs @@ -2,14 +2,12 @@ pub mod cross; pub mod targets; use std::fmt::Debug; -use rustc_hash::FxHashMap; + pub use targets::CompileShader; -use crate::reflect::semantics::{SemanticMap, TextureSemantics}; -use crate::reflect::UniformSemantic; #[derive(Debug)] -pub struct CompiledShader { - pub vertex: Source, - pub fragment: Source, +pub struct ShaderCompilerOutput { + pub vertex: T, + pub fragment: T, pub context: Context, } diff --git a/librashader-reflect/src/back/targets.rs b/librashader-reflect/src/back/targets.rs index 7fc487b..d3168cc 100644 --- a/librashader-reflect/src/back/targets.rs +++ b/librashader-reflect/src/back/targets.rs @@ -1,7 +1,6 @@ -use crate::back::CompiledShader; +use crate::back::ShaderCompilerOutput; use crate::error::{ShaderCompileError, ShaderReflectError}; use crate::reflect::{ReflectSemantics, ReflectShader, ShaderReflection}; -use std::marker::PhantomData; pub trait OutputTarget { type Output; @@ -43,7 +42,7 @@ pub trait CompileShader { fn compile( &mut self, options: Self::Options, - ) -> Result, ShaderCompileError>; + ) -> Result, ShaderCompileError>; } impl ReflectShader for CompilerBackend @@ -69,16 +68,16 @@ where fn compile( &mut self, options: Self::Options, - ) -> Result, ShaderCompileError> { + ) -> Result, ShaderCompileError> { self.backend.compile(options) } } mod test { - use crate::back::targets::{CompilerBackend, FromCompilation, GLSL}; + use crate::back::targets::{FromCompilation, GLSL}; use crate::front::shaderc::GlslangCompilation; pub fn huh(value: GlslangCompilation) { - let x = GLSL::from_compilation(value).unwrap(); + let _x = GLSL::from_compilation(value).unwrap(); } } diff --git a/librashader-reflect/src/reflect/cross.rs b/librashader-reflect/src/reflect/cross.rs index 5a65a50..acb314c 100644 --- a/librashader-reflect/src/reflect/cross.rs +++ b/librashader-reflect/src/reflect/cross.rs @@ -1,22 +1,20 @@ use crate::error::{SemanticsErrorKind, ShaderCompileError, ShaderReflectError}; use crate::front::shaderc::GlslangCompilation; use crate::reflect::semantics::{ - BindingStage, MemberOffset, PushReflection, SemanticMap, ShaderReflection, TextureImage, - TextureSemantics, TextureSizeMeta, TypeInfo, UboReflection, ValidateTypeSemantics, - VariableMeta, VariableSemantics, MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE, + BindingStage, MemberOffset, PushReflection, ShaderReflection, TextureImage, TextureSemantics, + TextureSizeMeta, TypeInfo, UboReflection, ValidateTypeSemantics, VariableMeta, + VariableSemantics, MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE, }; use crate::reflect::{ - ReflectMeta, ReflectSemantics, ReflectShader, TextureSemanticMap, UniformSemantic, - VariableSemanticMap, + ReflectMeta, ReflectSemantics, ReflectShader, TextureSemanticMap, VariableSemanticMap, }; -use rustc_hash::FxHashMap; + use spirv_cross::hlsl::ShaderModel; use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type}; use spirv_cross::{glsl, hlsl, ErrorCode}; use crate::back::targets::{GLSL, HLSL}; -use crate::back::{CompileShader, CompiledShader}; -use std::str::FromStr; +use crate::back::{CompileShader, ShaderCompilerOutput}; pub struct CrossReflect where @@ -99,8 +97,8 @@ where let vertex_module = Module::from_words(value.vertex.as_binary()); let fragment_module = Module::from_words(value.fragment.as_binary()); - let mut vertex = Ast::parse(&vertex_module)?; - let mut fragment = Ast::parse(&fragment_module)?; + let vertex = Ast::parse(&vertex_module)?; + let fragment = Ast::parse(&fragment_module)?; Ok(CrossReflect { vertex, fragment }) } @@ -681,7 +679,7 @@ impl CompileShader for CrossReflect { fn compile( &mut self, version: Self::Options, - ) -> Result>, ShaderCompileError> { + ) -> Result>, ShaderCompileError> { let mut options: glsl::CompilerOptions = Default::default(); options.version = version; options.fragment.default_float_precision = glsl::Precision::High; @@ -796,7 +794,7 @@ impl CompileShader for CrossReflect { texture_fixups.push(binding); } - Ok(CompiledShader { + Ok(ShaderCompilerOutput { vertex: self.vertex.compile()?, fragment: self.fragment.compile()?, context: texture_fixups, @@ -810,14 +808,14 @@ impl CompileShader for CrossReflect { fn compile( &mut self, _options: Self::Options, - ) -> Result, ShaderCompileError> { + ) -> Result, ShaderCompileError> { let mut options = hlsl::CompilerOptions::default(); options.shader_model = ShaderModel::V5_0; self.vertex.set_compiler_options(&options)?; self.fragment.set_compiler_options(&options)?; - Ok(CompiledShader { + Ok(ShaderCompilerOutput { vertex: self.vertex.compile()?, fragment: self.fragment.compile()?, context: (), diff --git a/librashader-runtime-dx11/src/lib.rs b/librashader-runtime-dx11/src/lib.rs index d32e590..44c4260 100644 --- a/librashader-runtime-dx11/src/lib.rs +++ b/librashader-runtime-dx11/src/lib.rs @@ -4,7 +4,7 @@ use std::path::Path; use rustc_hash::FxHashMap; use librashader::ShaderSource; use librashader_presets::ShaderPassConfig; -use librashader_reflect::back::{CompileShader, ShaderCompiler}; +use librashader_reflect::back::{CompileShader}; use librashader_reflect::back::targets::{FromCompilation, HLSL}; use librashader_reflect::front::shaderc::GlslangCompilation; use librashader_reflect::reflect::cross::{CrossReflect}; diff --git a/librashader-runtime-gl/src/lib.rs b/librashader-runtime-gl/src/lib.rs index 902f1e8..386f7d2 100644 --- a/librashader-runtime-gl/src/lib.rs +++ b/librashader-runtime-gl/src/lib.rs @@ -94,27 +94,20 @@ pub fn load(path: impl AsRef) -> Result<(), Box>{ let mut compiled = Vec::new(); for (index, (config, source, reflect)) in passes.iter_mut().enumerate() { - let reflection = reflect.reflect(index as u32, &semantics) - .unwrap(); - - - let glsl = reflect.compile(GlVersion::V4_60) - .unwrap(); - - eprintln!("{:#}", glsl.vertex); - eprintln!("{:#}", glsl.fragment); + let reflection = reflect.reflect(index as u32, &semantics)?; + let glsl = reflect.compile(GlVersion::V4_60)?; // shader_gl3: 1375 - // reflection.meta.texture_meta.get(&SemanticMap { - // semantics: TextureSemantics::PassOutput, - // index: 0 - // }).unwrap().binding; + reflection.meta.texture_meta.get(&SemanticMap { + semantics: TextureSemantics::Source, + index: 0 + }).unwrap().binding; compiled.push(glsl); reflections.push(reflection); - } + // todo: build gl semantics // shader_gl3:188 diff --git a/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/invoked.timestamp b/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/invoked.timestamp deleted file mode 100644 index e00328d..0000000 --- a/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/invoked.timestamp +++ /dev/null @@ -1 +0,0 @@ -This file has an mtime of when this was started. \ No newline at end of file diff --git a/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets b/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets deleted file mode 100644 index ec51516..0000000 --- a/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets +++ /dev/null @@ -1 +0,0 @@ -69df559cddabb887 \ No newline at end of file diff --git a/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets.json b/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets.json deleted file mode 100644 index 38f9c0b..0000000 --- a/target/debug/.fingerprint/librashader-presets-1efad29917dd9fd7/test-lib-librashader-presets.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":13014424268511301986,"features":"[]","target":5709258604770305642,"profile":1021633075455700787,"path":13800204036534426481,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\librashader-presets-1efad29917dd9fd7\\dep-test-lib-librashader-presets"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/target/debug/.fingerprint/librashader-presets-63cd868267815af8/invoked.timestamp b/target/debug/.fingerprint/librashader-presets-63cd868267815af8/invoked.timestamp deleted file mode 100644 index e00328d..0000000 --- a/target/debug/.fingerprint/librashader-presets-63cd868267815af8/invoked.timestamp +++ /dev/null @@ -1 +0,0 @@ -This file has an mtime of when this was started. \ No newline at end of file diff --git a/target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets b/target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets deleted file mode 100644 index fe4c073..0000000 --- a/target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets +++ /dev/null @@ -1 +0,0 @@ -036f6c17d9daa547 \ No newline at end of file diff --git a/target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets.json b/target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets.json deleted file mode 100644 index 77e9bad..0000000 --- a/target/debug/.fingerprint/librashader-presets-63cd868267815af8/lib-librashader-presets.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":13014424268511301986,"features":"[]","target":5709258604770305642,"profile":7309141686862299243,"path":13800204036534426481,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\librashader-presets-63cd868267815af8\\dep-lib-librashader-presets"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file