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

metal: Migrate from metal-rs to objc2 #229

Merged
merged 3 commits into from
Dec 21, 2024
Merged
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
78 changes: 41 additions & 37 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,64 @@ jobs:
- name: Linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu

- name: Windows
os: windows-latest
target: x86_64-pc-windows-msvc

- name: MacOS

- name: macOS
os: macos-latest
target: aarch64-apple-darwin

- name: iOS
os: macos-latest
target: x86_64-apple-darwin
target: aarch64-apple-ios

- name: Web
os: ubuntu-latest
target: wasm32-unknown-unknown

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: ${{ matrix.target }}
override: true

- name: Check Basics
uses: actions-rs/cargo@v1
with:
command: check
args: --target ${{ matrix.target }} --workspace --all --no-default-features
- name: Test Basics
if: matrix.name != 'Web'
uses: actions-rs/cargo@v1
with:
command: test
args: -p blade-render --no-default-features

- name: Test All
if: matrix.name != 'Web'
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features

- name: Test GLES
if: matrix.name == 'Linux'
uses: actions-rs/cargo@v1
with:
command: build
args: --example bunnymark
env:
RUSTFLAGS: "--cfg gles"
- name: Check Basics
uses: actions-rs/cargo@v1
with:
command: check
args: --target ${{ matrix.target }} --workspace --all --no-default-features

- name: Test Basics
if: matrix.name != 'Web'
uses: actions-rs/cargo@v1
with:
command: test
args: -p blade-render --no-default-features

- name: Test All
if: matrix.name != 'Web'
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features

- name: Test GLES
if: matrix.name == 'Linux'
uses: actions-rs/cargo@v1
with:
command: build
args: --example bunnymark
env:
RUSTFLAGS: "--cfg gles"

fmt:
name: Format
Expand Down
12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ glam = { version = "0.28", features = ["mint"] }
gltf = { version = "1.1", default-features = false }
log = "0.4"
mint = "0.5"
naga = { git = "https://github.com/gfx-rs/wgpu", rev = "1a643291c2e8854ba7e4f5445a4388202731bfa1", features = [
"wgsl-in",
] }
naga = { version = "23.1.0", features = ["wgsl-in"] }
profiling = "1"
slab = "0.4"
strum = { version = "0.25", features = ["derive"] }
Expand Down Expand Up @@ -90,11 +88,15 @@ del-geo = "=0.1.29"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
# see https://github.com/emilk/egui/issues/4270
egui-winit = { version="0.29", default-features=false, features=["links"] }
egui-winit = { version = "0.29", default-features = false, features = [
"links",
] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
# see https://github.com/emilk/egui/issues/4270
egui-winit = { version="0.29", default-features=false, features=["links"] }
egui-winit = { version = "0.29", default-features = false, features = [
"links",
] }
console_error_panic_hook = "0.1.7"
console_log = "1"
web-sys = { workspace = true, features = ["Window"] }
Expand Down
67 changes: 59 additions & 8 deletions blade-graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,67 @@ naga = { workspace = true }
raw-window-handle = "0.6"

[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
block = "0.1"
core-graphics-types = "0.1"
#TODO: switch to crates once these are published:
# - https://github.com/gfx-rs/metal-rs/pull/335
# - https://github.com/gfx-rs/metal-rs/pull/336
# - https://github.com/gfx-rs/metal-rs/pull/337
metal = { git = "https://github.com/gfx-rs/metal-rs", rev = "ef768ff9d742ae6a0f4e83ddc8031264e7d460c4" }
objc = "0.2.5"
objc2 = "0.5"
objc2-foundation = { version = "0.2", features = ["NSArray"] }
objc2-metal = { version = "0.2", features = [
"MTLTypes",
"MTLPixelFormat",
"MTLResource",
"MTLBuffer",
"MTLTexture",
"MTLSampler",
"MTLDrawable",
"MTLAccelerationStructure",
"MTLAccelerationStructureTypes",
"MTLCounters",
"MTLLibrary",
"MTLStageInputOutputDescriptor",
"MTLComputePipeline",
"MTLVertexDescriptor",
"MTLDepthStencil",
"MTLComputePipeline",
"MTLRenderPipeline",
"MTLCommandBuffer",
"MTLCommandEncoder",
"MTLAccelerationStructureCommandEncoder",
"MTLBlitCommandEncoder",
"MTLComputeCommandEncoder",
"MTLRenderCommandEncoder",
"MTLBlitPass",
"MTLComputePass",
"MTLRenderPass",
"MTLCommandQueue",
"MTLDevice",
"MTLCaptureManager",
"MTLCaptureScope",
"block2",
] }
objc2-quartz-core = { version = "0.2", features = [
"objc2-metal",
"CALayer",
"CAMetalLayer",
] }
naga = { workspace = true, features = ["msl-out"] }

[target.'cfg(target_os = "macos")'.dependencies]
objc2-app-kit = { version = "0.2", features = [
"objc2-quartz-core",
"NSResponder",
"NSView",
"NSWindow",
] }

[target.'cfg(target_os = "ios")'.dependencies]
objc2-ui-kit = { version = "0.2", features = [
"objc2-quartz-core",
"UIResponder",
"UIView",
"UIWindow",
"UIScene",
"UIWindowScene",
"UIScreen",
] }

[target.'cfg(any(vulkan, windows, target_os = "linux", target_os = "android", target_os = "freebsd"))'.dependencies]
ash = "0.38"
ash-window = "0.13"
Expand Down
1 change: 0 additions & 1 deletion blade-graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
clippy::missing_safety_doc,
)]
#![warn(
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
//TODO: re-enable. Currently doesn't like "mem::size_of" on newer Rust
Expand Down
Loading
Loading