Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple Silicon support #1002

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ parking_lot = "0.11.0"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
spirv-reflect = "0.2.3"

[target.'cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))'.dependencies]
[target.'cfg(all(not(target_os = "ios"), not(all(target_os = "macos", target_arch = "aarch64")), not(target_arch = "wasm32")))'.dependencies]
bevy-glsl-to-spirv = "0.2.0"

[target.'cfg(target_os = "ios")'.dependencies]
[target.'cfg(any(target_os = "ios", all(target_os = "macos", target_arch = "aarch64")))'.dependencies]
shaderc = "0.7.0"

[features]
Expand Down
16 changes: 12 additions & 4 deletions crates/bevy_render/src/shader/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ pub enum ShaderStage {
Compute,
}

#[cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))]
#[cfg(all(
not(target_os = "ios"),
not(all(target_os = "macos", target_arch = "aarch64")),
not(target_arch = "wasm32")
))]
impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
fn into(self) -> bevy_glsl_to_spirv::ShaderType {
match self {
Expand All @@ -22,7 +26,11 @@ impl Into<bevy_glsl_to_spirv::ShaderType> for ShaderStage {
}
}

#[cfg(all(not(target_os = "ios"), not(target_arch = "wasm32")))]
#[cfg(all(
not(target_os = "ios"),
not(all(target_os = "macos", target_arch = "aarch64")),
not(target_arch = "wasm32")
))]
pub fn glsl_to_spirv(
glsl_source: &str,
stage: ShaderStage,
Expand All @@ -31,7 +39,7 @@ pub fn glsl_to_spirv(
bevy_glsl_to_spirv::compile(glsl_source, stage.into(), shader_defs).unwrap()
}

#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", all(target_os = "macos", target_arch = "aarch64")))]
impl Into<shaderc::ShaderKind> for ShaderStage {
fn into(self) -> shaderc::ShaderKind {
match self {
Expand All @@ -42,7 +50,7 @@ impl Into<shaderc::ShaderKind> for ShaderStage {
}
}

#[cfg(target_os = "ios")]
#[cfg(any(target_os = "ios", all(target_os = "macos", target_arch = "aarch64")))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function below was updated recently to return a Result. You can copy what I added here to make this work on Apple Silicon:

#1027

I created my pull request before I saw yours, oops

pub fn glsl_to_spirv(
glsl_source: &str,
stage: ShaderStage,
Expand Down
6 changes: 4 additions & 2 deletions crates/bevy_winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ bevy_window = { path = "../bevy_window", version = "0.3.0" }
bevy_utils = { path = "../bevy_utils", version = "0.3.0" }

# other
winit = { version = "0.23.0", default-features = false }
# TODO: Waiting for winit to release a new version
winit = { git = "https://github.com/rust-windowing/winit", default-features = false }

[target.'cfg(target_arch = "wasm32")'.dependencies]
winit = { version = "0.23.0", features = ["web-sys"], default-features = false }
# TODO
winit = { git = "https://github.com/rust-windowing/winit", features = ["web-sys"], default-features = false }
wasm-bindgen = { version = "0.2" }
web-sys = "0.3"
2 changes: 1 addition & 1 deletion crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn run_return<F>(event_loop: &mut EventLoop<()>, event_handler: F)
where
F: FnMut(Event<'_, ()>, &EventLoopWindowTarget<()>, &mut ControlFlow),
{
use winit::platform::desktop::EventLoopExtDesktop;
use winit::platform::run_return::EventLoopExtRunReturn;
event_loop.run_return(event_handler)
}

Expand Down