Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1,262 @@
use std::{borrow::Cow, str::Lines};
use regex::Regex;
// outside of blocks and quotes, change state on //, /* or "
static RE_NONE: once_cell::sync::Lazy<Regex> =
once_cell::sync::Lazy::new(|| Regex::new(r#"(//|/\*|\")"#).unwrap());
// in blocks, change on /* and */
static RE_BLOCK: once_cell::sync::Lazy<Regex> =
once_cell::sync::Lazy::new(|| Regex::new(r"(/\*|\*/)").unwrap());
// in quotes, change only on "
static RE_QUOTE: once_cell::sync::Lazy<Regex> =
once_cell::sync::Lazy::new(|| Regex::new(r#"\""#).unwrap());
#[derive(PartialEq, Eq)]
enum CommentState {
None,
Block(usize),
Quote,
}
pub struct CommentReplaceIter<'a> {
lines: &'a mut Lines<'a>,
state: CommentState,
}
impl<'a> Iterator for CommentReplaceIter<'a> {
type Item = Cow<'a, str>;
fn next(&mut self) -> Option<Self::Item> {
let line_in = self.lines.next()?;
// fast path
if self.state == CommentState::None && !RE_NONE.is_match(line_in) {
return Some(Cow::Borrowed(line_in));
}
let mut output = String::new();
let mut section_start = 0;
loop {
let marker = match self.state {
CommentState::None => &RE_NONE,
CommentState::Block(_) => &RE_BLOCK,
CommentState::Quote => &RE_QUOTE,
}
.find(&line_in[section_start..]);
let section_end = marker
.map(|m| section_start + m.start())
.unwrap_or(line_in.len());
if let CommentState::Block(_) = self.state {
output.extend(std::iter::repeat_n(' ', section_end - section_start));
} else {
output.push_str(&line_in[section_start..section_end]);
}
match marker {
None => return Some(Cow::Owned(output)),
Some(marker) => {
match marker.as_str() {
// only possible in None state
"//" => {
output.extend(std::iter::repeat_n(
' ',
line_in.len() - marker.start() - section_start,
));
return Some(Cow::Owned(output));
}
// only possible in None or Block state
"/*" => {
self.state = match self.state {
CommentState::None => CommentState::Block(1),
CommentState::Block(n) => CommentState::Block(n + 1),
_ => unreachable!(),
};
output.push_str(" ");
}
// only possible in Block state
"*/" => {
self.state = match self.state {
CommentState::Block(1) => CommentState::None,
CommentState::Block(n) => CommentState::Block(n - 1),
_ => unreachable!(),
};
output.push_str(" ");
}
// only possible in None or Quote state
"\"" => {
self.state = match self.state {
CommentState::None => CommentState::Quote,
CommentState::Quote => CommentState::None,
_ => unreachable!(),
};
output.push('"');
}
_ => unreachable!(),
}
section_start += marker.end();
}
}
}
}
}
pub trait CommentReplaceExt<'a> {
/// replace WGSL and GLSL comments with whitespace characters
fn replace_comments(&'a mut self) -> CommentReplaceIter<'a>;
}
impl<'a> CommentReplaceExt<'a> for Lines<'a> {
fn replace_comments(&'a mut self) -> CommentReplaceIter<'a> {
CommentReplaceIter {
lines: self,
state: CommentState::None,
}
}
}
#[test]
fn comment_test() {
const INPUT: &str = r"
not commented
// line commented
not commented
/* block commented on a line */
not commented
// line comment with a /* block comment unterminated
not commented
/* block comment
spanning lines */
not commented
/* block comment
spanning lines and with // line comments
even with a // line commented terminator */
not commented
";
assert_eq!(
INPUT
.lines()
.replace_comments()
.zip(INPUT.lines())
.find(|(line, original)| {
(line != "not commented" && !line.chars().all(|c| c == ' '))
|| line.len() != original.len()
}),
None
);
const PARTIAL_TESTS: [(&str, &str); 11] = [
(
"1.0 /* block comment with a partial line comment on the end *// 2.0",
"1.0 / 2.0",
),
(
"1.0 /* block comment with a partial block comment on the end */* 2.0",
"1.0 * 2.0",
),
(
"1.0 /* block comment 1 *//* block comment 2 */ * 2.0",
"1.0 * 2.0",
),
(
"1.0 /* block comment with real line comment after */// line comment",
"1.0 ",
),
("*/", "*/"),
(
r#"#import "embedded://file.wgsl""#,
r#"#import "embedded://file.wgsl""#,
),
(
r#"// #import "embedded://file.wgsl""#,
r#" "#,
),
(
r#"/* #import "embedded://file.wgsl" */"#,
r#" "#,
),
(
r#"/* #import "embedded:*/file.wgsl" */"#,
r#" file.wgsl" */"#,
),
(
r#"#import "embedded://file.wgsl" // comment"#,
r#"#import "embedded://file.wgsl" "#,
),
(
r#"#import "embedded:/* */ /* /**/* / / /// * / //*/*/ / */*file.wgsl""#,
r#"#import "embedded:/* */ /* /**/* / / /// * / //*/*/ / */*file.wgsl""#,
),
];
for &(input, expected) in PARTIAL_TESTS.iter() {
let mut nasty_processed = input.lines();
let nasty_processed = nasty_processed.replace_comments().next().unwrap();
assert_eq!(&nasty_processed, expected);
}
}
#[test]
fn multiline_comment_test() {
let test_cases = [
(
// Basic test
r"/*
hoho
*/",
r"
",
),
(
// Testing the commenting-out of multiline comments
r"///*
hehe
//*/",
r"
hehe
",
),
(
// Testing the commenting-out of single-line comments
r"/* // */ code goes here /*
Still a comment // */
/* dummy */",
r" code goes here
",
),
(
// A comment with a nested multiline comment
// Notice how the "//" inside the multiline comment doesn't take effect
r"/*
//*
*/commented
*/not commented",
r"
not commented",
),
];
for &(input, expected) in test_cases.iter() {
for (output_line, expected_line) in input.lines().replace_comments().zip(expected.lines()) {
assert_eq!(output_line.as_ref(), expected_line);
}
}
}
#[test]
fn test_comment_becomes_spaces() {
let test_cases = [("let a/**/b =3u;", "let a b =3u;")];
for &(input, expected) in test_cases.iter() {
for (output_line, expected_line) in input.lines().replace_comments().zip(expected.lines()) {
assert_eq!(output_line.as_ref(), expected_line);
}
}
}

307
vendor/naga_oil/src/compose/error.rs vendored Normal file
View File

@@ -0,0 +1,307 @@
use std::{borrow::Cow, collections::HashMap, ops::Range};
use codespan_reporting::{
diagnostic::{Diagnostic, Label},
files::SimpleFile,
term,
term::termcolor::WriteColor,
};
use thiserror::Error;
use tracing::trace;
use super::{preprocess::PreprocessOutput, Composer, ShaderDefValue};
use crate::{compose::SPAN_SHIFT, redirect::RedirectError};
#[derive(Debug)]
pub enum ErrSource {
Module {
name: String,
offset: usize,
defs: HashMap<String, ShaderDefValue>,
},
Constructing {
path: String,
source: String,
offset: usize,
},
}
impl ErrSource {
pub fn path<'a>(&'a self, composer: &'a Composer) -> &'a String {
match self {
ErrSource::Module { name, .. } => &composer.module_sets.get(name).unwrap().file_path,
ErrSource::Constructing { path, .. } => path,
}
}
pub fn source<'a>(&'a self, composer: &'a Composer) -> Cow<'a, String> {
match self {
ErrSource::Module { name, defs, .. } => {
let raw_source = &composer.module_sets.get(name).unwrap().sanitized_source;
let Ok(PreprocessOutput {
preprocessed_source: source,
..
}) = composer.preprocessor.preprocess(raw_source, defs)
else {
return Default::default();
};
Cow::Owned(source)
}
ErrSource::Constructing { source, .. } => Cow::Borrowed(source),
}
}
pub fn offset(&self) -> usize {
match self {
ErrSource::Module { offset, .. } | ErrSource::Constructing { offset, .. } => *offset,
}
}
}
#[derive(Debug, Error)]
#[error("Composer error: {inner}")]
pub struct ComposerError {
#[source]
pub inner: ComposerErrorInner,
pub source: ErrSource,
}
#[derive(Debug, Error)]
pub enum ComposerErrorInner {
#[error("{0}")]
ImportParseError(String, usize),
#[error("required import '{0}' not found")]
ImportNotFound(String, usize),
#[error("{0}")]
WgslParseError(naga::front::wgsl::ParseError),
#[cfg(feature = "glsl")]
#[error("{0:?}")]
GlslParseError(naga::front::glsl::ParseErrors),
#[error("naga_oil bug, please file a report: failed to convert imported module IR back into WGSL for use with WGSL shaders: {0}")]
WgslBackError(naga::back::wgsl::Error),
#[cfg(feature = "glsl")]
#[error("naga_oil bug, please file a report: failed to convert imported module IR back into GLSL for use with GLSL shaders: {0}")]
GlslBackError(naga::back::glsl::Error),
#[error("naga_oil bug, please file a report: composer failed to build a valid header: {0}")]
HeaderValidationError(naga::WithSpan<naga::valid::ValidationError>),
#[error("failed to build a valid final module: {0}")]
ShaderValidationError(naga::WithSpan<naga::valid::ValidationError>),
#[error(
"Not enough '# endif' lines. Each if statement should be followed by an endif statement."
)]
NotEnoughEndIfs(usize),
#[error("Too many '# endif' lines. Each endif should be preceded by an if statement.")]
TooManyEndIfs(usize),
#[error("'#else' without preceding condition.")]
ElseWithoutCondition(usize),
#[error("Unknown shader def operator: '{operator}'")]
UnknownShaderDefOperator { pos: usize, operator: String },
#[error("Unknown shader def: '{shader_def_name}'")]
UnknownShaderDef { pos: usize, shader_def_name: String },
#[error(
"Invalid shader def comparison for '{shader_def_name}': expected {expected}, got {value}"
)]
InvalidShaderDefComparisonValue {
pos: usize,
shader_def_name: String,
expected: String,
value: String,
},
#[error("multiple inconsistent shader def values: '{def}'")]
InconsistentShaderDefValue { def: String },
#[error("Attempted to add a module with no #define_import_path")]
NoModuleName,
#[error("source contains internal decoration string, results probably won't be what you expect. if you have a legitimate reason to do this please file a report")]
DecorationInSource(Range<usize>),
#[error("naga oil only supports glsl 440 and 450")]
GlslInvalidVersion(usize),
#[error("invalid override :{0}")]
RedirectError(#[from] RedirectError),
#[error(
"override is invalid as `{name}` is not virtual (this error can be disabled with feature 'override_any')"
)]
OverrideNotVirtual { name: String, pos: usize },
#[error(
"Composable module identifiers must not require substitution according to naga writeback rules: `{original}`"
)]
InvalidIdentifier { original: String, at: naga::Span },
#[error("Invalid value for `#define`d shader def {name}: {value}")]
InvalidShaderDefDefinitionValue {
name: String,
value: String,
pos: usize,
},
#[error("#define statements are only allowed at the start of the top-level shaders")]
DefineInModule(usize),
}
struct ErrorSources<'a> {
current: Option<&'a (dyn std::error::Error + 'static)>,
}
impl<'a> ErrorSources<'a> {
fn of(error: &'a dyn std::error::Error) -> Self {
Self {
current: error.source(),
}
}
}
impl<'a> Iterator for ErrorSources<'a> {
type Item = &'a (dyn std::error::Error + 'static);
fn next(&mut self) -> Option<Self::Item> {
let current = self.current;
self.current = self.current.and_then(std::error::Error::source);
current
}
}
// impl<'a> FusedIterator for ErrorSources<'a> {}
impl ComposerError {
/// format a Composer error
pub fn emit_to_string(&self, composer: &Composer) -> String {
composer.undecorate(&self.emit_to_string_internal(composer))
}
fn emit_to_string_internal(&self, composer: &Composer) -> String {
let path = self.source.path(composer);
let source = self.source.source(composer);
let source_offset = self.source.offset();
trace!("source:\n~{}~", source);
trace!("source offset: {}", source_offset);
let map_span = |rng: Range<usize>| -> Range<usize> {
((rng.start & ((1 << SPAN_SHIFT) - 1)).saturating_sub(source_offset))
..((rng.end & ((1 << SPAN_SHIFT) - 1)).saturating_sub(source_offset))
};
let files = SimpleFile::new(path, source.as_str());
let config = term::Config::default();
let (labels, notes) = match &self.inner {
ComposerErrorInner::DecorationInSource(range) => {
(vec![Label::primary((), range.clone())], vec![])
}
ComposerErrorInner::HeaderValidationError(v)
| ComposerErrorInner::ShaderValidationError(v) => (
v.spans()
.map(|(span, desc)| {
trace!(
"mapping span {:?} -> {:?}",
span.to_range().unwrap_or(0..0),
map_span(span.to_range().unwrap_or(0..0))
);
Label::primary((), map_span(span.to_range().unwrap_or(0..0)))
.with_message(desc.to_owned())
})
.collect(),
ErrorSources::of(&v)
.map(|source| source.to_string())
.collect(),
),
ComposerErrorInner::ImportNotFound(msg, pos) => (
vec![Label::primary((), *pos..*pos)],
vec![format!("missing import '{msg}'")],
),
ComposerErrorInner::ImportParseError(msg, pos) => (
vec![Label::primary((), *pos..*pos)],
vec![format!("invalid import spec: '{msg}'")],
),
ComposerErrorInner::WgslParseError(e) => (
e.labels()
.map(|(range, msg)| {
Label::primary((), map_span(range.to_range().unwrap_or(0..0)))
.with_message(msg)
})
.collect(),
vec![e.message().to_owned()],
),
#[cfg(feature = "glsl")]
ComposerErrorInner::GlslParseError(e) => (
e.errors
.iter()
.map(|naga::front::glsl::Error { kind, meta }| {
Label::primary((), map_span(meta.to_range().unwrap_or(0..0)))
.with_message(kind.to_string())
})
.collect(),
vec![],
),
ComposerErrorInner::NotEnoughEndIfs(pos)
| ComposerErrorInner::TooManyEndIfs(pos)
| ComposerErrorInner::ElseWithoutCondition(pos)
| ComposerErrorInner::UnknownShaderDef { pos, .. }
| ComposerErrorInner::UnknownShaderDefOperator { pos, .. }
| ComposerErrorInner::InvalidShaderDefComparisonValue { pos, .. }
| ComposerErrorInner::OverrideNotVirtual { pos, .. }
| ComposerErrorInner::GlslInvalidVersion(pos)
| ComposerErrorInner::DefineInModule(pos)
| ComposerErrorInner::InvalidShaderDefDefinitionValue { pos, .. } => {
(vec![Label::primary((), *pos..*pos)], vec![])
}
ComposerErrorInner::WgslBackError(e) => {
return format!("{path}: wgsl back error: {e}");
}
#[cfg(feature = "glsl")]
ComposerErrorInner::GlslBackError(e) => {
return format!("{path}: glsl back error: {e}");
}
ComposerErrorInner::InconsistentShaderDefValue { def } => {
return format!("{path}: multiple inconsistent shader def values: '{def}'");
}
ComposerErrorInner::RedirectError(..) => (
vec![Label::primary((), 0..0)],
vec![format!("override error")],
),
ComposerErrorInner::NoModuleName => {
return format!(
"{path}: no #define_import_path declaration found in composable module"
);
}
ComposerErrorInner::InvalidIdentifier { at, .. } => (
vec![Label::primary((), map_span(at.to_range().unwrap_or(0..0)))
.with_message(self.inner.to_string())],
vec![],
),
};
let diagnostic = Diagnostic::error()
.with_message(self.inner.to_string())
.with_labels(labels)
.with_notes(notes);
let mut msg = Vec::with_capacity(256);
let mut color_writer;
let mut no_color_writer;
let writer: &mut dyn WriteColor = if supports_color() {
color_writer = term::termcolor::Ansi::new(&mut msg);
&mut color_writer
} else {
no_color_writer = term::termcolor::NoColor::new(&mut msg);
&mut no_color_writer
};
term::emit(writer, &config, &files, &diagnostic).expect("cannot write error");
String::from_utf8_lossy(&msg).into_owned()
}
}
#[cfg(any(test, target_arch = "wasm32"))]
fn supports_color() -> bool {
false
}
// termcolor doesn't expose this logic when using custom buffers
#[cfg(not(any(test, target_arch = "wasm32")))]
fn supports_color() -> bool {
match std::env::var_os("TERM") {
None if cfg!(unix) => false,
Some(term) if term == "dumb" => false,
_ => std::env::var_os("NO_COLOR").is_none(),
}
}

