diff --git a/.travis.yml b/.travis.yml index 5158a9f221..9815f3e952 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ before_install: script: - cargo test # TODO: enable GL backend - - (cd wgpu-native && cargo check --features local) + - (cd wgpu-native && cargo check --all-features) - if [[ $TRAVIS_OS_NAME == "osx" ]]; then (cd wgpu-native && cargo check --features gfx-backend-vulkan); fi - if [[ $TRAVIS_OS_NAME == "linux" ]]; then cargo check --release; fi - if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo +nightly install cbindgen; fi diff --git a/Cargo.lock b/Cargo.lock index 5b740d5ee6..ffcb9239e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,16 +52,6 @@ dependencies = [ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bincode" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "1.0.4" @@ -149,24 +139,6 @@ dependencies = [ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crossbeam-channel" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "crossbeam-utils" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "d3d12" version = "0.1.0" @@ -206,11 +178,6 @@ dependencies = [ "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "fnv" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "foreign-types" version = "0.3.2" @@ -224,25 +191,6 @@ name = "foreign-types-shared" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "fxhash" version = "0.2.1" @@ -353,32 +301,6 @@ dependencies = [ "atom 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "iovec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ipc-channel" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (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.55 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "js-sys" version = "0.3.25" @@ -387,15 +309,6 @@ dependencies = [ "wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lazy_static" version = "1.3.0" @@ -444,44 +357,6 @@ dependencies = [ "objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mio" -version = "0.6.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "net2" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nodrop" version = "0.1.13" @@ -549,102 +424,6 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "range-alloc" version = "0.1.0" @@ -658,14 +437,6 @@ dependencies = [ "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "redox_syscall" version = "0.1.54" @@ -681,14 +452,6 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "remove_dir_all" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rendy-descriptor" version = "0.4.0" @@ -825,32 +588,11 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tempfile" -version = "3.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "uuid" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "vec_map" version = "0.8.1" @@ -932,18 +674,11 @@ dependencies = [ name = "wgpu-remote" version = "0.1.0" dependencies = [ - "ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "wgpu-native 0.3.3", ] -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.7" @@ -953,11 +688,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -976,15 +706,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "x11" version = "2.18.1" @@ -1002,7 +723,6 @@ dependencies = [ "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "f92d5d536fa03dc3d93711d97bac1fae2eb59aba467ca4c6600c0119da614f51" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9f04a5e50dc80b3d5d35320889053637d15011aed5e66b66b37ae798c65da6f7" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" "checksum bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2cd43d82f27d68911e6ee11ee791fb248f138f5d69424dc02e098d4f152b0b05" @@ -1016,18 +736,12 @@ dependencies = [ "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" "checksum core-graphics 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" -"checksum crossbeam-channel 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f0ed1a4de2235cabda8558ff5840bffb97fcb64c97827f354a451307df5f72b" -"checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" "checksum d3d12 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4fda5547c55c93b070d59108464bbfd7d9da9563b2ce78fceefc6430e972a420" "checksum derivative 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6073e9676dbebdddeabaeb63e3b7cefd23c86f5c41d381ee1237cc77b1079898" "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 fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gfx-backend-dx11 0.3.0 (git+https://github.com/gfx-rs/gfx?rev=3d5db15661127c8cad8d85522a68ec36c82f6e69)" = "" @@ -1037,19 +751,13 @@ dependencies = [ "checksum gfx-backend-vulkan 0.3.0 (git+https://github.com/gfx-rs/gfx?rev=3d5db15661127c8cad8d85522a68ec36c82f6e69)" = "" "checksum gfx-hal 0.3.0 (git+https://github.com/gfx-rs/gfx?rev=3d5db15661127c8cad8d85522a68ec36c82f6e69)" = "" "checksum hibitset 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "47e7292fd9f7fe89fa35c98048f2d0a69b79ed243604234d18f6f8a1aa6f408d" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum ipc-channel 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "79d98ee7dd1d2e796d254807fd86ea7189d07571aeaa74007603e29a79d15217" "checksum js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "da3ea71161651a4cd97d999b2da139109c537b15ab33abc8ae4ead38deac8a03" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum malloc_buf 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" "checksum metal 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2832bd32c9068fb916aea0086f7422b8c31fd604d83b4393062974f862480a8f" -"checksum mio 0.6.17 (registry+https://github.com/rust-lang/crates.io-index)" = "049ba5ca2b63e837adeee724aa9e36b408ed593529dcc802aa96ca14bd329bdf" -"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum objc 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "31d20fd2b37e07cf5125be68357b588672e8cefe9a96f8c17a9d46053b3e590d" "checksum objc_exception 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "098cd29a2fa3c230d3463ae069cecccc3fdfd64c0d2496ab5b96f82dab6a00dc" @@ -1058,22 +766,10 @@ dependencies = [ "checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum range-alloc 0.1.0 (git+https://github.com/gfx-rs/gfx?rev=3d5db15661127c8cad8d85522a68ec36c82f6e69)" = "" "checksum raw-window-handle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e815b85b31e4d397ca9dd8eb1d692e9cb458b9f6ae8ac2232c995dca8236f87" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum relevant 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bbc232e13d37f4547f5b9b42a5efc380cabe5dbc1807f8b893580640b2ab0308" -"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rendy-descriptor 0.4.0 (git+https://github.com/amethyst/rendy?rev=e8ffcabc2bc74fbb282d4f71fa55c28d0ec31c86)" = "" "checksum rendy-memory 0.4.0 (git+https://github.com/amethyst/rendy?rev=e8ffcabc2bc74fbb282d4f71fa55c28d0ec31c86)" = "" "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" @@ -1090,20 +786,15 @@ dependencies = [ "checksum storage-map 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd0a4829a5c591dc24a944a736d6b1e4053e51339a79fd5d4702c4c999a9c45e" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum wasm-bindgen 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "4de97fa1806bb1a99904216f6ac5e0c050dc4f8c676dc98775047c38e5c01b55" "checksum wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "5d82c170ef9f5b2c63ad4460dfcee93f3ec04a9a36a4cc20bc973c39e59ab8e3" "checksum wasm-bindgen-macro 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f07d50f74bf7a738304f6b8157f4a581e1512cd9e9cdb5baad8c31bbe8ffd81d" "checksum wasm-bindgen-macro-support 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "95cf8fe77e45ba5f91bc8f3da0c3aa5d464b3d8ed85d84f4d4c7cc106436b1d7" "checksum wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "d9c2d4d4756b2e46d3a5422e06277d02e4d3e1d62d138b76a4c681e925743623" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" -"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum x11 2.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39697e3123f715483d311b5826e254b6f3cfebdd83cf7ef3358f579c3d68e235" diff --git a/examples/remote/main.c b/examples/remote/main.c index 81229e1739..fc0f93ab1f 100644 --- a/examples/remote/main.c +++ b/examples/remote/main.c @@ -1,17 +1,28 @@ +#define WGPU_INLINE +#define WGPU_FUNC + #include "./../../ffi/wgpu-remote.h" #include int main() { - WGPUInfrastructure infra = wgpu_initialize(); + WGPUInfrastructure infra = wgpu_client_new(); + + if (!infra.client || infra.error) { + printf("Cannot initialize WGPU client: %s", infra.error); + return 1; + } + + WGPUGlobal* server = wgpu_server_new(); - if (!infra.client || !infra.server || infra.error) { - printf("Cannot initialize WGPU: %s", infra.error); + if (!server) { + printf("Cannot initialize WGPU client: %s", server); return 1; } //TODO: do something meaningful - wgpu_terminate(infra.client); + wgpu_server_delete(server); + wgpu_client_delete(infra.client); return 0; } diff --git a/ffi/wgpu-remote.h b/ffi/wgpu-remote.h index 44d33f04d0..d920eef422 100644 --- a/ffi/wgpu-remote.h +++ b/ffi/wgpu-remote.h @@ -1,7 +1,19 @@ - +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* Generated with cbindgen:0.9.1 */ +/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. + * To generate this file: + * 1. Get the latest cbindgen using `cargo install --force cbindgen` + * a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release + * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h` + */ + +typedef void WGPUEmpty; + + #include #include #include @@ -15,15 +27,20 @@ typedef enum { typedef struct WGPUClient WGPUClient; -typedef struct WGPUServer WGPUServer; +typedef struct WGPUGlobal WGPUGlobal; + +typedef uint64_t WGPUId_Adapter_Dummy; + +typedef WGPUId_Adapter_Dummy WGPUAdapterId; typedef uint64_t WGPUId_Device_Dummy; typedef WGPUId_Device_Dummy WGPUDeviceId; -typedef uint64_t WGPUId_Adapter_Dummy; - -typedef WGPUId_Adapter_Dummy WGPUAdapterId; +typedef struct { + WGPUClient *client; + const uint8_t *error; +} WGPUInfrastructure; typedef struct { bool anisotropic_filtering; @@ -45,21 +62,59 @@ typedef struct { WGPUBackendBit backends; } WGPURequestAdapterOptions; -typedef struct { - WGPUClient *client; - WGPUServer *server; - const uint8_t *error; -} WGPUInfrastructure; - -WGPUDeviceId wgpu_client_adapter_create_device(const WGPUClient *client, - WGPUAdapterId adapter_id, - const WGPUDeviceDescriptor *desc); - -WGPUAdapterId wgpu_client_request_adapter(const WGPUClient *client, - const WGPURequestAdapterOptions *desc); - -WGPUInfrastructure wgpu_initialize(void); - -void wgpu_server_process(const WGPUServer *server); - -void wgpu_terminate(WGPUClient *client); +WGPU_INLINE +void wgpu_client_delete(WGPUClient *aClient) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_client_kill_adapter_ids(const WGPUClient *aClient, + const WGPUAdapterId *aIds, + uintptr_t aIdLength) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_client_kill_device_id(const WGPUClient *aClient, + WGPUDeviceId aId) +WGPU_FUNC; + +WGPU_INLINE +uintptr_t wgpu_client_make_adapter_ids(const WGPUClient *aClient, + WGPUAdapterId *aIds, + uintptr_t aIdLength) +WGPU_FUNC; + +WGPU_INLINE +WGPUDeviceId wgpu_client_make_device_id(const WGPUClient *aClient, + WGPUAdapterId aAdapterId) +WGPU_FUNC; + +WGPU_INLINE +WGPUInfrastructure wgpu_client_new(void) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_server_adapter_request_device(const WGPUGlobal *aGlobal, + WGPUAdapterId aSelfId, + const WGPUDeviceDescriptor *aDesc, + WGPUDeviceId aNewId) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_server_delete(WGPUGlobal *aGlobal) +WGPU_FUNC; + +WGPU_INLINE +void wgpu_server_device_destroy(const WGPUGlobal *aGlobal, + WGPUDeviceId aSelfId) +WGPU_FUNC; + +WGPU_INLINE +WGPUAdapterId wgpu_server_instance_request_adapter(const WGPUGlobal *aGlobal, + const WGPURequestAdapterOptions *aDesc, + const WGPUAdapterId *aIds, + uintptr_t aIdLength) +WGPU_FUNC; + +WGPU_INLINE +WGPUGlobal *wgpu_server_new(void) +WGPU_FUNC; diff --git a/wgpu-native/Cargo.toml b/wgpu-native/Cargo.toml index 357d97d109..175e586b05 100644 --- a/wgpu-native/Cargo.toml +++ b/wgpu-native/Cargo.toml @@ -17,7 +17,7 @@ crate-type = ["lib", "cdylib", "staticlib"] [features] default = [] -local = ["lazy_static"] +local = ["lazy_static", "raw-window-handle"] metal-auto-capture = ["gfx-backend-metal/auto-capture"] #NOTE: glutin feature is not stable, use at your own risk #glutin = ["gfx-backend-gl/glutin"] @@ -31,7 +31,7 @@ log = "0.4" hal = { package = "gfx-hal", git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" } gfx-backend-empty = { git = "https://github.com/gfx-rs/gfx", rev = "3d5db15661127c8cad8d85522a68ec36c82f6e69" } parking_lot = "0.9" -raw-window-handle = "0.3" +raw-window-handle = { version = "0.3", optional = true } rendy-memory = { git = "https://github.com/amethyst/rendy", rev = "e8ffcabc2bc74fbb282d4f71fa55c28d0ec31c86" } rendy-descriptor = { git = "https://github.com/amethyst/rendy", rev = "e8ffcabc2bc74fbb282d4f71fa55c28d0ec31c86" } serde = { version = "1.0", features = ["serde_derive"], optional = true } diff --git a/wgpu-native/cbindgen.toml b/wgpu-native/cbindgen.toml index 9e296d5ded..f111779e1e 100644 --- a/wgpu-native/cbindgen.toml +++ b/wgpu-native/cbindgen.toml @@ -32,7 +32,6 @@ bitflags = true [defines] "feature = local" = "WGPU_LOCAL" -"feature = remote" = "WGPU_REMOTE" "feature = gfx-backend-gl" = "WGPU_BACKEND_GL" "feature = winit" = "WGPU_WINIT" "feature = glutin" = "WGPU_GLUTIN" diff --git a/wgpu-native/src/command/allocator.rs b/wgpu-native/src/command/allocator.rs index 07ce1bfe98..fd33c367b9 100644 --- a/wgpu-native/src/command/allocator.rs +++ b/wgpu-native/src/command/allocator.rs @@ -60,16 +60,6 @@ pub struct CommandAllocator { } impl CommandAllocator { - pub fn new(queue_family: hal::queue::QueueFamilyId) -> Self { - CommandAllocator { - queue_family, - inner: Mutex::new(Inner { - pools: HashMap::new(), - pending: Vec::new(), - }), - } - } - pub(crate) fn allocate( &self, device_id: Stored, @@ -103,6 +93,18 @@ impl CommandAllocator { features, } } +} + +impl CommandAllocator { + pub fn new(queue_family: hal::queue::QueueFamilyId) -> Self { + CommandAllocator { + queue_family, + inner: Mutex::new(Inner { + pools: HashMap::new(), + pending: Vec::new(), + }), + } + } pub fn extend(&self, cmd_buf: &CommandBuffer) -> B::CommandBuffer { let mut inner = self.inner.lock(); diff --git a/wgpu-native/src/command/mod.rs b/wgpu-native/src/command/mod.rs index 4313ffe504..efa2d9956b 100644 --- a/wgpu-native/src/command/mod.rs +++ b/wgpu-native/src/command/mod.rs @@ -112,7 +112,7 @@ pub struct CommandBuffer { pub(crate) raw: Vec, is_recording: bool, recorded_thread_id: ThreadId, - device_id: Stored, + pub(crate) device_id: Stored, pub(crate) life_guard: LifeGuard, pub(crate) trackers: TrackerSet, pub(crate) used_swap_chain: Option<(Stored, B::Framebuffer)>, diff --git a/wgpu-native/src/device.rs b/wgpu-native/src/device.rs index ac07e7f8c6..0510655a88 100644 --- a/wgpu-native/src/device.rs +++ b/wgpu-native/src/device.rs @@ -768,6 +768,21 @@ impl Device { } } +impl Device { + pub(crate) fn destroy_bind_group(&self, bind_group: binding_model::BindGroup) { + unsafe { + self.desc_allocator.lock().free(iter::once(bind_group.raw)); + } + } + + pub(crate) fn destroy_self(self) { + self.com_allocator.destroy(&self.raw); + unsafe { + self.desc_allocator.lock().cleanup(&self.raw); + } + } +} + #[cfg(feature = "local")] #[no_mangle] pub extern "C" fn wgpu_device_get_limits(_device_id: DeviceId, limits: &mut Limits) { diff --git a/wgpu-native/src/hub.rs b/wgpu-native/src/hub.rs index b4f1328311..0e21b512d3 100644 --- a/wgpu-native/src/hub.rs +++ b/wgpu-native/src/hub.rs @@ -389,6 +389,67 @@ impl Default for Hub { } } +impl Drop for Hub { + fn drop(&mut self) { + use crate::resource::TextureViewInner; + use hal::device::Device as _; + + let mut devices = self.devices.data.write(); + + for (_, (sampler, _)) in self.samplers.data.write().map.drain() { + unsafe { + devices[sampler.device_id.value].raw.destroy_sampler(sampler.raw); + } + } + { + let textures = self.textures.data.read(); + for (_, (texture_view, _)) in self.texture_views.data.write().map.drain() { + match texture_view.inner { + TextureViewInner::Native { raw, source_id } => { + let device = &devices[textures[source_id.value].device_id.value]; + unsafe { + device.raw.destroy_image_view(raw); + } + } + TextureViewInner::SwapChain { .. } => {} //TODO + } + } + } + for (_, (texture, _)) in self.textures.data.write().map.drain() { + unsafe { + devices[texture.device_id.value].raw.destroy_image(texture.raw); + } + } + for (_, (buffer, _)) in self.buffers.data.write().map.drain() { + unsafe { + devices[buffer.device_id.value].raw.destroy_buffer(buffer.raw); + } + } + for (_, (command_buffer, _)) in self.command_buffers.data.write().map.drain() { + devices[command_buffer.device_id.value].com_allocator.after_submit(command_buffer, 0); + } + for (_, (bind_group, _)) in self.bind_groups.data.write().map.drain() { + let device = &devices[bind_group.device_id.value]; + device.destroy_bind_group(bind_group); + } + + //TODO: + // self.compute_pipelines + // self.compute_passes + // self.render_pipelines + // self.render_passes + // self.bind_group_layouts + // self.pipeline_layouts + // self.shader_modules + // self.swap_chains + // self.adapters + + for (_, (device, _)) in devices.map.drain() { + device.destroy_self(); + } + } +} + #[derive(Debug, Default)] pub struct Hubs { #[cfg(any( @@ -411,13 +472,34 @@ pub struct Global { hubs: Hubs, } +impl Global { + fn new_impl(name: &str) -> Self { + Global { + instance: Instance::new(name, 1), + surfaces: Registry::new(Backend::Empty), + hubs: Hubs::default(), + } + } + + #[cfg(not(feature = "local"))] + pub fn new(name: &str) -> Self { + Self::new_impl(name) + } + + #[cfg(not(feature = "local"))] + pub fn delete(self) { + let Global { mut instance, surfaces, hubs } = self; + drop(hubs); + // destroy surfaces + for (_, (surface, _)) in surfaces.data.write().map.drain() { + instance.destroy_surface(surface); + } + } +} + #[cfg(feature = "local")] lazy_static::lazy_static! { - pub static ref GLOBAL: Arc = Arc::new(Global { - instance: Instance::new("wgpu", 1), - surfaces: Registry::new(Backend::Empty), - hubs: Hubs::default(), - }); + pub static ref GLOBAL: Arc = Arc::new(Global::new_impl("wgpu")); } pub trait GfxBackend: hal::Backend { diff --git a/wgpu-native/src/instance.rs b/wgpu-native/src/instance.rs index fd6c932782..ab9e082313 100644 --- a/wgpu-native/src/instance.rs +++ b/wgpu-native/src/instance.rs @@ -58,6 +58,31 @@ impl Instance { dx11: gfx_backend_dx11::Instance::create(name, version).unwrap(), } } + + #[cfg(not(feature = "local"))] + pub(crate) fn destroy_surface(&mut self, surface: Surface) { + //TODO: fill out the proper destruction once we are on gfx-0.4 + #[cfg(any( + not(any(target_os = "ios", target_os = "macos")), + feature = "gfx-backend-vulkan" + ))] + { + if let Some(_suf) = surface.vulkan { + //self.vulkan.as_mut().unwrap().destroy_surface(suf); + } + } + #[cfg(any(target_os = "ios", target_os = "macos"))] + { + //self.metal.destroy_surface(surface.metal); + } + #[cfg(windows)] + { + if let Some(_suf) = surface.dx12 { + //self.dx12.as_mut().unwrap().destroy_surface(suf); + } + //self.dx11.destroy_surface(surface.dx11); + } + } } type GfxSurface = ::Surface; @@ -94,6 +119,7 @@ pub enum PowerPreference { #[cfg(feature = "local")] bitflags! { #[repr(transparent)] + #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct BackendBit: u32 { const VULKAN = 1 << Backend::Vulkan as u32; const GL = 1 << Backend::Gl as u32; diff --git a/wgpu-native/src/lib.rs b/wgpu-native/src/lib.rs index bb6c010941..673ddbd628 100644 --- a/wgpu-native/src/lib.rs +++ b/wgpu-native/src/lib.rs @@ -33,7 +33,7 @@ pub use self::binding_model::*; pub use self::command::*; pub use self::device::*; #[cfg(not(feature = "local"))] -pub use self::hub::{Access, IdentityManager, Registry, Token}; +pub use self::hub::{Access, Global, IdentityManager, Registry, Token}; pub use self::id::*; pub use self::instance::*; pub use self::pipeline::*; diff --git a/wgpu-remote/Cargo.toml b/wgpu-remote/Cargo.toml index 2dff45aae8..440f13bc46 100644 --- a/wgpu-remote/Cargo.toml +++ b/wgpu-remote/Cargo.toml @@ -14,8 +14,6 @@ crate-type = ["lib", "cdylib", "staticlib"] default = [] [dependencies] -wgpu-native = { path = "../wgpu-native", version = "0.3", features = ["serde"] } -ipc-channel = "0.12" +wgn = { path = "../wgpu-native", package = "wgpu-native", version = "0.3" } log = "0.4" parking_lot = { version = "0.9" } -serde = { version = "1.0", features = ["serde_derive"] } diff --git a/wgpu-remote/cbindgen.toml b/wgpu-remote/cbindgen.toml index 736de64dac..2d552f4819 100644 --- a/wgpu-remote/cbindgen.toml +++ b/wgpu-remote/cbindgen.toml @@ -1,4 +1,15 @@ -header = "" +header = """/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */""" +autogen_warning = """/* DO NOT MODIFY THIS MANUALLY! This file was generated using cbindgen. + * To generate this file: + * 1. Get the latest cbindgen using `cargo install --force cbindgen` + * a. Alternatively, you can clone `https://github.com/eqrion/cbindgen` and use a tagged release + * 2. Run `rustup run nightly cbindgen toolkit/library/rust/ --lockfile Cargo.lock --crate wgpu-remote -o dom/webgpu/ffi/wgpu_ffi_generated.h` + */ + +typedef void WGPUEmpty; +""" include_version = true braces = "SameLine" line_length = 100 @@ -14,6 +25,10 @@ parse_deps = true include = ["wgpu-native"] [fn] +prefix = "WGPU_INLINE" +postfix = "WGPU_FUNC" +args = "Vertical" +rename_args = "GeckoCase" [struct] derive_eq = true @@ -24,3 +39,8 @@ derive_helper_methods = true [macro_expansion] bitflags = true + +[defines] +"target_os = windows" = "XP_WIN" +"target_os = macos" = "XP_MACOSX" +"target_os = android" = "ANDROID" diff --git a/wgpu-remote/src/lib.rs b/wgpu-remote/src/lib.rs index 39823542df..0a209807f5 100644 --- a/wgpu-remote/src/lib.rs +++ b/wgpu-remote/src/lib.rs @@ -2,51 +2,18 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//TODO: remove once `cbindgen` is smart enough -extern crate wgpu_native as wgn; use wgn::{AdapterId, Backend, DeviceId, IdentityManager, SurfaceId}; -use crate::server::Server; - -use ipc_channel::ipc; use parking_lot::Mutex; -use serde::{Deserialize, Serialize}; - -use std::{ptr, sync::Arc}; - -mod server; - -/// A message on the timeline of devices, queues, and resources. -#[derive(Serialize, Deserialize, Debug)] -enum GlobalMessage { - RequestAdapter(wgn::RequestAdapterOptions, Vec), - AdapterRequestDevice(wgn::AdapterId, wgn::DeviceDescriptor, wgn::DeviceId), - //Device(DeviceMessage), - //Queue(QueueMessage), - //Texture(TextureMessage), - //Command(CommandMessage), - Terminate, -} + +use std::{ptr, slice}; + +pub mod server; #[derive(Debug)] struct IdentityHub { adapters: IdentityManager, devices: IdentityManager, - /* - pipeline_layouts: IdentityManager, - shader_modules: IdentityManager, - bind_group_layouts: IdentityManager, - bind_groups: IdentityManager, - command_buffers: IdentityManager, - render_passes: IdentityManager, - render_pipelines: IdentityManager, - compute_passes: IdentityManager, - compute_pipelines: IdentityManager, - buffers: IdentityManager, - textures: IdentityManager, - texture_views: IdentityManager, - samplers: IdentityManager, - */ } impl IdentityHub { @@ -92,85 +59,92 @@ impl Identities { } } - -#[derive(Clone, Debug)] +#[derive(Debug)] pub struct Client { - channel: ipc::IpcSender, - identities: Arc>, + identities: Mutex, } #[repr(C)] #[derive(Debug)] pub struct Infrastructure { pub client: *mut Client, - pub server: *mut Server, pub error: *const u8, } #[no_mangle] -pub extern "C" fn wgpu_initialize() -> Infrastructure { - match ipc::channel() { - Ok((sender, receiver)) => { - let client = Client { - channel: sender, - identities: Arc::new(Mutex::new(Identities::new())), - }; - let server = Server::new(receiver); - Infrastructure { - client: Box::into_raw(Box::new(client)), - server: Box::into_raw(Box::new(server)), - error: ptr::null(), - } - } - Err(e) => { - log::error!("WGPU initialize failed: {:?}", e); - Infrastructure { - client: ptr::null_mut(), - server: ptr::null_mut(), - error: ptr::null(), //TODO_remote_ - } - } +pub extern "C" fn wgpu_client_new() -> Infrastructure { + log::info!("Initializing WGPU client"); + let client = Box::new(Client { + identities: Mutex::new(Identities::new()), + }); + Infrastructure { + client: Box::into_raw(client), + error: ptr::null(), } } #[no_mangle] -pub extern "C" fn wgpu_terminate(client: *mut Client) { - let client = unsafe { Box::from_raw(client) }; - let msg = GlobalMessage::Terminate; - let _ = client.channel.send(msg); +pub extern "C" fn wgpu_client_delete(client: *mut Client) { + log::info!("Terminating WGPU client"); + let _client = unsafe { Box::from_raw(client) }; } #[no_mangle] -pub extern "C" fn wgpu_client_request_adapter( +pub extern "C" fn wgpu_client_make_adapter_ids( client: &Client, - desc: &wgn::RequestAdapterOptions, -) -> wgn::AdapterId { + ids: *mut wgn::AdapterId, + id_length: usize, +) -> usize { let mut identities = client.identities.lock(); - let ids = vec![ - identities.vulkan.adapters.alloc(), - #[cfg(any(target_os = "ios", target_os = "macos"))] - identities.metal.adapters.alloc(), - #[cfg(windows)] - identities.dx12.adapters.alloc(), - ]; - let msg = GlobalMessage::RequestAdapter(desc.clone(), ids); - client.channel.send(msg).unwrap(); - unimplemented!() + assert_ne!(id_length, 0); + let mut ids = unsafe { slice::from_raw_parts_mut(ids, id_length) }.iter_mut(); + + *ids.next().unwrap() = identities.vulkan.adapters.alloc(); + + #[cfg(any(target_os = "ios", target_os = "macos"))] + { + *ids.next().unwrap() = identities.metal.adapters.alloc(); + } + #[cfg(windows)] + { + *ids.next().unwrap() = identities.dx12.adapters.alloc(); + } + + id_length - ids.len() +} + +#[no_mangle] +pub extern "C" fn wgpu_client_kill_adapter_ids( + client: &Client, + ids: *const wgn::AdapterId, + id_length: usize, +) { + let mut identity = client.identities.lock(); + let ids = unsafe { slice::from_raw_parts(ids, id_length) }; + for &id in ids { + identity.select(id.backend()).adapters.free(id) + } } #[no_mangle] -pub extern "C" fn wgpu_client_adapter_create_device( +pub extern "C" fn wgpu_client_make_device_id( client: &Client, adapter_id: wgn::AdapterId, - desc: &wgn::DeviceDescriptor, ) -> wgn::DeviceId { - let device_id = client + client .identities .lock() .select(adapter_id.backend()) .devices - .alloc(); - let msg = GlobalMessage::AdapterRequestDevice(adapter_id, desc.clone(), device_id); - client.channel.send(msg).unwrap(); - device_id + .alloc() +} + +#[no_mangle] +pub extern "C" fn wgpu_client_kill_device_id(client: &Client, id: wgn::DeviceId) { + client + .identities + .lock() + .select(id.backend()) + .devices + .free(id) } diff --git a/wgpu-remote/src/server.rs b/wgpu-remote/src/server.rs index a909cb7ed4..719591ee42 100644 --- a/wgpu-remote/src/server.rs +++ b/wgpu-remote/src/server.rs @@ -2,49 +2,45 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use crate::GlobalMessage; +use std::slice; -use ipc_channel::ipc::IpcReceiver; -use wgn; - -#[derive(Debug)] -pub struct Server { - channel: IpcReceiver, +#[no_mangle] +pub extern "C" fn wgpu_server_new() -> *mut wgn::Global { + log::info!("Initializing WGPU server"); + Box::into_raw(Box::new(wgn::Global::new("wgpu"))) } -impl Server { - pub(crate) fn new(channel: IpcReceiver) -> Self { - Server { channel } - } +#[no_mangle] +pub extern "C" fn wgpu_server_delete(global: *mut wgn::Global) { + log::info!("Terminating WGPU server"); + unsafe { Box::from_raw(global) }.delete(); + log::info!("\t...done"); } -enum ControlFlow { - Continue, - Terminate, +#[no_mangle] +pub extern "C" fn wgpu_server_instance_request_adapter( + global: &wgn::Global, + desc: &wgn::RequestAdapterOptions, + ids: *const wgn::AdapterId, + id_length: usize, +) -> wgn::AdapterId { + let ids = unsafe { slice::from_raw_parts(ids, id_length) }; + wgn::request_adapter(global, desc, ids).unwrap() } -fn process(_message: GlobalMessage) -> ControlFlow { - /* - match message { - GlobalMessage::RequestAdapter(ref desc, ref ids) => { - wgn::request_adapter(desc, ids); - } - GlobalMessage::AdapterRequestDevice(adapter_id, ref desc, id) => { - use wgn::adapter_request_device as fun; - wgn::gfx_select!(adapter_id => fun(adapter_id, desc, id)); - } - GlobalMessage::Terminate => return ControlFlow::Terminate, - }*/ - - ControlFlow::Continue +#[no_mangle] +pub extern "C" fn wgpu_server_adapter_request_device( + global: &wgn::Global, + self_id: wgn::AdapterId, + desc: &wgn::DeviceDescriptor, + new_id: wgn::DeviceId, +) { + use wgn::adapter_request_device as func; + wgn::gfx_select!(self_id => func(global, self_id, desc, new_id)); } #[no_mangle] -pub extern "C" fn wgpu_server_process(server: &Server) { - while let Ok(message) = server.channel.try_recv() { - match process(message) { - ControlFlow::Continue => {} - ControlFlow::Terminate => break, - } - } +pub extern "C" fn wgpu_server_device_destroy(global: &wgn::Global, self_id: wgn::DeviceId) { + use wgn::device_destroy as func; + wgn::gfx_select!(self_id => func(global, self_id)) }