Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ce14ac3
Initial work for macro
inner-daemons Sep 12, 2025
d974548
More work for macro that wasn't commited?
inner-daemons Sep 12, 2025
c1f9549
Worked on macro a lot
inner-daemons Sep 12, 2025
95491ce
Removed shader stage parameter from the thing
inner-daemons Sep 12, 2025
9d52aca
Updated macro slightly
inner-daemons Sep 12, 2025
80509c6
Updated some stuff
inner-daemons Sep 12, 2025
59db4c7
Made more stuff build properly
inner-daemons Sep 12, 2025
1dfc2b2
Refactored slightly
inner-daemons Sep 12, 2025
f7ecc4c
Tried to fix a compile fail
inner-daemons Sep 12, 2025
930b35b
Merge branch 'trunk' into precompiled-shaders-macro
inner-daemons Sep 12, 2025
309919a
Added precompile test
inner-daemons Sep 12, 2025
bac4a48
Added more related macros
inner-daemons Sep 12, 2025
12d5e26
Worked more on the testing and such. Currently glsl include is broken…
inner-daemons Sep 12, 2025
a28790d
Added comment explaining why compiled spv is in tree
inner-daemons Sep 12, 2025
1a1d563
Made entry point specific to each backend in passthrough
inner-daemons Sep 12, 2025
2f0293d
Enhanced macro slightly
inner-daemons Sep 12, 2025
2229f05
Worked a little more
inner-daemons Sep 12, 2025
11c9bca
Fixed vulkan backend y flip
inner-daemons Sep 12, 2025
662c76c
Allowed precompiling dxil (will break everything again)
inner-daemons Sep 12, 2025
9d45fd9
Added a comment explaining why entry point name differs by shader lan…
inner-daemons Sep 12, 2025
78250d3
Tried to fix various compile errors/typos
inner-daemons Sep 12, 2025
9c8988e
Added changelog entry
inner-daemons Sep 15, 2025
f12f60f
Updated changelog entry again for the spirv passthrough change
inner-daemons Sep 15, 2025
d1f1675
Refactored to allow compilation guards
inner-daemons Sep 15, 2025
ed9934b
Reformatted cargo.toml
inner-daemons Sep 15, 2025
be1504d
Tried updating syn and quote to see if it fixes anything
inner-daemons Sep 15, 2025
038fb11
Merge branch 'trunk' into precompiled-shaders-macro
inner-daemons Sep 15, 2025
b66e991
Attempted to fix windows compilation
inner-daemons Sep 15, 2025
5c03032
This time I think DXC compilation should work, as I actually tested it
inner-daemons Sep 15, 2025
6b34506
Fixed stupid typo that would've broken it
inner-daemons Sep 15, 2025
0915522
Added typo to ignore list
inner-daemons Sep 15, 2025
fdfa221
Updated Fo typo thing
inner-daemons Sep 15, 2025
cf98e44
Actually fixed typos this time
inner-daemons Sep 15, 2025
507f3d4
Undid bump to syn/quote that didn't fix MSRV test
inner-daemons Sep 15, 2025
d954714
Tried to fix MSRV test
inner-daemons Sep 15, 2025
f586710
Removed dxil compilation from example so that clippy won't complain w…
inner-daemons Sep 15, 2025
10f31e0
Tried to make clippy happy
inner-daemons Sep 15, 2025
9281184
Fixed dependency tests
inner-daemons Sep 15, 2025
9e41b07
Updated deps to reflect #8246
inner-daemons Sep 21, 2025
f2a3620
Merge branch 'trunk' into precompiled-shaders-macro
inner-daemons Sep 22, 2025
113a75e
Update wgpu-precompile-macro/src/lib.rs
inner-daemons Sep 24, 2025
c860d50
Merge branch 'trunk' into precompiled-shaders-macro
inner-daemons Sep 24, 2025
5b9616e
Merge branch 'trunk' into precompiled-shaders-macro
inner-daemons Sep 24, 2025
6ea7ea7
I don't even understand what happened here
inner-daemons Sep 25, 2025
a0f613b
Now removes temporary folder regardless of crashing/etc
inner-daemons Sep 25, 2025
c01e505
Update wgpu-precompile-macro/src/lib.rs
inner-daemons Sep 25, 2025
fc4e1c7
Merge branch 'trunk' into precompiled-shaders-macro
inner-daemons Sep 25, 2025
bedc327
Updated to latest dx12 mesh shader changes
inner-daemons Sep 25, 2025
dff0697
Tried to improve error messages for dxc precompiling
inner-daemons Sep 25, 2025
8344a81
Made dependency tests also check build deps
inner-daemons Sep 25, 2025
537b32e
Fixed tests sorta (broke mesh shader test most likely due to requirin…
inner-daemons Sep 25, 2025
b06ce5e
Other part to last commit
inner-daemons Sep 25, 2025
1675170
Initial work on new shaders crate that will be used by wgpu-hal, the …
inner-daemons Sep 25, 2025
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
19 changes: 15 additions & 4 deletions wgpu-precompile-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ impl Parse for PrecompileDxilArgs {
}
}

struct TempFolder {
path: PathBuf,
}
impl Drop for TempFolder {
fn drop(&mut self) {
std::fs::remove_dir_all(&self.path).expect("Failed to remove temporary folder");
}
}

/// This is so we can conditionally hook into DXC depending on the target, which must be configured via #\[cfg] within the main program.
/// Proc macros don't directly have access to the target configuration. Invoking naga unnecessarily shouldn't be *too* major, but
/// compiling to macOS shouldn't require dxc be present.
Expand All @@ -213,13 +222,17 @@ pub fn precompile_hlsl_to_dxil(input: TokenStream) -> TokenStream {
.to_string(),
);
std::fs::create_dir(&temporary_folder_location).expect("Failed to create temporary directory");
// Drop guard essentially
let tempoary_folder = TempFolder {
path: temporary_folder_location,
};

// The naming matters for DXIL debug info. We don't want to give it a name that seems like something the
// user might've specified, as that could cause confusion.
let input_file = temporary_folder_location.join("__wgpu_inline.hlsl");
let input_file = tempoary_folder.path.join("__wgpu_inline.hlsl");
std::fs::write(&input_file, args.hlsl_code.as_bytes())
.expect("Failed to write to HLSL input file");
let temporary_file_location = temporary_folder_location.join("file.dxil");
let temporary_file_location = tempoary_folder.path.join("file.dxil");
let output = std::process::Command::new("dxc")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely need to make sure the errors when external tools aren't found are very good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the error messages slightly. You probably have a way you'd prefer to do it though

.args([
"-T",
Expand All @@ -238,8 +251,6 @@ pub fn precompile_hlsl_to_dxil(input: TokenStream) -> TokenStream {
panic!("DXC failed:\n{}", String::from_utf8(output.stderr).unwrap());
}
let dxil = std::fs::read(temporary_file_location).expect("Failed to read DXC output file");
std::fs::remove_dir_all(temporary_folder_location)
.expect("Failed to remove temporary directory");
quote! {
&[#(#dxil),*]
}
Expand Down
Loading