restructure this multi-crate project to use Cargo's "workspace" feature

this solves an issue in the Nix build, where managing multiple
Cargo.lock files is otherwise tricky. it causes (or fails to fix?) an adjacent issue where
the spirv builder doesn't seem to have everything it needs vendored.
This commit is contained in:
2022-07-05 17:34:21 -07:00
parent d3cd12aa47
commit 5b99d30cda
64 changed files with 108 additions and 206 deletions

38
Cargo.lock generated
View File

@@ -1355,9 +1355,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "oorandom"
@@ -1462,9 +1462,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "plotters"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a"
checksum = "9428003b84df1496fb9d6eeee9c5f8145cb41ca375eb0dad204328888832811f"
dependencies = [
"num-traits",
"plotters-backend",
@@ -1475,15 +1475,15 @@ dependencies = [
[[package]]
name = "plotters-backend"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c"
checksum = "1c89e57ae773e34419b0f62d68c1934a97ac0637f36741dfde4efb88aaf711a0"
[[package]]
name = "plotters-svg"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9"
checksum = "e0918736323d1baff32ee0eade54984f6f201ad7e97d5cfb5d6ab4a358529615"
dependencies = [
"plotters-backend",
]
@@ -1696,9 +1696,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.6"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
dependencies = [
"aho-corasick",
"memchr",
@@ -1713,9 +1713,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "regex-syntax"
version = "0.6.26"
version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "renderdoc-sys"
@@ -2031,6 +2031,20 @@ name = "spirv-types"
version = "0.4.0-alpha.12"
source = "git+https://github.com/EmbarkStudios/rust-gpu#0866cf591a7fdbbd15bdb3468e192bb9b6189fd0"
[[package]]
name = "spirv_backend"
version = "0.1.0"
dependencies = [
"spirv-std",
]
[[package]]
name = "spirv_backend_builder"
version = "0.1.0"
dependencies = [
"spirv-builder",
]
[[package]]
name = "spirv_backend_lib"
version = "0.1.0"

View File

@@ -1,65 +1,12 @@
[package]
name = "coremem"
version = "0.1.0"
authors = ["Colin <colin@uninsane.org>"]
edition = "2021"
[lib]
crate-type = ["lib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bincode = "1.3" # MIT
common_macros = "0.1" # MIT or Apache 2.0
crossterm = "0.24" # MIT
csv = "1.1" # MIT or Unlicense
dashmap = "5.3" # MIT
decorum = "0.3" # MIT
dyn-clone = "1.0" # MIT or Apache 2.0
enum_dispatch = "0.3" # MIT or Apache 2.0
env_logger = "0.9" # MIT or Apache 2.0
float_eq = "1.0" # MIT or Apache 2.0
font8x8 = "0.3" # MIT
futures = "0.3" # MIT or Apache 2.0
image = "0.24" # MIT
imageproc = "0.23" # MIT
indexmap = "1.9" # MIT or Apache 2.0
itertools = "0.10" # MIT or Apache 2.0
lazy_static = "1.4" # MIT or Apache 2.0
log = "0.4" # MIT or Apache 2.0
lru = "0.7" # MIT
more-asserts = "0.3" # CC0-1.0
natord = "1.0" # MIT
ndarray = { version = "0.15", features = ["rayon", "serde"] } # MIT or Apache 2.0
num = "0.4" # MIT or Apache 2.0
# plotly = { version = "0.6", features = ["kaleido", "plotly_ndarray"], path = "../plotly/plotly" }
rand = "0.8" # MIT or Apache 2.0
rayon = "1.5" # MIT or Apache 2.0
serde = "1.0" # MIT or Apache 2.0
structopt = "0.3" # MIT or Apache 2.0
threadpool = "1.8" # MIT or Apache 2.0
typetag = "0.2" # MIT or Apache 2.0
y4m = "0.7" # MIT
wgpu = "0.12"
# wgpu = { version = "0.12", features = ["spirv"] } # MIT or Apache 2.0
# TODO: update to 0.13
# wgpu = { version = "0.13", features = ["spirv", "vulkan-portability"] } # MIT or Apache 2.0
# spirv-* is MIT or Apache 2.0
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", features = ["use-compiled-tools"] }
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu" }
spirv-std-macros = { git = "https://github.com/EmbarkStudios/rust-gpu" }
spirv_backend_lib = { path = "src/sim/spirv/spirv_backend_lib" }
spirv_backend_runner = { path = "src/sim/spirv/spirv_backend_runner" }
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "driver"
harness = false
[workspace]
resolver = "2"
members = [
"crates/coremem",
"crates/spirv_backend",
"crates/spirv_backend_builder",
"crates/spirv_backend_lib",
"crates/spirv_backend_runner",
]
# [profile.release]
# LTO gives 3% perf boost

62
crates/coremem/Cargo.toml Normal file
View File

@@ -0,0 +1,62 @@
[package]
name = "coremem"
version = "0.1.0"
authors = ["Colin <colin@uninsane.org>"]
edition = "2021"
[lib]
crate-type = ["lib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bincode = "1.3" # MIT
common_macros = "0.1" # MIT or Apache 2.0
crossterm = "0.24" # MIT
csv = "1.1" # MIT or Unlicense
dashmap = "5.3" # MIT
decorum = "0.3" # MIT
dyn-clone = "1.0" # MIT or Apache 2.0
enum_dispatch = "0.3" # MIT or Apache 2.0
env_logger = "0.9" # MIT or Apache 2.0
float_eq = "1.0" # MIT or Apache 2.0
font8x8 = "0.3" # MIT
futures = "0.3" # MIT or Apache 2.0
image = "0.24" # MIT
imageproc = "0.23" # MIT
indexmap = "1.9" # MIT or Apache 2.0
itertools = "0.10" # MIT or Apache 2.0
lazy_static = "1.4" # MIT or Apache 2.0
log = "0.4" # MIT or Apache 2.0
lru = "0.7" # MIT
more-asserts = "0.3" # CC0-1.0
natord = "1.0" # MIT
ndarray = { version = "0.15", features = ["rayon", "serde"] } # MIT or Apache 2.0
num = "0.4" # MIT or Apache 2.0
# plotly = { version = "0.6", features = ["kaleido", "plotly_ndarray"], path = "../plotly/plotly" }
rand = "0.8" # MIT or Apache 2.0
rayon = "1.5" # MIT or Apache 2.0
serde = "1.0" # MIT or Apache 2.0
structopt = "0.3" # MIT or Apache 2.0
threadpool = "1.8" # MIT or Apache 2.0
typetag = "0.2" # MIT or Apache 2.0
y4m = "0.7" # MIT
wgpu = "0.12"
# wgpu = { version = "0.12", features = ["spirv"] } # MIT or Apache 2.0
# TODO: update to 0.13
# wgpu = { version = "0.13", features = ["spirv", "vulkan-portability"] } # MIT or Apache 2.0
# spirv-* is MIT or Apache 2.0
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", features = ["use-compiled-tools"] }
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu" }
spirv-std-macros = { git = "https://github.com/EmbarkStudios/rust-gpu" }
spirv_backend_lib = { path = "../spirv_backend_lib" }
spirv_backend_runner = { path = "../spirv_backend_runner" }
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "driver"
harness = false

View File

@@ -5,5 +5,4 @@ authors = ["Colin <colin@uninsane.org>"]
edition = "2021"
[dependencies]
log = "0.4"
spirv-builder = { git = "https://github.com/EmbarkStudios/rust-gpu", features = ["use-compiled-tools"] }

View File

@@ -1,5 +1,4 @@
use spirv_builder::{Capability, MetadataPrintout, SpirvBuilder};
use log::info;
use std::env;
use std::error::Error;
use std::path::PathBuf;
@@ -11,7 +10,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.iter()
.copied()
.collect::<PathBuf>();
info!("get_shader: constructing builder");
println!("get_shader: constructing builder");
let builder = SpirvBuilder::new(crate_path, "spirv-unknown-vulkan1.1")
//let builder = SpirvBuilder::new(crate_path, "spirv-unknown-spv1.3")
.print_metadata(MetadataPrintout::None)
@@ -21,10 +20,10 @@ fn main() -> Result<(), Box<dyn Error>> {
// .capability(Capability::GenericPointer)
;
info!("get_shader: building");
println!("get_shader: building");
let initial_result = builder.build()?;
let module_path = initial_result.module.unwrap_single();
info!("get_shader: built: {:?}", module_path);
println!("get_shader: built: {:?}", module_path);
Ok(())
}

View File

@@ -12,22 +12,13 @@ fn main() -> Result<(), Box<dyn Error>> {
let profile = env::var("PROFILE").unwrap();
println!("cargo:rustc-env=PROFILE={}", profile);
let mut dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
println!("OUT_DIR: {:?}", dir);
// recover the directory from which this was invoked
assert!(
dir.ends_with("out")
&& dir.pop()
&& dir.pop()
&& dir.ends_with("build")
&& dir.pop()
&& dir.ends_with(profile)
&& dir.pop()
);
while !dir.ends_with("target") {
dir.pop();
}
assert!(dir.pop());
// recover the toplevel directory
assert!(
dir.ends_with("target")
&& dir.pop()
);
if dir.ends_with("spirv_backend_runner") {
// being run from this dir
assert!(
@@ -42,7 +33,7 @@ fn main() -> Result<(), Box<dyn Error>> {
} // else already at the top-level dir
let target_dir = dir.join("target/spirv_backend_builder");
let manifest_path = dir.join("src/sim/spirv/spirv_backend_builder/Cargo.toml");
let manifest_path = dir.join("crates/spirv_backend_builder/Cargo.toml");
println!("target_dir: {:?}", target_dir);
println!("manifest_path: {:?}", manifest_path);

View File

@@ -3,6 +3,6 @@
pub fn spirv_module() -> &'static [u8] {
// we specifically include the bytes into this binary, for ease of packaging (v.s. attempting
// to locate the compiled result at runtime).
include_bytes!("../../../../../target/spirv-builder/spirv-unknown-vulkan1.1/release/deps/spirv_backend.spv.dir/module")
include_bytes!("../../../target/spirv-builder/spirv-unknown-vulkan1.1/release/deps/spirv_backend.spv.dir/module")
}

View File

@@ -33,7 +33,7 @@
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"rustc_codegen_spirv-0.4.0-alpha.12" = "sha256-T0WRXsCgPW6/mygmCfZ3ee1xnigfaG4YuDjIb/DZ0t8=";
"rustc_codegen_spirv-0.4.0-alpha.12" = "sha256-cZTUuyvNBuunK60r6vWVqqlovTXGpZZphBU8VP6tjsU=";
};
};
# rgpu tests expectedly fail due to a lack of spirv adapter exposed to the builder.

View File

@@ -1,110 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "glam"
version = "0.20.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f43e957e744be03f5801a55472f593d43fabdebf25a4585db250f04d86b1675f"
dependencies = [
"num-traits",
]
[[package]]
name = "libm"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db"
[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"autocfg",
"libm",
]
[[package]]
name = "proc-macro2"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
dependencies = [
"proc-macro2",
]
[[package]]
name = "spirv-std"
version = "0.4.0-alpha.12"
source = "git+https://github.com/EmbarkStudios/rust-gpu#0866cf591a7fdbbd15bdb3468e192bb9b6189fd0"
dependencies = [
"bitflags",
"glam",
"num-traits",
"spirv-std-macros",
"spirv-types",
]
[[package]]
name = "spirv-std-macros"
version = "0.4.0-alpha.12"
source = "git+https://github.com/EmbarkStudios/rust-gpu#0866cf591a7fdbbd15bdb3468e192bb9b6189fd0"
dependencies = [
"proc-macro2",
"quote",
"spirv-types",
"syn",
]
[[package]]
name = "spirv-types"
version = "0.4.0-alpha.12"
source = "git+https://github.com/EmbarkStudios/rust-gpu#0866cf591a7fdbbd15bdb3468e192bb9b6189fd0"
[[package]]
name = "spirv_backend"
version = "0.1.0"
dependencies = [
"spirv-std",
]
[[package]]
name = "syn"
version = "1.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"