diff --git a/.gitignore b/.gitignore index f5de731..23e50b0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ Cargo.lock bin/ wasm-pack.log +.idea \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 6f50aa1..9b1db3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,6 @@ wasm-bindgen = "0.2.84" console_error_panic_hook = { version = "0.1.7", optional = true } naga_oil = "0.16.0" naga = { version = "23.1.0", features = ["wgsl-out"] } -serde = { version = "1.0", features = ["derive"] } -serde-wasm-bindgen = "0.5" [dev-dependencies] wasm-bindgen-test = "0.3.34" diff --git a/pkg/package.json b/pkg/package.json index 0fb2c8a..2f50ee9 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -8,7 +8,7 @@ "type": "git", "url": "https://github.com/re-ovo/naga-oil-wasm" }, - "version": "0.1.0", + "version": "0.1.1", "files": [ "naga_oil_wasm_bg.wasm", "naga_oil_wasm.js", diff --git a/src/lib.rs b/src/lib.rs index bbd6309..d469b64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,19 +1,15 @@ mod shader_def; mod utils; -use std::{collections::HashMap, iter::FromIterator}; use naga::{ back::wgsl, - valid::{Capabilities, ModuleInfo, ValidationFlags, Validator}, + valid::{Capabilities, ValidationFlags, Validator}, }; use naga_oil::compose::{ ComposableModuleDescriptor, Composer, NagaModuleDescriptor, - ShaderDefValue as InternalShaderDefValue, }; -use shader_def::ShaderDefValue; use wasm_bindgen::prelude::*; -use serde::{Deserialize, Serialize}; #[wasm_bindgen] pub struct ShaderLibrary { @@ -47,8 +43,11 @@ impl ShaderLibrary { self.composer.remove_composable_module(name) } - pub fn process(&mut self, source: &str, shader_defs: shader_def::ShaderDefs) -> Result { - + pub fn process( + &mut self, + source: &str, + shader_defs: shader_def::ShaderDefs, + ) -> Result { // Create naga module let module = self .composer diff --git a/src/main.rs b/src/main.rs index fea88e8..047a81e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,7 @@ -use std::collections::HashMap; use naga::{ back::wgsl, - valid::{Capabilities, ModuleInfo, ValidationFlags, Validator}, + valid::{Capabilities, ValidationFlags, Validator}, }; use naga_oil::compose::{ ComposableModuleDescriptor, Composer, NagaModuleDescriptor, ShaderDefValue, @@ -31,10 +30,7 @@ fn process(composer: &mut Composer) { let module = composer .make_naga_module(NagaModuleDescriptor { source: include_str!("../shaders/pbr.wgsl"), - shader_defs: [ - ("MAX_LIGHTS".to_string(), ShaderDefValue::Int(222)), - ] - .into(), + shader_defs: [("MAX_LIGHTS".to_string(), ShaderDefValue::Int(222))].into(), ..Default::default() }) .unwrap(); diff --git a/src/shader_def.rs b/src/shader_def.rs index 8d85d8f..968700f 100644 --- a/src/shader_def.rs +++ b/src/shader_def.rs @@ -63,6 +63,9 @@ impl ShaderDefs { impl ShaderDefs { pub fn into_hash_map(self) -> HashMap { - self.shader_defs.into_iter().map(|(k, v)| (k, v.internal)).collect() + self.shader_defs + .into_iter() + .map(|(k, v)| (k, v.internal)) + .collect() } }