Add support for macos in example-runner (#60)

This commit is contained in:
XAMPPRocky 2020-10-14 18:33:37 +02:00 committed by GitHub
parent 16c35c6d0e
commit 16f7268edb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 11 deletions

36
Cargo.lock generated
View File

@ -71,6 +71,14 @@ dependencies = [
"libloading", "libloading",
] ]
[[package]]
name = "ash-molten"
version = "0.6.0+43"
source = "git+https://github.com/EmbarkStudios/ash-molten?branch=moltenvk-1.1.0#d0cb9e55d366b383e94ab5f5c299b2758e385f32"
dependencies = [
"ash",
]
[[package]] [[package]]
name = "ash-window" name = "ash-window"
version = "0.5.0" version = "0.5.0"
@ -106,7 +114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f813291114c186a042350e787af10c26534601062603d888be110f59f85ef8fa" checksum = "f813291114c186a042350e787af10c26534601062603d888be110f59f85ef8fa"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object",
@ -161,6 +169,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.33.3" version = "2.33.3"
@ -305,7 +319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if 0.1.10",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"maybe-uninit", "maybe-uninit",
@ -320,7 +334,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if 0.1.10",
"lazy_static", "lazy_static",
] ]
@ -389,7 +403,9 @@ name = "example-runner"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ash", "ash",
"ash-molten",
"ash-window", "ash-window",
"cfg-if 1.0.0",
"image", "image",
"spirv-builder", "spirv-builder",
"structopt", "structopt",
@ -402,7 +418,7 @@ version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"redox_syscall", "redox_syscall",
"winapi", "winapi",
@ -454,7 +470,7 @@ version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"wasi", "wasi",
] ]
@ -557,7 +573,7 @@ version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9" checksum = "2443d8f0478b16759158b2f66d525991a05491138bc05814ef52a250148ef4f9"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"winapi", "winapi",
] ]
@ -585,7 +601,7 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
] ]
[[package]] [[package]]
@ -662,7 +678,7 @@ checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags 1.2.1",
"cc", "cc",
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"void", "void",
] ]
@ -790,7 +806,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"cloudabi", "cloudabi",
"libc", "libc",
"redox_syscall", "redox_syscall",
@ -1341,7 +1357,7 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [ dependencies = [
"cfg-if", "cfg-if 0.1.10",
"libc", "libc",
"rand 0.7.3", "rand 0.7.3",
"redox_syscall", "redox_syscall",

View File

@ -7,9 +7,13 @@ edition = "2018"
[dependencies] [dependencies]
ash = "0.31" ash = "0.31"
ash-window = "0.5" ash-window = "0.5"
cfg-if = "1.0.0"
image = "0.10.4" image = "0.10.4"
structopt = "0.3.20" structopt = "0.3.20"
winit = "0.19.5" winit = "0.19.5"
[target.'cfg(target_os = "macos")'.dependencies]
ash-molten = { git = "https://github.com/EmbarkStudios/ash-molten", branch = "moltenvk-1.1.0" }
[build-dependencies] [build-dependencies]
spirv-builder = { path = "../../spirv-builder" } spirv-builder = { path = "../../spirv-builder" }

View File

@ -159,6 +159,9 @@ pub fn find_memorytype_index_f<F: Fn(vk::MemoryPropertyFlags, vk::MemoryProperty
} }
pub struct ExampleBase { pub struct ExampleBase {
#[cfg(target_os = "macos")]
pub entry: ash_molten::MoltenEntry,
#[cfg(not(target_os = "macos"))]
pub entry: Entry, pub entry: Entry,
pub instance: Instance, pub instance: Instance,
pub device: Device, pub device: Device,
@ -231,7 +234,15 @@ impl ExampleBase {
)) ))
.build(&events_loop) .build(&events_loop)
.unwrap(); .unwrap();
let entry = Entry::new().unwrap();
cfg_if::cfg_if! {
if #[cfg(target_os = "macos")] {
let entry = ash_molten::MoltenEntry::load().unwrap();
} else {
let entry = Entry::new().unwrap();
}
}
let app_name = CString::new("VulkanTriangle").unwrap(); let app_name = CString::new("VulkanTriangle").unwrap();
let layer_names = if options.debug_layer { let layer_names = if options.debug_layer {