-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
various changes: rename Wesl::new_spec_compliant=>new; make resolver …
…wrappers generic over inner type; Wesl.mangler is sync; tweaked doc comments; CLI no generics by default
- Loading branch information
Showing
8 changed files
with
88 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::collections::HashMap; | ||
|
||
use itertools::Itertools; | ||
use wgsl_parse::syntax::{ | ||
Function, GlobalDeclaration, Ident, Import, TranslationUnit, TypeExpression, | ||
}; | ||
|
||
use crate::{ | ||
import::{absolute_resource, imported_resources, normalize_resource}, | ||
visit::Visit, | ||
Mangler, Resource, | ||
}; | ||
|
||
fn normalize_ty( | ||
ty: &TypeExpression, | ||
parent_res: &Resource, | ||
imports: &HashMap<Ident, (Resource, Ident)>, | ||
) -> TypeExpression { | ||
let mut ty = ty.clone(); | ||
if let Some(path) = &ty.path { | ||
let res = normalize_resource(path, parent_res, imports); | ||
ty.path = Some(res.path().to_path_buf()); | ||
} else { | ||
ty.path = Some(parent_res.path().to_path_buf()); | ||
} | ||
ty | ||
} | ||
|
||
pub(crate) fn mangle(wesl: &mut TranslationUnit, resource: &Resource, mangler: &impl Mangler) { | ||
let imports = imported_resources(&wesl.imports, resource); | ||
|
||
for decl in &mut wesl.global_declarations { | ||
if let GlobalDeclaration::Function(decl) = decl { | ||
// TODO: type aliases | ||
let sig = decl | ||
.parameters | ||
.iter() | ||
.map(|p| normalize_ty(&p.ty, resource, &imports)).collect_vec() | ||
let res = mangler.mangle_signature(decl.ident.name().as_str(), &sig); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fn main() { | ||
#[cfg(feature = "build-time")] | ||
wesl::Wesl::new_spec_compliant("src/shaders") | ||
wesl::Wesl::new("src/shaders") | ||
.add_package(&wesl_random::random::Mod) | ||
.build_artefact("main", "main"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters