From 03af213184e21dba3133fcdad3ebe1a244847290 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 26 Jun 2019 14:10:13 -0400 Subject: [PATCH] Events hookup --- Cargo.lock | 177 ++++++++++++------------ libportability-gfx/Cargo.toml | 4 + libportability-gfx/src/impls.rs | 238 ++++++++++++++++++++------------ libportability-gfx/src/lib.rs | 16 ++- 4 files changed, 251 insertions(+), 184 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b1be40..98cdf4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,18 +261,6 @@ dependencies = [ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "env_logger" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "failure" version = "0.1.5" @@ -327,11 +315,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gfx-backend-dx11" version = "0.2.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)", + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "range-alloc 0.1.0 (git+https://github.com/gfx-rs/gfx)", @@ -345,12 +333,12 @@ dependencies = [ [[package]] name = "gfx-backend-dx12" version = "0.2.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "d3d12 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)", + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "range-alloc 0.1.0 (git+https://github.com/gfx-rs/gfx)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -359,27 +347,35 @@ dependencies = [ "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "gfx-backend-empty" +version = "0.2.0" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" +dependencies = [ + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", +] + [[package]] name = "gfx-backend-gl" version = "0.2.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)", - "glow 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "glutin 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", + "glow 0.2.0 (git+https://github.com/grovesNL/glow?rev=abc536c6b9b6a96c7f6c758d938fcb38f9b55938)", + "glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "spirv_cross 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gfx-backend-metal" -version = "0.2.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +version = "0.2.1" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -388,9 +384,9 @@ dependencies = [ "copyless 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)", + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "metal 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "range-alloc 0.1.0 (git+https://github.com/gfx-rs/gfx)", @@ -402,26 +398,27 @@ dependencies = [ [[package]] name = "gfx-backend-vulkan" -version = "0.2.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +version = "0.2.2" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" dependencies = [ "ash 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)", + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)", - "xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gfx-hal" -version = "0.2.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +version = "0.2.1" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -459,13 +456,13 @@ dependencies = [ [[package]] name = "glow" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/grovesNL/glow?rev=abc536c6b9b6a96c7f6c758d938fcb38f9b55938#abc536c6b9b6a96c7f6c758d938fcb38f9b55938" dependencies = [ "gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "slotmap 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -492,7 +489,7 @@ dependencies = [ [[package]] name = "glutin" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -500,16 +497,17 @@ dependencies = [ "cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_egl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "glutin_emscripten_sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_gles2_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_glx_sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "glutin_wgl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "osmesa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "wayland-client 0.21.12 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -524,6 +522,11 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "glutin_emscripten_sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "glutin_gles2_sys" version = "0.1.3" @@ -568,10 +571,10 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -666,7 +669,7 @@ dependencies = [ [[package]] name = "metal" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -674,7 +677,6 @@ dependencies = [ "cocoa 0.18.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -846,10 +848,11 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "gfx-backend-dx11 0.2.0 (git+https://github.com/gfx-rs/gfx)", "gfx-backend-dx12 0.2.0 (git+https://github.com/gfx-rs/gfx)", + "gfx-backend-empty 0.2.0 (git+https://github.com/gfx-rs/gfx)", "gfx-backend-gl 0.2.0 (git+https://github.com/gfx-rs/gfx)", - "gfx-backend-metal 0.2.0 (git+https://github.com/gfx-rs/gfx)", - "gfx-backend-vulkan 0.2.0 (git+https://github.com/gfx-rs/gfx)", - "gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)", + "gfx-backend-metal 0.2.1 (git+https://github.com/gfx-rs/gfx)", + "gfx-backend-vulkan 0.2.2 (git+https://github.com/gfx-rs/gfx)", + "gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "renderdoc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -994,7 +997,7 @@ dependencies = [ [[package]] name = "range-alloc" version = "0.1.0" -source = "git+https://github.com/gfx-rs/gfx#ff7727bde54b4279ef08722865ded3bca57cb402" +source = "git+https://github.com/gfx-rs/gfx#27b73c726c87142eb9714f607581595669939534" [[package]] name = "rdrand" @@ -1154,8 +1157,8 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1287,15 +1290,15 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1304,38 +1307,38 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1344,7 +1347,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1467,15 +1470,14 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1593,15 +1595,6 @@ dependencies = [ "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "xcb" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "xdg" version = "2.2.0" @@ -1653,7 +1646,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a" "checksum downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b92dfd5c2f75260cbf750572f95d387e7ca0ba5e3fbe9e1a33f23025be020f" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" -"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" @@ -1663,23 +1655,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gfx-backend-dx11 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gfx-backend-dx12 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" +"checksum gfx-backend-empty 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gfx-backend-gl 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" -"checksum gfx-backend-metal 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" -"checksum gfx-backend-vulkan 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" -"checksum gfx-hal 0.2.0 (git+https://github.com/gfx-rs/gfx)" = "" +"checksum gfx-backend-metal 0.2.1 (git+https://github.com/gfx-rs/gfx)" = "" +"checksum gfx-backend-vulkan 0.2.2 (git+https://github.com/gfx-rs/gfx)" = "" +"checksum gfx-hal 0.2.1 (git+https://github.com/gfx-rs/gfx)" = "" "checksum gl_generator 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "39a23d5e872a275135d66895d954269cf5e8661d234eb1c2480f4ce0d586acbd" "checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" "checksum gleam 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7f46fd8874e043ffac0d638ed1567a2584f7814f6d72b4db37ab1689004a26c4" -"checksum glow 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6fb431bf8855f4ad29b93f342048541c7f171c913d3eccf499edfc91dcee6b2" +"checksum glow 0.2.0 (git+https://github.com/grovesNL/glow?rev=abc536c6b9b6a96c7f6c758d938fcb38f9b55938)" = "" "checksum glutin 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9caee44b73388b2b4452ab783b13a1af80edb363bfc6e5292bdb2dd990a3171" -"checksum glutin 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff663466cd51f6fda5976e8a6f02a9fd65b8dde0b9b11db8344585174d015b2c" +"checksum glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb26027a84c3b9e1949ef0df0b6a3db8d0c124243a5c161ea25c7def90cb1474" "checksum glutin_egl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "23f48987ab6cb2b61ad903b59e54a2fd0c380a7baff68cffd6826b69a73dd326" +"checksum glutin_emscripten_sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "245b3fdb08df6ffed7585365851f8404af9c7e2dd4b59f15262e968b6a95a0c7" "checksum glutin_gles2_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "89996c30857ae1b4de4b5189abf1ea822a20a9fe9e1c93e5e7b862ff0bdd5cdf" "checksum glutin_glx_sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1290a5ca5e46fcfa7f66f949cc9d9194b2cb6f2ed61892c8c2b82343631dba57" "checksum glutin_wgl_sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f801bbc91efc22dd1c4818a47814fc72bf74d024510451b119381579bfa39021" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" -"checksum js-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "9987e7c13a91d9cf0efe59cca48a3a7a70e2b11695d5a4640f85ae71e28f5e73" +"checksum js-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "eac16f41aa9b9388230b1d6617d7ed897a1af5416b8fe1c8734dcef79c7aae10" "checksum khronos_api 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "037ab472c33f67b5fbd3e9163a2645319e5356fcd355efa6d4eb7fff4bbcb554" "checksum khronos_api 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" @@ -1693,7 +1687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -"checksum metal 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd3f21d259068945192293b7a98b1c6844af9eb7602e393c405198b229efc157" +"checksum metal 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "508aa26b306fdc5b927b200f9d16d9eb668c3d4034f0354242bf5be15f0bb431" "checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" @@ -1764,12 +1758,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" -"checksum wasm-bindgen 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "b7ccc7b93cfd13e26700a9e2e41e6305f1951b87e166599069f77d10358100e6" -"checksum wasm-bindgen-backend 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1953f91b1608eb1522513623c7739f047bb0fed4128ce51a93f08e12cc314645" -"checksum wasm-bindgen-macro 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "0f69da5696545d7ca6607a2e4b1a0edf5a6b36b2c49dbb0f1df6ad1d92884047" -"checksum wasm-bindgen-macro-support 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d4246f3bc73223bbb846f4f2430a60725826a96c9389adf715ed1d5af46dec6" -"checksum wasm-bindgen-shared 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "c08381e07e7a79e5e229ad7c60d15833d19033542cc5dd91d085df59d235f4a6" -"checksum wasm-bindgen-webidl 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "1f42ff7adb8102bf5ad8adbc45b1635c520c8175f9fdf6eb2c54479d485d435a" +"checksum wasm-bindgen 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "22029998cc650473cb05f10f19c06a1536b9e1f1572e4f5dacd45ab4d3f85877" +"checksum wasm-bindgen-backend 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "6f858ff3cb4196c702e8c24b75fba1d3ab46958de4f7c253627f0507aae1507c" +"checksum wasm-bindgen-macro 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "15c29f04eb117312931e7b02878453ee63d67a6f291797651890128bf5ee71db" +"checksum wasm-bindgen-macro-support 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "92b1356b623816248dfe0e2c4b7e113618d647808907ff6a3d9838ebee8e82ee" +"checksum wasm-bindgen-shared 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "15de16ddb30cfd424a87598b30021491bae1607d32e52056979865c98b7913b4" +"checksum wasm-bindgen-webidl 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "21724123084234fff2f986018b790afc5d6f45c9a3903025e6c55d0068cb7d15" "checksum wayland-client 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2b90adf943117ee4930d7944fe103dcb6f36ba05421f46521cb5adbf6bf0fbc8" "checksum wayland-client 0.21.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e77d1e6887f07ea2e5d79a3d7d03a875e62d3746334a909b5035d779d849a523" "checksum wayland-commons 0.21.12 (registry+https://github.com/rust-lang/crates.io-index)" = "dff69a5399ca212efa4966f3ee2a3773f19960d0fa329b9aca046a8508a0e09f" @@ -1781,7 +1775,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wayland-sys 0.12.5 (registry+https://github.com/rust-lang/crates.io-index)" = "377a2f83063c463e801ca10ae8cb9666e6e597eecac0049ac36cc7b9a83b0db3" "checksum wayland-sys 0.21.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e76af81a601b84d400744f85f083381daa77ac01f6c8711e57e662dc3a35d69d" "checksum wayland-window 0.13.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e5bf431e84f0de9cd06a30b2fb9ab9458f449cb6c36277da703e979ad5c141b1" -"checksum web-sys 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "540b8259eb242ff3a566fa0140bda03a4ece4e5c226e1284b5c95dddcd4341f6" +"checksum web-sys 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "22306ce642c58266cb5c5938150194911322bc179aa895146076217410ddbc82" "checksum weedle 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc44aa200daee8b1f3a004beaf16554369746f1b4486f0cf93b0caf8a3c2d1e" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" @@ -1793,7 +1787,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" "checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" "checksum x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "940586acb859ea05c53971ac231685799a7ec1dee66ac0bccc0e6ad96e06b4e3" -"checksum xcb 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" "checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5" diff --git a/libportability-gfx/Cargo.toml b/libportability-gfx/Cargo.toml index ba7cf6c..e31bc8a 100644 --- a/libportability-gfx/Cargo.toml +++ b/libportability-gfx/Cargo.toml @@ -34,6 +34,10 @@ optional = true git = "https://github.com/gfx-rs/gfx" #path = "../../gfx/src/hal" +[dependencies.gfx-backend-empty] +git = "https://github.com/gfx-rs/gfx" +#path = "../../gfx/src/backend/empty" + [target.'cfg(not(target_os = "macos"))'.dependencies.gfx-backend-vulkan] git = "https://github.com/gfx-rs/gfx" #path = "../../gfx/src/backend/vulkan" diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 0b06dae..0e31954 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -59,11 +59,23 @@ pub extern "C" fn gfxCreateInstance( ) -> VkResult { #[cfg(feature = "env_logger")] { - use env_logger; let _ = env_logger::try_init(); } - let backend = back::Instance::create("portability", 1); + let mut backend = back::Instance::create("portability", 1); + + #[cfg(feature = "gfx-backend-metal")] + { + if let Ok(value) = env::var("GFX_METAL_ARGUMENTS") { + backend.experiments.argument_buffers = match value.to_lowercase().as_str() { + "yes" => true, + "no" => false, + other => panic!("unknown arguments option: {}", other), + }; + println!("GFX: arguments override {:?}", backend.experiments.argument_buffers); + } + } + let adapters = backend .enumerate_adapters() .into_iter() @@ -1481,36 +1493,55 @@ pub extern "C" fn gfxDestroySemaphore( } #[inline] pub extern "C" fn gfxCreateEvent( - _gpu: VkDevice, + gpu: VkDevice, _pCreateInfo: *const VkEventCreateInfo, _pAllocator: *const VkAllocationCallbacks, - _pEvent: *mut VkEvent, + pEvent: *mut VkEvent, ) -> VkResult { - // Vulkan portability doesn't currently support events, but some - // test cases use them so fail with an obvious error message. - VkResult::VK_ERROR_DEVICE_LOST + let event = match gpu.device.create_event() { + Ok(e) => e, + Err(oom) => return map_oom(oom), + }; + + unsafe { + *pEvent = Handle::new(event); + } + VkResult::VK_SUCCESS } #[inline] pub extern "C" fn gfxDestroyEvent( - _gpu: VkDevice, + gpu: VkDevice, event: VkEvent, _pAllocator: *const VkAllocationCallbacks, ) { - if event != ptr::null_mut() { - unimplemented!() + if let Some(event) = event.unbox() { + unsafe { + gpu.device.destroy_event(event); + } } } #[inline] -pub extern "C" fn gfxGetEventStatus(_gpu: VkDevice, _event: VkEvent) -> VkResult { - unimplemented!() +pub extern "C" fn gfxGetEventStatus(gpu: VkDevice, event: VkEvent) -> VkResult { + match unsafe { gpu.device.get_event_status(&event) } { + Ok(true) => VkResult::VK_EVENT_SET, + Ok(false) => VkResult::VK_EVENT_RESET, + Err(hal::device::OomOrDeviceLost::OutOfMemory(oom)) => map_oom(oom), + Err(hal::device::OomOrDeviceLost::DeviceLost(hal::device::DeviceLost)) => VkResult::VK_ERROR_DEVICE_LOST, + } } #[inline] -pub extern "C" fn gfxSetEvent(_gpu: VkDevice, _event: VkEvent) -> VkResult { - unimplemented!() +pub extern "C" fn gfxSetEvent(gpu: VkDevice, event: VkEvent) -> VkResult { + match unsafe { gpu.device.set_event(&event) } { + Ok(()) => VkResult::VK_SUCCESS, + Err(oom) => map_oom(oom), + } } #[inline] -pub extern "C" fn gfxResetEvent(_gpu: VkDevice, _event: VkEvent) -> VkResult { - unimplemented!() +pub extern "C" fn gfxResetEvent(gpu: VkDevice, event: VkEvent) -> VkResult { + match unsafe { gpu.device.reset_event(&event) } { + Ok(()) => VkResult::VK_SUCCESS, + Err(oom) => map_oom(oom), + } } #[inline] pub extern "C" fn gfxCreateQueryPool( @@ -1780,7 +1811,7 @@ pub extern "C" fn gfxCreateShaderModule( ) -> VkResult { unsafe { let info = &*pCreateInfo; - let code = slice::from_raw_parts(info.pCode as *const u8, info.codeSize as usize); + let code = slice::from_raw_parts(info.pCode as *const u32, info.codeSize as usize / 4); let shader_module = gpu.device .create_shader_module(code) .expect("Error creating shader module"); // TODO @@ -3154,10 +3185,11 @@ pub extern "C" fn gfxDestroyCommandPool( pub extern "C" fn gfxResetCommandPool( _gpu: VkDevice, mut commandPool: VkCommandPool, - _flags: VkCommandPoolResetFlags, + flags: VkCommandPoolResetFlags, ) -> VkResult { + let release = (flags & VkCommandPoolResetFlagBits::VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT as u32) != 0; unsafe { - commandPool.pool.reset(); + commandPool.pool.reset(release); } VkResult::VK_SUCCESS } @@ -3863,35 +3895,103 @@ pub extern "C" fn gfxCmdResolveImage( } #[inline] pub extern "C" fn gfxCmdSetEvent( - _commandBuffer: VkCommandBuffer, - _event: VkEvent, - _stageMask: VkPipelineStageFlags, + mut commandBuffer: VkCommandBuffer, + event: VkEvent, + stageMask: VkPipelineStageFlags, ) { - unimplemented!() + unsafe { + commandBuffer.set_event( + &event, + conv::map_pipeline_stage_flags(stageMask), + ); + } } #[inline] pub extern "C" fn gfxCmdResetEvent( - _commandBuffer: VkCommandBuffer, - _event: VkEvent, - _stageMask: VkPipelineStageFlags, + mut commandBuffer: VkCommandBuffer, + event: VkEvent, + stageMask: VkPipelineStageFlags, ) { - unimplemented!() + unsafe { + commandBuffer.reset_event( + &event, + conv::map_pipeline_stage_flags(stageMask), + ); + } } + +fn make_barriers<'a>( + raw_globals: &'a [VkMemoryBarrier], + raw_buffers: &'a [VkBufferMemoryBarrier], + raw_images: &'a [VkImageMemoryBarrier], +) -> impl Iterator> { + let globals = raw_globals.iter().flat_map(|b| { + let buf = conv::map_buffer_access(b.srcAccessMask) .. conv::map_buffer_access(b.dstAccessMask); + let buf_bar = if !buf.start.is_empty() || !buf.end.is_empty() { + Some(memory::Barrier::AllBuffers(buf)) + } else { + None + }; + let img = conv::map_image_access(b.srcAccessMask) .. conv::map_image_access(b.dstAccessMask); + let img_bar = if !img.start.is_empty() || !img.end.is_empty() { + Some(memory::Barrier::AllImages(img)) + } else { + None + }; + buf_bar.into_iter().chain(img_bar) + }); + + let buffers = raw_buffers.iter().map(|b| memory::Barrier::Buffer { + states: conv::map_buffer_access(b.srcAccessMask) .. conv::map_buffer_access(b.dstAccessMask), + target: &*b.buffer, + range: Some(b.offset) .. if b.size as i32 == VK_WHOLE_SIZE { None } else { Some(b.offset + b.size) }, + families: None, + }); + let images = raw_images.iter().map(|b| memory::Barrier::Image { + states: + (conv::map_image_access(b.srcAccessMask), conv::map_image_layout(b.oldLayout)) .. + (conv::map_image_access(b.dstAccessMask), conv::map_image_layout(b.newLayout)), + target: &b.image.raw, + range: b.image.map_subresource_range(b.subresourceRange), + families: None, + }); + + globals.chain(buffers).chain(images) +} + #[inline] pub extern "C" fn gfxCmdWaitEvents( - _commandBuffer: VkCommandBuffer, - _eventCount: u32, - _pEvents: *const VkEvent, - _srcStageMask: VkPipelineStageFlags, - _dstStageMask: VkPipelineStageFlags, - _memoryBarrierCount: u32, - _pMemoryBarriers: *const VkMemoryBarrier, - _bufferMemoryBarrierCount: u32, - _pBufferMemoryBarriers: *const VkBufferMemoryBarrier, - _imageMemoryBarrierCount: u32, - _pImageMemoryBarriers: *const VkImageMemoryBarrier, + mut commandBuffer: VkCommandBuffer, + eventCount: u32, + pEvents: *const VkEvent, + srcStageMask: VkPipelineStageFlags, + dstStageMask: VkPipelineStageFlags, + memoryBarrierCount: u32, + pMemoryBarriers: *const VkMemoryBarrier, + bufferMemoryBarrierCount: u32, + pBufferMemoryBarriers: *const VkBufferMemoryBarrier, + imageMemoryBarrierCount: u32, + pImageMemoryBarriers: *const VkImageMemoryBarrier, ) { - unimplemented!() + let raw_globals = unsafe { + slice::from_raw_parts(pMemoryBarriers, memoryBarrierCount as _) + }; + let raw_buffers = unsafe { + slice::from_raw_parts(pBufferMemoryBarriers, bufferMemoryBarrierCount as _) + }; + let raw_images = unsafe { + slice::from_raw_parts(pImageMemoryBarriers, imageMemoryBarrierCount as _) + }; + + let barriers = make_barriers(raw_globals, raw_buffers, raw_images); + + unsafe { + commandBuffer.wait_events( + slice::from_raw_parts(pEvents, eventCount as usize).iter().map(|ev| &**ev), + conv::map_pipeline_stage_flags(srcStageMask) .. conv::map_pipeline_stage_flags(dstStageMask), + barriers, + ); + } } #[inline] pub extern "C" fn gfxCmdPipelineBarrier( @@ -3906,55 +4006,23 @@ pub extern "C" fn gfxCmdPipelineBarrier( imageMemoryBarrierCount: u32, pImageMemoryBarriers: *const VkImageMemoryBarrier, ) { - let global_barriers = unsafe { - slice::from_raw_parts(pMemoryBarriers, memoryBarrierCount as _) - } - .iter() - .flat_map(|b| { - let buf = conv::map_buffer_access(b.srcAccessMask) .. conv::map_buffer_access(b.dstAccessMask); - let buf_bar = if !buf.start.is_empty() || !buf.end.is_empty() { - Some(memory::Barrier::AllBuffers(buf)) - } else { - None - }; - let img = conv::map_image_access(b.srcAccessMask) .. conv::map_image_access(b.dstAccessMask); - let img_bar = if !img.start.is_empty() || !img.end.is_empty() { - Some(memory::Barrier::AllImages(img)) - } else { - None - }; - buf_bar.into_iter().chain(img_bar) - }); + let raw_globals = unsafe { + slice::from_raw_parts(pMemoryBarriers, memoryBarrierCount as _) + }; + let raw_buffers = unsafe { + slice::from_raw_parts(pBufferMemoryBarriers, bufferMemoryBarrierCount as _) + }; + let raw_images = unsafe { + slice::from_raw_parts(pImageMemoryBarriers, imageMemoryBarrierCount as _) + }; - let buffer_barriers = unsafe { - slice::from_raw_parts(pBufferMemoryBarriers, bufferMemoryBarrierCount as _) - } - .iter() - .map(|b| memory::Barrier::Buffer { - states: conv::map_buffer_access(b.srcAccessMask) .. conv::map_buffer_access(b.dstAccessMask), - target: &*b.buffer, - range: Some(b.offset) .. if b.size as i32 == VK_WHOLE_SIZE { None } else { Some(b.offset + b.size) }, - families: None, - }); - - let image_barriers = unsafe { - slice::from_raw_parts(pImageMemoryBarriers, imageMemoryBarrierCount as _) - } - .iter() - .map(|b| memory::Barrier::Image { - states: - (conv::map_image_access(b.srcAccessMask), conv::map_image_layout(b.oldLayout)) .. - (conv::map_image_access(b.dstAccessMask), conv::map_image_layout(b.newLayout)), - target: &b.image.raw, - range: b.image.map_subresource_range(b.subresourceRange), - families: None, - }); + let barriers = make_barriers(raw_globals, raw_buffers, raw_images); unsafe { commandBuffer.pipeline_barrier( conv::map_pipeline_stage_flags(srcStageMask) .. conv::map_pipeline_stage_flags(dstStageMask), memory::Dependencies::from_bits(dependencyFlags as _).unwrap_or(memory::Dependencies::empty()), - global_barriers.chain(buffer_barriers).chain(image_barriers), + barriers, ); } } @@ -4600,9 +4668,9 @@ pub extern "C" fn gfxAcquireNextImageKHR( Err(hal::AcquireError::OutOfDate) => VkResult::VK_ERROR_OUT_OF_DATE_KHR, Err(hal::AcquireError::SurfaceLost(_)) => VkResult::VK_ERROR_SURFACE_LOST_KHR, Err(hal::AcquireError::DeviceLost(_)) => VkResult::VK_ERROR_DEVICE_LOST, + Err(hal::AcquireError::Timeout) => VkResult::VK_TIMEOUT, Err(hal::AcquireError::OutOfMemory(OutOfDeviceMemory)) => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY, Err(hal::AcquireError::OutOfMemory(OutOfHostMemory)) => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY, - Err(hal::AcquireError::Timeout) => VkResult::VK_TIMEOUT, } } #[inline] @@ -4674,7 +4742,7 @@ pub extern "C" fn gfxCreateMacOSSurfaceMVK( ) -> VkResult { assert!(pAllocator.is_null()); let info = unsafe { &*pCreateInfo }; - #[cfg(target_os="macos")] + #[cfg(all(target_os="macos", feature = "gfx-backend-metal"))] unsafe { let enable_signposts = env::var("GFX_METAL_SIGNPOSTS").is_ok(); if enable_signposts { @@ -4686,7 +4754,7 @@ pub extern "C" fn gfxCreateMacOSSurfaceMVK( ); VkResult::VK_SUCCESS } - #[cfg(not(target_os = "macos"))] + #[cfg(not(all(target_os="macos", feature = "gfx-backend-metal")))] { let _ = (instance, info, pSurface); unreachable!() diff --git a/libportability-gfx/src/lib.rs b/libportability-gfx/src/lib.rs index c623e4e..61a5b2c 100644 --- a/libportability-gfx/src/lib.rs +++ b/libportability-gfx/src/lib.rs @@ -15,6 +15,14 @@ extern crate gfx_backend_metal as back; extern crate gfx_backend_vulkan as back; #[cfg(feature = "gfx-backend-gl")] extern crate gfx_backend_gl as back; +#[cfg(not(any( + feature = "gfx-backend-dx12", + feature = "gfx-backend-dx11", + feature = "gfx-backend-metal", + feature = "gfx-backend-vulkan", + feature = "gfx-backend-gl", +)))] +extern crate gfx_backend_empty as back; extern crate copyless; #[macro_use] @@ -57,6 +65,7 @@ pub type VkImage = Handle>; pub type VkImageView = Handle<::ImageView>; pub type VkBuffer = Handle<::Buffer>; pub type VkSemaphore = Handle<::Semaphore>; +pub type VkEvent = Handle<::Event>; pub type VkFence = Handle<::Fence>; pub type VkRenderPass = Handle<::RenderPass>; pub type VkFramebuffer = Handle<::Framebuffer>; @@ -622,13 +631,6 @@ pub type VkBool32 = u32; pub type VkDeviceSize = u64; pub type VkSampleMask = u32; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct VkEvent_T { - _unused: [u8; 0], -} -pub type VkEvent = *mut VkEvent_T; - pub const VkPipelineCacheHeaderVersion_VK_PIPELINE_CACHE_HEADER_VERSION_BEGIN_RANGE: VkPipelineCacheHeaderVersion = VkPipelineCacheHeaderVersion::VK_PIPELINE_CACHE_HEADER_VERSION_ONE;