fmt: run clippy
This commit is contained in:
parent
5ec604e536
commit
d6f47f83ca
|
@ -23,7 +23,7 @@ mod test {
|
|||
use naga::back::spv::{Capability, WriterFlags};
|
||||
use naga::front::glsl::{Options, Parser};
|
||||
use naga::front::spv::Options as SpvOptions;
|
||||
use naga::valid::{Capabilities, ModuleInfo, ValidationFlags};
|
||||
use naga::valid::{Capabilities, ValidationFlags};
|
||||
use naga::{FastHashSet, ShaderStage};
|
||||
use rspirv::binary::Disassemble;
|
||||
#[test]
|
||||
|
@ -36,7 +36,7 @@ mod test {
|
|||
let fragment_source = result.fragment;
|
||||
let mut parser = Parser::default();
|
||||
println!("{fragment_source}");
|
||||
let fragment = parser
|
||||
let _fragment = parser
|
||||
.parse(&Options::from(ShaderStage::Fragment), &fragment_source)
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ mod test {
|
|||
)
|
||||
.unwrap();
|
||||
let spirv = compile_spirv(&result).unwrap();
|
||||
eprintln!("{:?}", spirv)
|
||||
eprintln!("{spirv:?}")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -132,8 +132,8 @@ mod test {
|
|||
let mut ast = spirv_cross::spirv::Ast::<spirv_cross::glsl::Target>::parse(&loaded).unwrap();
|
||||
println!("{:#}", ast.compile().unwrap());
|
||||
println!("--- naga glsl---");
|
||||
println!("{:#}", glsl_out);
|
||||
println!("{glsl_out:#}");
|
||||
println!("--- naga wgsl---");
|
||||
println!("{:#}", wgsl)
|
||||
println!("{wgsl:#}")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::error::ShaderCompileError;
|
||||
use librashader::ShaderSource;
|
||||
use shaderc::{CompilationArtifact, CompileOptions, GlslProfile, Limit, ShaderKind};
|
||||
use shaderc::{CompilationArtifact, CompileOptions, Limit, ShaderKind};
|
||||
|
||||
pub struct GlslangCompilation {
|
||||
pub(crate) vertex: CompilationArtifact,
|
||||
|
@ -127,6 +127,6 @@ mod test {
|
|||
#[test]
|
||||
pub fn compile_shader() {
|
||||
let result = librashader_preprocess::load_shader_source("../test/basic.slang").unwrap();
|
||||
let spirv = compile_spirv(&result).unwrap();
|
||||
let _spirv = compile_spirv(&result).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use rustc_hash::FxHashMap;
|
|||
use spirv_cross::hlsl::{CompilerOptions, ShaderModel};
|
||||
use spirv_cross::spirv::{Ast, Decoration, Module, Resource, ShaderResources, Type};
|
||||
use spirv_cross::{hlsl, ErrorCode};
|
||||
use std::fmt::Debug;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
pub struct CrossReflect<T>
|
||||
|
@ -153,7 +153,7 @@ where
|
|||
));
|
||||
}
|
||||
|
||||
let mut vert_mask = vertex_res.stage_inputs.iter().try_fold(0, |mask, input| {
|
||||
let vert_mask = vertex_res.stage_inputs.iter().try_fold(0, |mask, input| {
|
||||
Ok::<u32, ErrorCode>(
|
||||
mask | 1 << self.vertex.get_decoration(input.id, Decoration::Location)?,
|
||||
)
|
||||
|
@ -219,10 +219,10 @@ enum SemanticErrorBlame {
|
|||
|
||||
impl SemanticErrorBlame {
|
||||
fn error(self, kind: SemanticsErrorKind) -> ShaderReflectError {
|
||||
return match self {
|
||||
match self {
|
||||
SemanticErrorBlame::Vertex => ShaderReflectError::VertexSemanticError(kind),
|
||||
SemanticErrorBlame::Fragment => ShaderReflectError::FragmentSemanticError(kind),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ impl TextureSemanticMap<UniformSemantic> for FxHashMap<String, UniformSemantic>
|
|||
});
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
Some(UniformSemantic::Variable(_)) => None,
|
||||
Some(UniformSemantic::Texture(texture)) => Some(*texture),
|
||||
|
@ -321,7 +321,7 @@ impl TextureSemanticMap<UniformSemantic> for FxHashMap<String, SemanticMap<Textu
|
|||
});
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
Some(texture) => Some(*texture),
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ where
|
|||
blame: SemanticErrorBlame,
|
||||
) -> Result<(), ShaderReflectError> {
|
||||
let ranges = ast.get_active_buffer_ranges(resource.id)?;
|
||||
eprintln!("{:?}", ranges);
|
||||
eprintln!("{ranges:?}");
|
||||
for range in ranges {
|
||||
let name = ast.get_member_name(resource.base_type_id, range.index)?;
|
||||
let ubo_type = ast.get_type(resource.base_type_id)?;
|
||||
|
@ -483,7 +483,7 @@ where
|
|||
});
|
||||
} else {
|
||||
meta.texture_size_meta.insert(
|
||||
texture.clone(),
|
||||
texture,
|
||||
TextureSizeMeta {
|
||||
offset,
|
||||
// todo: fix this.
|
||||
|
@ -661,13 +661,13 @@ where
|
|||
let fragment_res = self.fragment.get_shader_resources()?;
|
||||
self.validate(&vertex_res, &fragment_res)?;
|
||||
|
||||
let vertex_ubo = vertex_res.uniform_buffers.first().map(|f| f);
|
||||
let fragment_ubo = fragment_res.uniform_buffers.first().map(|f| f);
|
||||
let vertex_ubo = vertex_res.uniform_buffers.first();
|
||||
let fragment_ubo = fragment_res.uniform_buffers.first();
|
||||
|
||||
let ubo = self.reflect_ubos(vertex_ubo, fragment_ubo)?;
|
||||
|
||||
let vertex_push = vertex_res.push_constant_buffers.first().map(|f| f);
|
||||
let fragment_push = fragment_res.push_constant_buffers.first().map(|f| f);
|
||||
let vertex_push = vertex_res.push_constant_buffers.first();
|
||||
let fragment_push = fragment_res.push_constant_buffers.first();
|
||||
|
||||
let push_constant = self.reflect_push_constant_buffer(vertex_push, fragment_push)?;
|
||||
|
||||
|
@ -728,7 +728,7 @@ where
|
|||
if ubo_bindings & (1 << texture_data.binding) != 0 {
|
||||
return Err(ShaderReflectError::BindingInUse(texture_data.binding));
|
||||
}
|
||||
ubo_bindings |= (1 << texture_data.binding);
|
||||
ubo_bindings |= 1 << texture_data.binding;
|
||||
|
||||
self.reflect_texture_metas(texture_data, options, &mut meta)?;
|
||||
}
|
||||
|
@ -747,8 +747,8 @@ where
|
|||
mod test {
|
||||
use crate::reflect::cross::CrossReflect;
|
||||
use crate::reflect::{ReflectOptions, ReflectShader};
|
||||
use rspirv::binary::Disassemble;
|
||||
use spirv_cross::{glsl, hlsl};
|
||||
|
||||
use spirv_cross::{hlsl};
|
||||
|
||||
#[test]
|
||||
pub fn test_into() {
|
||||
|
@ -763,7 +763,7 @@ mod test {
|
|||
non_uniform_semantics: Default::default(),
|
||||
})
|
||||
.unwrap();
|
||||
eprintln!("{:#?}", huh);
|
||||
eprintln!("{huh:#?}");
|
||||
eprintln!("{:#}", reflect.fragment.compile().unwrap())
|
||||
// let mut loader = rspirv::dr::Loader::new();
|
||||
// rspirv::binary::parse_words(spirv.fragment.as_binary(), &mut loader).unwrap();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::error::{SemanticsErrorKind, ShaderReflectError};
|
||||
use crate::error::{ShaderReflectError};
|
||||
use crate::reflect::semantics::{
|
||||
SemanticMap, ShaderReflection, TextureImage, TextureSemantics, TextureSizeMeta, VariableMeta,
|
||||
VariableSemantics,
|
||||
|
|
|
@ -38,13 +38,13 @@ impl TryFrom<GlslangCompilation> for NagaReflect {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::reflect::naga::NagaReflect;
|
||||
use naga::front::spv::Options;
|
||||
use rspirv::binary::Disassemble;
|
||||
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
pub fn test_into() {
|
||||
let result = librashader_preprocess::load_shader_source("../test/basic.slang").unwrap();
|
||||
let spirv = crate::front::shaderc::compile_spirv(&result).unwrap();
|
||||
let _spirv = crate::front::shaderc::compile_spirv(&result).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ mod test {
|
|||
pub fn test_into() {
|
||||
let result = librashader_preprocess::load_shader_source("../test/basic.slang").unwrap();
|
||||
let spirv = crate::front::shaderc::compile_spirv(&result).unwrap();
|
||||
let mut reflect = RspirvReflect::try_from(spirv).unwrap();
|
||||
let reflect = RspirvReflect::try_from(spirv).unwrap();
|
||||
// let pcr = reflect.fragment.get_push_constant_range().unwrap()
|
||||
// .unwrap();
|
||||
println!("{:?}", reflect.fragment.get_descriptor_sets());
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::error::ShaderReflectError;
|
||||
|
||||
use crate::reflect::ReflectMeta;
|
||||
use bitflags::bitflags;
|
||||
|
||||
|
@ -143,3 +143,4 @@ pub struct ShaderReflection {
|
|||
pub push_constant: Option<PushReflection>,
|
||||
pub meta: ReflectMeta,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue