aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock372
-rw-r--r--Cargo.toml1
-rw-r--r--components/script/dom/gpu.rs17
-rw-r--r--components/script/dom/gpuadapter.rs8
-rw-r--r--components/script/dom/gpubuffer.rs99
-rw-r--r--components/script/dom/gpucommandencoder.rs2
-rw-r--r--components/script/dom/gpucomputepassencoder.rs3
-rw-r--r--components/script/dom/gpudevice.rs53
-rw-r--r--components/script/dom/identityhub.rs2
-rw-r--r--components/script/dom/webidls/GPUBindGroupLayout.webidl4
-rw-r--r--components/script/dom/webidls/GPUBuffer.webidl2
-rw-r--r--components/webgpu/Cargo.toml5
-rw-r--r--components/webgpu/identity.rs114
-rw-r--r--components/webgpu/lib.rs141
-rw-r--r--servo-tidy.toml4
15 files changed, 496 insertions, 331 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 9a1379f83c6..db26fe6a434 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -161,11 +161,11 @@ checksum = "3ae7d751998c189c1d4468cf0a39bb2eae052a9c58d50ebb3b9591ee3813ad50"
[[package]]
name = "ash"
-version = "0.29.0"
+version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "003d1fb2eb12eb06d4a03dbe02eea67a9fac910fa97932ab9e3a75b96a1ea5e5"
+checksum = "69daec0742947f33a85931fa3cb0ce5f07929159dcbd1f0cbb5b2912e2978509"
dependencies = [
- "shared_library",
+ "libloading 0.5.2",
]
[[package]]
@@ -430,6 +430,12 @@ dependencies = [
]
[[package]]
+name = "bumpalo"
+version = "3.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5356f1d23ee24a1f785a56d1d1a5f0fd5b0f6a0c0fb2412ce11da71649ab78f6"
+
+[[package]]
name = "byte-slice-cast"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -730,16 +736,25 @@ dependencies = [
]
[[package]]
-name = "color_quant"
-version = "1.0.0"
+name = "cocoa"
+version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
+checksum = "8f7b6f3f7f4f0b3ec5c5039aaa9e8c3cef97a7a480a400fd62944841314f293d"
+dependencies = [
+ "bitflags",
+ "block",
+ "core-foundation 0.7.0",
+ "core-graphics 0.19.0",
+ "foreign-types",
+ "libc",
+ "objc",
+]
[[package]]
-name = "colorful"
-version = "0.2.1"
+name = "color_quant"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0bca1619ff57dd7a56b58a8e25ef4199f123e78e503fe1653410350a1b98ae65"
+checksum = "a475fc4af42d83d28adf72968d9bcfaf035a1a9381642d8e85d8a04957767b0d"
[[package]]
name = "combine"
@@ -1797,9 +1812,9 @@ dependencies = [
[[package]]
name = "gfx-auxil"
-version = "0.1.0"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "572eee952a9a23c99cfe3e4fd95d277784058a89ac3c77ff6fa3d80a4e321919"
+checksum = "67bdbf8e8d6883c70e5a0d7379ad8ab3ac95127a3761306b36122d8f1c177a8e"
dependencies = [
"fxhash",
"gfx-hal",
@@ -1808,19 +1823,19 @@ dependencies = [
[[package]]
name = "gfx-backend-dx11"
-version = "0.4.2"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c66c77836ff26cf9916e5c8745715a22eae1fc61d994ffa0bea8a7dbd708ece2"
+checksum = "92de0ddc0fde1a89b2a0e92dcc6bbb554bd34af0135e53a28d5ef064611094a4"
dependencies = [
"bitflags",
"gfx-auxil",
"gfx-hal",
"libloading 0.5.2",
"log",
- "parking_lot",
+ "parking_lot 0.10.2",
"range-alloc",
"raw-window-handle",
- "smallvec 0.6.13",
+ "smallvec 1.3.0",
"spirv_cross",
"winapi",
"wio",
@@ -1828,9 +1843,9 @@ dependencies = [
[[package]]
name = "gfx-backend-dx12"
-version = "0.4.1"
+version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6e913cc800fb12eaba2c420091a02aca9aafbefd672600dfc5b52654343d341"
+checksum = "37365e2927d55cefac0d3f78dfd1d3119fbb13a8bd7afe2409d729961fee22fc"
dependencies = [
"bitflags",
"d3d12",
@@ -1839,16 +1854,16 @@ dependencies = [
"log",
"range-alloc",
"raw-window-handle",
- "smallvec 0.6.13",
+ "smallvec 1.3.0",
"spirv_cross",
"winapi",
]
[[package]]
name = "gfx-backend-empty"
-version = "0.4.0"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3d383e6bc48867cb37d298a20139fd1eec298f8f6d594690cd1c50ef25470cc7"
+checksum = "b67bd2d7bc022b257ddbdabc5fa3b10c29c292372c3409f2b6a6e3f4e11cdb85"
dependencies = [
"gfx-hal",
"raw-window-handle",
@@ -1856,60 +1871,83 @@ dependencies = [
[[package]]
name = "gfx-backend-metal"
-version = "0.4.0"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8de5c71f18ba805c95b84d6c78c472ef44485a6fc46e3b49fe1e6739c8d7b0c0"
+checksum = "205f3ca8e74ed814ea2c0206d47d8925077673cab2e21f9b12d48ff781cf87ee"
dependencies = [
"arrayvec 0.5.1",
"bitflags",
"block",
- "cocoa 0.19.1",
+ "cocoa 0.20.1",
"copyless",
- "core-graphics 0.17.3",
+ "core-graphics 0.19.0",
"foreign-types",
"gfx-auxil",
"gfx-hal",
"lazy_static",
"log",
- "metal",
+ "metal 0.18.0",
"objc",
- "parking_lot",
+ "parking_lot 0.10.2",
"range-alloc",
"raw-window-handle",
- "smallvec 0.6.13",
+ "smallvec 1.3.0",
"spirv_cross",
"storage-map",
]
[[package]]
name = "gfx-backend-vulkan"
-version = "0.4.0"
+version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62538fedd66a78968a162e8e1a29d085ffbc97f8782634684b2f7da7aea59207"
+checksum = "45ff36feae801fa23d29acd74082603a0145a697a23595757dd4e78828ab33da"
dependencies = [
"arrayvec 0.5.1",
"ash",
"byteorder",
- "core-graphics 0.17.3",
+ "core-graphics 0.19.0",
"gfx-hal",
"lazy_static",
"log",
"objc",
"raw-window-handle",
- "smallvec 0.6.13",
+ "smallvec 1.3.0",
"winapi",
"x11",
]
[[package]]
+name = "gfx-descriptor"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bf35f5d66d1bc56e63e68d7528441453f25992bd954b84309d23c659df2c5da"
+dependencies = [
+ "fxhash",
+ "gfx-hal",
+ "log",
+]
+
+[[package]]
name = "gfx-hal"
-version = "0.4.1"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7c88981665c780447bb08eb099e1ded330754a7246719bab927ee4a949c0ba7f"
+checksum = "bc96180204064c9493e0fe4a9efeb721e0ac59fe8e1906d0c659142a93114fb1"
dependencies = [
"bitflags",
"raw-window-handle",
- "smallvec 0.6.13",
+]
+
+[[package]]
+name = "gfx-memory"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2eed6cda674d9cd4d92229102dbd544292124533d236904f987e9afab456137"
+dependencies = [
+ "fxhash",
+ "gfx-hal",
+ "hibitset",
+ "log",
+ "slab",
]
[[package]]
@@ -2766,6 +2804,15 @@ dependencies = [
]
[[package]]
+name = "js-sys"
+version = "0.3.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa5a448de267e7358beaf4a5d849518fe9a0c13fce7afd44b06e68550e5562a7"
+dependencies = [
+ "wasm-bindgen",
+]
+
+[[package]]
name = "jstraceable_derive"
version = "0.0.1"
dependencies = [
@@ -2815,7 +2862,7 @@ dependencies = [
"msg",
"net_traits",
"num-traits",
- "parking_lot",
+ "parking_lot 0.9.0",
"profile_traits",
"range",
"rayon",
@@ -2858,7 +2905,7 @@ dependencies = [
"mitochondria",
"msg",
"net_traits",
- "parking_lot",
+ "parking_lot 0.9.0",
"range",
"rayon",
"rayon_croissant",
@@ -2900,7 +2947,7 @@ dependencies = [
"metrics",
"msg",
"net_traits",
- "parking_lot",
+ "parking_lot 0.9.0",
"profile_traits",
"range",
"rayon",
@@ -2945,7 +2992,7 @@ dependencies = [
"metrics",
"msg",
"net_traits",
- "parking_lot",
+ "parking_lot 0.9.0",
"profile_traits",
"range",
"script",
@@ -3164,9 +3211,9 @@ dependencies = [
[[package]]
name = "lock_api"
-version = "0.3.1"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc"
+checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75"
dependencies = [
"scopeguard",
]
@@ -3367,6 +3414,21 @@ dependencies = [
]
[[package]]
+name = "metal"
+version = "0.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
+dependencies = [
+ "bitflags",
+ "block",
+ "cocoa 0.20.1",
+ "core-graphics 0.19.0",
+ "foreign-types",
+ "log",
+ "objc",
+]
+
+[[package]]
name = "metrics"
version = "0.0.1"
dependencies = [
@@ -3549,7 +3611,7 @@ dependencies = [
"lazy_static",
"malloc_size_of",
"malloc_size_of_derive",
- "parking_lot",
+ "parking_lot 0.9.0",
"serde",
"servo_url",
"size_of_test",
@@ -3563,6 +3625,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "451a9a05d2a32c566c897835e0ea95cf79ed2fdfe957924045a1721a36c9980f"
[[package]]
+name = "naga"
+version = "0.1.0"
+source = "git+https://github.com/gfx-rs/naga?rev=bce6358eb1026c13d2f1c6d365af37afe8869a86#bce6358eb1026c13d2f1c6d365af37afe8869a86"
+dependencies = [
+ "bitflags",
+ "fxhash",
+ "log",
+ "num-traits",
+ "spirv_headers",
+]
+
+[[package]]
name = "net"
version = "0.0.1"
dependencies = [
@@ -3883,11 +3957,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
dependencies = [
"lock_api",
- "parking_lot_core",
+ "parking_lot_core 0.6.2",
"rustc_version",
]
[[package]]
+name = "parking_lot"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e"
+dependencies = [
+ "lock_api",
+ "parking_lot_core 0.7.2",
+]
+
+[[package]]
name = "parking_lot_core"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3903,6 +3987,20 @@ dependencies = [
]
[[package]]
+name = "parking_lot_core"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3"
+dependencies = [
+ "cfg-if",
+ "cloudabi",
+ "libc",
+ "redox_syscall",
+ "smallvec 1.3.0",
+ "winapi",
+]
+
+[[package]]
name = "paste"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3949,31 +4047,35 @@ version = "0.2.0"
source = "git+https://github.com/servo/webrender#01082a9091ab98c392af8934d04271eb1dd546df"
dependencies = [
"euclid",
- "peek-poke-derive 0.2.1",
+ "peek-poke-derive 0.2.1 (git+https://github.com/servo/webrender)",
]
[[package]]
name = "peek-poke"
version = "0.2.0"
-source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d93fd6a575ebf1ac2668d08443c97a22872cfb463fd8b7ddd141e9f6be59af2f"
dependencies = [
- "peek-poke-derive 0.2.0",
+ "peek-poke-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "peek-poke-derive"
-version = "0.2.0"
-source = "git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075#969bd7fe2be1a83f87916dc8b388c63cfd457075"
+version = "0.2.1"
+source = "git+https://github.com/servo/webrender#01082a9091ab98c392af8934d04271eb1dd546df"
dependencies = [
"proc-macro2 1.0.1",
"quote 1.0.2",
"syn",
+ "synstructure",
+ "unicode-xid 0.2.0",
]
[[package]]
name = "peek-poke-derive"
version = "0.2.1"
-source = "git+https://github.com/servo/webrender#01082a9091ab98c392af8934d04271eb1dd546df"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fb44a25c5bba983be0fc8592dfaf3e6d0935ce8be0c6b15b2a39507af34a926"
dependencies = [
"proc-macro2 1.0.1",
"quote 1.0.2",
@@ -4423,16 +4525,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1"
[[package]]
-name = "relevant"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbc232e13d37f4547f5b9b42a5efc380cabe5dbc1807f8b893580640b2ab0308"
-dependencies = [
- "cfg-if",
- "log",
-]
-
-[[package]]
name = "remove_dir_all"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4442,33 +4534,6 @@ dependencies = [
]
[[package]]
-name = "rendy-descriptor"
-version = "0.5.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f475bcc0505946e998590f1f0545c52ef4b559174a1b353a7ce6638def8b621e"
-dependencies = [
- "gfx-hal",
- "log",
- "relevant",
- "smallvec 0.6.13",
-]
-
-[[package]]
-name = "rendy-memory"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed492161a819feae7f27f418bb16035276ac20649c60d756699152cb5c1960ec"
-dependencies = [
- "colorful",
- "gfx-hal",
- "hibitset",
- "log",
- "relevant",
- "slab",
- "smallvec 0.6.13",
-]
-
-[[package]]
name = "rle-decode-fast"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4484,6 +4549,17 @@ dependencies = [
]
[[package]]
+name = "ron"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ece421e0c4129b90e4a35b6f625e472e96c552136f5093a2f4fa2bbb75a62d5"
+dependencies = [
+ "base64 0.10.1",
+ "bitflags",
+ "serde",
+]
+
+[[package]]
name = "rust-argon2"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4618,7 +4694,7 @@ dependencies = [
"msg",
"net_traits",
"num-traits",
- "parking_lot",
+ "parking_lot 0.9.0",
"percent-encoding",
"phf",
"phf_codegen",
@@ -4681,7 +4757,7 @@ dependencies = [
"metrics",
"msg",
"net_traits",
- "parking_lot",
+ "parking_lot 0.9.0",
"profile_traits",
"range",
"script_traits",
@@ -5223,16 +5299,6 @@ dependencies = [
]
[[package]]
-name = "shared_library"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
-dependencies = [
- "lazy_static",
- "libc",
-]
-
-[[package]]
name = "shellwords"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5397,10 +5463,23 @@ checksum = "b72d540d5c565dbe1f891d7e21ceb21d2649508306782f1066989fccb0b363d3"
[[package]]
name = "spirv_cross"
-version = "0.16.0"
-source = "git+https://github.com/servo/spirv_cross?branch=wgpu-servo#636677bad724797789239c16e6d332e9b4d97b86"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a33a9478e9c78782dd694d05dee074703a9c4c74b511de742b88a7e8149f1b37"
dependencies = [
"cc",
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "spirv_headers"
+version = "1.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f1418983d16481227ffa3ab3cf44ef92eebc9a76c092fbcd4c51a64ff032622"
+dependencies = [
+ "bitflags",
+ "num-traits",
]
[[package]]
@@ -5505,7 +5584,7 @@ dependencies = [
"num-traits",
"num_cpus",
"owning_ref",
- "parking_lot",
+ "parking_lot 0.9.0",
"precomputed-hash",
"rayon",
"regex",
@@ -5605,9 +5684,9 @@ dependencies = [
"libc",
"log",
"mach",
- "metal",
+ "metal 0.17.0",
"objc",
- "parking_lot",
+ "parking_lot 0.9.0",
"wayland-sys 0.24.0",
"winapi",
"winit",
@@ -6192,9 +6271,9 @@ checksum = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
[[package]]
name = "vec_map"
-version = "0.8.0"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
@@ -6261,6 +6340,60 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
[[package]]
+name = "wasm-bindgen"
+version = "0.2.62"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3c7d40d09cdbf0f4895ae58cf57d92e1e57a9dd8ed2e8390514b54a47cc5551"
+dependencies = [
+ "cfg-if",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.62"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3972e137ebf830900db522d6c8fd74d1900dcfc733462e9a12e942b00b4ac94"
+dependencies = [
+ "bumpalo",
+ "lazy_static",
+ "log",
+ "proc-macro2 1.0.1",
+ "quote 1.0.2",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.62"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2cd85aa2c579e8892442954685f0d801f9129de24fa2136b2c6a539c76b65776"
+dependencies = [
+ "quote 1.0.2",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.62"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8eb197bd3a47553334907ffd2f16507b4f4f01bbec3ac921a7719e0decdfe72a"
+dependencies = [
+ "proc-macro2 1.0.1",
+ "quote 1.0.2",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.62"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a91c2916119c17a8e316507afaaa2dd94b47646048014bbdf6bef098c1bb58ad"
+
+[[package]]
name = "wayland-client"
version = "0.21.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -6389,6 +6522,7 @@ dependencies = [
"servo_config",
"smallvec 0.6.13",
"wgpu-core",
+ "wgpu-types",
]
[[package]]
@@ -6420,7 +6554,7 @@ dependencies = [
"num-traits",
"plane-split",
"rayon",
- "ron",
+ "ron 0.1.7",
"serde",
"serde_json",
"smallvec 1.3.0",
@@ -6519,8 +6653,8 @@ dependencies = [
[[package]]
name = "wgpu-core"
-version = "0.1.0"
-source = "git+https://github.com/gfx-rs/wgpu#4f937c04e12572a56d96a160c30888ceecc930a9"
+version = "0.5.0"
+source = "git+https://github.com/gfx-rs/wgpu#a203333c3e144cfd431c812213966ee32ae59d98"
dependencies = [
"arrayvec 0.5.1",
"bitflags",
@@ -6531,15 +6665,29 @@ dependencies = [
"gfx-backend-empty",
"gfx-backend-metal",
"gfx-backend-vulkan",
+ "gfx-descriptor",
"gfx-hal",
+ "gfx-memory",
"log",
- "parking_lot",
- "peek-poke 0.2.0 (git+https://github.com/kvark/peek-poke?rev=969bd7fe2be1a83f87916dc8b388c63cfd457075)",
- "rendy-descriptor",
- "rendy-memory",
+ "naga",
+ "parking_lot 0.10.2",
+ "peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ron 0.5.1",
"serde",
"smallvec 1.3.0",
+ "spirv_headers",
"vec_map",
+ "wgpu-types",
+]
+
+[[package]]
+name = "wgpu-types"
+version = "0.5.0"
+source = "git+https://github.com/gfx-rs/wgpu#a203333c3e144cfd431c812213966ee32ae59d98"
+dependencies = [
+ "bitflags",
+ "peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde",
]
[[package]]
@@ -6605,7 +6753,7 @@ dependencies = [
"libc",
"log",
"objc",
- "parking_lot",
+ "parking_lot 0.9.0",
"percent-encoding",
"smithay-client-toolkit",
"wayland-client",
diff --git a/Cargo.toml b/Cargo.toml
index c1d7986da5f..732729bf3d4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -30,6 +30,5 @@ opt-level = 3
mio = { git = "https://github.com/servo/mio.git", branch = "servo" }
# https://github.com/retep998/winapi-rs/pull/816
winapi = { git = "https://github.com/servo/winapi-rs", branch = "patch-1" }
-spirv_cross = { git = "https://github.com/servo/spirv_cross", branch = "wgpu-servo" }
surfman-chains = { git = "https://github.com/asajeffrey/surfman-chains" }
surfman = { git = "https://github.com/servo/surfman" }
diff --git a/components/script/dom/gpu.rs b/components/script/dom/gpu.rs
index 358665c3a10..2839ed94835 100644
--- a/components/script/dom/gpu.rs
+++ b/components/script/dom/gpu.rs
@@ -20,8 +20,8 @@ use ipc_channel::router::ROUTER;
use js::jsapi::Heap;
use script_traits::ScriptMsg;
use std::rc::Rc;
-use webgpu::wgpu;
-use webgpu::{WebGPUResponse, WebGPUResponseResult};
+use webgpu::wgt::PowerPreference;
+use webgpu::{wgpu, WebGPUResponse, WebGPUResponseResult};
#[dom_struct]
pub struct GPU {
@@ -109,11 +109,9 @@ impl GPUMethods for GPU {
let promise = Promise::new_in_current_realm(global, comp);
let sender = response_async(&promise, self);
let power_preference = match options.powerPreference {
- Some(GPUPowerPreference::Low_power) => wgpu::instance::PowerPreference::LowPower,
- Some(GPUPowerPreference::High_performance) => {
- wgpu::instance::PowerPreference::HighPerformance
- },
- None => wgpu::instance::PowerPreference::Default,
+ Some(GPUPowerPreference::Low_power) => PowerPreference::LowPower,
+ Some(GPUPowerPreference::High_performance) => PowerPreference::HighPerformance,
+ None => PowerPreference::Default,
};
let ids = global.wgpu_id_hub().lock().create_adapter_ids();
@@ -121,7 +119,10 @@ impl GPUMethods for GPU {
if script_to_constellation_chan
.send(ScriptMsg::RequestAdapter(
sender,
- wgpu::instance::RequestAdapterOptions { power_preference },
+ wgpu::instance::RequestAdapterOptions {
+ power_preference,
+ compatible_surface: None,
+ },
ids,
))
.is_err()
diff --git a/components/script/dom/gpuadapter.rs b/components/script/dom/gpuadapter.rs
index 93729ae5e22..8420a0058fc 100644
--- a/components/script/dom/gpuadapter.rs
+++ b/components/script/dom/gpuadapter.rs
@@ -20,7 +20,7 @@ use dom_struct::dom_struct;
use js::jsapi::{Heap, JSObject};
use std::ptr::NonNull;
use std::rc::Rc;
-use webgpu::{wgpu, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse};
+use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse};
#[dom_struct]
pub struct GPUAdapter {
@@ -80,11 +80,11 @@ impl GPUAdapterMethods for GPUAdapter {
fn RequestDevice(&self, descriptor: &GPUDeviceDescriptor, comp: InRealm) -> Rc<Promise> {
let promise = Promise::new_in_current_realm(&self.global(), comp);
let sender = response_async(&promise, self);
- let desc = wgpu::instance::DeviceDescriptor {
- extensions: wgpu::instance::Extensions {
+ let desc = wgt::DeviceDescriptor {
+ extensions: wgt::Extensions {
anisotropic_filtering: descriptor.extensions.anisotropicFiltering,
},
- limits: wgpu::instance::Limits {
+ limits: wgt::Limits {
max_bind_groups: descriptor.limits.maxBindGroups,
},
};
diff --git a/components/script/dom/gpubuffer.rs b/components/script/dom/gpubuffer.rs
index 17379437fc8..415184eabfd 100644
--- a/components/script/dom/gpubuffer.rs
+++ b/components/script/dom/gpubuffer.rs
@@ -11,21 +11,14 @@ use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::DOMString;
use crate::dom::bindings::trace::RootedTraceableBox;
use crate::dom::globalscope::GlobalScope;
-use crate::dom::gpu::{response_async, AsyncWGPUListener};
-use crate::dom::promise::Promise;
-use crate::realms::InRealm;
use dom_struct::dom_struct;
use js::jsapi::{Heap, JSObject};
use js::jsval::UndefinedValue;
use js::rust::jsapi_wrapped::{DetachArrayBuffer, IsPromiseObject, RejectPromise};
-use js::rust::MutableHandle;
-use js::typedarray::{ArrayBuffer, CreateWith};
+use js::typedarray::ArrayBuffer;
use std::cell::Cell;
use std::ptr;
-use std::rc::Rc;
-use webgpu::{
- wgpu::resource::BufferUsage, WebGPU, WebGPUBuffer, WebGPUDevice, WebGPURequest, WebGPUResponse,
-};
+use webgpu::{WebGPU, WebGPUBuffer, WebGPUDevice, WebGPURequest};
// https://gpuweb.github.io/gpuweb/#buffer-state
#[derive(Clone, MallocSizeOf)]
@@ -193,72 +186,6 @@ impl GPUBufferMethods for GPUBuffer {
*self.state.borrow_mut() = GPUBufferState::Destroyed;
}
- #[allow(unsafe_code)]
- /// https://gpuweb.github.io/gpuweb/#dom-gpubuffer-mapreadasync
- fn MapReadAsync(&self, comp: InRealm) -> Rc<Promise> {
- // Step 1 & 2
- let promise = Promise::new_in_current_realm(&self.global(), comp);
- match *self.state.borrow() {
- GPUBufferState::Unmapped => {
- match BufferUsage::from_bits(self.usage) {
- Some(usage) => {
- if !usage.contains(BufferUsage::MAP_READ) {
- // TODO: Record validation error on the current scope
- promise.reject_error(Error::Abort);
- return promise;
- };
- },
- None => {
- promise.reject_error(Error::Abort);
- return promise;
- },
- }
- },
- _ => {
- promise.reject_error(Error::Abort);
- return promise;
- },
- }
- // Step 3
- self.mapping.set(*promise.promise_obj());
- // Step 4
- *self.state.borrow_mut() = GPUBufferState::MappedPendingForReading;
-
- // Step 5.1
- if unsafe {
- ArrayBuffer::create(
- *self.global().get_cx(),
- CreateWith::Length(self.size as u32),
- MutableHandle::from_raw(self.mapping.handle_mut()),
- )
- }
- .is_err()
- {
- promise.reject_error(Error::Operation);
- return promise;
- }
-
- let sender = response_async(&promise, self);
- if self
- .channel
- .0
- .send(WebGPURequest::MapReadAsync {
- sender,
- buffer_id: self.buffer.0,
- device_id: self.device.0,
- usage: self.usage,
- size: self.size,
- })
- .is_err()
- {
- promise.reject_error(Error::Operation);
- return promise;
- }
-
- // Step 6
- promise
- }
-
/// https://gpuweb.github.io/gpuweb/#dom-gpuobjectbase-label
fn GetLabel(&self) -> Option<DOMString> {
self.label.borrow().clone()
@@ -269,25 +196,3 @@ impl GPUBufferMethods for GPUBuffer {
*self.label.borrow_mut() = value;
}
}
-
-impl AsyncWGPUListener for GPUBuffer {
- #[allow(unsafe_code)]
- fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>) {
- match response {
- WebGPUResponse::MapReadAsync(bytes) => unsafe {
- match ArrayBuffer::from(self.mapping.get()) {
- Ok(mut array_buffer) => {
- // Step 5.2
- array_buffer.update(&bytes);
- // Step 5.3
- *self.state.borrow_mut() = GPUBufferState::MappedForReading;
- // Step 5.4
- promise.resolve_native(&array_buffer);
- },
- _ => promise.reject_error(Error::Operation),
- };
- },
- _ => promise.reject_error(Error::Operation),
- }
- }
-}
diff --git a/components/script/dom/gpucommandencoder.rs b/components/script/dom/gpucommandencoder.rs
index 16cfb993ec1..ac5dbcad983 100644
--- a/components/script/dom/gpucommandencoder.rs
+++ b/components/script/dom/gpucommandencoder.rs
@@ -19,7 +19,7 @@ use dom_struct::dom_struct;
use ipc_channel::ipc;
use std::cell::Cell;
use std::collections::HashSet;
-use webgpu::wgpu::resource::BufferUsage;
+use webgpu::wgt::BufferUsage;
use webgpu::{WebGPU, WebGPUCommandEncoder, WebGPURequest};
const BUFFER_COPY_ALIGN_MASK: u64 = 3;
diff --git a/components/script/dom/gpucomputepassencoder.rs b/components/script/dom/gpucomputepassencoder.rs
index eb4c20c0075..76c9ec8eea4 100644
--- a/components/script/dom/gpucomputepassencoder.rs
+++ b/components/script/dom/gpucomputepassencoder.rs
@@ -36,12 +36,13 @@ pub struct GPUComputePassEncoder {
}
impl GPUComputePassEncoder {
+ #[allow(unsafe_code)]
fn new_inherited(channel: WebGPU, parent: &GPUCommandEncoder) -> GPUComputePassEncoder {
GPUComputePassEncoder {
channel,
reflector_: Reflector::new(),
label: DomRefCell::new(None),
- raw_pass: RefCell::new(Some(RawPass::new_compute(parent.id().0))),
+ raw_pass: RefCell::new(Some(unsafe { RawPass::new_compute(parent.id().0) })),
command_encoder: Dom::from_ref(parent),
}
}
diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs
index f1e6bffda0b..fa773a74694 100644
--- a/components/script/dom/gpudevice.rs
+++ b/components/script/dom/gpudevice.rs
@@ -42,10 +42,12 @@ use js::typedarray::{ArrayBuffer, CreateWith};
use std::collections::{HashMap, HashSet};
use std::ptr::{self, NonNull};
use webgpu::wgpu::binding_model::{
- BindGroupBinding, BindGroupLayoutBinding, BindingResource, BindingType, BufferBinding,
- ShaderStage,
+ BindGroupEntry, BindGroupLayoutEntry, BindingResource, BindingType, BufferBinding,
+};
+use webgpu::wgt::{
+ BufferDescriptor, BufferUsage, ShaderStage, TextureComponentType, TextureFormat,
+ TextureViewDimension,
};
-use webgpu::wgpu::resource::{BufferDescriptor, BufferUsage};
use webgpu::{WebGPU, WebGPUDevice, WebGPUQueue, WebGPURequest};
#[dom_struct]
@@ -108,7 +110,7 @@ impl GPUDevice {
fn validate_buffer_descriptor(
&self,
descriptor: &GPUBufferDescriptor,
- ) -> (bool, BufferDescriptor) {
+ ) -> (bool, BufferDescriptor<std::string::String>) {
// TODO: Record a validation error in the current scope if the descriptor is invalid.
let wgpu_usage = BufferUsage::from_bits(descriptor.usage);
let valid = wgpu_usage.is_some() && descriptor.size > 0;
@@ -119,6 +121,7 @@ impl GPUDevice {
BufferDescriptor {
size: descriptor.size,
usage: wgpu_usage.unwrap(),
+ label: Default::default(),
},
)
} else {
@@ -127,6 +130,7 @@ impl GPUDevice {
BufferDescriptor {
size: 0,
usage: BufferUsage::STORAGE,
+ label: Default::default(),
},
)
}
@@ -276,18 +280,9 @@ impl GPUDeviceMethods for GPUDevice {
max_storage_textures_per_shader_stage: limits.maxStorageTexturesPerShaderStage as i32,
max_samplers_per_shader_stage: limits.maxSamplersPerShaderStage as i32,
};
- validation_map.insert(
- webgpu::wgpu::binding_model::ShaderStage::VERTEX,
- maxLimits.clone(),
- );
- validation_map.insert(
- webgpu::wgpu::binding_model::ShaderStage::FRAGMENT,
- maxLimits.clone(),
- );
- validation_map.insert(
- webgpu::wgpu::binding_model::ShaderStage::COMPUTE,
- maxLimits.clone(),
- );
+ validation_map.insert(ShaderStage::VERTEX, maxLimits.clone());
+ validation_map.insert(ShaderStage::FRAGMENT, maxLimits.clone());
+ validation_map.insert(ShaderStage::COMPUTE, maxLimits.clone());
let mut max_dynamic_uniform_buffers_per_pipeline_layout =
limits.maxDynamicUniformBuffersPerPipelineLayout as i32;
let mut max_dynamic_storage_buffers_per_pipeline_layout =
@@ -344,14 +339,23 @@ impl GPUDeviceMethods for GPUDevice {
};
BindingType::SampledTexture
},
- GPUBindingType::Storage_texture => {
+ GPUBindingType::Readonly_storage_texture => {
+ if let Some(limit) = validation_map.get_mut(&visibility) {
+ limit.max_storage_textures_per_shader_stage -= 1;
+ }
+ if bind.hasDynamicOffset {
+ valid = false
+ };
+ BindingType::ReadonlyStorageTexture
+ },
+ GPUBindingType::Writeonly_storage_texture => {
if let Some(limit) = validation_map.get_mut(&visibility) {
limit.max_storage_textures_per_shader_stage -= 1;
}
if bind.hasDynamicOffset {
valid = false
};
- BindingType::StorageTexture
+ BindingType::WriteonlyStorageTexture
},
GPUBindingType::Sampler => {
if let Some(limit) = validation_map.get_mut(&visibility) {
@@ -364,16 +368,19 @@ impl GPUDeviceMethods for GPUDevice {
},
};
- BindGroupLayoutBinding {
+ BindGroupLayoutEntry {
binding: bind.binding,
visibility,
ty,
- dynamic: bind.hasDynamicOffset,
+ has_dynamic_offset: bind.hasDynamicOffset,
multisampled: bind.multisampled,
- texture_dimension: webgpu::wgpu::resource::TextureViewDimension::D2, // Use as default for now
+ // Use as default for now
+ texture_component_type: TextureComponentType::Float,
+ storage_texture_format: TextureFormat::Rgba8UnormSrgb,
+ view_dimension: TextureViewDimension::D2,
}
})
- .collect::<Vec<BindGroupLayoutBinding>>();
+ .collect::<Vec<BindGroupLayoutEntry>>();
// bindings are unique
valid &= storeBindings.len() == bindings.len();
@@ -523,7 +530,7 @@ impl GPUDeviceMethods for GPUDevice {
let bindings = descriptor
.entries
.iter()
- .map(|bind| BindGroupBinding {
+ .map(|bind| BindGroupEntry {
binding: bind.binding,
resource: BindingResource::Buffer(BufferBinding {
buffer: bind.resource.buffer.id().0,
diff --git a/components/script/dom/identityhub.rs b/components/script/dom/identityhub.rs
index 702172f6d72..809a68e37ea 100644
--- a/components/script/dom/identityhub.rs
+++ b/components/script/dom/identityhub.rs
@@ -9,8 +9,8 @@ use webgpu::wgpu::{
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandEncoderId, ComputePipelineId,
DeviceId, PipelineLayoutId, ShaderModuleId,
},
- Backend,
};
+use webgpu::wgt::Backend;
#[derive(Debug)]
pub struct IdentityHub {
diff --git a/components/script/dom/webidls/GPUBindGroupLayout.webidl b/components/script/dom/webidls/GPUBindGroupLayout.webidl
index b5327f107d3..b2e705e6cc5 100644
--- a/components/script/dom/webidls/GPUBindGroupLayout.webidl
+++ b/components/script/dom/webidls/GPUBindGroupLayout.webidl
@@ -28,5 +28,7 @@ enum GPUBindingType {
"readonly-storage-buffer",
"sampler",
"sampled-texture",
- "storage-texture"
+ "readonly-storage-texture",
+ "writeonly-storage-texture",
+ //"comparison-sampler",
};
diff --git a/components/script/dom/webidls/GPUBuffer.webidl b/components/script/dom/webidls/GPUBuffer.webidl
index be18b54bce7..4896caf46c1 100644
--- a/components/script/dom/webidls/GPUBuffer.webidl
+++ b/components/script/dom/webidls/GPUBuffer.webidl
@@ -5,7 +5,7 @@
// https://gpuweb.github.io/gpuweb/#gpubuffer
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom.webgpu.enabled"]
interface GPUBuffer {
- Promise<ArrayBuffer> mapReadAsync();
+ //Promise<ArrayBuffer> mapReadAsync();
// Promise<ArrayBuffer> mapWriteAsync();
void unmap();
diff --git a/components/webgpu/Cargo.toml b/components/webgpu/Cargo.toml
index 23944e6eb8e..da03897d694 100644
--- a/components/webgpu/Cargo.toml
+++ b/components/webgpu/Cargo.toml
@@ -15,7 +15,8 @@ embedder_traits = {path = "../embedder_traits"}
ipc-channel = "0.14"
log = "0.4"
malloc_size_of = { path = "../malloc_size_of" }
-serde = "1.0"
+serde = { version = "1.0", features = ["serde_derive"] }
servo_config = {path = "../config"}
smallvec = { version = "0.6", features = ["serde"] }
-wgpu-core = { version = "0.1.0", git = "https://github.com/gfx-rs/wgpu", features = ["serde"] }
+wgpu-core = { version = "0.5.0", git = "https://github.com/gfx-rs/wgpu", features = ["trace", "replay"] }
+wgpu-types = { version = "0.5.0", git = "https://github.com/gfx-rs/wgpu", features = ["trace", "replay"] }
diff --git a/components/webgpu/identity.rs b/components/webgpu/identity.rs
new file mode 100644
index 00000000000..590007dc33f
--- /dev/null
+++ b/components/webgpu/identity.rs
@@ -0,0 +1,114 @@
+/* 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 https://mozilla.org/MPL/2.0/. */
+
+use ipc_channel::ipc::IpcSender;
+use serde::{Deserialize, Serialize};
+use wgpu::{
+ hub::{GlobalIdentityHandlerFactory, IdentityHandler, IdentityHandlerFactory},
+ id::{
+ AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, ComputePipelineId,
+ DeviceId, PipelineLayoutId, RenderPipelineId, SamplerId, ShaderModuleId, SurfaceId,
+ SwapChainId, TextureId, TextureViewId, TypedId,
+ },
+};
+use wgt::Backend;
+
+#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
+pub enum WebGPUMsg {
+ FreeAdapter(AdapterId),
+ FreeDevice(DeviceId),
+ FreeBuffer(BufferId),
+ FreeSwapChain(SwapChainId),
+ FreePipelineLayout(PipelineLayoutId),
+ FreeComputePipeline(ComputePipelineId),
+ FreeRenderPipeline(RenderPipelineId),
+ FreeBindGroup(BindGroupId),
+ FreeBindGroupLayout(BindGroupLayoutId),
+ FreeCommandBuffer(CommandBufferId),
+ FreeTexture(TextureId),
+ FreeTextureView(TextureViewId),
+ FreeSampler(SamplerId),
+ FreeSurface(SurfaceId),
+ FreeShaderModule(ShaderModuleId),
+}
+
+#[derive(Debug)]
+pub struct IdentityRecycler {
+ sender: IpcSender<WebGPUMsg>,
+}
+
+pub struct IdentityRecyclerFactory {
+ pub sender: IpcSender<WebGPUMsg>,
+}
+
+macro_rules! impl_identity_handler {
+ ($id:ty, $st:tt, $($var:tt)*) => {
+ impl IdentityHandler<$id> for IdentityRecycler {
+ type Input = $id;
+ fn process(&self, id: $id, _backend: Backend) -> $id {
+ log::debug!("process {} {:?}", $st, id);
+ //debug_assert_eq!(id.unzip().2, backend);
+ id
+ }
+ fn free(&self, id: $id) {
+ log::debug!("free {} {:?}", $st, id);
+ let msg = $($var)*(id);
+ if self.sender.send(msg).is_err() {
+ log::error!("Failed to send {:?}", msg);
+ }
+ }
+ }
+ };
+}
+
+impl_identity_handler!(AdapterId, "adapter", WebGPUMsg::FreeAdapter);
+impl_identity_handler!(DeviceId, "device", WebGPUMsg::FreeDevice);
+impl_identity_handler!(SurfaceId, "surface", WebGPUMsg::FreeSurface);
+impl_identity_handler!(SamplerId, "sampler", WebGPUMsg::FreeSampler);
+impl_identity_handler!(TextureId, "texture", WebGPUMsg::FreeTexture);
+impl_identity_handler!(TextureViewId, "texture_view", WebGPUMsg::FreeTextureView);
+impl_identity_handler!(BufferId, "buffer", WebGPUMsg::FreeBuffer);
+impl_identity_handler!(BindGroupId, "bind_group", WebGPUMsg::FreeBindGroup);
+impl_identity_handler!(SwapChainId, "swap_chain", WebGPUMsg::FreeSwapChain);
+impl_identity_handler!(ShaderModuleId, "shader_module", WebGPUMsg::FreeShaderModule);
+impl_identity_handler!(
+ RenderPipelineId,
+ "render_pipeline",
+ WebGPUMsg::FreeRenderPipeline
+);
+impl_identity_handler!(
+ ComputePipelineId,
+ "compute_pipeline",
+ WebGPUMsg::FreeComputePipeline
+);
+impl_identity_handler!(
+ CommandBufferId,
+ "command_buffer",
+ WebGPUMsg::FreeCommandBuffer
+);
+impl_identity_handler!(
+ BindGroupLayoutId,
+ "bind_group_layout",
+ WebGPUMsg::FreeBindGroupLayout
+);
+impl_identity_handler!(
+ PipelineLayoutId,
+ "pipeline_layout",
+ WebGPUMsg::FreePipelineLayout
+);
+
+impl<I: TypedId + Clone + std::fmt::Debug> IdentityHandlerFactory<I> for IdentityRecyclerFactory
+where
+ I: TypedId + Clone + std::fmt::Debug,
+ IdentityRecycler: IdentityHandler<I>,
+{
+ type Filter = IdentityRecycler;
+ fn spawn(&self, _min_index: u32) -> Self::Filter {
+ IdentityRecycler {
+ sender: self.sender.clone(),
+ }
+ }
+}
+
+impl GlobalIdentityHandlerFactory for IdentityRecyclerFactory {}
diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs
index c8c5db15dfa..aacbcbd4043 100644
--- a/components/webgpu/lib.rs
+++ b/components/webgpu/lib.rs
@@ -6,21 +6,28 @@
extern crate log;
#[macro_use]
pub extern crate wgpu_core as wgpu;
+pub extern crate wgpu_types as wgt;
-use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory};
+mod identity;
+
+use identity::{IdentityRecyclerFactory, WebGPUMsg};
+use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
+use serde::{Deserialize, Serialize};
use servo_config::pref;
use smallvec::SmallVec;
+use std::ptr;
use wgpu::{
- binding_model::{BindGroupBinding, BindGroupLayoutBinding},
+ binding_model::{
+ BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry,
+ },
id::{
AdapterId, BindGroupId, BindGroupLayoutId, BufferId, CommandBufferId, CommandEncoderId,
ComputePipelineId, DeviceId, PipelineLayoutId, QueueId, ShaderModuleId,
},
- instance::{DeviceDescriptor, RequestAdapterOptions},
- resource::BufferDescriptor,
- BufferAddress,
+ instance::RequestAdapterOptions,
};
+use wgt::{BufferAddress, BufferDescriptor, CommandBufferDescriptor, DeviceDescriptor};
#[derive(Debug, Deserialize, Serialize)]
pub enum WebGPUResponse {
@@ -34,7 +41,6 @@ pub enum WebGPUResponse {
queue_id: WebGPUQueue,
_descriptor: DeviceDescriptor,
},
- MapReadAsync(IpcSharedMemory),
}
pub type WebGPUResponseResult = Result<WebGPUResponse, String>;
@@ -60,25 +66,25 @@ pub enum WebGPURequest {
device_id: DeviceId,
bind_group_id: BindGroupId,
bind_group_layout_id: BindGroupLayoutId,
- bindings: Vec<BindGroupBinding>,
+ bindings: Vec<BindGroupEntry>,
},
CreateBindGroupLayout {
sender: IpcSender<WebGPUBindGroupLayout>,
device_id: DeviceId,
bind_group_layout_id: BindGroupLayoutId,
- bindings: Vec<BindGroupLayoutBinding>,
+ bindings: Vec<BindGroupLayoutEntry>,
},
CreateBuffer {
sender: IpcSender<WebGPUBuffer>,
device_id: DeviceId,
buffer_id: BufferId,
- descriptor: BufferDescriptor,
+ descriptor: BufferDescriptor<String>,
},
CreateBufferMapped {
sender: IpcSender<WebGPUBuffer>,
device_id: DeviceId,
buffer_id: BufferId,
- descriptor: BufferDescriptor,
+ descriptor: BufferDescriptor<String>,
},
CreateCommandEncoder {
sender: IpcSender<WebGPUCommandEncoder>,
@@ -109,13 +115,6 @@ pub enum WebGPURequest {
},
DestroyBuffer(BufferId),
Exit(IpcSender<()>),
- MapReadAsync {
- sender: IpcSender<WebGPUResponseResult>,
- buffer_id: BufferId,
- device_id: DeviceId,
- usage: u32,
- size: u64,
- },
RequestAdapter {
sender: IpcSender<WebGPUResponseResult>,
options: RequestAdapterOptions,
@@ -154,7 +153,7 @@ impl WebGPU {
Ok(sender_and_receiver) => sender_and_receiver,
Err(e) => {
warn!(
- "Failed to create sender and receiciver for WGPU thread ({})",
+ "Failed to create sender and receiver for WGPU thread ({})",
e
);
return None;
@@ -162,10 +161,21 @@ impl WebGPU {
};
let sender_clone = sender.clone();
+ let (script_sender, _script_recv) = match ipc::channel() {
+ Ok(sender_and_receiver) => sender_and_receiver,
+ Err(e) => {
+ warn!(
+ "Failed to create receiver and sender for WGPU thread ({})",
+ e
+ );
+ return None;
+ },
+ };
+
if let Err(e) = std::thread::Builder::new()
.name("WGPU".to_owned())
.spawn(move || {
- WGPU::new(receiver, sender_clone).run();
+ WGPU::new(receiver, sender_clone, script_sender).run();
})
{
warn!("Failed to spwan WGPU thread ({})", e);
@@ -184,7 +194,7 @@ impl WebGPU {
struct WGPU {
receiver: IpcReceiver<WebGPURequest>,
sender: IpcSender<WebGPURequest>,
- global: wgpu::hub::Global<()>,
+ global: wgpu::hub::Global<IdentityRecyclerFactory>,
adapters: Vec<WebGPUAdapter>,
devices: Vec<WebGPUDevice>,
// Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
@@ -192,21 +202,24 @@ struct WGPU {
}
impl WGPU {
- fn new(receiver: IpcReceiver<WebGPURequest>, sender: IpcSender<WebGPURequest>) -> Self {
+ fn new(
+ receiver: IpcReceiver<WebGPURequest>,
+ sender: IpcSender<WebGPURequest>,
+ script_sender: IpcSender<WebGPUMsg>,
+ ) -> Self {
+ let factory = IdentityRecyclerFactory {
+ sender: script_sender,
+ };
WGPU {
receiver,
sender,
- global: wgpu::hub::Global::new("wgpu-core"),
+ global: wgpu::hub::Global::new("wgpu-core", factory),
adapters: Vec::new(),
devices: Vec::new(),
_invalid_adapters: Vec::new(),
}
}
- fn deinit(self) {
- self.global.delete()
- }
-
fn run(mut self) {
while let Ok(msg) = self.receiver.recv() {
match msg {
@@ -217,7 +230,7 @@ impl WGPU {
let global = &self.global;
let command_buffer_id = gfx_select!(command_encoder_id => global.command_encoder_finish(
command_encoder_id,
- &wgpu::command::CommandBufferDescriptor::default()
+ &CommandBufferDescriptor::default()
));
if let Err(e) = sender.send(WebGPUCommandBuffer(command_buffer_id)) {
warn!(
@@ -252,10 +265,11 @@ impl WGPU {
bindings,
} => {
let global = &self.global;
- let descriptor = wgpu_core::binding_model::BindGroupDescriptor {
+ let descriptor = BindGroupDescriptor {
layout: bind_group_layout_id,
- bindings: bindings.as_ptr(),
- bindings_length: bindings.len(),
+ entries: bindings.as_ptr(),
+ entries_length: bindings.len(),
+ label: ptr::null(),
};
let bg_id = gfx_select!(bind_group_id =>
global.device_create_bind_group(device_id, &descriptor, bind_group_id));
@@ -275,9 +289,10 @@ impl WGPU {
bindings,
} => {
let global = &self.global;
- let descriptor = wgpu_core::binding_model::BindGroupLayoutDescriptor {
- bindings: bindings.as_ptr(),
- bindings_length: bindings.len(),
+ let descriptor = BindGroupLayoutDescriptor {
+ entries: bindings.as_ptr(),
+ entries_length: bindings.len(),
+ label: ptr::null(),
};
let bgl_id = gfx_select!(bind_group_layout_id =>
global.device_create_bind_group_layout(device_id, &descriptor, bind_group_layout_id));
@@ -297,7 +312,12 @@ impl WGPU {
descriptor,
} => {
let global = &self.global;
- let id = gfx_select!(buffer_id => global.device_create_buffer(device_id, &descriptor, buffer_id));
+ let desc = BufferDescriptor {
+ size: descriptor.size,
+ usage: descriptor.usage,
+ label: ptr::null(),
+ };
+ let id = gfx_select!(buffer_id => global.device_create_buffer(device_id, &desc, buffer_id));
let buffer = WebGPUBuffer(id);
if let Err(e) = sender.send(buffer) {
warn!(
@@ -313,8 +333,13 @@ impl WGPU {
descriptor,
} => {
let global = &self.global;
+ let desc = BufferDescriptor {
+ size: descriptor.size,
+ usage: descriptor.usage,
+ label: ptr::null(),
+ };
let (buffer_id, _arr_buff_ptr) = gfx_select!(buffer_id =>
- global.device_create_buffer_mapped(device_id, &descriptor, buffer_id));
+ global.device_create_buffer_mapped(device_id, &desc, buffer_id));
let buffer = WebGPUBuffer(buffer_id);
if let Err(e) = sender.send(buffer) {
@@ -418,55 +443,12 @@ impl WGPU {
gfx_select!(buffer => global.buffer_destroy(buffer));
},
WebGPURequest::Exit(sender) => {
- self.deinit();
+ drop(self.global);
if let Err(e) = sender.send(()) {
warn!("Failed to send response to WebGPURequest::Exit ({})", e)
}
return;
},
- WebGPURequest::MapReadAsync {
- sender,
- buffer_id,
- device_id,
- usage,
- size,
- } => {
- let global = &self.global;
- let on_read = move |status: wgpu::resource::BufferMapAsyncStatus,
- ptr: *const u8| {
- match status {
- wgpu::resource::BufferMapAsyncStatus::Success => {
- let array_buffer =
- unsafe { std::slice::from_raw_parts(ptr, size as usize) };
- if let Err(e) = sender.send(Ok(WebGPUResponse::MapReadAsync(
- IpcSharedMemory::from_bytes(array_buffer),
- ))) {
- warn!(
- "Failed to send response to WebGPURequest::MapReadAsync ({})",
- e
- )
- }
- },
- _ => {
- if let Err(e) = sender
- .send(Err("MapReadAsync: Failed to map buffer".to_owned()))
- {
- warn!(
- "Failed to send response to WebGPURequest::MapReadAsync ({})",
- e
- )
- }
- },
- }
- };
- gfx_select!(buffer_id => global.buffer_map_async(
- buffer_id,
- wgpu::resource::BufferUsage::from_bits(usage).unwrap(),
- 0..size,
- wgpu::resource::BufferMapOperation::Read(Box::new(on_read))
- ));
- gfx_select!(device_id => global.device_poll(device_id, true));
- },
WebGPURequest::RequestAdapter {
sender,
options,
@@ -523,6 +505,7 @@ impl WGPU {
let id = gfx_select!(device_id => global.adapter_request_device(
adapter_id.0,
&descriptor,
+ None,
device_id
));
diff --git a/servo-tidy.toml b/servo-tidy.toml
index 2673a5d4a24..3fe1f290113 100644
--- a/servo-tidy.toml
+++ b/servo-tidy.toml
@@ -35,6 +35,10 @@ packages = [
"peek-poke",
"peek-poke-derive",
"wayland-sys",
+ "metal",
+ "parking_lot",
+ "parking_lot_core",
+ "ron",
# https://github.com/servo/servo/pull/23288#issuecomment-494687746
"gl_generator",