mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-19 18:33:30 +00:00
Merge #65
65: First bits of wgpu-remote r=grovesNL a=kvark Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com> Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
commit
dd73675868
174
Cargo.lock
generated
174
Cargo.lock
generated
@ -102,6 +102,16 @@ dependencies = [
|
||||
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.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)",
|
||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.0.4"
|
||||
@ -235,6 +245,24 @@ dependencies = [
|
||||
"libc 0.2.48 (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.8 (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.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "d3d12"
|
||||
version = "0.1.0"
|
||||
@ -321,6 +349,11 @@ name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "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"
|
||||
@ -491,11 +524,46 @@ dependencies = [
|
||||
"quick-error 1.2.2 (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.48 (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.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bincode 1.1.1 (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.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.3"
|
||||
source = "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 = "0.2.11"
|
||||
@ -506,6 +574,11 @@ name = "lazy_static"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.48"
|
||||
@ -588,6 +661,45 @@ dependencies = [
|
||||
"objc_id 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.6.16"
|
||||
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)",
|
||||
"lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.48 (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.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.12.0"
|
||||
@ -1004,6 +1116,11 @@ dependencies = [
|
||||
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "0.6.8"
|
||||
@ -1182,6 +1299,14 @@ name = "utf8-ranges"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.1"
|
||||
@ -1275,6 +1400,7 @@ dependencies = [
|
||||
name = "wgpu-native"
|
||||
version = "0.1.0"
|
||||
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)",
|
||||
"gfx-backend-dx11 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gfx-backend-dx12 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1285,9 +1411,27 @@ dependencies = [
|
||||
"lazy_static 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)",
|
||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winit 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wgpu-remote"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ipc-channel 0.11.2 (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.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wgpu-native 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.6"
|
||||
@ -1297,6 +1441,11 @@ 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"
|
||||
@ -1354,6 +1503,15 @@ dependencies = [
|
||||
"winapi 0.3.6 (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"
|
||||
@ -1405,6 +1563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
|
||||
"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5"
|
||||
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
|
||||
"checksum bincode 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "58470ad6460f0b0e89b0df5f17b8bd77ebae26af69dca0bd9ddc8b9e38abb2ff"
|
||||
"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 block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
|
||||
@ -1421,6 +1580,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"
|
||||
"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 digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90"
|
||||
@ -1430,6 +1591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"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 fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
"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-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
|
||||
@ -1445,9 +1607,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum gfx-hal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84c470bce77fcaaea6854858682a99026ff796b880b0ca30511593a6b2bc77c0"
|
||||
"checksum glsl-to-spirv 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "28caebc98746d507603a2d3df66dcbe04e41d4febad0320f3eec1ef72b6bbef1"
|
||||
"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114"
|
||||
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
|
||||
"checksum ipc-channel 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3a369bb751cf24f18084aabb56995268ec1f68d2b69937aaf031d41690c1bef"
|
||||
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
|
||||
"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
|
||||
"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
|
||||
"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
|
||||
"checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2"
|
||||
"checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"
|
||||
@ -1457,6 +1623,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8"
|
||||
"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 mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432"
|
||||
"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 nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "921f61dc817b379d0834e45d5ec45beaacfae97082090a49c2cf30dcbc30206f"
|
||||
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
||||
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
|
||||
@ -1507,6 +1676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "4b90a9fbe1211e57d3e1c15670f1cb00802988fb23a1a4aad7a2b63544f1920e"
|
||||
"checksum sha2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eb6be24e4c23a84d7184280d2722f7f2731fcdd4a9d886efbfe4413e4847ea0"
|
||||
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
|
||||
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||
"checksum smallvec 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "88aea073965ab29f6edb5493faf96ad662fb18aa9eeb186a3b7057951605ed15"
|
||||
"checksum smithay-client-toolkit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d858330eeed4efaf71c560555e2a6a0597d01b7d52685c3cc964ab1cc360f8c6"
|
||||
"checksum spirv_cross 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d957f729f8f52ad6fa75c4561e3169836bcdf7eac1126571d9a1834549f50f22"
|
||||
@ -1529,6 +1699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
||||
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||
"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737"
|
||||
"checksum uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0238db0c5b605dd1cf51de0f21766f97fba2645897024461d6a00c036819a768"
|
||||
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
"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"
|
||||
@ -1537,13 +1708,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum wayland-protocols 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fd94211387fa8ff50df1e4ff7a5529b5a9aebe68ba88acc48e5b7f5fd98f6eef"
|
||||
"checksum wayland-scanner 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3611f231e675e15c2feb7623103e6449edc6f10b0598cafb3e16e590a0561355"
|
||||
"checksum wayland-sys 0.21.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2a69d729a1747a5bf40ae05b94c7904b64fbf2381e365c046d872ce4a34aa826"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
||||
"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-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
|
||||
"checksum winit 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c57c15bd4c0ef18dff33e263e452abe32d00e2e05771cacaa410a14cc1c0776"
|
||||
"checksum wio 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8a31e8a268d6941ffb7f8d7989fc93e4692bd3e75a27d400a72b4be1dadb213"
|
||||
"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"
|
||||
"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"
|
||||
|
@ -2,6 +2,7 @@
|
||||
members = [
|
||||
"wgpu-native",
|
||||
"wgpu-bindings",
|
||||
"wgpu-remote",
|
||||
"wgpu-rs",
|
||||
"examples",
|
||||
"gfx-examples",
|
||||
|
2
Makefile
2
Makefile
@ -53,7 +53,7 @@ lib-native: Cargo.lock wgpu-native/Cargo.toml $(wildcard wgpu-native/**/*.rs)
|
||||
lib-rust: Cargo.lock wgpu-rs/Cargo.toml $(wildcard wgpu-rs/**/*.rs)
|
||||
cargo build --manifest-path wgpu-rs/Cargo.toml --features $(FEATURE_RUST)
|
||||
|
||||
wgpu-bindings/wgpu.h: Cargo.lock wgpu-bindings/src/*.rs lib-native
|
||||
wgpu-bindings/*.h: Cargo.lock wgpu-bindings/src/*.rs lib-native
|
||||
cargo +nightly-2018-12-27 run --manifest-path wgpu-bindings/Cargo.toml
|
||||
|
||||
examples-native: lib-native wgpu-bindings/wgpu.h $(wildcard wgpu-native/**/*.c)
|
||||
|
@ -1,6 +1,7 @@
|
||||
use log::info;
|
||||
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn cast_slice<T>(data: &[T]) -> &[u8] {
|
||||
use std::mem::size_of;
|
||||
use std::slice::from_raw_parts;
|
||||
|
@ -1 +1,2 @@
|
||||
newline_style = "Native"
|
||||
spaces_around_ranges = true
|
||||
|
@ -2,42 +2,51 @@ extern crate cbindgen;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
const HEADER: &str = "
|
||||
#ifdef WGPU_REMOTE
|
||||
typedef uint32_t WGPUId;
|
||||
#else
|
||||
typedef void *WGPUId;
|
||||
#endif
|
||||
";
|
||||
struct Binding<'a> {
|
||||
library: &'a str,
|
||||
features: &'a [&'a str],
|
||||
output: &'a str,
|
||||
}
|
||||
|
||||
const BINDINGS: [Binding; 2] = [
|
||||
Binding {
|
||||
library: "wgpu-native",
|
||||
features: &["local"],
|
||||
output: "wgpu.h",
|
||||
},
|
||||
Binding {
|
||||
library: "wgpu-remote",
|
||||
features: &[],
|
||||
output: "wgpu-remote.h",
|
||||
},
|
||||
];
|
||||
|
||||
fn main() {
|
||||
let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
let source_dir = crate_dir.parent().unwrap().join("wgpu-native");
|
||||
let parent = crate_dir.parent().unwrap();
|
||||
|
||||
let config = cbindgen::Config {
|
||||
header: Some(String::from(HEADER.trim())),
|
||||
enumeration: cbindgen::EnumConfig {
|
||||
prefix_with_name: true,
|
||||
for bind in &BINDINGS {
|
||||
let config = cbindgen::Config {
|
||||
enumeration: cbindgen::EnumConfig {
|
||||
prefix_with_name: true,
|
||||
..Default::default()
|
||||
},
|
||||
export: cbindgen::ExportConfig {
|
||||
prefix: Some(String::from("WGPU")),
|
||||
..Default::default()
|
||||
},
|
||||
language: cbindgen::Language::C,
|
||||
..Default::default()
|
||||
},
|
||||
export: cbindgen::ExportConfig {
|
||||
prefix: Some(String::from("WGPU")),
|
||||
exclude: vec![
|
||||
// We manually define `Id` is within the header, so exclude it here
|
||||
String::from("Id"),
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
language: cbindgen::Language::C,
|
||||
..Default::default()
|
||||
};
|
||||
};
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(source_dir)
|
||||
.with_config(config)
|
||||
.with_parse_expand(&["wgpu-native"])
|
||||
.with_parse_expand_features(&["local"])
|
||||
.generate()
|
||||
.unwrap()
|
||||
.write_to_file(crate_dir.join("wgpu.h"));
|
||||
println!("Generating {}...", bind.output);
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(parent.join(bind.library))
|
||||
.with_config(config)
|
||||
.with_parse_expand(&[bind.library])
|
||||
.with_parse_expand_features(bind.features)
|
||||
.generate()
|
||||
.unwrap()
|
||||
.write_to_file(crate_dir.join(bind.output));
|
||||
}
|
||||
}
|
||||
|
14
wgpu-bindings/wgpu-remote.h
Normal file
14
wgpu-bindings/wgpu-remote.h
Normal file
@ -0,0 +1,14 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct WGPUClient WGPUClient;
|
||||
|
||||
WGPUDeviceId wgpu_adapter_create_device(const WGPUClient *client,
|
||||
WGPUAdapterId adapter_id,
|
||||
const WGPUDeviceDescriptor *desc);
|
||||
|
||||
WGPUAdapterId wgpu_instance_get_adapter(const WGPUClient *client,
|
||||
WGPUInstanceId instance_id,
|
||||
const WGPUAdapterDescriptor *desc);
|
@ -1,9 +1,3 @@
|
||||
#ifdef WGPU_REMOTE
|
||||
typedef uint32_t WGPUId;
|
||||
#else
|
||||
typedef void *WGPUId;
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -138,7 +132,8 @@ typedef enum {
|
||||
WGPUTextureFormat_R8g8b8a8Unorm = 0,
|
||||
WGPUTextureFormat_R8g8b8a8Uint = 1,
|
||||
WGPUTextureFormat_B8g8r8a8Unorm = 2,
|
||||
WGPUTextureFormat_D32FloatS8Uint = 3,
|
||||
WGPUTextureFormat_D32Float = 3,
|
||||
WGPUTextureFormat_D32FloatS8Uint = 4,
|
||||
} WGPUTextureFormat;
|
||||
|
||||
typedef enum {
|
||||
@ -155,8 +150,13 @@ typedef enum {
|
||||
WGPUVertexFormat_FloatR32G32B32 = 1,
|
||||
WGPUVertexFormat_FloatR32G32 = 2,
|
||||
WGPUVertexFormat_FloatR32 = 3,
|
||||
WGPUVertexFormat_IntR8G8B8A8 = 4,
|
||||
} WGPUVertexFormat;
|
||||
|
||||
typedef struct WGPUBufferMapAsyncStatus WGPUBufferMapAsyncStatus;
|
||||
|
||||
typedef struct WGPUId WGPUId;
|
||||
|
||||
typedef WGPUId WGPUDeviceId;
|
||||
|
||||
typedef WGPUId WGPUAdapterId;
|
||||
@ -171,6 +171,10 @@ typedef struct {
|
||||
|
||||
typedef WGPUId WGPUBufferId;
|
||||
|
||||
typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, const uint8_t *data, uint8_t *userdata);
|
||||
|
||||
typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, uint8_t *data, uint8_t *userdata);
|
||||
|
||||
typedef WGPUId WGPUCommandBufferId;
|
||||
|
||||
typedef struct {
|
||||
@ -555,11 +559,25 @@ WGPUDeviceId wgpu_adapter_create_device(WGPUAdapterId adapter_id, const WGPUDevi
|
||||
|
||||
void wgpu_buffer_destroy(WGPUBufferId buffer_id);
|
||||
|
||||
void wgpu_buffer_map_read_async(WGPUBufferId buffer_id,
|
||||
uint32_t start,
|
||||
uint32_t size,
|
||||
WGPUBufferMapReadCallback callback,
|
||||
uint8_t *userdata);
|
||||
|
||||
void wgpu_buffer_map_write_async(WGPUBufferId buffer_id,
|
||||
uint32_t start,
|
||||
uint32_t size,
|
||||
WGPUBufferMapWriteCallback callback,
|
||||
uint8_t *userdata);
|
||||
|
||||
void wgpu_buffer_set_sub_data(WGPUBufferId buffer_id,
|
||||
uint32_t start,
|
||||
uint32_t count,
|
||||
const uint8_t *data);
|
||||
|
||||
void wgpu_buffer_unmap(WGPUBufferId buffer_id);
|
||||
|
||||
void wgpu_command_buffer_copy_buffer_to_buffer(WGPUCommandBufferId command_buffer_id,
|
||||
WGPUBufferId src,
|
||||
uint32_t src_offset,
|
||||
@ -632,6 +650,8 @@ WGPUSwapChainId wgpu_device_create_swap_chain(WGPUDeviceId device_id,
|
||||
|
||||
WGPUTextureId wgpu_device_create_texture(WGPUDeviceId device_id, const WGPUTextureDescriptor *desc);
|
||||
|
||||
void wgpu_device_destroy(WGPUBufferId device_id);
|
||||
|
||||
WGPUQueueId wgpu_device_get_queue(WGPUDeviceId device_id);
|
||||
|
||||
WGPUSurfaceId wgpu_instance_create_surface_from_macos_layer(WGPUInstanceId instance_id,
|
||||
|
@ -18,9 +18,11 @@ crate-type = ["lib", "cdylib", "staticlib"]
|
||||
[features]
|
||||
default = []
|
||||
local = ["winit", "gfx-backend-empty/winit"]
|
||||
remote = ["serde"]
|
||||
metal-auto-capture = ["gfx-backend-metal/auto-capture"]
|
||||
|
||||
[dependencies]
|
||||
arrayvec = "0.4"
|
||||
bitflags = "1.0"
|
||||
lazy_static = "1.1.0"
|
||||
log = "0.4"
|
||||
@ -32,4 +34,6 @@ gfx-backend-dx11 = { version = "0.1.0", optional = true }
|
||||
gfx-backend-dx12 = { version = "0.1.0", optional = true }
|
||||
gfx-backend-metal = { version = "0.1.0", optional = true }
|
||||
#rendy-memory = { git = "https://github.com/rustgd/rendy", rev = "ce7dd7f", features = ["gfx-hal"] }
|
||||
serde = { version = "1.0", features = ["serde_derive"], optional = true }
|
||||
vec_map = "0.8"
|
||||
winit = { version = "0.18", optional = true }
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::track::TrackerSet;
|
||||
use crate::{
|
||||
LifeGuard, WeaklyStored,
|
||||
LifeGuard,
|
||||
BindGroupLayoutId, BufferId, SamplerId, TextureViewId,
|
||||
};
|
||||
|
||||
@ -50,7 +50,7 @@ pub struct PipelineLayoutDescriptor {
|
||||
|
||||
pub struct PipelineLayout<B: hal::Backend> {
|
||||
pub(crate) raw: B::PipelineLayout,
|
||||
pub(crate) bind_group_layout_ids: Vec<WeaklyStored<BindGroupLayoutId>>,
|
||||
pub(crate) bind_group_layout_ids: Vec<BindGroupLayoutId>,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@ -82,7 +82,7 @@ pub struct BindGroupDescriptor {
|
||||
|
||||
pub struct BindGroup<B: hal::Backend> {
|
||||
pub(crate) raw: B::DescriptorSet,
|
||||
pub(crate) layout_id: WeaklyStored<BindGroupLayoutId>,
|
||||
pub(crate) layout_id: BindGroupLayoutId,
|
||||
pub(crate) life_guard: LifeGuard,
|
||||
pub(crate) used: TrackerSet,
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
use crate::{
|
||||
BindGroupHandle, Stored, WeaklyStored,
|
||||
BindGroupHandle, Stored,
|
||||
BindGroupId, BindGroupLayoutId, PipelineLayoutId,
|
||||
};
|
||||
|
||||
|
||||
pub struct BindGroupPair {
|
||||
layout_id: WeaklyStored<BindGroupLayoutId>,
|
||||
layout_id: BindGroupLayoutId,
|
||||
group_id: Stored<BindGroupId>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct BindGroupEntry {
|
||||
expected_layout_id: Option<WeaklyStored<BindGroupLayoutId>>,
|
||||
expected_layout_id: Option<BindGroupLayoutId>,
|
||||
provided: Option<BindGroupPair>,
|
||||
}
|
||||
|
||||
@ -38,12 +38,12 @@ impl BindGroupEntry {
|
||||
pub fn expect_layout(
|
||||
&mut self, bind_group_layout_id: BindGroupLayoutId,
|
||||
) -> Option<BindGroupId> {
|
||||
let some = Some(WeaklyStored(bind_group_layout_id));
|
||||
let some = Some(bind_group_layout_id);
|
||||
if self.expected_layout_id != some {
|
||||
self.expected_layout_id = some;
|
||||
match self.provided {
|
||||
Some(BindGroupPair { ref layout_id, ref group_id })
|
||||
if layout_id.0 == bind_group_layout_id => Some(group_id.value),
|
||||
Some(BindGroupPair { layout_id, ref group_id })
|
||||
if layout_id == bind_group_layout_id => Some(group_id.value),
|
||||
Some(_) | None => None,
|
||||
}
|
||||
} else {
|
||||
@ -54,7 +54,7 @@ impl BindGroupEntry {
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Binder {
|
||||
pub(crate) pipeline_layout_id: Option<WeaklyStored<PipelineLayoutId>>, //TODO: strongly `Stored`
|
||||
pub(crate) pipeline_layout_id: Option<PipelineLayoutId>, //TODO: strongly `Stored`
|
||||
pub(crate) entries: Vec<BindGroupEntry>,
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ impl Binder {
|
||||
) -> Option<PipelineLayoutId> {
|
||||
self.ensure_length(index + 1);
|
||||
if self.entries[index].provide(bind_group_id, bind_group) {
|
||||
self.pipeline_layout_id.as_ref().map(|&WeaklyStored(id)| id)
|
||||
self.pipeline_layout_id.as_ref().cloned()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -112,18 +112,18 @@ pub extern "C" fn wgpu_compute_pass_set_pipeline(
|
||||
}
|
||||
|
||||
let pipeline_layout_guard = HUB.pipeline_layouts.read();
|
||||
let pipeline_layout = pipeline_layout_guard.get(pipeline.layout_id.0);
|
||||
let pipeline_layout = pipeline_layout_guard.get(pipeline.layout_id);
|
||||
let bing_group_guard = HUB.bind_groups.read();
|
||||
|
||||
pass.binder.pipeline_layout_id = Some(pipeline.layout_id.clone());
|
||||
pass.binder.ensure_length(pipeline_layout.bind_group_layout_ids.len());
|
||||
|
||||
for (index, (entry, bgl_id)) in pass.binder.entries
|
||||
for (index, (entry, &bgl_id)) in pass.binder.entries
|
||||
.iter_mut()
|
||||
.zip(&pipeline_layout.bind_group_layout_ids)
|
||||
.enumerate()
|
||||
{
|
||||
if let Some(bg_id) = entry.expect_layout(bgl_id.0) {
|
||||
if let Some(bg_id) = entry.expect_layout(bgl_id) {
|
||||
let bind_group = bing_group_guard.get(bg_id);
|
||||
unsafe {
|
||||
pass.raw.bind_compute_descriptor_sets(
|
||||
|
@ -22,7 +22,7 @@ use crate::{
|
||||
BufferId, CommandBufferId, CommandEncoderId, DeviceId,
|
||||
TextureId, TextureViewId,
|
||||
BufferUsageFlags, TextureUsageFlags, Color,
|
||||
LifeGuard, Stored, WeaklyStored,
|
||||
LifeGuard, Stored,
|
||||
CommandBufferHandle,
|
||||
};
|
||||
#[cfg(feature = "local")]
|
||||
@ -294,9 +294,9 @@ pub fn command_encoder_begin_render_pass(
|
||||
let fb_key = FramebufferKey {
|
||||
attachments: color_attachments
|
||||
.iter()
|
||||
.map(|at| WeaklyStored(at.attachment))
|
||||
.map(|at| at.attachment)
|
||||
.chain(
|
||||
depth_stencil_attachment.map(|at| WeaklyStored(at.attachment)),
|
||||
depth_stencil_attachment.map(|at| at.attachment),
|
||||
)
|
||||
.collect(),
|
||||
};
|
||||
@ -308,7 +308,7 @@ pub fn command_encoder_begin_render_pass(
|
||||
.key()
|
||||
.attachments
|
||||
.iter()
|
||||
.map(|&WeaklyStored(id)| &view_guard.get(id).raw);
|
||||
.map(|&id| &view_guard.get(id).raw);
|
||||
|
||||
unsafe {
|
||||
device
|
||||
@ -374,7 +374,7 @@ pub extern "C" fn wgpu_command_encoder_begin_render_pass(
|
||||
desc: RenderPassDescriptor,
|
||||
) -> RenderPassId {
|
||||
let pass = command_encoder_begin_render_pass(command_encoder_id, desc);
|
||||
HUB.render_passes.register(pass)
|
||||
HUB.render_passes.register_local(pass)
|
||||
}
|
||||
|
||||
pub fn command_encoder_begin_compute_pass(
|
||||
@ -398,5 +398,5 @@ pub extern "C" fn wgpu_command_encoder_begin_compute_pass(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
) -> ComputePassId {
|
||||
let pass = command_encoder_begin_compute_pass(command_encoder_id);
|
||||
HUB.compute_passes.register(pass)
|
||||
HUB.compute_passes.register_local(pass)
|
||||
}
|
||||
|
@ -224,18 +224,18 @@ pub extern "C" fn wgpu_render_pass_set_pipeline(
|
||||
}
|
||||
|
||||
let pipeline_layout_guard = HUB.pipeline_layouts.read();
|
||||
let pipeline_layout = pipeline_layout_guard.get(pipeline.layout_id.0);
|
||||
let pipeline_layout = pipeline_layout_guard.get(pipeline.layout_id);
|
||||
let bing_group_guard = HUB.bind_groups.read();
|
||||
|
||||
pass.binder.pipeline_layout_id = Some(pipeline.layout_id.clone());
|
||||
pass.binder.ensure_length(pipeline_layout.bind_group_layout_ids.len());
|
||||
|
||||
for (index, (entry, bgl_id)) in pass.binder.entries
|
||||
for (index, (entry, &bgl_id)) in pass.binder.entries
|
||||
.iter_mut()
|
||||
.zip(&pipeline_layout.bind_group_layout_ids)
|
||||
.enumerate()
|
||||
{
|
||||
if let Some(bg_id) = entry.expect_layout(bgl_id.0) {
|
||||
if let Some(bg_id) = entry.expect_layout(bgl_id) {
|
||||
let bind_group = bing_group_guard.get(bg_id);
|
||||
unsafe {
|
||||
pass.raw.bind_graphics_descriptor_sets(
|
||||
|
@ -2,7 +2,7 @@ use crate::{binding_model, command, conv, pipeline, resource, swap_chain};
|
||||
use crate::hub::HUB;
|
||||
use crate::track::{TrackerSet, TrackPermit};
|
||||
use crate::{
|
||||
LifeGuard, RefCount, Stored, SubmissionIndex, WeaklyStored,
|
||||
LifeGuard, RefCount, Stored, SubmissionIndex,
|
||||
BufferMapAsyncStatus, BufferMapOperation,
|
||||
};
|
||||
use crate::{
|
||||
@ -15,6 +15,7 @@ use crate::{
|
||||
ShaderModuleId, CommandEncoderId, RenderPipelineId, ComputePipelineId,
|
||||
};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use back;
|
||||
use hal::backend::FastHashMap;
|
||||
use hal::command::RawCommandBuffer;
|
||||
@ -34,6 +35,8 @@ use std::collections::hash_map::Entry;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
|
||||
type AttachmentVec<T> = ArrayVec<[T; 5]>;
|
||||
|
||||
pub fn all_buffer_stages() -> hal::pso::PipelineStage {
|
||||
use hal::pso::PipelineStage as Ps;
|
||||
Ps::DRAW_INDIRECT |
|
||||
@ -57,13 +60,13 @@ pub fn all_image_stages() -> hal::pso::PipelineStage {
|
||||
|
||||
#[derive(Hash, PartialEq)]
|
||||
pub(crate) struct RenderPassKey {
|
||||
pub attachments: Vec<hal::pass::Attachment>,
|
||||
pub attachments: AttachmentVec<hal::pass::Attachment>,
|
||||
}
|
||||
impl Eq for RenderPassKey {}
|
||||
|
||||
#[derive(Hash, PartialEq)]
|
||||
pub(crate) struct FramebufferKey {
|
||||
pub attachments: Vec<WeaklyStored<TextureViewId>>,
|
||||
pub attachments: AttachmentVec<TextureViewId>,
|
||||
}
|
||||
impl Eq for FramebufferKey {}
|
||||
|
||||
@ -222,7 +225,7 @@ impl DestroyedResources<back::Backend> {
|
||||
let mut buffer_guard = HUB.buffers.write();
|
||||
|
||||
for buffer_id in self.ready_to_map.drain(..) {
|
||||
let mut buffer = buffer_guard.get_mut(buffer_id);
|
||||
let buffer = buffer_guard.get_mut(buffer_id);
|
||||
let mut operation = None;
|
||||
std::mem::swap(&mut operation, &mut buffer.pending_map_operation);
|
||||
match operation {
|
||||
@ -254,7 +257,7 @@ impl DestroyedResources<back::Backend> {
|
||||
|
||||
pub struct Device<B: hal::Backend> {
|
||||
pub(crate) raw: B::Device,
|
||||
adapter_id: WeaklyStored<AdapterId>,
|
||||
adapter_id: AdapterId,
|
||||
pub(crate) queue_group: hal::QueueGroup<B, hal::General>,
|
||||
//mem_allocator: Heaps<B::Memory>,
|
||||
pub(crate) com_allocator: command::CommandAllocator<B>,
|
||||
@ -270,7 +273,7 @@ pub struct Device<B: hal::Backend> {
|
||||
impl<B: hal::Backend> Device<B> {
|
||||
pub(crate) fn new(
|
||||
raw: B::Device,
|
||||
adapter_id: WeaklyStored<AdapterId>,
|
||||
adapter_id: AdapterId,
|
||||
queue_group: hal::QueueGroup<B, hal::General>,
|
||||
mem_props: hal::MemoryProperties,
|
||||
) -> Self {
|
||||
@ -431,7 +434,7 @@ pub extern "C" fn wgpu_device_create_buffer(
|
||||
) -> BufferId {
|
||||
let buffer = device_create_buffer(device_id, desc);
|
||||
let ref_count = buffer.life_guard.ref_count.clone();
|
||||
let id = HUB.buffers.register(buffer);
|
||||
let id = HUB.buffers.register_local(buffer);
|
||||
device_track_buffer(device_id, id, ref_count);
|
||||
id
|
||||
}
|
||||
@ -543,7 +546,7 @@ pub extern "C" fn wgpu_device_create_texture(
|
||||
) -> TextureId {
|
||||
let texture = device_create_texture(device_id, desc);
|
||||
let ref_count = texture.life_guard.ref_count.clone();
|
||||
let id = HUB.textures.register(texture);
|
||||
let id = HUB.textures.register_local(texture);
|
||||
device_track_texture(device_id, id, ref_count);
|
||||
id
|
||||
}
|
||||
@ -617,7 +620,7 @@ pub extern "C" fn wgpu_texture_create_view(
|
||||
let view = texture_create_view(texture_id, desc);
|
||||
let texture_id = view.texture_id.value;
|
||||
let ref_count = view.life_guard.ref_count.clone();
|
||||
let id = HUB.texture_views.register(view);
|
||||
let id = HUB.texture_views.register_local(view);
|
||||
device_track_view(texture_id, id, ref_count);
|
||||
id
|
||||
}
|
||||
@ -671,7 +674,7 @@ pub extern "C" fn wgpu_texture_create_default_view(texture_id: TextureId) -> Tex
|
||||
let view = texture_create_default_view(texture_id);
|
||||
let texture_id = view.texture_id.value;
|
||||
let ref_count = view.life_guard.ref_count.clone();
|
||||
let id = HUB.texture_views.register(view);
|
||||
let id = HUB.texture_views.register_local(view);
|
||||
device_track_view(texture_id, id, ref_count);
|
||||
id
|
||||
}
|
||||
@ -757,7 +760,7 @@ pub extern "C" fn wgpu_device_create_sampler(
|
||||
device_id: DeviceId, desc: &resource::SamplerDescriptor
|
||||
) -> SamplerId {
|
||||
let sampler = device_create_sampler(device_id, desc);
|
||||
HUB.samplers.register(sampler)
|
||||
HUB.samplers.register_local(sampler)
|
||||
}
|
||||
|
||||
|
||||
@ -799,7 +802,7 @@ pub extern "C" fn wgpu_device_create_bind_group_layout(
|
||||
desc: &binding_model::BindGroupLayoutDescriptor,
|
||||
) -> BindGroupLayoutId {
|
||||
let layout = device_create_bind_group_layout(device_id, desc);
|
||||
HUB.bind_group_layouts.register(layout)
|
||||
HUB.bind_group_layouts.register_local(layout)
|
||||
}
|
||||
|
||||
pub fn device_create_pipeline_layout(
|
||||
@ -829,7 +832,6 @@ pub fn device_create_pipeline_layout(
|
||||
bind_group_layout_ids: bind_group_layout_ids
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(WeaklyStored)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
@ -841,7 +843,7 @@ pub extern "C" fn wgpu_device_create_pipeline_layout(
|
||||
desc: &binding_model::PipelineLayoutDescriptor,
|
||||
) -> PipelineLayoutId {
|
||||
let layout = device_create_pipeline_layout(device_id, desc);
|
||||
HUB.pipeline_layouts.register(layout)
|
||||
HUB.pipeline_layouts.register_local(layout)
|
||||
}
|
||||
|
||||
pub fn device_create_bind_group(
|
||||
@ -916,7 +918,7 @@ pub fn device_create_bind_group(
|
||||
|
||||
binding_model::BindGroup {
|
||||
raw: desc_set,
|
||||
layout_id: WeaklyStored(desc.layout),
|
||||
layout_id: desc.layout,
|
||||
life_guard: LifeGuard::new(),
|
||||
used,
|
||||
}
|
||||
@ -929,7 +931,7 @@ pub extern "C" fn wgpu_device_create_bind_group(
|
||||
desc: &binding_model::BindGroupDescriptor,
|
||||
) -> BindGroupId {
|
||||
let bind_group = device_create_bind_group(device_id, desc);
|
||||
HUB.bind_groups.register(bind_group)
|
||||
HUB.bind_groups.register_local(bind_group)
|
||||
}
|
||||
|
||||
|
||||
@ -957,7 +959,7 @@ pub extern "C" fn wgpu_device_create_shader_module(
|
||||
desc: &pipeline::ShaderModuleDescriptor,
|
||||
) -> ShaderModuleId {
|
||||
let module = device_create_shader_module(device_id, desc);
|
||||
HUB.shader_modules.register(module)
|
||||
HUB.shader_modules.register_local(module)
|
||||
}
|
||||
|
||||
pub fn device_create_command_encoder(
|
||||
@ -988,7 +990,7 @@ pub extern "C" fn wgpu_device_create_command_encoder(
|
||||
desc: &command::CommandEncoderDescriptor,
|
||||
) -> CommandEncoderId {
|
||||
let cmb = device_create_command_encoder(device_id, desc);
|
||||
HUB.command_buffers.register(cmb)
|
||||
HUB.command_buffers.register_local(cmb)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@ -1084,7 +1086,7 @@ pub extern "C" fn wgpu_queue_submit(
|
||||
.flat_map(|link| {
|
||||
//TODO: check the epoch
|
||||
surface_guard
|
||||
.get(link.swap_chain_id.0)
|
||||
.get(link.swap_chain_id)
|
||||
.swap_chain
|
||||
.as_ref()
|
||||
.map(|swap_chain| (
|
||||
@ -1339,7 +1341,7 @@ pub fn device_create_render_pipeline(
|
||||
|
||||
pipeline::RenderPipeline {
|
||||
raw: pipeline,
|
||||
layout_id: WeaklyStored(desc.layout),
|
||||
layout_id: desc.layout,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1350,7 +1352,7 @@ pub extern "C" fn wgpu_device_create_render_pipeline(
|
||||
desc: &pipeline::RenderPipelineDescriptor,
|
||||
) -> RenderPipelineId {
|
||||
let pipeline = device_create_render_pipeline(device_id, desc);
|
||||
HUB.render_pipelines.register(pipeline)
|
||||
HUB.render_pipelines.register_local(pipeline)
|
||||
}
|
||||
|
||||
pub fn device_create_compute_pipeline(
|
||||
@ -1397,7 +1399,7 @@ pub fn device_create_compute_pipeline(
|
||||
|
||||
pipeline::ComputePipeline {
|
||||
raw: pipeline,
|
||||
layout_id: WeaklyStored(desc.layout),
|
||||
layout_id: desc.layout,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1408,7 +1410,7 @@ pub extern "C" fn wgpu_device_create_compute_pipeline(
|
||||
desc: &pipeline::ComputePipelineDescriptor,
|
||||
) -> ComputePipelineId {
|
||||
let pipeline = device_create_compute_pipeline(device_id, desc);
|
||||
HUB.compute_pipelines.register(pipeline)
|
||||
HUB.compute_pipelines.register_local(pipeline)
|
||||
}
|
||||
|
||||
pub fn device_create_swap_chain(
|
||||
@ -1425,7 +1427,7 @@ pub fn device_create_swap_chain(
|
||||
|
||||
let (caps, formats, _present_modes, _composite_alphas) = {
|
||||
let adapter_guard = HUB.adapters.read();
|
||||
let adapter = adapter_guard.get(device.adapter_id.0);
|
||||
let adapter = adapter_guard.get(device.adapter_id);
|
||||
assert!(surface.raw.supports_queue_family(&adapter.queue_families[0]));
|
||||
surface.raw.compatibility(&adapter.physical_device)
|
||||
};
|
||||
@ -1556,13 +1558,13 @@ pub fn swap_chain_populate_textures(
|
||||
.unwrap()
|
||||
};
|
||||
texture.swap_chain_link = Some(swap_chain::SwapChainLink {
|
||||
swap_chain_id: WeaklyStored(swap_chain_id), //TODO: strongly
|
||||
swap_chain_id, //TODO: strongly
|
||||
epoch: Mutex::new(0),
|
||||
image_index: i as hal::SwapImageIndex,
|
||||
});
|
||||
let texture_id = Stored {
|
||||
ref_count: texture.life_guard.ref_count.clone(),
|
||||
value: HUB.textures.register(texture),
|
||||
value: HUB.textures.register_local(texture),
|
||||
};
|
||||
trackers.textures.query(
|
||||
texture_id.value,
|
||||
@ -1581,7 +1583,7 @@ pub fn swap_chain_populate_textures(
|
||||
};
|
||||
let view_id = Stored {
|
||||
ref_count: view.life_guard.ref_count.clone(),
|
||||
value: HUB.texture_views.register(view),
|
||||
value: HUB.texture_views.register_local(view),
|
||||
};
|
||||
trackers.views.query(
|
||||
view_id.value,
|
||||
|
@ -7,56 +7,92 @@ use crate::{
|
||||
SurfaceHandle,
|
||||
};
|
||||
|
||||
use hal::backend::FastHashMap;
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
#[cfg(feature = "local")]
|
||||
use parking_lot::Mutex;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
use vec_map::VecMap;
|
||||
|
||||
use std::ops;
|
||||
use std::sync::Arc;
|
||||
|
||||
//TODO: use Vec instead of HashMap
|
||||
//TODO: track epochs of indices
|
||||
|
||||
pub type Id = u32;
|
||||
pub(crate) type Index = u32;
|
||||
pub(crate) type Epoch = u32;
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Id(Index, Epoch);
|
||||
|
||||
pub trait NewId {
|
||||
fn new(index: Index, epoch: Epoch) -> Self;
|
||||
fn index(&self) -> Index;
|
||||
fn epoch(&self) -> Epoch;
|
||||
}
|
||||
|
||||
impl NewId for Id {
|
||||
fn new(index: Index, epoch: Epoch) -> Self {
|
||||
Id(index, epoch)
|
||||
}
|
||||
|
||||
fn index(&self) -> Index {
|
||||
self.0
|
||||
}
|
||||
|
||||
fn epoch(&self) -> Epoch {
|
||||
self.1
|
||||
}
|
||||
}
|
||||
|
||||
/// A simple structure to manage identities of objects.
|
||||
#[derive(Default)]
|
||||
pub struct IdentityManager {
|
||||
last_id: Id,
|
||||
free: Vec<Id>,
|
||||
free: Vec<Index>,
|
||||
epochs: Vec<Epoch>,
|
||||
}
|
||||
|
||||
impl IdentityManager {
|
||||
pub fn alloc(&mut self) -> Id {
|
||||
match self.free.pop() {
|
||||
Some(id) => id,
|
||||
Some(index) => {
|
||||
Id(index, self.epochs[index as usize])
|
||||
}
|
||||
None => {
|
||||
self.last_id += 1;
|
||||
assert_ne!(self.last_id, 0);
|
||||
self.last_id
|
||||
let id = Id(self.epochs.len() as Index, 1);
|
||||
self.epochs.push(id.1);
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn free(&mut self, id: Id) {
|
||||
debug_assert!(id <= self.last_id && !self.free.contains(&id));
|
||||
self.free.push(id);
|
||||
pub fn free(&mut self, Id(index, epoch): Id) {
|
||||
// avoid doing this check in release
|
||||
if cfg!(debug_assertions) {
|
||||
assert!(!self.free.contains(&index));
|
||||
}
|
||||
let pe = &mut self.epochs[index as usize];
|
||||
assert_eq!(*pe, epoch);
|
||||
*pe += 1;
|
||||
self.free.push(index);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Storage<T> {
|
||||
//TODO: consider concurrent hashmap?
|
||||
map: FastHashMap<Id, T>,
|
||||
map: VecMap<(T, Epoch)>,
|
||||
}
|
||||
|
||||
impl<T> Storage<T> {
|
||||
pub fn get(&self, id: Id) -> &T {
|
||||
self.map.get(&id).unwrap()
|
||||
let (ref value, epoch) = self.map[id.0 as usize];
|
||||
assert_eq!(epoch, id.1);
|
||||
value
|
||||
}
|
||||
pub fn get_mut(&mut self, id: Id) -> &mut T {
|
||||
self.map.get_mut(&id).unwrap()
|
||||
let (ref mut value, epoch) = self.map[id.0 as usize];
|
||||
assert_eq!(epoch, id.1);
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +108,7 @@ impl<T> Default for Registry<T> {
|
||||
#[cfg(feature = "local")]
|
||||
identity: Mutex::new(IdentityManager::default()),
|
||||
data: RwLock::new(Storage {
|
||||
map: FastHashMap::default(),
|
||||
map: VecMap::new(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
@ -92,18 +128,26 @@ impl<T> ops::DerefMut for Registry<T> {
|
||||
}
|
||||
|
||||
impl<T> Registry<T> {
|
||||
#[cfg(feature = "local")]
|
||||
pub fn register(&self, value: T) -> Id {
|
||||
let id = self.identity.lock().alloc();
|
||||
let old = self.data.write().map.insert(id, value);
|
||||
pub fn register(&self, id: Id, value: T) {
|
||||
let old = self.data.write().map.insert(id.0 as usize, (value, id.1));
|
||||
assert!(old.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Registry<T> {
|
||||
#[cfg(feature = "local")]
|
||||
pub fn register_local(&self, value: T) -> Id {
|
||||
let id = self.identity.lock().alloc();
|
||||
self.register(id, value);
|
||||
id
|
||||
}
|
||||
|
||||
pub fn unregister(&self, id: Id) -> T {
|
||||
#[cfg(feature = "local")]
|
||||
self.identity.lock().free(id);
|
||||
self.data.write().map.remove(&id).unwrap()
|
||||
let (value, epoch) = self.data.write().map.remove(id.0 as usize).unwrap();
|
||||
assert_eq!(epoch, id.1);
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,20 @@
|
||||
use crate::hub::HUB;
|
||||
use crate::{
|
||||
WeaklyStored,
|
||||
AdapterHandle, DeviceHandle, SurfaceHandle,
|
||||
AdapterId, InstanceId,
|
||||
};
|
||||
#[cfg(feature = "local")]
|
||||
use crate::{DeviceId, SurfaceId};
|
||||
|
||||
#[cfg(feature = "remote")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use hal::{self, Instance as _Instance, PhysicalDevice as _PhysicalDevice};
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "remote", derive(Serialize, Deserialize))]
|
||||
pub enum PowerPreference {
|
||||
Default = 0,
|
||||
LowPower = 1,
|
||||
@ -19,16 +22,19 @@ pub enum PowerPreference {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
|
||||
pub struct AdapterDescriptor {
|
||||
pub power_preference: PowerPreference,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
|
||||
pub struct Extensions {
|
||||
pub anisotropic_filtering: bool,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
|
||||
pub struct DeviceDescriptor {
|
||||
pub extensions: Extensions,
|
||||
}
|
||||
@ -41,7 +47,7 @@ pub fn create_instance() -> ::back::Instance {
|
||||
#[cfg(feature = "local")]
|
||||
pub extern "C" fn wgpu_create_instance() -> InstanceId {
|
||||
let inst = create_instance();
|
||||
HUB.instances.register(inst)
|
||||
HUB.instances.register_local(inst)
|
||||
}
|
||||
|
||||
#[cfg(feature = "local")]
|
||||
@ -55,7 +61,7 @@ pub extern "C" fn wgpu_instance_create_surface_from_winit(
|
||||
.get(instance_id)
|
||||
.create_surface(window);
|
||||
let surface = SurfaceHandle::new(raw);
|
||||
HUB.surfaces.register(surface)
|
||||
HUB.surfaces.register_local(surface)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -83,7 +89,7 @@ pub extern "C" fn wgpu_instance_create_surface_from_xlib(
|
||||
window: u64,
|
||||
) -> SurfaceId {
|
||||
let surface = instance_create_surface_from_xlib(instance_id, display, window);
|
||||
HUB.surfaces.register(surface)
|
||||
HUB.surfaces.register_local(surface)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -109,7 +115,7 @@ pub extern "C" fn wgpu_instance_create_surface_from_macos_layer(
|
||||
layer: *mut std::ffi::c_void,
|
||||
) -> SurfaceId {
|
||||
let surface = instance_create_surface_from_macos_layer(instance_id, layer);
|
||||
HUB.surfaces.register(surface)
|
||||
HUB.surfaces.register_local(surface)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
@ -145,7 +151,7 @@ pub extern "C" fn wgpu_instance_create_surface_from_windows_hwnd(
|
||||
hwnd: *mut std::ffi::c_void,
|
||||
) -> SurfaceId {
|
||||
let surface = instance_create_surface_from_windows_hwnd(instance_id, hinstance, hwnd);
|
||||
HUB.surfaces.register(surface)
|
||||
HUB.surfaces.register_local(surface)
|
||||
}
|
||||
|
||||
pub fn instance_get_adapter(
|
||||
@ -177,7 +183,7 @@ pub extern "C" fn wgpu_instance_get_adapter(
|
||||
desc: &AdapterDescriptor,
|
||||
) -> AdapterId {
|
||||
let adapter = instance_get_adapter(instance_id, desc);
|
||||
HUB.adapters.register(adapter)
|
||||
HUB.adapters.register_local(adapter)
|
||||
}
|
||||
|
||||
pub fn adapter_create_device(
|
||||
@ -188,7 +194,7 @@ pub fn adapter_create_device(
|
||||
let adapter = adapter_guard.get_mut(adapter_id);
|
||||
let (raw, queue_group) = adapter.open_with::<_, hal::General>(1, |_qf| true).unwrap();
|
||||
let mem_props = adapter.physical_device.memory_properties();
|
||||
DeviceHandle::new(raw, WeaklyStored(adapter_id), queue_group, mem_props)
|
||||
DeviceHandle::new(raw, adapter_id, queue_group, mem_props)
|
||||
}
|
||||
|
||||
#[cfg(feature = "local")]
|
||||
@ -198,5 +204,5 @@ pub extern "C" fn wgpu_adapter_create_device(
|
||||
desc: &DeviceDescriptor,
|
||||
) -> DeviceId {
|
||||
let device = adapter_create_device(adapter_id, desc);
|
||||
HUB.devices.register(device)
|
||||
HUB.devices.register_local(device)
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ pub use self::instance::*;
|
||||
pub use self::pipeline::*;
|
||||
pub use self::resource::*;
|
||||
pub use self::swap_chain::*;
|
||||
#[cfg(not(feature = "local"))]
|
||||
pub use self::hub::{Id, IdentityManager};
|
||||
#[cfg(feature = "remote")]
|
||||
pub use self::hub::{HUB, Id, IdentityManager, Registry};
|
||||
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@ -100,9 +100,6 @@ struct Stored<T> {
|
||||
ref_count: RefCount,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
|
||||
struct WeaklyStored<T>(T);
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::resource;
|
||||
use crate::{
|
||||
ByteArray, PipelineLayoutId, ShaderModuleId, WeaklyStored,
|
||||
ByteArray, PipelineLayoutId, ShaderModuleId,
|
||||
};
|
||||
|
||||
use bitflags::bitflags;
|
||||
@ -181,7 +181,7 @@ pub struct ComputePipelineDescriptor {
|
||||
|
||||
pub struct ComputePipeline<B: hal::Backend> {
|
||||
pub(crate) raw: B::ComputePipeline,
|
||||
pub(crate) layout_id: WeaklyStored<PipelineLayoutId>,
|
||||
pub(crate) layout_id: PipelineLayoutId,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@ -235,5 +235,5 @@ pub struct RenderPipelineDescriptor {
|
||||
|
||||
pub struct RenderPipeline<B: hal::Backend> {
|
||||
pub(crate) raw: B::GraphicsPipeline,
|
||||
pub(crate) layout_id: WeaklyStored<PipelineLayoutId>,
|
||||
pub(crate) layout_id: PipelineLayoutId,
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
Extent3d, Stored, WeaklyStored,
|
||||
Extent3d, Stored,
|
||||
DeviceId, SwapChainId, TextureId, TextureViewId,
|
||||
};
|
||||
use crate::{conv, resource};
|
||||
@ -17,7 +17,7 @@ use std::{iter, mem};
|
||||
pub type SwapImageEpoch = u16;
|
||||
|
||||
pub(crate) struct SwapChainLink<E> {
|
||||
pub swap_chain_id: WeaklyStored<SwapChainId>, //TODO: strongly
|
||||
pub swap_chain_id: SwapChainId, //TODO: strongly
|
||||
pub epoch: E,
|
||||
pub image_index: hal::SwapImageIndex,
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
use crate::hub::{Id, Storage};
|
||||
use crate::hub::{NewId, Id, Index, Epoch, Storage};
|
||||
use crate::resource::{BufferUsageFlags, TextureUsageFlags};
|
||||
use crate::{
|
||||
RefCount, WeaklyStored,
|
||||
RefCount,
|
||||
BufferId, TextureId, TextureViewId,
|
||||
};
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::hash::Hash;
|
||||
use std::mem;
|
||||
use std::ops::{BitOr, Range};
|
||||
|
||||
use bitflags::bitflags;
|
||||
use hal::backend::FastHashMap;
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::ops::{BitOr, Range};
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[allow(unused)]
|
||||
@ -72,16 +72,19 @@ struct Track<U> {
|
||||
ref_count: RefCount,
|
||||
init: U,
|
||||
last: U,
|
||||
epoch: Epoch,
|
||||
}
|
||||
|
||||
//TODO: consider having `I` as an associated type of `U`?
|
||||
pub struct Tracker<I, U> {
|
||||
map: FastHashMap<WeaklyStored<I>, Track<U>>,
|
||||
map: FastHashMap<Index, Track<U>>,
|
||||
_phantom: PhantomData<I>,
|
||||
}
|
||||
pub type BufferTracker = Tracker<BufferId, BufferUsageFlags>;
|
||||
pub type TextureTracker = Tracker<TextureId, TextureUsageFlags>;
|
||||
pub struct DummyTracker<I> {
|
||||
map: FastHashMap<WeaklyStored<I>, RefCount>,
|
||||
map: FastHashMap<Index, (RefCount, Epoch)>,
|
||||
_phantom: PhantomData<I>,
|
||||
}
|
||||
pub type TextureViewTracker = DummyTracker<TextureViewId>;
|
||||
|
||||
@ -102,67 +105,88 @@ impl TrackerSet {
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Clone + Hash + Eq> DummyTracker<I> {
|
||||
impl<I: NewId> DummyTracker<I> {
|
||||
pub fn new() -> Self {
|
||||
DummyTracker {
|
||||
map: FastHashMap::default(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove an id from the tracked map.
|
||||
pub(crate) fn remove(&mut self, id: I) -> bool {
|
||||
self.map.remove(&WeaklyStored(id)).is_some()
|
||||
match self.map.remove(&id.index()) {
|
||||
Some((_, epoch)) => {
|
||||
assert_eq!(epoch, id.epoch());
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the last usage on a resource.
|
||||
pub(crate) fn query(&mut self, id: I, ref_count: &RefCount) -> bool {
|
||||
match self.map.entry(WeaklyStored(id)) {
|
||||
match self.map.entry(id.index()) {
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(ref_count.clone());
|
||||
e.insert((ref_count.clone(), id.epoch()));
|
||||
true
|
||||
}
|
||||
Entry::Occupied(_) => false,
|
||||
Entry::Occupied(e) => {
|
||||
assert_eq!(e.get().1, id.epoch());
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Consume another tacker.
|
||||
pub fn consume(&mut self, other: &Self) {
|
||||
for (id, ref_count) in &other.map {
|
||||
self.query(id.0.clone(), ref_count);
|
||||
for (&index, &(ref ref_count, epoch)) in &other.map {
|
||||
self.query(I::new(index, epoch), ref_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Clone + Hash + Eq, U: Copy + GenericUsage + BitOr<Output = U> + PartialEq> Tracker<I, U> {
|
||||
impl<I: NewId, U: Copy + GenericUsage + BitOr<Output = U> + PartialEq> Tracker<I, U> {
|
||||
pub fn new() -> Self {
|
||||
Tracker {
|
||||
map: FastHashMap::default(),
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove an id from the tracked map.
|
||||
pub(crate) fn remove(&mut self, id: I) -> bool {
|
||||
self.map.remove(&WeaklyStored(id)).is_some()
|
||||
match self.map.remove(&id.index()) {
|
||||
Some(track) => {
|
||||
assert_eq!(track.epoch, id.epoch());
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the last usage on a resource.
|
||||
pub(crate) fn query(&mut self, id: I, ref_count: &RefCount, default: U) -> Query<U> {
|
||||
match self.map.entry(WeaklyStored(id)) {
|
||||
match self.map.entry(id.index()) {
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(Track {
|
||||
ref_count: ref_count.clone(),
|
||||
init: default,
|
||||
last: default,
|
||||
epoch: id.epoch(),
|
||||
});
|
||||
Query {
|
||||
usage: default,
|
||||
initialized: true,
|
||||
}
|
||||
}
|
||||
Entry::Occupied(e) => Query {
|
||||
usage: e.get().last,
|
||||
initialized: false,
|
||||
},
|
||||
Entry::Occupied(e) => {
|
||||
assert_eq!(e.get().epoch, id.epoch());
|
||||
Query {
|
||||
usage: e.get().last,
|
||||
initialized: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,16 +198,18 @@ impl<I: Clone + Hash + Eq, U: Copy + GenericUsage + BitOr<Output = U> + PartialE
|
||||
usage: U,
|
||||
permit: TrackPermit,
|
||||
) -> Result<Tracktion<U>, U> {
|
||||
match self.map.entry(WeaklyStored(id)) {
|
||||
match self.map.entry(id.index()) {
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(Track {
|
||||
ref_count: ref_count.clone(),
|
||||
init: usage,
|
||||
last: usage,
|
||||
epoch: id.epoch(),
|
||||
});
|
||||
Ok(Tracktion::Init)
|
||||
}
|
||||
Entry::Occupied(mut e) => {
|
||||
assert_eq!(e.get().epoch, id.epoch());
|
||||
let old = e.get().last;
|
||||
if usage == old {
|
||||
Ok(Tracktion::Keep)
|
||||
@ -201,37 +227,43 @@ impl<I: Clone + Hash + Eq, U: Copy + GenericUsage + BitOr<Output = U> + PartialE
|
||||
}
|
||||
|
||||
/// Consume another tacker, adding it's transitions to `self`.
|
||||
/// Transitions the current usage to the new one.
|
||||
pub fn consume_by_replace<'a>(&'a mut self, other: &'a Self) -> impl 'a + Iterator<Item = (I, Range<U>)> {
|
||||
other.map.iter().flat_map(move |(id, new)| {
|
||||
match self.map.entry(WeaklyStored(id.0.clone())) {
|
||||
other.map.iter().flat_map(move |(&index, new)| {
|
||||
match self.map.entry(index) {
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(new.clone());
|
||||
None
|
||||
}
|
||||
Entry::Occupied(mut e) => {
|
||||
assert_eq!(e.get().epoch, new.epoch);
|
||||
let old = mem::replace(&mut e.get_mut().last, new.last);
|
||||
if old == new.init {
|
||||
None
|
||||
} else {
|
||||
Some((id.0.clone(), old..new.last))
|
||||
Some((I::new(index, new.epoch), old .. new.last))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Consume another tacker, adding it's transitions to `self`.
|
||||
/// Extends the current usage without doing any transitions.
|
||||
pub fn consume_by_extend<'a>(&'a mut self, other: &'a Self) -> Result<(), (I, Range<U>)> {
|
||||
for (id, new) in other.map.iter() {
|
||||
match self.map.entry(WeaklyStored(id.0.clone())) {
|
||||
for (&index, new) in other.map.iter() {
|
||||
match self.map.entry(index) {
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(new.clone());
|
||||
}
|
||||
Entry::Occupied(mut e) => {
|
||||
assert_eq!(e.get().epoch, new.epoch);
|
||||
let old = e.get().last;
|
||||
if old != new.last {
|
||||
let extended = old | new.last;
|
||||
if extended.is_exclusive() {
|
||||
return Err((id.0.clone(), old..new.last));
|
||||
let id = I::new(index, new.epoch);
|
||||
return Err((id, old .. new.last));
|
||||
}
|
||||
e.get_mut().last = extended;
|
||||
}
|
||||
@ -243,7 +275,7 @@ impl<I: Clone + Hash + Eq, U: Copy + GenericUsage + BitOr<Output = U> + PartialE
|
||||
|
||||
/// Return an iterator over used resources keys.
|
||||
pub fn used<'a>(&'a self) -> impl 'a + Iterator<Item = I> {
|
||||
self.map.keys().map(|&WeaklyStored(ref id)| id.clone())
|
||||
self.map.iter().map(|(&index, track)| I::new(index, track.epoch))
|
||||
}
|
||||
}
|
||||
|
||||
|
18
wgpu-remote/Cargo.toml
Normal file
18
wgpu-remote/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "wgpu-remote"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
"Dzmitry Malyshau <kvark@mozilla.com>",
|
||||
"Joshua Groves <josh@joshgroves.com>",
|
||||
]
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
wgpu-native = { path = "../wgpu-native", features = ["remote"] }
|
||||
ipc-channel = "0.11"
|
||||
log = "0.4"
|
||||
parking_lot = { version = "0.7" }
|
||||
serde = { version = "1.0", features = ["serde_derive"] }
|
67
wgpu-remote/src/lib.rs
Normal file
67
wgpu-remote/src/lib.rs
Normal file
@ -0,0 +1,67 @@
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use parking_lot::Mutex;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use wgpu_native as wgn;
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum InstanceMessage {
|
||||
InstanceGetAdapter(wgn::InstanceId, wgn::AdapterDescriptor, wgn::AdapterId),
|
||||
AdapterCreateDevice(wgn::AdapterId, wgn::DeviceDescriptor, wgn::DeviceId),
|
||||
}
|
||||
|
||||
/// A message on the timeline of devices, queues, and resources.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum GlobalMessage {
|
||||
Instance(InstanceMessage),
|
||||
//Device(DeviceMessage),
|
||||
//Queue(QueueMessage),
|
||||
//Texture(TextureMessage),
|
||||
//Command(CommandMessage),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct IdentityHub {
|
||||
adapters: wgn::IdentityManager,
|
||||
devices: wgn::IdentityManager,
|
||||
}
|
||||
|
||||
pub struct Client {
|
||||
channel: IpcSender<GlobalMessage>,
|
||||
identity: Mutex<IdentityHub>,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new(channel: IpcSender<GlobalMessage>) -> Self {
|
||||
Client {
|
||||
channel,
|
||||
identity: Mutex::new(IdentityHub::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_instance_get_adapter(
|
||||
client: &Client,
|
||||
instance_id: wgn::InstanceId,
|
||||
desc: &wgn::AdapterDescriptor,
|
||||
) -> wgn::AdapterId {
|
||||
let id = client.identity.lock().adapters.alloc();
|
||||
let msg = GlobalMessage::Instance(InstanceMessage::InstanceGetAdapter(instance_id, desc.clone(), id));
|
||||
client.channel.send(msg).unwrap();
|
||||
id
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_adapter_create_device(
|
||||
client: &Client,
|
||||
adapter_id: wgn::AdapterId,
|
||||
desc: &wgn::DeviceDescriptor,
|
||||
) -> wgn::DeviceId {
|
||||
let id = client.identity.lock().devices.alloc();
|
||||
let msg = GlobalMessage::Instance(InstanceMessage::AdapterCreateDevice(adapter_id, desc.clone(), id));
|
||||
client.channel.send(msg).unwrap();
|
||||
id
|
||||
}
|
35
wgpu-remote/src/server.rs
Normal file
35
wgpu-remote/src/server.rs
Normal file
@ -0,0 +1,35 @@
|
||||
use crate::{GlobalMessage, InstanceMessage}
|
||||
|
||||
use ipc_channel::ipc::IpcReceiver;
|
||||
|
||||
use wgn;
|
||||
|
||||
|
||||
struct Server {
|
||||
channel: IpcReceiver<GlobalMessage>,
|
||||
instance_id: wgn::IntanceId,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
pub fn new(channel: IpcReceiver<GlobalMessage>) -> Self {
|
||||
Server {
|
||||
channel,
|
||||
instance_id: wgn::wgpu_create_instance(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process(message: GlobalMessage) {
|
||||
match message {
|
||||
GlobalMessage::Instance(msg) => match msg {
|
||||
InstanceMessage::InstanceGetAdapter(instance_id, ref desc, id) => {
|
||||
let adapter = wgn::instance_get_adapter(instance_id, desc);
|
||||
wgn::HUB.adapters.register(id, adapter);
|
||||
}
|
||||
InstanceMessage::AdapterCreateDevice(adapter_id, ref desc, id) => {
|
||||
let device = wgn::adapter_create_device(adapter_id, desc);
|
||||
wgn::HUB.devices.register(id, device);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user