1940
vendor/naga_oil/src/compose/mod.rs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,370 @@
use indexmap::IndexMap;
use super::{
tokenizer::{Token, Tokenizer},
Composer, ImportDefWithOffset, ImportDefinition,
};
pub fn parse_imports<'a>(
input: &'a str,
declared_imports: &mut IndexMap<String, Vec<String>>,
) -> Result<(), (&'a str, usize)> {
let mut tokens = Tokenizer::new(input, false).peekable();
match tokens.next() {
Some(Token::Other('#', _)) => (),
Some(other) => return Err(("expected `#import`", other.pos())),
None => return Err(("expected #import", input.len())),
};
match tokens.next() {
Some(Token::Identifier("import", _)) => (),
Some(other) => return Err(("expected `#import`", other.pos())),
None => return Err(("expected `#import`", input.len())),
};
let mut stack = Vec::default();
let mut current = String::default();
let mut as_name = None;
let mut is_deprecated_itemlist = false;
loop {
match tokens.peek() {
Some(Token::Identifier(ident, _)) => {
current.push_str(ident);
tokens.next();
if tokens.peek().and_then(Token::identifier) == Some("as") {
let pos = tokens.next().unwrap().pos();
let Some(Token::Identifier(name, _)) = tokens.next() else {
return Err(("expected identifier after `as`", pos));
};
as_name = Some(name);
}
// support deprecated #import mod item
if let Some(Token::Identifier(..)) = tokens.peek() {
#[cfg(not(feature = "allow_deprecated"))]
tracing::warn!("item list imports are deprecated, please use `rust::style::item_imports` (or use feature `allow_deprecated`)`\n| {}", input);
is_deprecated_itemlist = true;
stack.push(format!("{}::", current));
current = String::default();
as_name = None;
}
continue;
}
Some(Token::Other('{', pos)) => {
if !current.ends_with("::") {
return Err(("open brace must follow `::`", *pos));
}
stack.push(current);
current = String::default();
as_name = None;
}
Some(Token::Other(',', _))
| Some(Token::Other('}', _))
| Some(Token::Other('\n', _))
| None => {
if !current.is_empty() {
let used_name = as_name.map(ToString::to_string).unwrap_or_else(|| {
current
.rsplit_once("::")
.map(|(_, name)| name.to_owned())
.unwrap_or(current.clone())
});
declared_imports.entry(used_name).or_default().push(format!(
"{}{}",
stack.join(""),
current
));
current = String::default();
as_name = None;
}
if let Some(Token::Other('}', pos)) = tokens.peek() {
if stack.pop().is_none() {
return Err(("close brace without open", *pos));
}
}
if tokens.peek().is_none() {
break;
}
}
Some(Token::Other(';', _)) => {
tokens.next();
if let Some(token) = tokens.peek() {
return Err(("unexpected token after ';'", token.pos()));
}
}
Some(Token::Other(_, pos)) => return Err(("unexpected token", *pos)),
Some(Token::Whitespace(..)) => unreachable!(),
}
tokens.next();
}
if !(stack.is_empty() || is_deprecated_itemlist && stack.len() == 1) {
return Err(("missing close brace", input.len()));
}
Ok(())
}
pub fn substitute_identifiers(
input: &str,
offset: usize,
declared_imports: &IndexMap<String, Vec<String>>,
used_imports: &mut IndexMap<String, ImportDefWithOffset>,
allow_ambiguous: bool,
) -> Result<String, usize> {
let tokens = Tokenizer::new(input, true);
let mut output = String::with_capacity(input.len());
let mut in_substitution_position = true;
for token in tokens {
match token {
Token::Identifier(ident, token_pos) => {
if in_substitution_position {
let (first, residual) = ident.split_once("::").unwrap_or((ident, ""));
let full_paths = declared_imports
.get(first)
.cloned()
.unwrap_or(vec![first.to_owned()]);
if !allow_ambiguous && full_paths.len() > 1 {
return Err(offset + token_pos);
}
for mut full_path in full_paths {
if !residual.is_empty() {
full_path.push_str("::");
full_path.push_str(residual);
}
if let Some((module, item)) = full_path.rsplit_once("::") {
used_imports
.entry(module.to_owned())
.or_insert_with(|| ImportDefWithOffset {
definition: ImportDefinition {
import: module.to_owned(),
..Default::default()
},
offset: offset + token_pos,
})
.definition
.items
.push(item.to_owned());
output.push_str(item);
output.push_str(&Composer::decorate(module));
} else if full_path.find('"').is_some() {
// we don't want to replace local variables that shadow quoted module imports with the
// quoted name as that won't compile.
// since quoted items always refer to modules, we can just emit the original ident
// in this case
output.push_str(ident);
} else {
// if there are no quotes we do the replacement. this means that individually imported
// items can be used, and any shadowing local variables get harmlessly renamed.
// TODO: it can lead to weird errors, but such is life
output.push_str(&full_path);
}
}
} else {
output.push_str(ident);
}
}
Token::Other(other, _) => {
output.push(other);
if other == '.' || other == '@' {
in_substitution_position = false;
continue;
}
}
Token::Whitespace(ws, _) => output.push_str(ws),
}
in_substitution_position = true;
}
Ok(output)
}
#[cfg(test)]
fn test_parse(input: &str) -> Result<IndexMap<String, Vec<String>>, (&str, usize)> {
let mut declared_imports = IndexMap::default();
parse_imports(input, &mut declared_imports)?;
Ok(declared_imports)
}
#[test]
fn import_tokens() {
let input = r"
#import a::b
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([(
"b".to_owned(),
vec!("a::b".to_owned())
)]))
);
let input = r"
#import a::{b, c}
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("b".to_owned(), vec!("a::b".to_owned())),
("c".to_owned(), vec!("a::c".to_owned())),
]))
);
let input = r"
#import a::{b as d, c}
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("d".to_owned(), vec!("a::b".to_owned())),
("c".to_owned(), vec!("a::c".to_owned())),
]))
);
let input = r"
#import a::{b::{c, d}, e}
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("c".to_owned(), vec!("a::b::c".to_owned())),
("d".to_owned(), vec!("a::b::d".to_owned())),
("e".to_owned(), vec!("a::e".to_owned())),
]))
);
let input = r"
#import a::b::{c, d}, e
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("c".to_owned(), vec!("a::b::c".to_owned())),
("d".to_owned(), vec!("a::b::d".to_owned())),
("e".to_owned(), vec!("e".to_owned())),
]))
);
let input = r"
#import a, b
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("a".to_owned(), vec!("a".to_owned())),
("b".to_owned(), vec!("b".to_owned())),
]))
);
let input = r"
#import a::b c, d
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("c".to_owned(), vec!("a::b::c".to_owned())),
("d".to_owned(), vec!("a::b::d".to_owned())),
]))
);
let input = r"
#import a::b c
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([(
"c".to_owned(),
vec!("a::b::c".to_owned())
),]))
);
let input = r"
#import a::b::{c::{d, e}, f, g::{h as i, j}}
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("d".to_owned(), vec!("a::b::c::d".to_owned())),
("e".to_owned(), vec!("a::b::c::e".to_owned())),
("f".to_owned(), vec!("a::b::f".to_owned())),
("i".to_owned(), vec!("a::b::g::h".to_owned())),
("j".to_owned(), vec!("a::b::g::j".to_owned())),
]))
);
let input = r"
#import a::b::{
c::{d, e},
f,
g::{
h as i,
j::k::l as m,
}
}
";
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
("d".to_owned(), vec!("a::b::c::d".to_owned())),
("e".to_owned(), vec!("a::b::c::e".to_owned())),
("f".to_owned(), vec!("a::b::f".to_owned())),
("i".to_owned(), vec!("a::b::g::h".to_owned())),
("m".to_owned(), vec!("a::b::g::j::k::l".to_owned())),
]))
);
let input = r#"
#import "path//with\ all sorts of .stuff"::{a, b}
"#;
assert_eq!(
test_parse(input),
Ok(IndexMap::from_iter([
(
"a".to_owned(),
vec!(r#""path//with\ all sorts of .stuff"::a"#.to_owned())
),
(
"b".to_owned(),
vec!(r#""path//with\ all sorts of .stuff"::b"#.to_owned())
),
]))
);
let input = r"
#import a::b::{
";
assert!(test_parse(input).is_err());
let input = r"
#import a::b::{{c}
";
assert!(test_parse(input).is_err());
let input = r"
#import a::b::{c}}
";
assert!(test_parse(input).is_err());
let input = r"
#import a::b{{c,d}}
";
assert!(test_parse(input).is_err());
let input = r"
#import a:b
";
assert!(test_parse(input).is_err());
}

1524
vendor/naga_oil/src/compose/preprocess.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1554
vendor/naga_oil/src/compose/test.rs vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
#define_import_path overridable
virtual fn func() -> f32 {
return 1.0;
}

View File

@@ -0,0 +1,5 @@
#import overridable
override fn overridable::func() -> f32 {
return overridable::func() + 1.0;
}

View File

@@ -0,0 +1,5 @@
#import overridable
fn entry_point() -> f32 {
return overridable::func();
}

View File

@@ -0,0 +1,19 @@
#define_import_path test_module
var<workgroup> atom: atomic<u32>;
fn entry_point() -> f32 {
atomicStore(&atom, 1u); // atom = 1
var y = atomicLoad(&atom); // y = 1, atom = 1
y += atomicAdd(&atom, 2u); // y = 2, atom = 3
y += atomicSub(&atom, 1u); // y = 5, atom = 2
y += atomicMax(&atom, 5u); // y = 7, atom = 5
y += atomicMin(&atom, 4u); // y = 12, atom = 4
y += atomicExchange(&atom, y); // y = 16, atom = 12
let exchange = atomicCompareExchangeWeak(&atom, 12u, 0u);
if exchange.exchanged {
y += exchange.old_value; // y = 28, atom = 0
}
return f32(y); // 28.0
}

View File

@@ -0,0 +1,5 @@
#import test_module
fn main() -> f32 {
return test_module::entry_point();
}

View File

@@ -0,0 +1,31 @@
#import "shaders/skills/shared.wgsl" Vertex, VertexOutput
#if EFFECT_ID == 0
#import "shaders/skills/sound.wgsl" frag, vert
#else if EFFECT_ID == 1
#import "shaders/skills/orb.wgsl" frag, vert
#else if EFFECT_ID == 2
#import "shaders/skills/slash.wgsl" frag, vert
#else if EFFECT_ID == 3
#import "shaders/skills/railgun_trail.wgsl" frag, vert
#else if EFFECT_ID == 4
#import "shaders/skills/magic_arrow.wgsl" frag, vert
#else if EFFECT_ID == 5
#import "shaders/skills/hit.wgsl" frag, vert
#else if EFFECT_ID == 6
#import "shaders/skills/lightning_ring.wgsl" frag, vert
#else if EFFECT_ID == 7
#import "shaders/skills/lightning.wgsl" frag, vert
#endif
#import something_unused
@fragment
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
return frag(in);
}
@vertex
fn vertex(vertex: Vertex) -> VertexOutput {
return vert(vertex);
}

