Skip to content

Commit 5481089

Browse files
committed
Add visionos support
1 parent c22c062 commit 5481089

File tree

24 files changed

+32
-31
lines changed

24 files changed

+32
-31
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
105105

106106
- Return submission index in `map_async` and `on_submitted_work_done` to track down completion of async callbacks. By @eliemichel in [#6360](https://github.com/gfx-rs/wgpu/pull/6360).
107107
- Move raytracing alignments into HAL instead of in core. By @Vecvec in [#6563](https://github.com/gfx-rs/wgpu/pull/6563).
108+
- Add build support for Apple Vision Pro. By @guusw in [#6611](https://github.com/gfx-rs/wgpu/pull/6611).
108109

109110
### Changes
110111

deno_webgpu/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ features = [
3535
]
3636

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

naga/build.rs

+1-1
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(any(target_os = "ios", target_os = "visionos", target_os = "macos"), feature = "msl-out-if-target-apple")) },
77
spv_out: { feature = "spv-out" },
88
wgsl_out: { feature = "wgsl-out" },
99
}

naga/fuzz/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ license = "MIT OR Apache-2.0"
99
[package.metadata]
1010
cargo-fuzz = true
1111

12-
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios")))'.dependencies]
12+
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))'.dependencies]
1313
arbitrary = { version = "1.3.2", features = ["derive"] }
1414
libfuzzer-sys = "0.4"
1515

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

naga/fuzz/fuzz_targets/glsl_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_main]
2-
#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))]
2+
#[cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))]
33
mod fuzz {
44
use arbitrary::Arbitrary;
55
use libfuzzer_sys::fuzz_target;

naga/fuzz/fuzz_targets/ir.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_main]
2-
#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))]
2+
#[cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))]
33
mod fuzz {
44
use libfuzzer_sys::fuzz_target;
55

naga/fuzz/fuzz_targets/spv_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_main]
2-
#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))]
2+
#[cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))]
33
mod fuzz {
44
use libfuzzer_sys::fuzz_target;
55
use naga::front::spv::{Frontend, Options};

naga/fuzz/fuzz_targets/wgsl_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_main]
2-
#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))]
2+
#[cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))]
33
mod fuzz {
44
use libfuzzer_sys::fuzz_target;
55
use naga::front::wgsl::Frontend;

naga/xtask/src/validate.rs

+1-1
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!(any(target_os = "macos", target_os = "ios", target_os = "visionos")),
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

+1-1
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(any(target_os = "ios", target_os = "visionos", target_os = "macos"), feature = "metal") },
1111
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") }
1212
}
1313
}

wgpu-core/src/lib.rs

+1-1
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_os = "macos", target_os = "ios", target_os = "visionos"))),
1414
not(all(feature = "dx12", windows)),
1515
not(feature = "gles"),
1616
),

wgpu-hal/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ windows-core = { workspace = true, optional = true }
164164
# backend: Gles
165165
glutin_wgl_sys = { workspace = true, optional = true }
166166

167-
[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
167+
[target.'cfg(any(target_os="macos", target_os="ios", target_os="visionos"))'.dependencies]
168168
# backend: Metal
169169
block = { workspace = true, optional = true }
170170

@@ -208,7 +208,7 @@ env_logger.workspace = true
208208
glam.workspace = true # for ray-traced-triangle example
209209
winit.workspace = true # for "halmark" example
210210

211-
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios")))'.dev-dependencies]
211+
[target.'cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))'.dev-dependencies]
212212
glutin-winit = { workspace = true, features = [
213213
"egl",
214214
"wgl",

wgpu-hal/build.rs

+1-1
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(any(target_os = "ios", target_os = "visionos", target_os = "macos"), feature = "metal") },
1313
vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") }
1414
}
1515
}

wgpu-hal/examples/halmark/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ impl<A: hal::Api> Example<A> {
782782

783783
cfg_if::cfg_if! {
784784
// Apple + Metal
785-
if #[cfg(all(any(target_os = "macos", target_os = "ios"), feature = "metal"))] {
785+
if #[cfg(all(any(target_os = "macos", target_os = "ios", target_os = "visionos"), feature = "metal"))] {
786786
type Api = hal::api::Metal;
787787
}
788788
// Wasm + Vulkan

wgpu-hal/examples/raw-gles.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
extern crate wgpu_hal as hal;
1212

13-
#[cfg(not(any(target_arch = "wasm32", target_os = "ios")))]
13+
#[cfg(not(any(target_arch = "wasm32", target_os = "ios", target_os = "visionos")))]
1414
fn main() {
1515
use std::{ffi::CString, num::NonZeroU32};
1616

@@ -256,15 +256,15 @@ fn main() {
256256

257257
#[cfg(any(
258258
all(target_arch = "wasm32", not(target_os = "emscripten")),
259-
target_os = "ios"
259+
target_os = "ios", target_os = "visionos"
260260
))]
261261
fn main() {
262262
eprintln!("This example is not supported on Windows and non-emscripten wasm32")
263263
}
264264

