Skip to content
Open
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
16 changes: 6 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[workspace]
members = [
"crates/minislang",
"crates/slang-hal",
"crates/slang-hal-derive",
]
members = ["crates/minislang", "crates/slang-hal", "crates/slang-hal-derive"]
resolver = "2"

[workspace.dependencies]
Expand All @@ -13,9 +9,8 @@ anyhow = "1"
async-channel = "2"
thiserror = "2"
futures = "0.3"

shader-slang = "0.1"
shader-slang-sys = "0.1"
shader-slang = { git = "https://github.com/Vrixyz/slang-rs.git", branch = "static-build", default-features = false }
shader-slang-sys = { git = "https://github.com/Vrixyz/slang-rs.git", branch = "static-build", default-features = false }

# TODO: make the wgpu dependency optional too (all backends should be optional but with
# wgpu enabled by default).
Expand All @@ -24,12 +19,13 @@ encase = "0.12"

[workspace.lints]
rust.unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(feature, values("dim2", "dim3"))'
'cfg(feature, values("dim2", "dim3"))',
] }

[profile.release]
opt-level = 'z'

[patch.crates-io]
#encase = { path = "../encase" }
#shader-slang = { path = "../slang-rs" }
#shader-slang = { path = "../slang-rs" }
shader-slang = { git = "https://github.com/Vrixyz/slang-rs.git", branch = "static-build" }
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ In order to compile and run any slang project, be sure to define the `SLANG_DIR`
2. Unzip the downloaded directory, and use its path as value to the `SLANG_DIR` environment variable: `SLANG_DIR=/path/to/slang`.
Note that the variable must point to the root of the slang installation (i.e. the directory that contains `bin` and `lib`).
We recommend adding that as a system-wide environment variables so that it also becomes available to your IDE.
3. Linking statically requires you to compile with `--no-default features --features slang-static`, and an additional environment variable, check out https://github.com/FloatyMonkey/slang-rs/pull/25 for more info.

### Supported backends

Expand Down
5 changes: 5 additions & 0 deletions crates/minislang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ version = "0.1.0"
edition = "2024"
license = "MIT OR Apache-2.0"

[features]
default = ["slang-static"]
slang-static = ["shader-slang/static"]
slang-dynamic = ["shader-slang/dynamic"]

[dependencies]
shader-slang = { workspace = true }
shader-slang-sys = { workspace = true }
Expand Down
4 changes: 1 addition & 3 deletions crates/minislang/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ impl SlangCompiler {

let entry_points: Vec<_> = module
.entry_points()
.filter(|e| {
entry_point.is_none() || Some(e.function_reflection().name()) == entry_point
})
.filter(|e| entry_point.is_none() || e.function_reflection().name() == entry_point)
.map(|e| e.downcast().clone())
.collect();
let program = session
Expand Down
19 changes: 13 additions & 6 deletions crates/slang-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ edition = "2024"
license = "MIT OR Apache-2.0"

[features]
default = ["slang-dynamic"]
derive = ["slang-hal-derive"]
cuda = ["cudarc"]
cublas = [ "cudarc?/cublas"]
cublas = ["cudarc?/cublas"]
slang-static = ["minislang/slang-static"]
slang-dynamic = ["minislang/slang-dynamic"]

[dependencies]
nalgebra = { workspace = true }
Expand All @@ -25,17 +28,21 @@ futures = { workspace = true }
async-trait = "0.1"
include_dir = "0.7"

minislang = { version = "0.1", path = "../minislang" }
minislang = { version = "0.1", path = "../minislang", default-features = false }
slang-hal-derive = { version = "0.1", path = "../slang-hal-derive", optional = true }
dashmap = "5"
regex = "1"


# For test_shader_compilation
paste = "1"

# CUDA runtime
cudarc = { version = "0.16", default-features = false, features = ["std", "driver", "dynamic-loading", "cuda-version-from-build-system"], optional = true }
cudarc = { version = "0.16", default-features = false, features = [
"std",
"driver",
"dynamic-loading",
"cuda-version-from-build-system",
], optional = true }
log = "0.4.27"

[dev-dependencies]
Expand All @@ -44,7 +51,7 @@ futures-test = "0.3"
serial_test = "3"
approx = "0.5"
async-std = { version = "1", features = ["attributes"] }
slang-hal = { path = ".", features = ["derive"] }
slang-hal = { path = ".", features = ["derive"], default-features = false }

[build-dependencies]
dircpy = "0.3"
dircpy = "0.3"
5 changes: 4 additions & 1 deletion crates/slang-hal/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::env;
use std::path::Path;

// Automatically copy the dynamic libraries from the slang dir to the target dir.
// When not linking statically: automatically copy the dynamic libraries from the slang dir to the target dir.
fn main() {
if cfg!(feature = "slang-static") {
return;
}
println!("cargo:rerun-if-env-changed=SLANG_LIB_DIR");

let lib_dir = if let Ok(dir) = env::var("SLANG_LIB_DIR") {
Expand Down
2 changes: 1 addition & 1 deletion crates/slang-hal/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<B: Backend> GpuFunction<B> {
buffers.push((
param_var
.name()
// .expect("unnamed parameters not supported yet")
.expect("unnamed parameters not supported yet")
.to_string(),
binding,
));
Expand Down
Loading