View File

@@ -0,0 +1,144 @@
#define_import_path mod
fn f() -> f32 {
var x = 0.0;
#ifdef a1
#ifdef a2
#ifdef a3
#ifdef a4
#ifdef a5
#ifdef a6
#ifdef a7
#ifdef a8
#ifdef a9
#ifdef a10
#ifdef a11
#ifdef a12
#ifdef a13
#ifdef a14
#ifdef a15
#ifdef a16
#ifdef a17
#ifdef a18
#ifdef a19
#ifdef a20
#ifdef a21
#ifdef a22
#ifdef a23
#ifdef a24
#ifdef a25
#ifdef a26
#ifdef a27
#ifdef a28
#ifdef a29
#ifdef a30
#ifdef a31
#ifdef a32
#ifdef a33
#ifdef a34
#ifdef a35
#ifdef a36
#ifdef a37
#ifdef a38
#ifdef a39
#ifdef a40
#ifdef a41
#ifdef a42
#ifdef a43
#ifdef a44
#ifdef a45
#ifdef a46
#ifdef a47
#ifdef a48
#ifdef a49
#ifdef a50
#ifdef a51
#ifdef a52
#ifdef a53
#ifdef a54
#ifdef a55
#ifdef a56
#ifdef a57
#ifdef a58
#ifdef a59
#ifdef a60
#ifdef a61
#ifdef a62
#ifdef a63
#ifdef a64
#ifdef a65
#ifdef a66
#ifdef a66
#ifdef a67
x = 1.0;
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
#endif
return x;
}

