Skip to content

Commit 3d142dd

Browse files
authored
Merge pull request #48 from lambda-sh/vmarcella/fixes-for-metal
Fixes for default platform detection
2 parents 7c064e9 + 278a09d commit 3d142dd

File tree

10 files changed

+62
-34
lines changed

10 files changed

+62
-34
lines changed

.github/workflows/compile_lambda_rs.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,32 @@ defaults:
1515

1616
jobs:
1717
build_and_test:
18-
name: Build lambda-rs on ${{ matrix.os }}.
18+
name: Build lambda-rs on ${{ matrix.os }} with features ${{ matrix.features }}.
1919
runs-on: ${{ matrix.os }}
2020
strategy:
2121
matrix:
22-
os: [ubuntu-latest, windows-latest, macos-latest]
23-
rustup-toolchain: ["stable"]
22+
include:
23+
- os: ubuntu-latest
24+
rustup-toolchain: "stable"
25+
features: "lambda/with-opengl"
26+
- os: ubuntu-latest
27+
rustup-toolchain: "stable"
28+
features: "lambda/with-vulkan"
29+
- os: windows-latest
30+
rustup-toolchain: "stable"
31+
features: "lambda/with-vulkan"
32+
- os: windows-latest
33+
rustup-toolchain: "stable"
34+
features: "lambda/with-dx11"
35+
- os: windows-latest
36+
rustup-toolchain: "stable"
37+
features: "lambda/with-dx12"
38+
- os: macos-latest
39+
rustup-toolchain: "stable"
40+
features: "lambda/with-opengl"
41+
- os: macos-latest
42+
rustup-toolchain: "stable"
43+
features: "lambda/with-metal"
2444

2545
steps:
2646
- name: Checkout Repository
@@ -47,7 +67,7 @@ jobs:
4767
rustup default ${{ matrix.rustup-toolchain }}
4868
4969
- name: Build Lambda & other default workspace members.
50-
run: cargo test --all
70+
run: cargo test --all --features ${{ matrix.features }} --no-default-features
5171

5272
- uses: actions/setup-ruby@v1
5373
- name: Send Webhook Notification for build status.

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/lambda-platform/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[package]
22
name = "lambda-platform"
3-
version = "0.1.0"
3+
version = "2023.1.25"
44
edition = "2021"
5+
resolver = "2"
56

67
[lib]
78
name = "lambda_platform"
@@ -39,14 +40,14 @@ gfx-with-dx12=["dep:gfx-backend-dx12"]
3940
crate-type = ["cdylib", "rlib"]
4041
incremental = true
4142

42-
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies.gfx-platform-backend]
43+
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies.gfx-backend-gl]
4344
package = "gfx-backend-gl"
4445
version = "=0.9.0"
4546

46-
[target.'cfg(all(target_os = "macos"))'.dependencies.gfx-platform-backend]
47+
[target.'cfg(all(target_os = "macos"))'.dependencies.gfx-backend-metal]
4748
package = "gfx-backend-metal"
4849
version = "=0.9.0"
4950

50-
[target.'cfg(all(windows))'.dependencies.gfx-platform-backend]
51+
[target.'cfg(all(windows))'.dependencies.gfx-backend-dx12]
5152
package = "gfx-backend-dx12"
5253
version = "=0.9.0"

crates/lambda-platform/src/gfx/api.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22
//! implementations to use.
33
44
cfg_if::cfg_if! {
5-
if #[cfg(feature = "gfx-with-gl")] {
6-
pub use gfx_backend_gl as RenderingAPI;
7-
} else if #[cfg(feature = "gfx-with-vulkan")] {
8-
pub use gfx_backend_vulkan as RenderingAPI;
9-
} else if #[cfg(feature = "gfx-with-metal")] {
10-
pub use gfx_backend_metal as RenderingAPI;
11-
} else if #[cfg(feature = "gfx-with-dx11")] {
12-
pub use gfx_backend_dx11 as RenderingAPI;
13-
} else if #[cfg(feature = "gfx-with-dx12")] {
5+
if #[cfg(feature = "gfx-with-gl")] {
6+
pub use gfx_backend_gl as RenderingAPI;
7+
} else if #[cfg(feature = "gfx-with-metal")] {
8+
pub use gfx_backend_metal as RenderingAPI;
9+
} else if #[cfg(feature = "gfx-with-vulkan")] {
10+
pub use gfx_backend_vulkan as RenderingAPI;
11+
} else if #[cfg(feature = "gfx-with-dx11")] {
12+
pub use gfx_backend_dx11 as RenderingAPI;
13+
} else if #[cfg(feature = "gfx-with-dx12")] {
14+
pub use gfx_backend_dx12 as RenderingAPI;
15+
} else if #[cfg(all(feature = "detect-platform", windows))] {
1416
pub use gfx_backend_dx12 as RenderingAPI;
15-
} else if #[cfg(feature = "detect-platform")] {
16-
pub use gfx_platform_backend as RenderingAPI;
17-
} else {}
17+
} else if #[cfg(all(feature = "detect-platform", target_os = "macos"))] {
18+
pub use gfx_backend_metal as RenderingAPI;
19+
} else if #[cfg(all(feature = "detect-platform", unix, not(target_os = "macos")))] {
20+
pub use gfx_backend_gl as RenderingAPI;
21+
} else {
22+
panic!("No supported GPU API found for the current platform.");
23+
}
1824
}

crates/lambda-platform/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod gfx;
2+
pub mod obj;
23
pub mod rand;
34
pub mod shaderc;
45
pub mod winit;
5-
pub mod obj;

lambda/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ name = "lambda"
1111
path = "src/lib.rs"
1212

1313
[dependencies]
14-
lambda-platform = { path = "../crates/lambda-platform", version = "0.1.0" }
14+
lambda-platform = { path = "../crates/lambda-platform" }
1515

1616
[dev-dependencies]
1717
cargo-audit = "0.16.0"
1818
mockall = "0.11.3"
1919

2020
[features]
21-
default = ["lambda-platform/detect-platform"]
21+
default=["lambda-platform/detect-platform"]
22+
detect-platform=["lambda-platform/detect-platform"]
2223
with-vulkan=["lambda-platform/gfx-with-vulkan"]
2324
with-opengl=["lambda-platform/gfx-with-opengl"]
2425
with-dx11=["lambda-platform/gfx-with-dx11"]

tools/lambda_rs_demo/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_rs_demo"
3-
version = "0.1.0"
3+
version = "2023.1.25"
44
edition = "2021"
55

66
[[bin]]
@@ -9,3 +9,6 @@ path = "src/main.rs"
99

1010
[dependencies]
1111
lambda = { path = "../../lambda" }
12+
13+
[features]
14+
default = ["lambda/detect-platform"]

tools/minimal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_rs_minimal"
3-
version = "0.1.0"
3+
version = "2023.1.25"
44
edition = "2021"
55

66
[[bin]]

tools/obj_loader/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ path = "src/main.rs"
99

1010
[dependencies]
1111
lambda = { path = "../../lambda" }
12-
lambda-args = { path = "../../crates/lambda-args" }
13-
14-
[features]
15-
default = ["lambda/with-vulkan"]
12+
lambda-args = { path = "../../crates/lambda-args" }

tools/triangles_demo/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda_rs_triangles"
3-
version = "0.1.0"
3+
version = "2023.1.25"
44
edition = "2021"
55

66
[[bin]]

0 commit comments

Comments
 (0)