Skip to content
Closed
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: 1 addition & 1 deletion crates/spirv-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub use rustc_codegen_spirv_types::Capability;
pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult};

#[cfg(feature = "watch")]
pub use self::watch::Watch;
pub use self::watch::{AcceptFirstCompile, Watch};

#[cfg(feature = "include-target-specs")]
pub use rustc_codegen_spirv_target_specs::TARGET_SPEC_DIR_PATH;
Expand Down
24 changes: 9 additions & 15 deletions crates/spirv-builder/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ impl SpirvBuilder {
/// Watches the module for changes using [`notify`], rebuilding it upon changes.
///
/// Calls `on_compilation_finishes` after each successful compilation.
/// The second `Option<AcceptFirstCompile<T>>` param allows you to return some `T`
/// on the first compile, which is then returned by this function
/// in pair with [`JoinHandle`] to the watching thread.
pub fn watch<T>(
&self,
mut on_compilation_finishes: impl FnMut(CompileResult, Option<AcceptFirstCompile<'_, T>>)
+ Send
+ 'static,
) -> Result<Watch<T>, SpirvBuilderError> {
pub fn watch<T, F>(&self, mut on_compilation_finishes: F) -> Result<Watch<T>, SpirvBuilderError>
where
F: FnMut(CompileResult, Option<AcceptFirstCompile<'_, T>>) + Send + 'static,
{
let path_to_crate = self
.path_to_crate
.as_ref()
Expand Down Expand Up @@ -79,15 +74,14 @@ impl SpirvBuilder {
}
}

/// The second parameter of the callback passed to [`SpirvBuilder::watch()`]
/// which allows it to return some value of `T` on the first compile.
pub struct AcceptFirstCompile<'a, T>(&'a mut Option<T>);

impl<'a, T> AcceptFirstCompile<'a, T> {
pub fn new(write: &'a mut Option<T>) -> Self {
Self(write)
}

pub fn submit(self, t: T) {
*self.0 = Some(t);
/// Accepts some value of `T` to be later returned by [`SpirvBuilder::watch()`].
pub fn submit(self, value: T) {
*self.0 = Some(value);
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/difftests/lib/src/scaffold/compute/wgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ where
#[cfg(target_os = "windows")]
dx12: wgpu::Dx12BackendOptions {
shader_compiler: wgpu::Dx12Compiler::StaticDxc,
..Default::default()
},
..Default::default()
},
Expand Down