265265
#[cfg(not(any(
266266
all(target_arch = "wasm32", not(target_os = "emscripten")),
267-
target_os = "ios"
267+
target_os = "ios", target_os = "visionos"
268268
)))]
269269
fn fill_screen(exposed: &hal::ExposedAdapter<hal::api::Gles>, width: u32, height: u32) {
270270
use hal::{Adapter as _, CommandEncoder as _, Device as _, Queue as _};

wgpu-hal/examples/ray-traced-triangle/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ impl<A: hal::Api> Example<A> {
10781078

10791079
cfg_if::cfg_if! {
10801080
// Apple + Metal
1081-
if #[cfg(all(any(target_os = "macos", target_os = "ios"), feature = "metal"))] {
1081+
if #[cfg(all(any(target_os = "macos", target_os = "ios", target_os = "visionos"), feature = "metal"))] {
10821082
type Api = hal::api::Metal;
10831083
}
10841084
// Wasm + Vulkan

wgpu-hal/src/gles/egl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ impl crate::Instance for Instance {
785785
"libEGL.dll",
786786
)
787787
}
788-
} else if cfg!(any(target_os = "macos", target_os = "ios")) {
788+
} else if cfg!(any(target_os = "macos", target_os = "ios", target_os = "visionos")) {
789789
unsafe {
790790
khronos_egl::DynamicInstance::<khronos_egl::EGL1_4>::load_required_from_filename(
791791
"libEGL.dylib",
@@ -1313,7 +1313,7 @@ impl crate::Surface for Surface {
13131313
let window_ptr = handle.ns_view.as_ptr();
13141314
#[cfg(target_os = "macos")]
13151315
let window_ptr = {
1316-
use objc::{msg_send, runtime::Object, sel, sel_impl};
1316+
use objc::{msg_send, runtime::Object, sel};
13171317
// ns_view always have a layer and don't need to verify that it exists.
13181318
let layer: *mut Object =
13191319
msg_send![handle.ns_view.as_ptr().cast::<Object>(), layer];

wgpu-hal/src/metal/adapter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use metal::{MTLFeatureSet, MTLGPUFamily, MTLLanguageVersion, MTLReadWriteTextureTier};
2-
use objc::{class, msg_send, sel, sel_impl};
2+
use objc::{class, msg_send, sel};
33
use parking_lot::Mutex;
44
use wgt::{AstcBlock, AstcChannel};
55

wgpu-hal/src/metal/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl crate::Instance for Instance {
120120
window_handle: raw_window_handle::RawWindowHandle,
121121
) -> Result<Surface, crate::InstanceError> {
122122
match window_handle {
123-
#[cfg(target_os = "ios")]
123+
#[cfg(any(target_os = "ios", target_os = "visionos"))]
124124
raw_window_handle::RawWindowHandle::UiKit(handle) => {
125125
Ok(unsafe { Surface::from_view(handle.ui_view.cast()) })
126126
}

wgpu-hal/src/metal/surface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use objc::{
1616
msg_send,
1717
rc::{autoreleasepool, StrongPtr},
1818
runtime::{Class, Object, Sel, BOOL, NO, YES},
19-
sel, sel_impl,
19+
sel
2020
};
2121
use parking_lot::{Mutex, RwLock};
2222

wgpu-hal/src/vulkan/adapter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ impl PhysicalDeviceProperties {
10051005
}
10061006

10071007
// Require `VK_KHR_portability_subset` on macOS/iOS
1008-
#[cfg(any(target_os = "macos", target_os = "ios"))]
1008+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))]
10091009
extensions.push(khr::portability_subset::NAME);
10101010

10111011
// Require `VK_EXT_texture_compression_astc_hdr` if the associated feature was requested

wgpu-hal/src/vulkan/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ impl crate::Instance for super::Instance {
881881
{
882882
self.create_surface_from_view(handle.ns_view)
883883
}
884-
#[cfg(all(target_os = "ios", feature = "metal"))]
884+
#[cfg(all(any(target_os = "ios", target_os = "visionos"), feature = "metal"))]
885885
(Rwh::UiKit(handle), _)
886886
if self.shared.extensions.contains(&ext::metal_surface::NAME) =>
887887
{

wgpu/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ features = ["indirect-validation"]
138138

139139
# Enable `wgc` by default on macOS and iOS to allow the `metal` crate feature to
140140
# enable the Metal backend while being no-op on other targets.
141-
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc]
141+
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "visionos"))'.dependencies.wgc]
142142
workspace = true
143143

144144
# We want the wgpu-core Direct3D backend and OpenGL (via WGL) on Windows.
@@ -147,12 +147,12 @@ workspace = true
147147
features = ["gles"]
148148

149149
# We want the wgpu-core Vulkan backend on Unix (but not emscripten, macOS, iOS) and Windows.
150-
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc]
150+
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "visionos"), not(target_os = "macos"))))'.dependencies.wgc]
151151
workspace = true
152152
features = ["vulkan"]
153153

154154
# We want the wgpu-core GLES backend on Unix (but not macOS, iOS).
155-
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies.wgc]
155+
[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "visionos"), not(target_os = "macos")))'.dependencies.wgc]
156156
workspace = true
157157
features = ["gles"]
158158

@@ -163,7 +163,7 @@ workspace = true
163163
[target.'cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))'.dependencies]
164164
hal = { workspace = true }
165165

166-
[target.'cfg(all(not(target_arch = "wasm32"), unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies]
166+
[target.'cfg(all(not(target_arch = "wasm32"), unix, not(target_os = "ios"), not(target_os = "visionos"), not(target_os = "macos")))'.dependencies]
167167
hal = { workspace = true, features = ["renderdoc"] }
168168

169169
[target.'cfg(windows)'.dependencies]

wgpu/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
all(feature = "fragile-send-sync-non-atomic-wasm", not(target_feature = "atomics"))
1111
) },
1212
dx12: { all(target_os = "windows", feature = "dx12") },
13-
metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") },
13+
metal: { all(any(target_os = "ios", target_os = "visionos", target_os = "macos"), feature = "metal") },
1414
// This alias is _only_ if _we_ need naga in the wrapper. wgpu-core provides
1515
// its own re-export of naga, which can be used in other situations
1616
naga: { any(feature = "naga-ir", feature = "spirv", feature = "glsl") },

0 commit comments

Comments
 (0)