View File

@@ -0,0 +1,5 @@
#import mod
fn main() -> f32 {
return mod::f();
}

View File

@@ -0,0 +1,12 @@
#define_import_path include
fn non_ep(f: f32) -> f32 {
return f * 2.0;
}
@fragment
fn fragment(
@builtin(position) frag_coord: vec4<f32>,
) -> @location(0) vec4<f32> {
return vec4<f32>(1.5 * frag_coord);
}

View File

@@ -0,0 +1,8 @@
#import include as Inc
@fragment
fn fragment(
@builtin(position) frag_coord: vec4<f32>,
) -> @location(0) vec4<f32> {
return Inc::fragment(frag_coord);
}

View File

@@ -0,0 +1,10 @@
#import test_module
@group(0) @binding(0)
var<storage, read_write> buffer: f32;
@compute @workgroup_size(1, 1, 1)
fn run_test() {
let res = test_module::entry_point();
buffer = res;
}

View File

@@ -0,0 +1,3 @@
#define_import_path a
const C: u32 = 1u;

View File

@@ -0,0 +1,3 @@
#define_import_path b
const C: u32 = 2u;

View File

@@ -0,0 +1,9 @@
#ifdef USE_A
#import a C
#else
#import b C
#endif
fn main() -> u32 {
return C;
}

