fmt: run clippy
This commit is contained in:
parent
41f721aa6d
commit
f3d0b2acae
|
@ -1,9 +1,9 @@
|
||||||
use crate::back::targets::{CompilerBackend, FromCompilation, GLSL, HLSL};
|
use crate::back::targets::{CompilerBackend, FromCompilation, GLSL, HLSL};
|
||||||
use crate::back::CompileShader;
|
use crate::back::CompileShader;
|
||||||
use crate::error::{ShaderCompileError, ShaderReflectError};
|
use crate::error::ShaderReflectError;
|
||||||
use crate::front::shaderc::GlslangCompilation;
|
use crate::front::shaderc::GlslangCompilation;
|
||||||
use crate::reflect::cross::{GlslReflect, HlslReflect};
|
use crate::reflect::cross::{GlslReflect, HlslReflect};
|
||||||
use crate::reflect::{ReflectShader, ShaderReflection};
|
use crate::reflect::ReflectShader;
|
||||||
|
|
||||||
pub type GlVersion = spirv_cross::glsl::Version;
|
pub type GlVersion = spirv_cross::glsl::Version;
|
||||||
impl FromCompilation<GlslangCompilation> for GLSL {
|
impl FromCompilation<GlslangCompilation> for GLSL {
|
||||||
|
|
|
@ -2,14 +2,12 @@ pub mod cross;
|
||||||
pub mod targets;
|
pub mod targets;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
pub use targets::CompileShader;
|
pub use targets::CompileShader;
|
||||||
use crate::reflect::semantics::{SemanticMap, TextureSemantics};
|
|
||||||
use crate::reflect::UniformSemantic;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CompiledShader<Source, Context = ()> {
|
pub struct ShaderCompilerOutput<T, Context = ()> {
|
||||||
pub vertex: Source,
|
pub vertex: T,
|
||||||
pub fragment: Source,
|
pub fragment: T,
|
||||||
pub context: Context,
|
pub context: Context,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::back::CompiledShader;
|
use crate::back::ShaderCompilerOutput;
|
||||||
use crate::error::{ShaderCompileError, ShaderReflectError};
|
use crate::error::{ShaderCompileError, ShaderReflectError};
|
||||||
use crate::reflect::{ReflectSemantics, ReflectShader, ShaderReflection};
|
use crate::reflect::{ReflectSemantics, ReflectShader, ShaderReflection};
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
pub trait OutputTarget {
|
pub trait OutputTarget {
|
||||||
type Output;
|
type Output;
|
||||||
|
@ -43,7 +42,7 @@ pub trait CompileShader<T: OutputTarget> {
|
||||||
fn compile(
|
fn compile(
|
||||||
&mut self,
|
&mut self,
|
||||||
options: Self::Options,
|
options: Self::Options,
|
||||||
) -> Result<CompiledShader<T::Output, T::AdditionalContext>, ShaderCompileError>;
|
) -> Result<ShaderCompilerOutput<T::Output, T::AdditionalContext>, ShaderCompileError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ReflectShader for CompilerBackend<T>
|
impl<T> ReflectShader for CompilerBackend<T>
|
||||||
|
@ -69,16 +68,16 @@ where
|
||||||
fn compile(
|
fn compile(
|
||||||
&mut self,
|
&mut self,
|
||||||
options: Self::Options,
|
options: Self::Options,
|
||||||
) -> Result<CompiledShader<E::Output, E::AdditionalContext>, ShaderCompileError> {
|
) -> Result<ShaderCompilerOutput<E::Output, E::AdditionalContext>, ShaderCompileError> {
|
||||||
self.backend.compile(options)
|
self.backend.compile(options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test {
|
mod test {
|
||||||
use crate::back::targets::{CompilerBackend, FromCompilation, GLSL};
|
use crate::back::targets::{FromCompilation, GLSL};
|
||||||
use crate::front::shaderc::GlslangCompilation;
|
use crate::front::shaderc::GlslangCompilation;
|
||||||
pub fn huh(value: GlslangCompilation) {
|
pub fn huh(value: GlslangCompilation) {
|
||||||
let x = GLSL::from_compilation(value).unwrap();
|
let _x = GLSL::from_compilation(value).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
use crate::error::{SemanticsErrorKind, ShaderCompileError, ShaderReflectError};
|
use crate::error::{SemanticsErrorKind, ShaderCompileError, ShaderReflectError};
|
||||||
use crate::front::shaderc::GlslangCompilation;
|
use crate::front::shaderc::GlslangCompilation;
|
||||||
use crate::reflect::semantics::{
|
use crate::reflect::semantics::{
|
||||||
BindingStage, MemberOffset, PushReflection, SemanticMap, ShaderReflection, TextureImage,
|
BindingStage, MemberOffset, PushReflection, ShaderReflection, TextureImage, TextureSemantics,
|
||||||
TextureSemantics, TextureSizeMeta, TypeInfo, UboReflection, ValidateTypeSemantics,
|
TextureSizeMeta, TypeInfo, UboReflection, ValidateTypeSemantics, VariableMeta,
|
||||||
VariableMeta, VariableSemantics, MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE,
|
VariableSemantics, MAX_BINDINGS_COUNT, MAX_PUSH_BUFFER_SIZE,
|
||||||
};
|
};
|
||||||
use crate::reflect::{
|
use crate::reflect::{
|
||||||
ReflectMeta, ReflectSemantics, ReflectShader, TextureSemanticMap, UniformSemantic,
|
ReflectMeta, ReflectSemantics, ReflectShader, TextureSemanticMap, VariableSemanticMap,
|
||||||
VariableSemanticMap,
|
|
||||||
};
|
};
|
||||||
use rustc_hash::FxHashMap;
|
|
||||||
use spirv_cross::hlsl::ShaderModel;
|
use spirv_cross::hlsl::ShaderModel;
|
||||||
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
||||||
use spirv_cross::{glsl, hlsl, ErrorCode};
|
use spirv_cross::{glsl, hlsl, ErrorCode};
|
||||||
|
|
||||||
use crate::back::targets::{GLSL, HLSL};
|
use crate::back::targets::{GLSL, HLSL};
|
||||||
use crate::back::{CompileShader, CompiledShader};
|
use crate::back::{CompileShader, ShaderCompilerOutput};
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
pub struct CrossReflect<T>
|
pub struct CrossReflect<T>
|
||||||
where
|
where
|
||||||
|
@ -99,8 +97,8 @@ where
|
||||||
let vertex_module = Module::from_words(value.vertex.as_binary());
|
let vertex_module = Module::from_words(value.vertex.as_binary());
|
||||||
let fragment_module = Module::from_words(value.fragment.as_binary());
|
let fragment_module = Module::from_words(value.fragment.as_binary());
|
||||||
|
|
||||||
let mut vertex = Ast::parse(&vertex_module)?;
|
let vertex = Ast::parse(&vertex_module)?;
|
||||||
let mut fragment = Ast::parse(&fragment_module)?;
|
let fragment = Ast::parse(&fragment_module)?;
|
||||||
|
|
||||||
Ok(CrossReflect { vertex, fragment })
|
Ok(CrossReflect { vertex, fragment })
|
||||||
}
|
}
|
||||||
|
@ -681,7 +679,7 @@ impl CompileShader<GLSL> for CrossReflect<glsl::Target> {
|
||||||
fn compile(
|
fn compile(
|
||||||
&mut self,
|
&mut self,
|
||||||
version: Self::Options,
|
version: Self::Options,
|
||||||
) -> Result<CompiledShader<String, Vec<u32>>, ShaderCompileError> {
|
) -> Result<ShaderCompilerOutput<String, Vec<u32>>, ShaderCompileError> {
|
||||||
let mut options: glsl::CompilerOptions = Default::default();
|
let mut options: glsl::CompilerOptions = Default::default();
|
||||||
options.version = version;
|
options.version = version;
|
||||||
options.fragment.default_float_precision = glsl::Precision::High;
|
options.fragment.default_float_precision = glsl::Precision::High;
|
||||||
|
@ -796,7 +794,7 @@ impl CompileShader<GLSL> for CrossReflect<glsl::Target> {
|
||||||
texture_fixups.push(binding);
|
texture_fixups.push(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(CompiledShader {
|
Ok(ShaderCompilerOutput {
|
||||||
vertex: self.vertex.compile()?,
|
vertex: self.vertex.compile()?,
|
||||||
fragment: self.fragment.compile()?,
|
fragment: self.fragment.compile()?,
|
||||||
context: texture_fixups,
|
context: texture_fixups,
|
||||||
|
@ -810,14 +808,14 @@ impl CompileShader<HLSL> for CrossReflect<hlsl::Target> {
|
||||||
fn compile(
|
fn compile(
|
||||||
&mut self,
|
&mut self,
|
||||||
_options: Self::Options,
|
_options: Self::Options,
|
||||||
) -> Result<CompiledShader<String>, ShaderCompileError> {
|
) -> Result<ShaderCompilerOutput<String>, ShaderCompileError> {
|
||||||
let mut options = hlsl::CompilerOptions::default();
|
let mut options = hlsl::CompilerOptions::default();
|
||||||
options.shader_model = ShaderModel::V5_0;
|
options.shader_model = ShaderModel::V5_0;
|
||||||
|
|
||||||
self.vertex.set_compiler_options(&options)?;
|
self.vertex.set_compiler_options(&options)?;
|
||||||
self.fragment.set_compiler_options(&options)?;
|
self.fragment.set_compiler_options(&options)?;
|
||||||
|
|
||||||
Ok(CompiledShader {
|
Ok(ShaderCompilerOutput {
|
||||||
vertex: self.vertex.compile()?,
|
vertex: self.vertex.compile()?,
|
||||||
fragment: self.fragment.compile()?,
|
fragment: self.fragment.compile()?,
|
||||||
context: (),
|
context: (),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use librashader::ShaderSource;
|
use librashader::ShaderSource;
|
||||||
use librashader_presets::ShaderPassConfig;
|
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::back::targets::{FromCompilation, HLSL};
|
||||||
use librashader_reflect::front::shaderc::GlslangCompilation;
|
use librashader_reflect::front::shaderc::GlslangCompilation;
|
||||||
use librashader_reflect::reflect::cross::{CrossReflect};
|
use librashader_reflect::reflect::cross::{CrossReflect};
|
||||||
|
|
|
@ -94,27 +94,20 @@ pub fn load(path: impl AsRef<Path>) -> Result<(), Box<dyn Error>>{
|
||||||
let mut compiled = Vec::new();
|
let mut compiled = Vec::new();
|
||||||
|
|
||||||
for (index, (config, source, reflect)) in passes.iter_mut().enumerate() {
|
for (index, (config, source, reflect)) in passes.iter_mut().enumerate() {
|
||||||
let reflection = reflect.reflect(index as u32, &semantics)
|
let reflection = reflect.reflect(index as u32, &semantics)?;
|
||||||
.unwrap();
|
let glsl = reflect.compile(GlVersion::V4_60)?;
|
||||||
|
|
||||||
|
|
||||||
let glsl = reflect.compile(GlVersion::V4_60)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
eprintln!("{:#}", glsl.vertex);
|
|
||||||
eprintln!("{:#}", glsl.fragment);
|
|
||||||
|
|
||||||
// shader_gl3: 1375
|
// shader_gl3: 1375
|
||||||
// reflection.meta.texture_meta.get(&SemanticMap {
|
reflection.meta.texture_meta.get(&SemanticMap {
|
||||||
// semantics: TextureSemantics::PassOutput,
|
semantics: TextureSemantics::Source,
|
||||||
// index: 0
|
index: 0
|
||||||
// }).unwrap().binding;
|
}).unwrap().binding;
|
||||||
|
|
||||||
compiled.push(glsl);
|
compiled.push(glsl);
|
||||||
reflections.push(reflection);
|
reflections.push(reflection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// todo: build gl semantics
|
// todo: build gl semantics
|
||||||
|
|
||||||
// shader_gl3:188
|
// shader_gl3:188
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
This file has an mtime of when this was started.
|
|
|
@ -1 +0,0 @@
|
||||||
69df559cddabb887
|
|
|
@ -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}
|
|
|
@ -1 +0,0 @@
|
||||||
This file has an mtime of when this was started.
|
|
|
@ -1 +0,0 @@
|
||||||
036f6c17d9daa547
|
|
|
@ -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}
|
|
Loading…
Reference in a new issue