Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ glsl = ["naga/glsl-in", "naga/glsl-out"]
override_any = []
prune = []
allow_deprecated = []
# forces composable modules to include "enable wgpu_ray_query"
override_enable_ray_query = []

[dependencies]
naga = { version = "28", features = ["wgsl-in", "wgsl-out", "termcolor"] }
Expand Down
29 changes: 8 additions & 21 deletions src/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ pub struct ComposableModuleDefinition {
modules: HashMap<ModuleKey, ComposableModule>,
// used in spans when this module is included
module_index: usize,
// any directives used in this module
wgsl_directives: WgslDirectives,
}

impl ComposableModuleDefinition {
Expand Down Expand Up @@ -585,17 +587,12 @@ impl Composer {
language: ShaderLanguage,
imports: &[ImportDefinition],
shader_defs: &HashMap<String, ShaderDefValue>,
wgsl_directives: Option<WgslDirectives>,
wgsl_directives: &WgslDirectives,
) -> Result<IrBuildResult, ComposerError> {
debug!("creating IR for {} with defs: {:?}", name, shader_defs);

let mut wgsl_string = String::new();
if let Some(wgsl_directives) = &wgsl_directives {
trace!("adding WGSL directives for {}", name);
wgsl_string = wgsl_directives.to_wgsl_string();
}
let mut module_string = match language {
ShaderLanguage::Wgsl => wgsl_string,
ShaderLanguage::Wgsl => wgsl_directives.to_wgsl_string(),
#[cfg(feature = "glsl")]
ShaderLanguage::Glsl => String::from("#version 450\n"),
};
Expand Down Expand Up @@ -853,7 +850,6 @@ impl Composer {
demote_entrypoints: bool,
source: &str,
imports: Vec<ImportDefWithOffset>,
wgsl_directives: Option<WgslDirectives>,
) -> Result<ComposableModule, ComposerError> {
let mut imports: Vec<_> = imports
.into_iter()
Expand Down Expand Up @@ -987,7 +983,7 @@ impl Composer {
module_definition.language,
&imports,
shader_defs,
wgsl_directives,
&module_definition.wgsl_directives,
)?;

// from here on errors need to be reported using the modified source with start_offset
Expand Down Expand Up @@ -1389,17 +1385,6 @@ impl Composer {
true,
&preprocessed_source,
imports,
if cfg!(feature = "override_enable_ray_query") {
Some(WgslDirectives {
enables: vec![EnableDirective {
extensions: vec!["wgpu_ray_query".to_string()],
source_location: 0,
}],
..Default::default()
})
} else {
None
},
)
.map_err(|err| err.into())
}
Expand Down Expand Up @@ -1544,6 +1529,7 @@ impl Composer {
mut imports,
mut effective_defs,
cleaned_source,
wgsl_directives,
..
} = self
.preprocessor
Expand Down Expand Up @@ -1629,6 +1615,7 @@ impl Composer {
shader_defs,
module_index,
modules: Default::default(),
wgsl_directives,
};

// invalidate dependent modules if this module already exists
Expand Down Expand Up @@ -1775,6 +1762,7 @@ impl Composer {
all_imports: Default::default(),
shader_defs: Default::default(),
modules: Default::default(),
wgsl_directives,
};

let PreprocessOutput {
Expand All @@ -1801,7 +1789,6 @@ impl Composer {
false,
&preprocessed_source,
imports,
Some(wgsl_directives),
)
.map_err(|e| ComposerError {
inner: e.inner,
Expand Down
1 change: 0 additions & 1 deletion src/compose/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,6 @@ mod test {
output_eq!(wgsl, "tests/expected/atomics.txt");
}

#[cfg(feature = "override_enable_ray_query")]
#[test]
fn test_raycasts() {
let mut composer =
Expand Down
2 changes: 2 additions & 0 deletions src/compose/tests/raycast/mod.wgsl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
enable wgpu_ray_query;

#define_import_path test_module

@group(0) @binding(0) var tlas: acceleration_structure;
Expand Down