View File

@@ -0,0 +1,9 @@
#define_import_path middle
#ifdef USE_A
#import a::b
#endif
fn mid_fn() -> u32 {
return b::C;
}

View File

@@ -0,0 +1,3 @@
#define_import_path a::b
const C: u32 = 1u;

View File

@@ -0,0 +1,7 @@
#ifdef USE_A
#import a::b
#endif
fn main() -> u32 {
return b::C;
}

View File

@@ -0,0 +1,5 @@
#import middle
fn main() -> u32 {
return middle::mid_fn();
}

View File

@@ -0,0 +1,7 @@
#define_import_path bind
#import consts
const y: u32 = 2u;
var<private> arr: array<u32, consts::X>;

View File

@@ -0,0 +1,3 @@
#define_import_path consts
const X: u32 = 1u;

View File

@@ -0,0 +1,6 @@
#import consts
#import bind
fn main() -> f32 {
return f32(bind::arr[0]);
}

View File

@@ -0,0 +1,12 @@
#define_import_path filters
diagnostic(warning, derivative_uniformity);
fn diagnostic_test(s : sampler, tex : texture_2d<f32>, ro_buffer : array<f32, 4>) -> vec4f {
if ro_buffer[0] == 0 {
// Emits a derivative uniformity error during validation.
return textureSample(tex, s, vec2(0.,0.));
}
return vec4f(0.);
}

View File

@@ -0,0 +1,10 @@
#import filters
@group(0) @binding(0) var s : sampler;
@group(0) @binding(2) var tex : texture_2d<f32>;
@group(1) @binding(0) var<storage, read> ro_buffer : array<f32, 4>;
@fragment
fn main(@builtin(position) p : vec4f) -> @location(0) vec4f {
return filters::diagnostic_test();
}

View File

@@ -0,0 +1,7 @@
#define_import_path a
#import consts
fn f() -> f32 {
return consts::PI * 1.0;
}

View File

@@ -0,0 +1,20 @@
const PI: f32 = 3.1;
fn b__f() -> f32 {
return PI * 2.0;
}
fn b__g() -> f32 {
return PI * 2.0;
}
fn a__f() -> f32 {
return PI * 1.0;
}
fn main() -> f32 {
let x = a__f();
let y = b__f();
return x*y;
}

View File

@@ -0,0 +1,11 @@
#define_import_path b
#import consts
fn f() -> f32 {
return consts::PI * 2.0;
}
fn g() -> f32 {
return consts::PI * 2.0;
}

View File

@@ -0,0 +1,3 @@
#define_import_path consts
const PI: f32 = 3.1;

View File

@@ -0,0 +1,9 @@
#import a
#import b
fn main() -> f32 {
let x = a::f();
let y = b::f();
return x*y;
}

View File

@@ -0,0 +1,8 @@
#define_import_path a
#import struct
fn a() -> struct::MyStruct {
var s_a: struct::MyStruct;
s_a.value = 1.0;
return s_a;
}

View File

@@ -0,0 +1,8 @@
#define_import_path b
#import struct
fn b() -> struct::MyStruct {
var s_b: struct::MyStruct;
s_b.value = 2.0;
return s_b;
}

View File

@@ -0,0 +1,5 @@
#define_import_path struct
struct MyStruct {
value: f32,
}

View File

@@ -0,0 +1,8 @@
#import a
#import b
fn main() -> f32 {
let a = a::a();
let b = b::b();
return a.value / b.value;
}

View File

@@ -0,0 +1,19 @@
#define_import_path mod
#ifdef DEF_ONE
const a: u32 = 1u;
#else
const a: u32 = 0u;
#endif
#ifndef DEF_TWO
const b: u32 = 0u;
#else
const b: u32 = 2u;
#endif
#if DEF_THREE == true
const c: u32 = 4u;
#else
const c: u32 = 0u;
#endif

View File

@@ -0,0 +1,6 @@
#define_import_path test_module
#import mod a, b, c
fn entry_point() -> f32 {
return f32(a + b + c);
}

View File

@@ -0,0 +1,12 @@
#define_import_path include
doesn't matter what goes here for this test
or here, just moving lines around a bit
#import missing
fn sub() {
// have to use something for it to be declared missing
let x = missing::y();
}

View File

@@ -0,0 +1,17 @@
#define_import_path wgsl_parse_err
const VAL: u32 = 1u;
fn all_ok() -> f32 {
let x = 1.0;
var y = sqrt(x);
y += 1.0;
return y;
}
fn woops() -> f32 {
let x = 1.0;
var y = sqrt(x);
y += 1.0;
return zdd;
}

View File

@@ -0,0 +1,3 @@
fn ok() {
wgsl_parse_err::woops();
}

View File

