Skip to content

Commit

Permalink
spirv-builder: force a single CGU (codegen-unit).
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 17, 2023
1 parent cbe922d commit b560a21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added ⭐
- [PR#1031](https://github.com/EmbarkStudios/rust-gpu/pull/1031) added `Components` generic parameter to `Image` type, allowing images to return lower dimensional vectors and even scalars from the sampling API

### Changed 🛠
- [PR#1031](https://github.com/EmbarkStudios/rust-gpu/pull/1031) Added `Components` generic parameter to `Image` type, allowing images to return lower dimensional vectors and even scalars from the sampling API.
- [PR#1035](https://github.com/EmbarkStudios/rust-gpu/pull/1035) reduced the number of CGUs ("codegen units") used by `spirv-builder` to just `1`
- [PR#1011](https://github.com/EmbarkStudios/rust-gpu/pull/1011) made `NonWritable` all read-only storage buffers (i.e. those typed `&T`, where `T` doesn't have interior mutability)
- [PR#1029](https://github.com/EmbarkStudios/rust-gpu/pull/1029) fixed SampledImage::sample() fns being unnecessarily marked as unsafe

Expand Down
10 changes: 10 additions & 0 deletions crates/spirv-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,16 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
join_checking_for_separators(rustflags, "\x1f"),
);

let profile_in_env_var = profile.replace('-', "_").to_ascii_uppercase();

// NOTE(eddyb) there's no parallelism to take advantage of multiple CGUs,
// and inter-CGU duplication can be wasteful, so this forces 1 CGU for now.
let num_cgus = 1;
cargo.env(
format!("CARGO_PROFILE_{profile_in_env_var}_CODEGEN_UNITS"),
num_cgus.to_string(),
);

let build = cargo
.stderr(Stdio::inherit())
.current_dir(&builder.path_to_crate)
Expand Down

0 comments on commit b560a21

Please sign in to comment.