Skip to content

Commit b0f1fa6

Browse files
cwfitzgeraldguusw
andauthored
Add VisionOS Support (#6888)
* Add visionos support * Use `target_vendor = "apple"` * Fixes * Build VisionOS * Gah * Bleh * Typos --------- Co-authored-by: Guus Waals <_@guusw.nl>
1 parent 1aabf22 commit b0f1fa6

File tree

20 files changed

+78
-46
lines changed

20 files changed

+78
-46
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ env:
3434
# We sometimes need nightly to use special things in CI.
3535
#
3636
# In order to prevent CI regressions, we pin the nightly version.
37-
NIGHTLY_VERSION: "nightly-2024-10-10"
37+
NIGHTLY_VERSION: "nightly-2024-10-17"
3838
# This is the MSRV used by `wgpu` itself and all surrounding infrastructure.
3939
REPO_MSRV: "1.83"
4040
# This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates,
@@ -111,6 +111,14 @@ jobs:
111111
target: aarch64-apple-ios
112112
kind: native
113113

114+
# VisionOS
115+
- name: VisionOS aarch64
116+
os: macos-14
117+
target: aarch64-apple-visionos
118+
kind: wgpu-only
119+
toolchain: nightly
120+
extra-flags: -Zbuild-std
121+
114122
# Linux
115123
- name: Linux x86_64
116124
os: ubuntu-22.04
@@ -137,7 +145,7 @@ jobs:
137145
- name: Emscripten
138146
os: ubuntu-22.04
139147
target: wasm32-unknown-emscripten
140-
kind: em
148+
kind: wgpu-only
141149

142150
name: Clippy ${{ matrix.name }}
143151
runs-on: ${{ matrix.os }}
@@ -146,12 +154,31 @@ jobs:
146154
- name: checkout repo
147155
uses: actions/checkout@v4
148156

149-
- name: Install Repo MSRV toolchain
157+
- name: Install Toolchain (Repo MSRV)
158+
if: matrix.toolchain != 'nightly'
150159
run: |
151-
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy --target ${{ matrix.target }}
160+
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy
161+
rustup target add ${{ matrix.target }} --toolchain ${{ env.REPO_MSRV }}
152162
rustup override set ${{ env.REPO_MSRV }}
153163
cargo -V
154164
165+
# In order to build on platforms that require a nightly toolchain, we install stable as expected,
166+
# add the rust-src component, then tell stable to consider itself nightly by setting RUSTC_BOOTSTRAP=1.
167+
#
168+
# This is not formally "correct" thing to do, but it saves significant maintainer burden. If we were to
169+
# use a proper nightly toolchain we would have to manually find a date that works. Even with a date that is
170+
# carefully coordinated with the version of stable we are using, there are often mismatches of clippy lints
171+
# between nightly and stable. This is a real mess. By using RUSTC_BOOTSTRAP=1, we get access to all the nice
172+
# nightly features without needing to go through the hassle of maintaining a nightly toolchain.
173+
#
174+
# RUSTC_BOOTSTRAP=1 is how the rust project builds itself when bootstrapping the compiler, so while not "stable"
175+
# it has been around for many years and don't anticipate it going away any time soon.
176+
- name: Install Toolchain (Repo MSRV - Pseudo Nightly)
177+
if: matrix.toolchain == 'nightly'
178+
run: |
179+
rustup toolchain install ${{ env.REPO_MSRV }} --no-self-update --profile=minimal --component clippy,rust-src
180+
echo "RUSTC_BOOTSTRAP=1" >> "$GITHUB_ENV"
181+
155182
- name: disable debug
156183
shell: bash
157184
run: |
@@ -183,50 +210,53 @@ jobs:
183210
# the android sdk doesn't use the conventional name for ar, so explicitly set it.
184211
echo "AR_aarch64_linux_android=llvm-ar" >> "$GITHUB_ENV"
185212
213+
# Building for wasm32 requires a series of specific tests for the WebGPU backend.
186214
- name: check web
187215
if: matrix.kind == 'web'
188216
shell: bash
189217
run: |
190218
set -e
191219
192220
# build for WebGPU
193-
cargo clippy --target ${{ matrix.target }} --tests --features glsl,spirv,fragile-send-sync-non-atomic-wasm
194-
cargo clippy --target ${{ matrix.target }} --tests --features glsl,spirv
195-
cargo doc --target ${{ matrix.target }} --no-deps --features glsl,spirv
221+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,spirv,fragile-send-sync-non-atomic-wasm
222+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --features glsl,spirv
223+
cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-deps --features glsl,spirv
196224
197225
# all features
198-
cargo clippy --target ${{ matrix.target }} --tests --all-features
199-
cargo doc --target ${{ matrix.target }} --no-deps --all-features
226+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --all-features
227+
cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-deps --all-features
200228
201-
- name: check em
202-
if: matrix.kind == 'em'
229+
# Building for platforms where the tests do not compile.
230+
- name: check wgpu only
231+
if: matrix.kind == 'wgpu-only'
203232
shell: bash
204233
run: |
205234
set -e
206235
207-
# build for Emscripten
208-
cargo clippy --target ${{ matrix.target }} -p wgpu -p wgpu-hal --no-default-features
236+
# check with no features
237+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu -p wgpu-hal --no-default-features
209238
210239
# Don't check samples since we use winit in our samples which has dropped support for Emscripten.
211240
212-
# all features
213-
cargo clippy --target ${{ matrix.target }} -p wgpu-hal --all-features
214-
cargo clippy --target ${{ matrix.target }} -p wgpu --all-features
241+
# Check with all features.
242+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu-hal --all-features
243+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} -p wgpu --all-features
215244
245+
# Building for native platforms with standard tests.
216246
- name: check native
217247
if: matrix.kind == 'native'
218248
shell: bash
219249
run: |
220250
set -e
221251
222252
# check with no features
223-
cargo clippy --target ${{ matrix.target }} --no-default-features
253+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --no-default-features
224254
225255
# Check with all features.
226-
cargo clippy --target ${{ matrix.target }} --tests --benches --all-features
256+
cargo clippy --target ${{ matrix.target }} ${{ matrix.extra-flags }} --tests --benches --all-features
227257
228258
# build docs
229-
cargo doc --target ${{ matrix.target }} --all-features --no-deps
259+
cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} --all-features --no-deps
230260
231261
- name: check private item docs
232262
if: matrix.kind == 'native'
@@ -235,7 +265,7 @@ jobs:
235265
set -e
236266
237267
# wgpu_core package
238-
cargo doc --target ${{ matrix.target }} \
268+
cargo doc --target ${{ matrix.target }} ${{ matrix.extra-flags }} \
239269
--package wgpu-core \
240270
--package wgpu-hal \
241271
--package naga \

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ By @wumpf in [#6849](https://github.com/gfx-rs/wgpu/pull/6849).
162162
- Move raytracing alignments into HAL instead of in core. By @Vecvec in [#6563](https://github.com/gfx-rs/wgpu/pull/6563).
163163
- Allow for statically linking DXC rather than including separate `.dll` files. By @DouglasDwyer in [#6574](https://github.com/gfx-rs/wgpu/pull/6574).
164164
- `DeviceType` and `AdapterInfo` now impl `Hash` by @cwfitzgerald in [#6868](https://github.com/gfx-rs/wgpu/pull/6868)
165+
- Add build support for Apple Vision Pro. By @guusw in [#6611](https://github.com/gfx-rs/wgpu/pull/6611).
165166
- Add `wgsl_language_features` for obtaining available WGSL language feature by @sagudev in [#6814](https://github.com/gfx-rs/wgpu/pull/6814)
166167

167168
##### Vulkan
@@ -171,6 +172,7 @@ By @wumpf in [#6849](https://github.com/gfx-rs/wgpu/pull/6849).
171172
##### Metal
172173

173174
- Allow using some 32-bit floating-point atomic operations (load, store, add, sub, exchange) in shaders. It requires Metal 3.0+ with Apple 7, 8, 9 or Mac 2. By @AsherJingkongChen in [#6234](https://github.com/gfx-rs/wgpu/pull/6234).
175+
- Add build support for Apple Vision Pro. By @guusw in [#6611](https://github.com/gfx-rs/wgpu/pull/6611).
174176

175177
#### Changes
176178

deno_webgpu/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ features = [
3636
]
3737

3838
# We want the wgpu-core Metal backend on macOS and iOS.
39-
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgpu-core]
39+
[target.'cfg(target_vendor = "apple")'.dependencies.wgpu-core]
4040
workspace = true
4141
features = ["metal"]
4242

naga/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn main() {
33
dot_out: { feature = "dot-out" },
44
glsl_out: { feature = "glsl-out" },
55
hlsl_out: { any(feature = "hlsl-out", all(target_os = "windows", feature = "hlsl-out-if-target-windows")) },
6-
msl_out: { any(feature = "msl-out", all(any(target_os = "ios", target_os = "macos"), feature = "msl-out-if-target-apple")) },
6+
msl_out: { any(feature = "msl-out", all(target_vendor = "apple", feature = "msl-out-if-target-apple")) },
77
spv_out: { feature = "spv-out" },
88
wgsl_out: { feature = "wgsl-out" },
99
}

naga/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ arbitrary = { version = "1.4.1", features = ["derive"] }
1515
# See https://github.com/rust-fuzz/libfuzzer/issues/126
1616
libfuzzer-sys = ">0.4.0,<=0.4.7"
1717

18-
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios")))'.dependencies.naga]
18+
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))'.dependencies.naga]
1919
path = ".."
2020
version = "23.0.0"
2121
features = ["arbitrary", "spv-in", "wgsl-in", "glsl-in"]

naga/xtask/src/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn collect_validation_jobs(jobs: &mut Vec<Job>, cmd: ValidateSubcommand) -> anyh
150150
| ValidateSubcommand::Spirv
151151
| ValidateSubcommand::Glsl
152152
| ValidateSubcommand::Dot => true,
153-
ValidateSubcommand::Metal => cfg!(any(target_os = "macos", target_os = "ios")),
153+
ValidateSubcommand::Metal => cfg!(target_vendor = "apple"),
154154
// The FXC compiler is only available on Windows.
155155
//
156156
// The DXC compiler can be built and run on any platform,

wgpu-core/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
webgl: { all(target_arch = "wasm32", not(target_os = "emscripten"), gles) },
88
dx12: { all(target_os = "windows", feature = "dx12") },
99
gles: { all(feature = "gles") },
10-
metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") },
10+
metal: { all(target_vendor = "apple", feature = "metal") },
1111
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") }
1212
}
1313
}

wgpu-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![cfg_attr(
1111
all(
1212
not(all(feature = "vulkan", not(target_arch = "wasm32"))),
13-
not(all(feature = "metal", any(target_os = "macos", target_os = "ios"))),
13+
not(all(feature = "metal", any(target_vendor = "apple"))),
1414
not(all(feature = "dx12", windows)),
1515
not(feature = "gles"),
1616
),

wgpu-hal/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ glutin_wgl_sys = { workspace = true, optional = true }
177177
[target.'cfg(all(windows, not(target_arch = "aarch64")))'.dependencies]
178178
mach-dxcompiler-rs = { workspace = true, optional = true }
179179

180-
[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
180+
[target.'cfg(target_vendor = "apple")'.dependencies]
181181
# backend: Metal
182182
block = { workspace = true, optional = true }
183183

@@ -221,7 +221,7 @@ env_logger.workspace = true
221221
glam.workspace = true # for ray-traced-triangle example
222222
winit.workspace = true # for "halmark" example
223223

224-
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios")))'.dev-dependencies]
224+
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))'.dev-dependencies]
225225
glutin-winit = { workspace = true, features = [
226226
"egl",
227227
"wgl",

wgpu-hal/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99
Emscripten: { all(target_os = "emscripten", gles) },
1010
dx12: { all(target_os = "windows", feature = "dx12") },
1111
gles: { all(feature = "gles") },
12-
metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") },
12+
metal: { all(target_vendor = "apple", feature = "metal") },
1313
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") },
1414
// ⚠️ Keep in sync with target.cfg() definition in Cargo.toml and cfg_alias in `wgpu` crate ⚠️
1515
static_dxc: { all(target_os = "windows", feature = "static-dxc", not(target_arch = "aarch64")) }

0 commit comments

Comments
 (0)