@@ -0,0 +1,17 @@
#define_import_path valid_inc
fn ok() -> f32 {
return 1.0;
}
fn func() -> f32 {
return 1u;
}
fn still_ok() -> f32 {
return 1.0;
}
fn main() {
let x: f32 = func();
}

View File

@@ -0,0 +1,3 @@
fn whatever() {
valid_inc::main();
}

View File

@@ -0,0 +1,14 @@
fn funcX_naga_oil_mod_XN53GK4TSNFSGCYTMMUX() -> f32 {
return 1f;
}
fn funcX_naga_oil_vrt_XN53GK4TSNFSGCYTMMUXX_naga_oil_mod_XOBWHKZ3JNYX() -> f32 {
let _e0: f32 = funcX_naga_oil_mod_XN53GK4TSNFSGCYTMMUX();
return (_e0 + 1f);
}
fn entry_point() -> f32 {
let _e0: f32 = funcX_naga_oil_vrt_XN53GK4TSNFSGCYTMMUXX_naga_oil_mod_XOBWHKZ3JNYX();
return _e0;
}

View File

@@ -0,0 +1,38 @@
var<workgroup> atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX: atomic<u32>;
fn entry_pointX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX() -> f32 {
var y: u32;
atomicStore((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 1u);
let _e3: u32 = atomicLoad((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX));
y = _e3;
let _e7: u32 = atomicAdd((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 2u);
let _e8: u32 = y;
y = (_e8 + _e7);
let _e12: u32 = atomicSub((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 1u);
let _e13: u32 = y;
y = (_e13 + _e12);
let _e17: u32 = atomicMax((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 5u);
let _e18: u32 = y;
y = (_e18 + _e17);
let _e22: u32 = atomicMin((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 4u);
let _e23: u32 = y;
y = (_e23 + _e22);
let _e25: u32 = y;
let _e27: u32 = atomicExchange((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), _e25);
let _e28: u32 = y;
y = (_e28 + _e27);
let _e33: _atomic_compare_exchange_resultUint4_ = atomicCompareExchangeWeak((&atomX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX), 12u, 0u);
if _e33.exchanged {
let _e36: u32 = y;
y = (_e36 + _e33.old_value);
}
let _e38: u32 = y;
return f32(_e38);
}
fn main() -> f32 {
let _e0: f32 = entry_pointX_naga_oil_mod_XORSXG5C7NVXWI5LMMUX();
return _e0;
}

View File

@@ -0,0 +1,39 @@
struct IsFineX_naga_oil_mod_XON2HE5LDORZQX {
fine: f32,
}
struct Isbad_X_naga_oil_mod_XON2HE5LDORZQX {
fine_member: f32,
}
const fineX_naga_oil_mod_XMNXW443UOMX: f32 = 1f;
const bad_X_naga_oil_mod_XMNXW443UOMX: f32 = 1f;
var<private> fineX_naga_oil_mod_XM5WG6YTBNRZQX: f32 = 1f;
var<private> bad_X_naga_oil_mod_XM5WG6YTBNRZQX: f32 = 1f;
fn fineX_naga_oil_mod_XMZXHGX(in: f32) -> f32 {
return in;
}
fn bad_X_naga_oil_mod_XMZXHGX(in_1: f32) -> f32 {
return in_1;
}
fn main() -> f32 {
var d: IsFineX_naga_oil_mod_XON2HE5LDORZQX;
var e: Isbad_X_naga_oil_mod_XON2HE5LDORZQX;
let _e1: f32 = fineX_naga_oil_mod_XMZXHGX(1f);
let _e3: f32 = bad_X_naga_oil_mod_XMZXHGX(2f);
let b: f32 = (_e1 + _e3);
let _e6: f32 = fineX_naga_oil_mod_XM5WG6YTBNRZQX;
let _e8: f32 = bad_X_naga_oil_mod_XM5WG6YTBNRZQX;
let c: f32 = (_e6 + _e8);
d.fine = 3f;
e.fine_member = 4f;
let _e20: f32 = d.fine;
let _e23: f32 = e.fine_member;
return ((((2f + b) + c) + _e20) + _e23);
}

View File

@@ -0,0 +1,13 @@
fn fX_naga_oil_mod_XNVXWIX() -> f32 {
var x: f32 = 0f;
x = 1f;
let _e3: f32 = x;
return _e3;
}
fn main() -> f32 {
let _e0: f32 = fX_naga_oil_mod_XNVXWIX();
return _e0;
}

View File

@@ -0,0 +1,6 @@
const CX_naga_oil_mod_XMEX: u32 = 1u;
fn main() -> u32 {
return CX_naga_oil_mod_XMEX;
}

View File

@@ -0,0 +1,6 @@
const CX_naga_oil_mod_XMIX: u32 = 2u;
fn main() -> u32 {
return CX_naga_oil_mod_XMIX;
}

View File

@@ -0,0 +1,8 @@
error: required import 'b' not found
┌─ tests/conditional_import_fail/top.wgsl:6:12
6 │ return b::C;
│ ^
= missing import 'b'

View File

@@ -0,0 +1,8 @@
error: required import 'b' not found
┌─ tests/conditional_import_fail/top_nested.wgsl:1:1
1 │ #import middle
│ ^
= missing import 'b'

View File

@@ -0,0 +1,20 @@
@group(0) @binding(0) var s : sampler;
@group(0) @binding(2) var tex : texture_2d<f32>;
@group(1) @binding(0) var<storage, read> ro_buffer : array<f32, 4>;
@fragment
fn main(@builtin(position) p : vec4f) -> @location(0) vec4f {
return filters::diagnostic_test();
}
diagnostic(warning, derivative_uniformity);
fn diagnostic_test() -> vec4f {
diagnostic(off, derivative_uniformity);
if ro_buffer[0] == 0 {
// Emits a derivative uniformity error during validation.
return textureSample(tex, s, vec2(0.,0.));
}
return vec4f(0.);
}

View File

@@ -0,0 +1,16 @@
const PIX_naga_oil_mod_XMNXW443UOMX: f32 = 3.1f;
fn fX_naga_oil_mod_XMEX() -> f32 {
return 3.1f;
}
fn fX_naga_oil_mod_XMIX() -> f32 {
return 6.2f;
}
fn main() -> f32 {
let _e0: f32 = fX_naga_oil_mod_XMEX();
let _e1: f32 = fX_naga_oil_mod_XMIX();
return (_e0 * _e1);
}

View File

@@ -0,0 +1,26 @@
struct MyStructX_naga_oil_mod_XON2HE5LDOQX {
value: f32,
}
fn aX_naga_oil_mod_XMEX() -> MyStructX_naga_oil_mod_XON2HE5LDOQX {
var s_a: MyStructX_naga_oil_mod_XON2HE5LDOQX;
s_a.value = 1f;
let _e3: MyStructX_naga_oil_mod_XON2HE5LDOQX = s_a;
return _e3;
}
fn bX_naga_oil_mod_XMIX() -> MyStructX_naga_oil_mod_XON2HE5LDOQX {
var s_b: MyStructX_naga_oil_mod_XON2HE5LDOQX;
s_b.value = 2f;
let _e3: MyStructX_naga_oil_mod_XON2HE5LDOQX = s_b;
return _e3;
}
fn main() -> f32 {
let _e0: MyStructX_naga_oil_mod_XON2HE5LDOQX = aX_naga_oil_mod_XMEX();
let _e1: MyStructX_naga_oil_mod_XON2HE5LDOQX = bX_naga_oil_mod_XMIX();
return (_e0.value / _e1.value);
}

View File

@@ -0,0 +1,8 @@
error: no definition in scope for identifier: `zdd`
┌─ tests/error_test/wgsl_parse_err.wgsl:16:12
16 │ return zdd;
│ ^^^ unknown identifier
= no definition in scope for identifier: `zdd`

View File

@@ -0,0 +1,10 @@
error: failed to build a valid final module: Function [1] 'func' is invalid
┌─ tests/error_test/wgsl_valid_err.wgsl:7:1
7 │ ╭ fn func() -> f32 {
8 │ │ return 1u;
│ │ ^^ naga::Expression [0]
│ ╰──────────────^ naga::Function [1]
= The `return` value Some([0]) does not match the function return value

View File

@@ -0,0 +1,10 @@
error: failed to build a valid final module: Function [0] 'valid_inc::func' is invalid
┌─ tests/error_test/wgsl_valid_err.wgsl:7:1
7 │ ╭ fn func() -> f32 {
8 │ │ return 1u;
│ │ ^^ naga::Expression [0]
│ ╰──────────────^ naga::Function [0]
= The `return` value Some([0]) does not match the function return value

View File

@@ -0,0 +1,22 @@
struct VertexOutput {
@builtin(position) gl_Position: vec4<f32>,
}
var<private> gl_Position: vec4<f32>;
fn wgsl_funcX_naga_oil_mod_XO5TXG3C7NVXWI5LMMUX() -> f32 {
return 53f;
}
fn main_1() {
let _e0: f32 = wgsl_funcX_naga_oil_mod_XO5TXG3C7NVXWI5LMMUX();
gl_Position = vec4(_e0);
return;
}
@vertex
fn main() -> VertexOutput {
main_1();
let _e1: vec4<f32> = gl_Position;
return VertexOutput(_e1);
}

View File

@@ -0,0 +1,19 @@
struct FragmentOutput {
@location(0) out_color: vec4<f32>,
}
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5f;
var<private> out_color: vec4<f32>;
fn main_1() {
out_color = vec4<f32>(1f, 0.5f, 0f, 1f);
return;
}
@fragment
fn main() -> FragmentOutput {
main_1();
let _e1: vec4<f32> = out_color;
return FragmentOutput(_e1);
}

View File

@@ -0,0 +1,6 @@
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5f;
fn main() -> vec4<f32> {
return vec4<f32>(1f, 0.5f, 0f, 1f);
}

View File

@@ -0,0 +1,9 @@
const XX_naga_oil_mod_XMNXW443UOMX: u32 = 1u;
var<private> arrX_naga_oil_mod_XMJUW4ZAX: array<u32, 1>;
fn main() -> f32 {
let _e2: u32 = arrX_naga_oil_mod_XMJUW4ZAX[0];
return f32(_e2);
}

View File

@@ -0,0 +1,6 @@
error: override is invalid as `outer` is not virtual (this error can be disabled with feature 'override_any')
┌─ tests/overrides/top_invalid.wgsl:3:13
3 │ override fn mod::outer() -> f32 {
│ ^

View File

@@ -0,0 +1,17 @@
const XX_naga_oil_mod_XMNXW443UOMX: u32 = 1u;
const YX_naga_oil_mod_XMNXW443UOMX: u32 = 2u;
fn doubleX_naga_oil_mod_XMNXW443UOMX(in: u32) -> u32 {
return (in * 2u);
}
fn main() -> u32 {
let _e1: u32 = doubleX_naga_oil_mod_XMNXW443UOMX(XX_naga_oil_mod_XMNXW443UOMX);
return _e1;
}
fn other() -> u32 {
let _e1: u32 = doubleX_naga_oil_mod_XMNXW443UOMX(YX_naga_oil_mod_XMNXW443UOMX);
return _e1;
}

View File

@@ -0,0 +1,17 @@
struct FragX_naga_oil_mod_XNVXWIX {
fragment: f32,
}
fn fragmentX_naga_oil_mod_XNVXWIX(f_1: FragX_naga_oil_mod_XNVXWIX) -> f32 {
return (f_1.fragment * 2f);
}
@fragment
fn main() -> @location(0) f32 {
var f: FragX_naga_oil_mod_XNVXWIX;
f.fragment = 3f;
let _e3: FragX_naga_oil_mod_XNVXWIX = f;
let _e4: f32 = fragmentX_naga_oil_mod_XNVXWIX(_e3);
return _e4;
}

View File

@@ -0,0 +1,8 @@
error: required import 'missing' not found
┌─ tests/error_test/include.wgsl:11:13
11 │ let x = missing::y();
│ ^
= missing import 'missing'

View File

@@ -0,0 +1,9 @@
fn helloX_naga_oil_mod_XNFXGGX() -> f32 {
return 1f;
}
fn main() -> f32 {
let _e0: f32 = helloX_naga_oil_mod_XNFXGGX();
return _e0;
}

View File

@@ -0,0 +1,14 @@
fn fooX_naga_oil_mod_XEJYXK33UMVSF63LPMR2WYZJCX() -> f32 {
return 3f;
}
fn myfunc(foo: u32) -> f32 {
return (f32(foo) * 2f);
}
fn main() -> f32 {
let _e1: f32 = myfunc(1u);
let _e2: f32 = fooX_naga_oil_mod_XEJYXK33UMVSF63LPMR2WYZJCX();
return (_e1 + _e2);
}

View File

@@ -0,0 +1,15 @@
var<private> aX_naga_oil_mod_XNVXWIX: f32 = 0f;
fn add() {
let _e2: f32 = aX_naga_oil_mod_XNVXWIX;
aX_naga_oil_mod_XNVXWIX = (_e2 + 1f);
return;
}
fn main() -> f32 {
add();
add();
let _e1: f32 = aX_naga_oil_mod_XNVXWIX;
return _e1;
}

View File

@@ -0,0 +1,9 @@
fn fragmentX_naga_oil_mod_XNFXGG3DVMRSQX(frag_coord_1: vec4<f32>) -> vec4<f32> {
return vec4<f32>((1.5f * frag_coord_1));
}
@fragment
fn fragment(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {
let _e1: vec4<f32> = fragmentX_naga_oil_mod_XNFXGG3DVMRSQX(frag_coord);
return _e1;
}

View File

@@ -0,0 +1,16 @@
struct CustomMaterialX_naga_oil_mod_XM5WHG3C7NVXWI5LMMUX {
Color: vec4<f32>,
}
@group(1) @binding(0)
var<uniform> global: CustomMaterialX_naga_oil_mod_XM5WHG3C7NVXWI5LMMUX;
fn glsl_funcX_naga_oil_mod_XM5WHG3C7NVXWI5LMMUX() -> f32 {
return 3f;
}
fn fraggo() -> f32 {
let _e0: f32 = glsl_funcX_naga_oil_mod_XM5WHG3C7NVXWI5LMMUX();
return _e0;
}

View File

@@ -0,0 +1,19 @@
struct FragmentOutput {
@location(0) out_color: vec4<f32>,
}
const my_constantX_naga_oil_mod_XMNXW23LPNYX: f32 = 0.5f;
var<private> out_color: vec4<f32>;
fn main_1() {
out_color = vec4<f32>(1f, 0.5f, 0f, 1f);
return;
}
@fragment
fn main() -> FragmentOutput {
main_1();
let _e1: vec4<f32> = out_color;
return FragmentOutput(_e1);
}

View File

@@ -0,0 +1,18 @@
#version 450
float _xaga_oil_mod__wgsl_module__wgsl_func() {
return 53.0;
}
layout(location = 0) out vec4 o_Target;
void main() {
o_Target = vec4(_xaga_oil_mod__wgsl_module__wgsl_func());
}

View File

@@ -0,0 +1,22 @@
#define_import_path glsl_module
#version 450
layout(location = 0) in vec2 v_Uv;
layout(location = 0) out vec4 o_Target;
layout(set = 1, binding = 0) uniform CustomMaterial {
vec4 Color;
};
layout(set = 1, binding = 1) uniform texture2D CustomMaterial_texture;
layout(set = 1, binding = 2) uniform sampler CustomMaterial_sampler;
void main() {
o_Target = Color * texture(sampler2D(CustomMaterial_texture,CustomMaterial_sampler), v_Uv);
}
float glsl_func() {
return 3.0;
}

View File

@@ -0,0 +1,5 @@
#define_import_path wgsl_module
fn wgsl_func() -> f32 {
return 53.0;
}

View File

@@ -0,0 +1,9 @@
#version 450
#import wgsl_module
void main() {
gl_Position = vec4(wgsl_module::wgsl_func());
}

View File

@@ -0,0 +1,6 @@
#import glsl_module
fn fraggo() -> f32 {
let x = glsl_module::glsl_func();
return x;
}

View File

@@ -0,0 +1,5 @@
#define_import_path common
const float my_constant = 0.5;
void main() {}

View File

@@ -0,0 +1,3 @@
#define_import_path common
const my_constant: f32 = 0.5;

View File

@@ -0,0 +1,9 @@
#version 450
#import common
out vec4 out_color;
void main() {
out_color = vec4(1, common::my_constant, 0, 1);
}

View File

@@ -0,0 +1,7 @@
#version 450
#import common
fn main() -> vec4<f32> {
return vec4(1.0, common::my_constant, 0.0, 1.0);
}

View File

@@ -0,0 +1,4 @@
#define_import_path consts
const fine: f32 = 1.0;
const bad_: f32 = 1.0;

View File

@@ -0,0 +1,4 @@
#define_import_path fns
fn fine(in: f32) -> f32 {return in;}
fn bad_(in: f32) -> f32 {return in;}

View File

@@ -0,0 +1,4 @@
#define_import_path globals
var<private> fine: f32 = 1.0;
var<private> bad_: f32 = 1.0;

View File

@@ -0,0 +1,9 @@
#define_import_path structs
struct IsFine {
fine: f32,
}
struct Isbad_ {
fine_member: f32,
}

View File

@@ -0,0 +1,10 @@
#define_import_path struct_members
struct FineStruct {
fine: f32,
}
struct BadStruct {
also_fine: f32,
bad_: f32,
}

View File

@@ -0,0 +1,23 @@
// #import consts
// #import fns
// #import globals
#import struct_members
// #import structs
fn main() -> f32 {
// let a = consts::fine + consts::bad_;
// let b = fns::fine(1.0) + fns::bad_(2.0);
// let c = globals::fine + globals::bad_;
// var d: structs::IsFine;
// d.fine = 3.0;
// var e: structs::Isbad_;
// e.fine_member = 4.0;
var f = struct_members::FineStruct;
f.fine = 5.0;
var g = struct_members::BadStruct;
g.also_fine = 6.0;
g.bad_ = 7.0;
// return a + b + c + d.fine + e.fine_member;
return f.fine + g.also_fine + g.bad_;
}

View File

@@ -0,0 +1,22 @@
#import consts
#import fns
#import globals
// #import struct_members
#import structs
fn main() -> f32 {
let a = consts::fine + consts::bad_;
let b = fns::fine(1.0) + fns::bad_(2.0);
let c = globals::fine + globals::bad_;
var d: structs::IsFine;
d.fine = 3.0;
var e: structs::Isbad_;
e.fine_member = 4.0;
// var f = struct_members::FineStruct;
// f.fine = 5.0;
// var g = struct_members::BadStruct;
// g.also_fine = 6.0;
// g.bad_ = 7.0;
return a + b + c + d.fine + e.fine_member; // + f.fine + g.also_fine + g.bad_;
}

View File

@@ -0,0 +1,16 @@
#define_import_path consts
const X: u32 = 1u;
const Y: u32 = 2u;
const Z: u32 = 3u;
@group(0) @binding(0)
var something: sampler;
fn double(in: u32) -> u32 {
return in * 2u;
}
fn triple(in: u32) -> u32 {
return in * 3u;
}

View File

@@ -0,0 +1,10 @@
#import consts X, double
#import consts Y
fn main() -> u32 {
return double(X);
}
fn other() -> u32 {
return double(Y);
}

View File

@@ -0,0 +1,9 @@
#define_import_path mod
struct Frag {
fragment: f32,
}
fn fragment(f: Frag) -> f32 {
return f.fragment * 2.0;
}

View File

@@ -0,0 +1,8 @@
#import mod Frag, fragment
@fragment
fn main() -> @location(0) f32 {
var f: Frag;
f.fragment = 3.0;
return fragment(f);
}

View File

@@ -0,0 +1,13 @@
#define_import_path test_module
fn fract_times_whole(x: f32) -> f32 {
let fw = modf(x);
let f = fw.fract;
let w = fw.whole;
return f * w;
}
fn entry_point() -> f32 {
let fract_times_whole = fract_times_whole(3.25);
return fract_times_whole - 0.75;
}

View File

@@ -0,0 +1,6 @@
#import test_module
fn entry_point() -> f32 {
let fract_times_whole = test_module::fract_times_whole(3.1);
return fract_times_whole - 0.3;
}

View File

@@ -0,0 +1,8 @@
#define_import_path middle
#import mod
override fn mod::inner(arg: f32) -> f32 {
return arg * 3.0;
}

View File

@@ -0,0 +1,9 @@
#define_import_path mod
virtual fn inner(arg: f32) -> f32 {
return arg * 2.0;
}
fn outer() -> f32 {
return inner(1.0);
}

View File

@@ -0,0 +1,9 @@
#import mod
override fn mod::inner(arg: f32) -> f32 {
return arg * 3.0;
}
fn top() -> f32 {
return mod::outer();
}

View File

@@ -0,0 +1,9 @@
#import mod
override fn mod::outer() -> f32 {
return 99.0;
}
fn top() -> f32 {
return mod::outer();
}

View File

@@ -0,0 +1,8 @@
#define_import_path test_module
#import middle
#import mod
fn entry_point() -> f32 {
return mod::outer();
}

Some files were not shown because too many files have changed in this diff Show More