Skip to content

Commit 2d46031

Browse files
committed
feat!(wgcore): rename Shader::absolute_path to Shader::wgsl_path
1 parent e261839 commit 2d46031

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Diff for: crates/wgcore-derive/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub fn derive_shader(item: TokenStream) -> TokenStream {
7777
// First try to find a path from the shader registry.
7878
// If doesn’t exist in the registry, try the absolute path.
7979
// If it doesn’t exist in the absolute path, load the embedded string.
80-
if let Some(path) = Self::absolute_path() {
80+
if let Some(path) = Self::wgsl_path() {
8181
// TODO: handle error
8282
std::fs::read_to_string(path).unwrap()
8383
} else {
@@ -139,7 +139,7 @@ pub fn derive_shader(item: TokenStream) -> TokenStream {
139139
#naga_module
140140
}
141141

142-
fn absolute_path() -> Option<std::path::PathBuf> {
142+
fn wgsl_path() -> Option<std::path::PathBuf> {
143143
if let Some(path) = wgcore::ShaderRegistry::get().get_path::<#struct_identifier>() {
144144
Some(path.clone())
145145
} else {
@@ -181,7 +181,7 @@ pub fn derive_shader(item: TokenStream) -> TokenStream {
181181
#to_derive::watch_sources(state)?;
182182
)*
183183

184-
if let Some(path) = Self::absolute_path() {
184+
if let Some(path) = Self::wgsl_path() {
185185
state.watch_file(&path)?;
186186
}
187187

@@ -195,7 +195,7 @@ pub fn derive_shader(item: TokenStream) -> TokenStream {
195195
}
196196
)*
197197

198-
Self::absolute_path()
198+
Self::wgsl_path()
199199
.map(|path| state.file_changed(&path))
200200
.unwrap_or_default()
201201
}

Diff for: crates/wgcore/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Changed
88

99
- Rename `Shader::set_absolute_path` to `Shader::set_wgsl_path`.
10+
- Rename `Shader::absolute_path` to `Shader::wgsl_path`.
1011
- Workgroup memory automatic zeroing is now **disabled** by default due to its significant
1112
performance impact.
1213

Diff for: crates/wgcore/src/shader.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use wgpu::{Device, Label, ShaderModule};
1515
/// To access the global shader registry, call [`ShaderRegistry::get`].
1616
/// Whenever a shader source is needed (e.g. as a dependency of another, for instantiating one
1717
/// of its kernel, for hot-reloading), the path registered in this map will take precedence in the
18-
/// automatically-generated implementation of [`Shader::absolute_path`]. If no path is provided
18+
/// automatically-generated implementation of [`Shader::wgsl_path`]. If no path is provided
1919
/// by this registry, the absolute path detected automatically by the `derive(Shader)` will be
2020
/// applied. If neither exist, the shader loading code will default to the shader sources that
2121
/// were embedded at the time of compilation of the module.
@@ -102,11 +102,11 @@ pub trait Shader: Sized + 'static {
102102
Ok(composer)
103103
}
104104

105-
/// The absolute path of this wgsl shader source file.
105+
/// The path of this wgsl shader source file.
106106
///
107107
/// This returns the path from the global [`ShaderRegistry`] if it was set. Otherwise, this returns
108108
/// the path automatically-computed by the `derive(Shader)`. If that failed too, returns `None`.
109-
fn absolute_path() -> Option<PathBuf>;
109+
fn wgsl_path() -> Option<PathBuf>;
110110

111111
/// Registers in the global [`ShaderRegistry`] known path for this shader.
112112
///

0 commit comments

Comments
 (0)