From 96833582366efea19cd898de80b3a58381bb6b78 Mon Sep 17 00:00:00 2001 From: Rajesh Malviya Date: Sun, 4 Aug 2024 16:16:57 +0530 Subject: [PATCH] Update wgpu to v22.1.0 --- Cargo.lock | 313 ++++++------ Cargo.toml | 31 +- examples/capture/main.c | 2 +- examples/compute/main.c | 2 +- examples/texture_arrays/main.c | 45 +- examples/triangle/main.c | 43 +- ffi/wgpu.h | 15 +- src/conv.rs | 8 +- src/lib.rs | 838 +++++++++++++++++++-------------- 9 files changed, 695 insertions(+), 602 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8596fb3..429bdac1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,11 +49,11 @@ dependencies = [ [[package]] name = "ash" -version = "0.37.3+1.3.251" +version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "libloading 0.7.4", + "libloading", ] [[package]] @@ -62,19 +62,13 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "bindgen" version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "cexpr", "clang-sys", "itertools", @@ -87,24 +81,24 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.63", + "syn 2.0.72", "which", ] [[package]] name = "bit-set" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" -version = "0.6.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22" [[package]] name = "bitflags" @@ -114,9 +108,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" dependencies = [ "serde", ] @@ -135,9 +129,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" [[package]] name = "cexpr" @@ -162,13 +156,13 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "clang-sys" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" dependencies = [ "glob", "libc", - "libloading 0.8.3", + "libloading", ] [[package]] @@ -241,28 +235,28 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.20.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" +version = "22.0.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ - "bitflags 2.5.0", - "libloading 0.8.3", + "bitflags 2.6.0", + "libloading", "winapi", ] [[package]] name = "document-features" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" dependencies = [ "litrs", ] [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "equivalent" @@ -277,7 +271,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -304,7 +298,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.72", ] [[package]] @@ -344,9 +338,9 @@ dependencies = [ [[package]] name = "glutin_wgl_sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" +checksum = "0a4e1951bbd9434a81aa496fe59ccc2235af3820d27b85f9314e279609211e2c" dependencies = [ "gl_generator", ] @@ -357,7 +351,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "gpu-alloc-types", ] @@ -367,14 +361,14 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] name = "gpu-allocator" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" +checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7" dependencies = [ "log", "presser", @@ -389,7 +383,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "gpu-descriptor-types", "hashbrown", ] @@ -400,7 +394,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -419,10 +413,10 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "com", "libc", - "libloading 0.8.3", + "libloading", "thiserror", "widestring", "winapi", @@ -440,14 +434,14 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", @@ -485,7 +479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.8.3", + "libloading", "pkg-config", ] @@ -497,9 +491,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lazycell" @@ -509,25 +503,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "libloading" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", "windows-targets", @@ -535,9 +519,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litrs" @@ -557,9 +541,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "malloc_buf" @@ -572,17 +556,17 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "metal" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5637e166ea14be6063a3f8ba5ccb9a4159df7d8f6d61c02fc3d480b1f90dcfcb" +checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block", "core-graphics-types", "foreign-types", @@ -599,17 +583,17 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "naga" -version = "0.20.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" +version = "22.1.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ "arrayvec", "bit-set", - "bitflags 2.5.0", + "bitflags 2.6.0", + "cfg_aliases", "codespan-reporting", "hexf-parse", "indexmap", "log", - "num-traits", "petgraph", "pp-rs", "rustc-hash", @@ -639,15 +623,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - [[package]] name = "objc" version = "0.2.7" @@ -665,9 +640,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -730,14 +705,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.63", + "syn 2.0.72", ] [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -765,24 +740,24 @@ checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" [[package]] name = "raw-window-handle" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cc3bcbdb1ddfc11e700e62968e6b4cc9c75bb466464ad28fb61c5b2c964418b" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.4" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -792,9 +767,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -803,9 +778,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "renderdoc-sys" @@ -813,18 +788,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" -[[package]] -name = "ron" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" -dependencies = [ - "base64", - "bitflags 2.5.0", - "serde", - "serde_derive", -] - [[package]] name = "rustc-hash" version = "1.1.0" @@ -837,11 +800,11 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -852,22 +815,22 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.201" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.72", ] [[package]] @@ -897,7 +860,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -913,9 +876,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -933,22 +896,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.72", ] [[package]] @@ -959,9 +922,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -971,9 +934,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasm-bindgen" @@ -996,7 +959,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -1018,7 +981,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1041,15 +1004,14 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.20.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" +version = "22.1.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ "arrayvec", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", "bytemuck", "cfg_aliases", - "codespan-reporting", "document-features", "indexmap", "log", @@ -1058,26 +1020,24 @@ dependencies = [ "parking_lot", "profiling", "raw-window-handle", - "ron", "rustc-hash", "serde", "smallvec", "thiserror", - "web-sys", "wgpu-hal", "wgpu-types", ] [[package]] name = "wgpu-hal" -version = "0.20.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" +version = "22.0.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set", - "bitflags 2.5.0", + "bitflags 2.6.0", "block", "cfg_aliases", "core-graphics-types", @@ -1091,7 +1051,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.3", + "libloading", "log", "metal", "naga", @@ -1133,10 +1093,10 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.20.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" +version = "22.0.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "js-sys", "serde", "web-sys", @@ -1178,11 +1138,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1219,11 +1179,20 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1237,51 +1206,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "xml-rs" @@ -1291,20 +1260,20 @@ checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.72", ] diff --git a/Cargo.toml b/Cargo.toml index c0bdeffa..4a60c4a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,32 +23,32 @@ resolver = "2" [workspace.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "4521502da69bcf4f92c8350042c268573ef216d4" -version = "0.20" +rev = "5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" +version = "22.0.0" [workspace.dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "4521502da69bcf4f92c8350042c268573ef216d4" -version = "0.20" +rev = "5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" +version = "22.0.0" [workspace.dependencies.hal] package = "wgpu-hal" git = "https://github.com/gfx-rs/wgpu" -rev = "4521502da69bcf4f92c8350042c268573ef216d4" -version = "0.20" +rev = "5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" +version = "22.0.0" [workspace.dependencies.naga] package = "naga" git = "https://github.com/gfx-rs/wgpu" -rev = "4521502da69bcf4f92c8350042c268573ef216d4" -version = "0.20" +rev = "5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" +version = "22.0.0" [lib] crate-type = ["cdylib", "staticlib"] [features] -default = ["wgsl", "spirv", "glsl", "dx12", "metal", "trace"] +default = ["wgsl", "spirv", "glsl", "dx12", "metal"] #! ### Backends # -------------------------------------------------------------------- @@ -68,6 +68,10 @@ angle = ["wgc/gles"] ## Enables the Vulkan backend on macOS & iOS. vulkan-portability = ["wgc/vulkan"] +#! **Note:** In the documentation, if you see that an item depends on a backend, +#! it means that the item is only available when that backend is enabled _and_ the backend +#! is supported on the current platform. + #! ### Shading language support # -------------------------------------------------------------------- @@ -80,10 +84,6 @@ glsl = ["naga/glsl-in", "wgc/glsl"] ## Enable accepting WGSL shaders as input. wgsl = ["wgc/wgsl"] -# TODO: needs to be exposed in wgpu.h -# ## Enable accepting naga IR shaders as input. -# naga-ir = ["naga"] - #! ### Logging & Tracing # -------------------------------------------------------------------- #! The following features do not have any effect on the WebGPU backend. @@ -98,8 +98,9 @@ api_log_info = ["wgc/api_log_info"] ## Enables serialization via `serde` on common wgpu types. serde = ["dep:serde", "wgc/serde"] -## Allow writing of trace capture files. See [`Adapter::request_device`]. -trace = ["serde", "wgc/trace"] +# Uncomment once upstream adds it again — https://github.com/gfx-rs/wgpu/issues/5974 +# ## Allow writing of trace capture files. See [`Adapter::request_device`]. +# trace = ["serde", "wgc/trace"] ## Allow deserializing of trace capture files that were written with the `trace` feature. ## To replay a trace file use the [wgpu player](https://github.com/gfx-rs/wgpu/tree/trunk/player). diff --git a/examples/capture/main.c b/examples/capture/main.c index 7c098c9d..e7133836 100644 --- a/examples/capture/main.c +++ b/examples/capture/main.c @@ -144,6 +144,7 @@ int main(int argc, char *argv[]) { assert(render_pass_encoder); wgpuRenderPassEncoderEnd(render_pass_encoder); + wgpuRenderPassEncoderRelease(render_pass_encoder); wgpuCommandEncoderCopyTextureToBuffer( command_encoder, @@ -186,7 +187,6 @@ int main(int argc, char *argv[]) { wgpuBufferUnmap(output_buffer); wgpuCommandBufferRelease(command_buffer); - wgpuRenderPassEncoderRelease(render_pass_encoder); wgpuCommandEncoderRelease(command_encoder); wgpuTextureViewRelease(texture_view); wgpuTextureRelease(texture); diff --git a/examples/compute/main.c b/examples/compute/main.c index 34d4f711..03dcaeba 100644 --- a/examples/compute/main.c +++ b/examples/compute/main.c @@ -124,6 +124,7 @@ int main(int argc, char *argv[]) { wgpuComputePassEncoderDispatchWorkgroups(compute_pass_encoder, numbers_length, 1, 1); wgpuComputePassEncoderEnd(compute_pass_encoder); + wgpuComputePassEncoderRelease(compute_pass_encoder); wgpuCommandEncoderCopyBufferToBuffer(command_encoder, storage_buffer, 0, staging_buffer, 0, numbers_size); @@ -149,7 +150,6 @@ int main(int argc, char *argv[]) { wgpuBufferUnmap(staging_buffer); wgpuCommandBufferRelease(command_buffer); - wgpuComputePassEncoderRelease(compute_pass_encoder); wgpuCommandEncoderRelease(command_encoder); wgpuBindGroupRelease(bind_group); wgpuBindGroupLayoutRelease(bind_group_layout); diff --git a/examples/texture_arrays/main.c b/examples/texture_arrays/main.c index 5ee65335..907355f7 100644 --- a/examples/texture_arrays/main.c +++ b/examples/texture_arrays/main.c @@ -689,27 +689,28 @@ int main(int argc, char *argv[]) { WGPURenderPassEncoder render_pass_encoder = wgpuCommandEncoderBeginRenderPass( - command_encoder, &(const WGPURenderPassDescriptor){ - .label = "render_pass_encoder", - .colorAttachmentCount = 1, - .colorAttachments = - (const WGPURenderPassColorAttachment[]){ - (const WGPURenderPassColorAttachment){ - .view = frame, - .loadOp = WGPULoadOp_Clear, - .storeOp = WGPUStoreOp_Store, - .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, - .clearValue = - (const WGPUColor){ - .r = 0.0, - .g = 0.0, - .b = 0.0, - .a = 1.0, - }, - }, - }, - - }); + command_encoder, + &(const WGPURenderPassDescriptor){ + .label = "render_pass_encoder", + .colorAttachmentCount = 1, + .colorAttachments = + (const WGPURenderPassColorAttachment[]){ + (const WGPURenderPassColorAttachment){ + .view = frame, + .loadOp = WGPULoadOp_Clear, + .storeOp = WGPUStoreOp_Store, + .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, + .clearValue = + (const WGPUColor){ + .r = 0.0, + .g = 0.0, + .b = 0.0, + .a = 1.0, + }, + }, + }, + + }); assert(render_pass_encoder); wgpuRenderPassEncoderSetPipeline(render_pass_encoder, pipeline); @@ -730,6 +731,7 @@ int main(int argc, char *argv[]) { wgpuRenderPassEncoderDrawIndexed(render_pass_encoder, 12, 1, 0, 0, 0); } wgpuRenderPassEncoderEnd(render_pass_encoder); + wgpuRenderPassEncoderRelease(render_pass_encoder); WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish( command_encoder, &(const WGPUCommandBufferDescriptor){ @@ -741,7 +743,6 @@ int main(int argc, char *argv[]) { wgpuSurfacePresent(demo.surface); wgpuCommandBufferRelease(command_buffer); - wgpuRenderPassEncoderRelease(render_pass_encoder); wgpuCommandEncoderRelease(command_encoder); wgpuTextureViewRelease(frame); wgpuTextureRelease(surface_texture.texture); diff --git a/examples/triangle/main.c b/examples/triangle/main.c index 6bfb9b49..fb6eacdd 100644 --- a/examples/triangle/main.c +++ b/examples/triangle/main.c @@ -308,31 +308,33 @@ int main(int argc, char *argv[]) { WGPURenderPassEncoder render_pass_encoder = wgpuCommandEncoderBeginRenderPass( - command_encoder, &(const WGPURenderPassDescriptor){ - .label = "render_pass_encoder", - .colorAttachmentCount = 1, - .colorAttachments = - (const WGPURenderPassColorAttachment[]){ - (const WGPURenderPassColorAttachment){ - .view = frame, - .loadOp = WGPULoadOp_Clear, - .storeOp = WGPUStoreOp_Store, - .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, - .clearValue = - (const WGPUColor){ - .r = 0.0, - .g = 1.0, - .b = 0.0, - .a = 1.0, - }, - }, - }, - }); + command_encoder, + &(const WGPURenderPassDescriptor){ + .label = "render_pass_encoder", + .colorAttachmentCount = 1, + .colorAttachments = + (const WGPURenderPassColorAttachment[]){ + (const WGPURenderPassColorAttachment){ + .view = frame, + .loadOp = WGPULoadOp_Clear, + .storeOp = WGPUStoreOp_Store, + .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED, + .clearValue = + (const WGPUColor){ + .r = 0.0, + .g = 1.0, + .b = 0.0, + .a = 1.0, + }, + }, + }, + }); assert(render_pass_encoder); wgpuRenderPassEncoderSetPipeline(render_pass_encoder, render_pipeline); wgpuRenderPassEncoderDraw(render_pass_encoder, 3, 1, 0, 0); wgpuRenderPassEncoderEnd(render_pass_encoder); + wgpuRenderPassEncoderRelease(render_pass_encoder); WGPUCommandBuffer command_buffer = wgpuCommandEncoderFinish( command_encoder, &(const WGPUCommandBufferDescriptor){ @@ -344,7 +346,6 @@ int main(int argc, char *argv[]) { wgpuSurfacePresent(demo.surface); wgpuCommandBufferRelease(command_buffer); - wgpuRenderPassEncoderRelease(render_pass_encoder); wgpuCommandEncoderRelease(command_encoder); wgpuTextureViewRelease(frame); wgpuTextureRelease(surface_texture.texture); diff --git a/ffi/wgpu.h b/ffi/wgpu.h index 2b5893db..3d5e1fa6 100644 --- a/ffi/wgpu.h +++ b/ffi/wgpu.h @@ -46,14 +46,13 @@ typedef enum WGPUNativeFeature { // WGPUNativeFeature_SpirvShaderPassthrough = 0x00030017, // WGPUNativeFeature_Multiview = 0x00030018, WGPUNativeFeature_VertexAttribute64bit = 0x00030019, - WGPUNativeFeature_ShaderUnusedVertexOutput = 0x0003001A, - WGPUNativeFeature_TextureFormatNv12 = 0x0003001B, - WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001C, - WGPUNativeFeature_RayQuery = 0x0003001D, - WGPUNativeFeature_ShaderF64 = 0x0003001E, - WGPUNativeFeature_ShaderI16 = 0x0003001F, - WGPUNativeFeature_ShaderPrimitiveIndex = 0x00030020, - WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030021, + WGPUNativeFeature_TextureFormatNv12 = 0x0003001A, + WGPUNativeFeature_RayTracingAccelerationStructure = 0x0003001B, + WGPUNativeFeature_RayQuery = 0x0003001C, + WGPUNativeFeature_ShaderF64 = 0x0003001D, + WGPUNativeFeature_ShaderI16 = 0x0003001E, + WGPUNativeFeature_ShaderPrimitiveIndex = 0x0003001F, + WGPUNativeFeature_ShaderEarlyDepthTest = 0x00030020, WGPUNativeFeature_Force32 = 0x7FFFFFFF } WGPUNativeFeature; diff --git a/src/conv.rs b/src/conv.rs index 68980a35..c0d110b2 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -327,6 +327,8 @@ pub(crate) fn map_device_descriptor<'a>( }, None => base_limits, }, + // TODO(wgpu.h) + memory_hints: Default::default(), }, match extras { Some(extras) => extras.tracePath, @@ -568,7 +570,7 @@ pub enum ShaderParseError { Spirv(#[from] naga::front::spv::Error), #[cfg(feature = "glsl")] #[error(transparent)] - Glsl(#[from] naga::front::glsl::ParseError), + Glsl(#[from] naga::front::glsl::ParseErrors), } #[inline] @@ -1183,9 +1185,6 @@ pub fn features_to_native(features: wgt::Features) -> Vec Option { // native::WGPUNativeFeature_SpirvShaderPassthrough => Some(Features::SPIRV_SHADER_PASSTHROUGH), // native::WGPUNativeFeature_Multiview => Some(Features::MULTIVIEW), native::WGPUNativeFeature_VertexAttribute64bit => Some(Features::VERTEX_ATTRIBUTE_64BIT), - native::WGPUNativeFeature_ShaderUnusedVertexOutput => Some(Features::SHADER_UNUSED_VERTEX_OUTPUT), native::WGPUNativeFeature_TextureFormatNv12 => Some(Features::TEXTURE_FORMAT_NV12), native::WGPUNativeFeature_RayTracingAccelerationStructure => Some(Features::RAY_TRACING_ACCELERATION_STRUCTURE), native::WGPUNativeFeature_RayQuery => Some(Features::RAY_QUERY), diff --git a/src/lib.rs b/src/lib.rs index f8629b5f..49f557ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,10 @@ use std::{ use utils::{ get_base_device_limits_from_adapter_limits, make_slice, ptr_into_label, ptr_into_path, }; -use wgc::{command::bundle_ffi, gfx_select, id, resource, Label}; +use wgc::{ + command::{bundle_ffi, DynComputePass, DynRenderPass}, + gfx_select, id, resource, Label, +}; pub mod conv; pub mod logging; @@ -35,8 +38,6 @@ pub mod native { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); } -const LABEL: &str = "label"; - pub type Context = wgc::global::Global; pub struct WGPUAdapterImpl { @@ -128,7 +129,7 @@ impl Drop for WGPUCommandEncoderImpl { pub struct WGPUComputePassEncoderImpl { context: Arc, - encoder: *mut wgc::command::ComputePass, + encoder: *mut dyn DynComputePass, error_sink: ErrorSink, } impl Drop for WGPUComputePassEncoderImpl { @@ -182,7 +183,7 @@ impl Drop for WGPUDeviceImpl { match gfx_select!(self.id => context.device_poll(self.id, wgt::Maintain::Wait)) { Ok(_) => (), - Err(err) => handle_error_fatal(context, err, "WGPUDeviceImpl::drop"), + Err(err) => handle_error_fatal(err, "WGPUDeviceImpl::drop"), } gfx_select!(self.id => context.device_drop(self.id)); @@ -263,7 +264,7 @@ unsafe impl Sync for WGPURenderBundleEncoderImpl {} pub struct WGPURenderPassEncoderImpl { context: Arc, - encoder: *mut wgc::command::RenderPass, + encoder: *mut dyn DynRenderPass, error_sink: ErrorSink, } impl Drop for WGPURenderPassEncoderImpl { @@ -370,7 +371,7 @@ impl Drop for WGPUTextureImpl { let context = &self.context; match gfx_select!(self.id => context.surface_texture_discard(surface_id)) { Ok(_) => (), - Err(cause) => handle_error_fatal(context, cause, "wgpuTextureRelease"), + Err(cause) => handle_error_fatal(cause, "wgpuTextureRelease"), } } } @@ -545,48 +546,52 @@ impl ErrorSinkRaw { } } -fn format_error(context: &Context, err: &(impl error::Error + 'static)) -> String { - let mut err_descs = vec![]; +fn format_error(err: &(impl error::Error + 'static)) -> String { + let mut output = String::new(); + let mut level = 1; - let mut err_str = String::new(); - wgc::error::format_pretty_any(&mut err_str, context, err); - err_descs.push(err_str); + fn print_tree(output: &mut String, level: &mut usize, e: &(dyn error::Error + 'static)) { + let mut print = |e: &(dyn error::Error + 'static)| { + use std::fmt::Write; + writeln!(output, "{}{}", " ".repeat(*level * 2), e).unwrap(); - let mut source_opt = err.source(); - while let Some(source) = source_opt { - let mut source_str = String::new(); - wgc::error::format_pretty_any(&mut source_str, context, source); - err_descs.push(source_str); - source_opt = source.source(); + if let Some(e) = e.source() { + *level += 1; + print_tree(output, level, e); + *level -= 1; + } + }; + if let Some(multi) = e.downcast_ref::() { + for e in multi.errors() { + print(e); + } + } else { + print(e); + } } - format!("Validation Error\n\nCaused by:\n{}", err_descs.join("")) + print_tree(&mut output, &mut level, err); + + format!("Validation Error\n\nCaused by:\n{}", output) } fn handle_error_fatal( - context: &Context, cause: impl error::Error + Send + Sync + 'static, operation: &'static str, ) -> ! { - panic!( - "Error in {operation}: {f}", - f = format_error(context, &cause) - ); + panic!("Error in {operation}: {f}", f = format_error(&cause)); } fn handle_error( - context: &Context, sink_mutex: &Mutex, - cause: impl error::Error + Send + Sync + 'static, - label_key: &'static str, - label: Label, - string: &'static str, + source: impl error::Error + Send + Sync + 'static, + label: Label<'_>, + fn_ident: &'static str, ) { let error = wgc::error::ContextError { - string, - cause: Box::new(cause), + fn_ident, + source: Box::new(source), label: label.unwrap_or_default().to_string(), - label_key, }; let mut sink = sink_mutex.lock(); let mut source_opt: Option<&(dyn error::Error + 'static)> = Some(&error); @@ -609,7 +614,7 @@ fn handle_error( // Otherwise, it is a validation error sink.handle_error(crate::Error::Validation { - description: format_error(context, &error), + description: format_error(&error), source: Box::new(error), }); } @@ -646,7 +651,7 @@ pub unsafe extern "C" fn wgpuAdapterEnumerateFeatures( }; let adapter_features = match gfx_select!(adapter_id => context.adapter_features(adapter_id)) { Ok(features) => features, - Err(err) => handle_error_fatal(context, err, "wgpuAdapterEnumerateFeatures"), + Err(err) => handle_error_fatal(err, "wgpuAdapterEnumerateFeatures"), }; let temp = conv::features_to_native(adapter_features); @@ -672,7 +677,7 @@ pub unsafe extern "C" fn wgpuAdapterGetLimits( let result = gfx_select!(adapter_id => context.adapter_limits(adapter_id)); match result { Ok(wgt_limits) => conv::write_limits_struct(wgt_limits, limits), - Err(err) => handle_error_fatal(context, err, "wgpuAdapterGetLimits"), + Err(err) => handle_error_fatal(err, "wgpuAdapterGetLimits"), } true as native::WGPUBool // indicates that we can fill WGPUChainedStructOut @@ -691,7 +696,7 @@ pub unsafe extern "C" fn wgpuAdapterGetInfo( let result = gfx_select!(adapter_id => context.adapter_get_info(adapter_id)); let result = match result { Ok(info) => info, - Err(err) => handle_error_fatal(context, err, "wgpuAdapterGetInfo"), + Err(err) => handle_error_fatal(err, "wgpuAdapterGetInfo"), }; info.vendor = CString::new(format!("{:#x}", result.vendor)) @@ -719,7 +724,7 @@ pub unsafe extern "C" fn wgpuAdapterHasFeature( }; let adapter_features = match gfx_select!(adapter_id => context.adapter_features(adapter_id)) { Ok(features) => features, - Err(err) => handle_error_fatal(context, err, "wgpuAdapterHasFeature"), + Err(err) => handle_error_fatal(err, "wgpuAdapterHasFeature"), }; let feature = match conv::map_feature(feature) { @@ -762,7 +767,7 @@ pub unsafe extern "C" fn wgpuAdapterRequestDevice( let adapter_limits = match gfx_select!(adapter_id => context.adapter_limits(adapter_id)) { Ok(adapter_limits) => adapter_limits, Err(cause) => { - let msg = CString::new(format_error(context, &cause)).unwrap(); + let msg = CString::new(format_error(&cause)).unwrap(); callback( native::WGPURequestDeviceStatus_Error, std::ptr::null(), @@ -830,7 +835,7 @@ pub unsafe extern "C" fn wgpuAdapterRequestDevice( ); } Some(err) => { - let message = CString::new(format_error(context, &err)).unwrap(); + let message = CString::new(format_error(&err)).unwrap(); callback( native::WGPURequestDeviceStatus_Error, std::ptr::null_mut(), @@ -899,7 +904,7 @@ pub unsafe extern "C" fn wgpuBufferGetConstMappedRange( buffer: native::WGPUBuffer, offset: usize, size: usize, -) -> *const ::std::os::raw::c_void { +) -> *const u8 { let (buffer_id, context) = { let buffer = buffer.as_ref().expect("invalid buffer"); (buffer.id, &buffer.context) @@ -914,10 +919,10 @@ pub unsafe extern "C" fn wgpuBufferGetConstMappedRange( } )) { Ok((ptr, _)) => ptr, - Err(err) => handle_error_fatal(context, err, "wgpuBufferGetConstMappedRange"), + Err(err) => handle_error_fatal(err, "wgpuBufferGetConstMappedRange"), }; - buf as *const ::std::os::raw::c_void + buf.as_ptr() } #[no_mangle] @@ -925,7 +930,7 @@ pub unsafe extern "C" fn wgpuBufferGetMappedRange( buffer: native::WGPUBuffer, offset: usize, size: usize, -) -> *mut ::std::os::raw::c_void { +) -> *mut u8 { let (buffer_id, context) = { let buffer = buffer.as_ref().expect("invalid buffer"); (buffer.id, &buffer.context) @@ -940,10 +945,10 @@ pub unsafe extern "C" fn wgpuBufferGetMappedRange( } )) { Ok((ptr, _)) => ptr, - Err(err) => handle_error_fatal(context, err, "wgpuBufferGetMappedRange"), + Err(err) => handle_error_fatal(err, "wgpuBufferGetMappedRange"), }; - buf as *mut ::std::os::raw::c_void + buf.as_ptr() } #[no_mangle] @@ -992,8 +997,8 @@ pub unsafe extern "C" fn wgpuBufferMapAsync( Err(resource::BufferAccessError::MapAlreadyPending) => { native::WGPUBufferMapAsyncStatus_MappingAlreadyPending } - Err(resource::BufferAccessError::Invalid) - | Err(resource::BufferAccessError::Destroyed) => { + Err(resource::BufferAccessError::InvalidBufferId(_)) + | Err(resource::BufferAccessError::DestroyedResource(_)) => { native::WGPUBufferMapAsyncStatus_DestroyedBeforeCallback } Err(_) => native::WGPUBufferMapAsyncStatus_ValidationError, @@ -1012,7 +1017,7 @@ pub unsafe extern "C" fn wgpuBufferMapAsync( Some(size as wgt::BufferAddress), operation, )) { - handle_error(context, error_sink, cause, "", None, "wgpuBufferMapAsync"); + handle_error(error_sink, cause, None, "wgpuBufferMapAsync"); }; } @@ -1024,7 +1029,7 @@ pub unsafe extern "C" fn wgpuBufferUnmap(buffer: native::WGPUBuffer) { }; if let Err(cause) = gfx_select!(buffer_id => context.buffer_unmap(buffer_id)) { - handle_error(context, error_sink, cause, "", None, "wgpuBufferUnmap"); + handle_error(error_sink, cause, None, "wgpuBufferUnmap"); } } @@ -1070,7 +1075,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderBeginComputePass( let timestamp_writes = descriptor.and_then(|descriptor| { descriptor.timestampWrites.as_ref().map(|timestamp_write| { - wgc::command::ComputePassTimestampWrites { + wgc::command::PassTimestampWrites { query_set: timestamp_write .querySet .as_ref() @@ -1092,10 +1097,18 @@ pub unsafe extern "C" fn wgpuCommandEncoderBeginComputePass( None => wgc::command::ComputePassDescriptor::default(), }; - let compute_pass_encoder = wgc::command::ComputePass::new(command_encoder_id, &desc); + let (pass, err) = gfx_select!(command_encoder_id => context.command_encoder_create_compute_pass_dyn(command_encoder_id, &desc)); + if let Some(cause) = err { + handle_error( + error_sink, + cause, + desc.label, + "wgpuCommandEncoderBeginComputePass", + ); + } Arc::into_raw(Arc::new(WGPUComputePassEncoderImpl { context: context.clone(), - encoder: Box::into_raw(Box::new(compute_pass_encoder)), + encoder: Box::into_raw(pass), error_sink: error_sink.clone(), })) } @@ -1141,7 +1154,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderBeginRenderPass( }); let timestamp_writes = descriptor.timestampWrites.as_ref().map(|timestamp_write| { - wgc::command::RenderPassTimestampWrites { + wgc::command::PassTimestampWrites { query_set: timestamp_write .querySet .as_ref() @@ -1186,10 +1199,18 @@ pub unsafe extern "C" fn wgpuCommandEncoderBeginRenderPass( occlusion_query_set: descriptor.occlusionQuerySet.as_ref().map(|v| v.id), }; - let render_pass_encoder = wgc::command::RenderPass::new(command_encoder_id, &desc); + let (pass, err) = gfx_select!(command_encoder_id => context.command_encoder_create_render_pass_dyn(command_encoder_id, &desc)); + if let Some(cause) = err { + handle_error( + error_sink, + cause, + desc.label, + "wgpuCommandEncoderBeginRenderPass", + ); + } Arc::into_raw(Arc::new(WGPURenderPassEncoderImpl { context: context.clone(), - encoder: Box::into_raw(Box::new(render_pass_encoder)), + encoder: Box::into_raw(pass), error_sink: error_sink.clone(), })) } @@ -1221,14 +1242,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderClearBuffer( _ => Some(size), } )) { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuCommandEncoderClearBuffer", - ); + handle_error(error_sink, cause, None, "wgpuCommandEncoderClearBuffer"); } } @@ -1261,10 +1275,8 @@ pub unsafe extern "C" fn wgpuCommandEncoderCopyBufferToBuffer( size )) { handle_error( - context, error_sink, cause, - "", None, "wgpuCommandEncoderCopyBufferToBuffer", ); @@ -1294,10 +1306,8 @@ pub unsafe extern "C" fn wgpuCommandEncoderCopyBufferToTexture( &conv::map_extent3d(copy_size.expect("invalid copy size")) )) { handle_error( - context, error_sink, cause, - "", None, "wgpuCommandEncoderCopyBufferToTexture", ); @@ -1327,10 +1337,8 @@ pub unsafe extern "C" fn wgpuCommandEncoderCopyTextureToBuffer( &conv::map_extent3d(copy_size.expect("invalid copy size")) )) { handle_error( - context, error_sink, cause, - "", None, "wgpuCommandEncoderCopyTextureToBuffer", ); @@ -1360,10 +1368,8 @@ pub unsafe extern "C" fn wgpuCommandEncoderCopyTextureToTexture( &conv::map_extent3d(copy_size.expect("invalid copy size")) )) { handle_error( - context, error_sink, cause, - "", None, "wgpuCommandEncoderCopyTextureToTexture", ); @@ -1392,14 +1398,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderFinish( let (command_buffer_id, error) = gfx_select!(command_encoder_id => context.command_encoder_finish(command_encoder_id, &desc)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuCommandEncoderFinish", - ); + handle_error(error_sink, cause, None, "wgpuCommandEncoderFinish"); } Arc::into_raw(Arc::new(WGPUCommandBufferImpl { @@ -1426,10 +1425,8 @@ pub unsafe extern "C" fn wgpuCommandEncoderInsertDebugMarker( if let Err(cause) = gfx_select!(command_encoder_id => context.command_encoder_insert_debug_marker(command_encoder_id, CStr::from_ptr(marker_label).to_str().unwrap())) { handle_error( - context, error_sink, cause, - "", None, "wgpuCommandEncoderInsertDebugMarker", ); @@ -1451,14 +1448,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderPopDebugGroup( if let Err(cause) = gfx_select!(command_encoder_id => context.command_encoder_pop_debug_group(command_encoder_id)) { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuCommandEncoderPopDebugGroup", - ); + handle_error(error_sink, cause, None, "wgpuCommandEncoderPopDebugGroup"); } } @@ -1478,14 +1468,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderPushDebugGroup( if let Err(cause) = gfx_select!(command_encoder_id => context.command_encoder_push_debug_group(command_encoder_id, CStr::from_ptr(group_label).to_str().unwrap())) { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuCommandEncoderPushDebugGroup", - ); + handle_error(error_sink, cause, None, "wgpuCommandEncoderPushDebugGroup"); } } @@ -1517,14 +1500,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderResolveQuerySet( destination_buffer_id, destination_offset )) { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuCommandEncoderResolveQuerySet", - ); + handle_error(error_sink, cause, None, "wgpuCommandEncoderResolveQuerySet"); } } @@ -1549,14 +1525,7 @@ pub unsafe extern "C" fn wgpuCommandEncoderWriteTimestamp( query_set_id, query_index )) { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuCommandEncoderWriteTimestamp", - ); + handle_error(error_sink, cause, None, "wgpuCommandEncoderWriteTimestamp"); } } @@ -1583,12 +1552,20 @@ pub unsafe extern "C" fn wgpuComputePassEncoderDispatchWorkgroups( let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_dispatch_workgroups( - encoder, + match encoder.dispatch_workgroups( + &pass.context, workgroup_count_x, workgroup_count_y, workgroup_count_z, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderDispatchWorkgroups", + ), + } } #[no_mangle] @@ -1605,31 +1582,25 @@ pub unsafe extern "C" fn wgpuComputePassEncoderDispatchWorkgroupsIndirect( let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_dispatch_workgroups_indirect( - encoder, - indirect_buffer_id, - indirect_offset, - ); + match encoder.dispatch_workgroups_indirect(&pass.context, indirect_buffer_id, indirect_offset) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderDispatchWorkgroupsIndirect", + ), + } } #[no_mangle] pub unsafe extern "C" fn wgpuComputePassEncoderEnd(pass: native::WGPUComputePassEncoder) { let pass = pass.as_ref().expect("invalid compute pass"); - let (context, error_sink) = (&pass.context, &pass.error_sink); - let encoder = pass.encoder.as_ref().unwrap(); - let command_encoder_id = encoder.parent_id(); + let encoder = pass.encoder.as_mut().unwrap(); - if let Err(cause) = gfx_select!(command_encoder_id => context.command_encoder_run_compute_pass(command_encoder_id, encoder)) - { - let name = wgc::gfx_select!(command_encoder_id => context.command_buffer_label(command_encoder_id.into_command_buffer_id())); - handle_error( - context, - error_sink, - cause, - "encoder", - Some(Cow::Borrowed(&name)), - "wgpuComputePassEncoderEnd", - ); + match encoder.end(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error(&pass.error_sink, cause, None, "wgpuComputePassEncoderEnd"), } } @@ -1641,11 +1612,19 @@ pub unsafe extern "C" fn wgpuComputePassEncoderInsertDebugMarker( let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_insert_debug_marker( - encoder, + match encoder.insert_debug_marker( + &pass.context, CStr::from_ptr(marker_label).to_str().unwrap(), 0, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderInsertDebugMarker", + ), + } } #[no_mangle] @@ -1653,7 +1632,15 @@ pub unsafe extern "C" fn wgpuComputePassEncoderPopDebugGroup(pass: native::WGPUC let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_pop_debug_group(encoder); + match encoder.pop_debug_group(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderPopDebugGroup", + ), + } } #[no_mangle] @@ -1664,11 +1651,19 @@ pub unsafe extern "C" fn wgpuComputePassEncoderPushDebugGroup( let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_push_debug_group( - encoder, + match encoder.push_debug_group( + &pass.context, CStr::from_ptr(group_label).to_str().unwrap(), 0, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderPushDebugGroup", + ), + } } #[no_mangle] @@ -1684,12 +1679,20 @@ pub unsafe extern "C" fn wgpuComputePassEncoderSetBindGroup( let bind_group_id = bind_group.as_ref().expect("invalid bind group").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_set_bind_group( - encoder, + match encoder.set_bind_group( + &pass.context, group_index, bind_group_id, make_slice(dynamic_offsets, dynamic_offset_count), - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderSetBindGroup", + ), + } } #[no_mangle] @@ -1704,7 +1707,15 @@ pub unsafe extern "C" fn wgpuComputePassEncoderSetPipeline( .id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_set_pipeline(encoder, compute_pipeline_id); + match encoder.set_pipeline(&pass.context, compute_pipeline_id) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderSetPipeline", + ), + } } #[no_mangle] @@ -1743,10 +1754,8 @@ pub unsafe extern "C" fn wgpuComputePipelineGetBindGroupLayout( let (bind_group_layout_id, error) = gfx_select!(pipeline_id => context.compute_pipeline_get_bind_group_layout(pipeline_id, group_index, None)); if let Some(cause) = error { handle_error( - context, error_sink, cause, - "", None, "wgpuComputePipelineGetBindGroupLayout", ); @@ -1806,14 +1815,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateBindGroup( let (bind_group_id, error) = gfx_select!(device_id => context.device_create_bind_group(device_id, &desc, None)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - LABEL, - desc.label, - "wgpuDeviceCreateBindGroup", - ); + handle_error(error_sink, cause, desc.label, "wgpuDeviceCreateBindGroup"); } Arc::into_raw(Arc::new(WGPUBindGroupImpl { @@ -1850,10 +1852,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateBindGroupLayout( gfx_select!(device_id => context.device_create_bind_group_layout(device_id, &desc, None)); if let Some(cause) = error { handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateBindGroupLayout", ); @@ -1886,14 +1886,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateBuffer( let (buffer_id, error) = gfx_select!(device_id => context.device_create_buffer(device_id, &desc, None)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - LABEL, - desc.label, - "wgpuDeviceCreateBuffer", - ); + handle_error(error_sink, cause, desc.label, "wgpuDeviceCreateBuffer"); } Arc::into_raw(Arc::new(WGPUBufferImpl { @@ -1926,10 +1919,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateCommandEncoder( gfx_select!(device_id => context.device_create_command_encoder(device_id, &desc, None)); if let Some(cause) = error { handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateCommandEncoder", ); @@ -1980,24 +1971,20 @@ pub unsafe extern "C" fn wgpuDeviceCreateComputePipeline( }) .collect(), ), - // TODO:(wgpu.h) + // TODO(wgpu.h) zero_initialize_workgroup_memory: false, + // TODO(wgpu.h) + vertex_pulling_transform: false, }, - }; - - let implicit_pipeline_ids = match desc.layout { - Some(_) => None, - None => Some(wgc::device::ImplicitPipelineIds { - root_id: None, - group_ids: &[None; wgc::MAX_BIND_GROUPS], - }), + // TODO(wgpu.h) + cache: None, }; let (compute_pipeline_id, error) = gfx_select!(device_id => context.device_create_compute_pipeline( device_id, &desc, None, - implicit_pipeline_ids + None )); if let Some(cause) = error { if let wgc::pipeline::CreateComputePipelineError::Internal(ref error) = cause { @@ -2009,10 +1996,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateComputePipeline( log::warn!("Please report it to https://github.com/gfx-rs/wgpu"); } handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateComputePipeline", ); @@ -2045,10 +2030,8 @@ pub unsafe extern "C" fn wgpuDeviceCreatePipelineLayout( gfx_select!(device_id => context.device_create_pipeline_layout(device_id, &desc, None)); if let Some(cause) = error { handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreatePipelineLayout", ); @@ -2080,14 +2063,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateQuerySet( let (query_set_id, error) = gfx_select!(device_id => context.device_create_query_set(device_id, &desc, None)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - LABEL, - desc.label, - "wgpuDeviceCreateQuerySet", - ); + handle_error(error_sink, cause, desc.label, "wgpuDeviceCreateQuerySet"); } Arc::into_raw(Arc::new(WGPUQuerySetImpl { @@ -2134,7 +2110,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderBundleEncoder( encoder: Box::into_raw(Box::new(Some(Box::into_raw(Box::new(encoder))))), })), Err(cause) => { - handle_error_fatal(context, cause, "wgpuDeviceCreateRenderBundleEncoder"); + handle_error_fatal(cause, "wgpuDeviceCreateRenderBundleEncoder"); } } } @@ -2174,8 +2150,10 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline( }) .collect(), ), - // TODO: expose via wgpu.h + // TODO(wgpu.h) zero_initialize_workgroup_memory: false, + // TODO(wgpu.h) + vertex_pulling_transform: false, }, buffers: Cow::Owned( make_slice(descriptor.vertex.buffers, descriptor.vertex.bufferCount) @@ -2276,6 +2254,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline( ), // TODO(wgpu.h) zero_initialize_workgroup_memory: false, + // TODO(wgpu.h) + vertex_pulling_transform: false, }, targets: Cow::Owned( make_slice(fragment.targets, fragment.targetCount) @@ -2298,28 +2278,21 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline( .collect(), ), }), + // TODO(wgpu.h) multiview: None, + // TODO(wgpu.h) + cache: None, }; - let implicit_pipeline_ids = match desc.layout { - Some(_) => None, - None => Some(wgc::device::ImplicitPipelineIds { - root_id: None, - group_ids: &[None; wgc::MAX_BIND_GROUPS], - }), - }; - - let (render_pipeline_id, error) = gfx_select!(device_id => context.device_create_render_pipeline(device_id, &desc, None, implicit_pipeline_ids)); + let (render_pipeline_id, error) = gfx_select!(device_id => context.device_create_render_pipeline(device_id, &desc, None, None)); if let Some(cause) = error { if let wgc::pipeline::CreateRenderPipelineError::Internal { stage, ref error } = cause { log::error!("Shader translation error for stage {:?}: {}", stage, error); log::error!("Please report it to https://github.com/gfx-rs/wgpu"); } handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateRenderPipeline", ); @@ -2357,6 +2330,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateSampler( lod_max_clamp: descriptor.lodMaxClamp, compare: conv::map_compare_function(descriptor.compare).ok(), anisotropy_clamp: descriptor.maxAnisotropy, + // TODO(wgpu.h) border_color: None, }, // wgpu-core doesn't have Default implementation for SamplerDescriptor, @@ -2383,14 +2357,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateSampler( let (sampler_id, error) = gfx_select!(device_id => context.device_create_sampler(device_id, &desc, None)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - LABEL, - desc.label, - "wgpuDeviceCreateSampler", - ); + handle_error(error_sink, cause, desc.label, "wgpuDeviceCreateSampler"); } Arc::into_raw(Arc::new(WGPUSamplerImpl { @@ -2424,10 +2391,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateShaderModule( Ok(source) => source, Err(cause) => { handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateShaderModule", ); @@ -2442,10 +2407,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateShaderModule( let (shader_module_id, error) = gfx_select!(device_id => context.device_create_shader_module(device_id, &desc, source, None)); if let Some(cause) = error { handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateShaderModule", ); @@ -2489,14 +2452,7 @@ pub unsafe extern "C" fn wgpuDeviceCreateTexture( let (texture_id, error) = gfx_select!(device_id => context.device_create_texture(device_id, &desc, None)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - LABEL, - desc.label, - "wgpuDeviceCreateTexture", - ); + handle_error(error_sink, cause, desc.label, "wgpuDeviceCreateTexture"); } Arc::into_raw(Arc::new(WGPUTextureImpl { @@ -2532,7 +2488,7 @@ pub unsafe extern "C" fn wgpuDeviceEnumerateFeatures( }; let device_features = match gfx_select!(device_id => context.device_features(device_id)) { Ok(features) => features, - Err(err) => handle_error_fatal(context, err, "wgpuDeviceEnumerateFeatures"), + Err(err) => handle_error_fatal(err, "wgpuDeviceEnumerateFeatures"), }; let temp = conv::features_to_native(device_features); @@ -2558,7 +2514,7 @@ pub unsafe extern "C" fn wgpuDeviceGetLimits( let result = gfx_select!(device_id => context.device_limits(device_id)); match result { Ok(wgt_limits) => conv::write_limits_struct(wgt_limits, limits), - Err(err) => handle_error_fatal(context, err, "wgpuDeviceGetLimits"), + Err(err) => handle_error_fatal(err, "wgpuDeviceGetLimits"), } true as native::WGPUBool // indicates that we can fill WGPUChainedStructOut @@ -2588,7 +2544,7 @@ pub unsafe extern "C" fn wgpuDeviceHasFeature( }; let device_features = match gfx_select!(device_id => context.device_features(device_id)) { Ok(features) => features, - Err(err) => handle_error_fatal(context, err, "wgpuDeviceHasFeature"), + Err(err) => handle_error_fatal(err, "wgpuDeviceHasFeature"), }; let feature = match conv::map_feature(feature) { @@ -2686,14 +2642,14 @@ pub unsafe extern "C" fn wgpuInstanceCreateSurface( CreateSurfaceParams::Raw((rdh, rwh)) => { match context.instance_create_surface(rdh, rwh, None) { Ok(surface_id) => surface_id, - Err(cause) => handle_error_fatal(context, cause, "wgpuInstanceCreateSurface"), + Err(cause) => handle_error_fatal(cause, "wgpuInstanceCreateSurface"), } } #[cfg(metal)] CreateSurfaceParams::Metal(layer) => { match context.instance_create_surface_metal(layer, None) { Ok(surface_id) => surface_id, - Err(cause) => handle_error_fatal(context, cause, "wgpuInstanceCreateSurface"), + Err(cause) => handle_error_fatal(cause, "wgpuInstanceCreateSurface"), } } }; @@ -2774,7 +2730,7 @@ pub unsafe extern "C" fn wgpuInstanceRequestAdapter( ); } Err(err) => { - let message = CString::new(format_error(context, &err)).unwrap(); + let message = CString::new(format_error(&err)).unwrap(); callback( match err { wgc::instance::RequestAdapterError::NotFound => { @@ -2914,7 +2870,7 @@ pub unsafe extern "C" fn wgpuQueueOnSubmittedWorkDone( if let Err(cause) = gfx_select!(queue_id => context.queue_on_submitted_work_done(queue_id, closure)) { - handle_error_fatal(context, cause, "wgpuQueueOnSubmittedWorkDone"); + handle_error_fatal(cause, "wgpuQueueOnSubmittedWorkDone"); }; } @@ -2939,7 +2895,7 @@ pub unsafe extern "C" fn wgpuQueueSubmit( .collect::>(); if let Err(cause) = gfx_select!(queue_id => context.queue_submit(queue_id, &command_buffers)) { - handle_error_fatal(context, cause, "wgpuQueueSubmit"); + handle_error_fatal(cause, "wgpuQueueSubmit"); } } @@ -2963,7 +2919,7 @@ pub unsafe extern "C" fn wgpuQueueWriteBuffer( buffer_offset, make_slice(data, data_size) )) { - handle_error(context, error_sink, cause, "", None, "wgpuQueueWriteBuffer"); + handle_error(error_sink, cause, None, "wgpuQueueWriteBuffer"); } } @@ -2988,14 +2944,7 @@ pub unsafe extern "C" fn wgpuQueueWriteTexture( &conv::map_texture_data_layout(data_layout.expect("invalid data layout")), &conv::map_extent3d(write_size.expect("invalid write size")) )) { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuQueueWriteTexture", - ); + handle_error(error_sink, cause, None, "wgpuQueueWriteTexture"); } } @@ -3131,7 +3080,7 @@ pub unsafe extern "C" fn wgpuRenderBundleEncoderFinish( let (render_bundle_id, error) = gfx_select!(encoder.parent() => context.render_bundle_encoder_finish(*encoder, &desc, None)); if let Some(cause) = error { - handle_error_fatal(context, cause, "wgpuRenderBundleEncoderFinish"); + handle_error_fatal(cause, "wgpuRenderBundleEncoderFinish"); } Arc::into_raw(Arc::new(WGPURenderBundleImpl { @@ -3302,7 +3251,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderBeginOcclusionQuery( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_begin_occlusion_query(encoder, query_index); + match encoder.begin_occlusion_query(&pass.context, query_index) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderBeginOcclusionQuery", + ), + } } #[no_mangle] @@ -3316,13 +3273,16 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderDraw( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_draw( - encoder, + match encoder.draw( + &pass.context, vertex_count, instance_count, first_vertex, first_instance, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error(&pass.error_sink, cause, None, "wgpuRenderPassEncoderDraw"), + } } #[no_mangle] @@ -3331,74 +3291,86 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderDrawIndexed( index_count: u32, instance_count: u32, first_index: u32, - base_vertex: u32, + base_vertex: i32, first_instance: u32, ) { let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_draw_indexed( - encoder, + match encoder.draw_indexed( + &pass.context, index_count, instance_count, first_index, - base_vertex as i32, + base_vertex, first_instance, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderDrawIndexed", + ), + } } #[no_mangle] pub unsafe extern "C" fn wgpuRenderPassEncoderDrawIndexedIndirect( pass: native::WGPURenderPassEncoder, - buffer: native::WGPUBuffer, + indirect_buffer: native::WGPUBuffer, indirect_offset: u64, ) { let pass = pass.as_ref().expect("invalid render pass"); - let buffer_id = buffer.as_ref().expect("invalid buffer").id; + let indirect_buffer_id = indirect_buffer + .as_ref() + .expect("invalid indirect buffer") + .id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_draw_indexed_indirect( - encoder, - buffer_id, - indirect_offset, - ); + match encoder.draw_indexed_indirect(&pass.context, indirect_buffer_id, indirect_offset) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderDrawIndexedIndirect", + ), + } } #[no_mangle] pub unsafe extern "C" fn wgpuRenderPassEncoderDrawIndirect( pass: native::WGPURenderPassEncoder, - buffer: native::WGPUBuffer, + indirect_buffer: native::WGPUBuffer, indirect_offset: u64, ) { let pass = pass.as_ref().expect("invalid render pass"); - let buffer_id = buffer.as_ref().expect("invalid buffer").id; + let indirect_buffer_id = indirect_buffer + .as_ref() + .expect("invalid indirect buffer") + .id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_draw_indirect( - encoder, - buffer_id, - indirect_offset, - ); + match encoder.draw_indirect(&pass.context, indirect_buffer_id, indirect_offset) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderDrawIndexedIndirect", + ), + } } #[no_mangle] pub unsafe extern "C" fn wgpuRenderPassEncoderEnd(pass: native::WGPURenderPassEncoder) { let pass = pass.as_ref().expect("invalid render pass"); - let (context, error_sink) = (&pass.context, &pass.error_sink); - let encoder = pass.encoder.as_ref().unwrap(); - let command_encoder_id = encoder.parent_id(); + let encoder = pass.encoder.as_mut().unwrap(); - if let Err(cause) = gfx_select!(command_encoder_id => context.command_encoder_run_render_pass(command_encoder_id, encoder)) - { - let name = gfx_select!(command_encoder_id => context.command_buffer_label(command_encoder_id.into_command_buffer_id())); - handle_error( - context, - error_sink, - cause, - "encoder", - Some(Cow::Borrowed(&name)), - "wgpuRenderPassEncoderEnd", - ); + match encoder.end(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error(&pass.error_sink, cause, None, "wgpuRenderPassEncoderEnd"), } } @@ -3409,7 +3381,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderEndOcclusionQuery( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_end_occlusion_query(encoder); + match encoder.end_occlusion_query(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderEndOcclusionQuery", + ), + } } #[no_mangle] @@ -3425,7 +3405,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderExecuteBundles( .collect::>(); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_execute_bundles(encoder, &bundle_ids); + match encoder.execute_bundles(&pass.context, &bundle_ids) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderExecuteBundles", + ), + } } #[no_mangle] @@ -3436,11 +3424,19 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderInsertDebugMarker( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_insert_debug_marker( - encoder, + match encoder.insert_debug_marker( + &pass.context, CStr::from_ptr(marker_label).to_str().unwrap(), 0, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderInsertDebugMarker", + ), + } } #[no_mangle] @@ -3448,7 +3444,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderPopDebugGroup(pass: native::WGPURe let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_pop_debug_group(encoder); + match encoder.pop_debug_group(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderPopDebugGroup", + ), + } } #[no_mangle] @@ -3459,11 +3463,19 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderPushDebugGroup( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_push_debug_group( - encoder, + match encoder.push_debug_group( + &pass.context, CStr::from_ptr(group_label).to_str().unwrap(), 0, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderPushDebugGroup", + ), + } } #[no_mangle] @@ -3479,12 +3491,20 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetBindGroup( let bind_group_id = bind_group.as_ref().expect("invalid bind group").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_bind_group( - encoder, + match encoder.set_bind_group( + &pass.context, group_index, bind_group_id, make_slice(dynamic_offsets, dynamic_offset_count), - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetBindGroup", + ), + } } #[no_mangle] @@ -3495,10 +3515,18 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetBlendConstant( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_blend_constant( - encoder, - &conv::map_color(color.expect("invalid color")), - ); + match encoder.set_blend_constant( + &pass.context, + conv::map_color(color.expect("invalid color")), + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetBlendConstant", + ), + } } #[no_mangle] @@ -3513,16 +3541,25 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetIndexBuffer( let buffer_id = buffer.as_ref().expect("invalid buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - encoder.set_index_buffer( + match encoder.set_index_buffer( + &pass.context, buffer_id, - conv::map_index_format(index_format).expect("Index format cannot be undefined"), + conv::map_index_format(index_format).expect("invalid index format"), offset, match size { 0 => panic!("invalid size"), conv::WGPU_WHOLE_SIZE => None, _ => Some(NonZeroU64::new_unchecked(size)), }, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetIndexBuffer", + ), + } } #[no_mangle] @@ -3537,7 +3574,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetPipeline( .id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_pipeline(encoder, render_pipeline_id); + match encoder.set_pipeline(&pass.context, render_pipeline_id) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetPipeline", + ), + } } #[no_mangle] @@ -3545,13 +3590,21 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetScissorRect( pass: native::WGPURenderPassEncoder, x: u32, y: u32, - w: u32, - h: u32, + width: u32, + height: u32, ) { let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_scissor_rect(encoder, x, y, w, h); + match encoder.set_scissor_rect(&pass.context, x, y, width, height) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetPipeline", + ), + } } #[no_mangle] @@ -3562,7 +3615,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetStencilReference( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_stencil_reference(encoder, reference); + match encoder.set_stencil_reference(&pass.context, reference) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetStencilReference", + ), + } } #[no_mangle] @@ -3578,8 +3639,8 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetVertexBuffer( let buffer_id = buffer.as_ref().expect("invalid buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_vertex_buffer( - encoder, + match encoder.set_vertex_buffer( + &pass.context, slot, buffer_id, offset, @@ -3588,7 +3649,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetVertexBuffer( conv::WGPU_WHOLE_SIZE => None, _ => Some(NonZeroU64::new_unchecked(size)), }, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetVertexBuffer", + ), + } } #[no_mangle] @@ -3596,17 +3665,23 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetViewport( pass: native::WGPURenderPassEncoder, x: f32, y: f32, - w: f32, - h: f32, - depth_min: f32, - depth_max: f32, + width: f32, + height: f32, + min_depth: f32, + max_depth: f32, ) { let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_viewport( - encoder, x, y, w, h, depth_min, depth_max, - ); + match encoder.set_viewport(&pass.context, x, y, width, height, min_depth, max_depth) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetViewport", + ), + } } #[no_mangle] @@ -3648,10 +3723,8 @@ pub unsafe extern "C" fn wgpuRenderPipelineGetBindGroupLayout( let (bind_group_layout_id, error) = gfx_select!(render_pipeline_id => context.render_pipeline_get_bind_group_layout(render_pipeline_id, group_index, None)); if let Some(cause) = error { handle_error( - context, error_sink, cause, - "", None, "wgpuRenderPipelineGetBindGroupLayout", ); @@ -3722,7 +3795,7 @@ pub unsafe extern "C" fn wgpuSurfaceConfigure( match wgc::gfx_select!(device.id => context.surface_configure(surface.id, device.id, &surface_config)) { - Some(cause) => handle_error_fatal(context, cause, "wgpuSurfaceConfigure"), + Some(cause) => handle_error_fatal(cause, "wgpuSurfaceConfigure"), None => { let mut surface_data_guard = surface.data.lock(); *surface_data_guard = Some(SurfaceData { @@ -3767,7 +3840,7 @@ pub unsafe extern "C" fn wgpuSurfaceGetCapabilities( Err(wgc::instance::GetSurfaceSupportError::Unsupported) => { wgt::SurfaceCapabilities::default() } - Err(cause) => handle_error_fatal(context, cause, "wgpuSurfaceGetCapabilities"), + Err(cause) => handle_error_fatal(cause, "wgpuSurfaceGetCapabilities"), }; capabilities.usages = @@ -3838,7 +3911,6 @@ pub unsafe extern "C" fn wgpuSurfaceGetCurrentTexture( let surface_data = match surface_data_guard.as_ref() { Some(surface_data) => surface_data, None => handle_error_fatal( - context, wgc::present::SurfaceError::NotConfigured, "wgpuSurfaceGetCurrentTexture", ), @@ -3875,7 +3947,7 @@ pub unsafe extern "C" fn wgpuSurfaceGetCurrentTexture( None => std::ptr::null_mut(), }; } - Err(cause) => handle_error_fatal(context, cause, "wgpuSurfaceGetCurrentTexture"), + Err(cause) => handle_error_fatal(cause, "wgpuSurfaceGetCurrentTexture"), }; } @@ -3887,7 +3959,6 @@ pub unsafe extern "C" fn wgpuSurfacePresent(surface: native::WGPUSurface) { let surface_data = match surface_data_guard.as_ref() { Some(surface_data) => surface_data, None => handle_error_fatal( - context, wgc::present::SurfaceError::NotConfigured, "wgpuSurfacePresent", ), @@ -3897,7 +3968,7 @@ pub unsafe extern "C" fn wgpuSurfacePresent(surface: native::WGPUSurface) { Ok(_status) => surface .has_surface_presented .store(true, atomic::Ordering::SeqCst), - Err(cause) => handle_error_fatal(context, cause, "wgpuSurfacePresent"), + Err(cause) => handle_error_fatal(cause, "wgpuSurfacePresent"), }; } @@ -3990,14 +4061,7 @@ pub unsafe extern "C" fn wgpuTextureCreateView( let (texture_view_id, error) = gfx_select!(texture_id => context.texture_create_view(texture_id, &desc, None)); if let Some(cause) = error { - handle_error( - context, - error_sink, - cause, - "", - None, - "wgpuTextureCreateView", - ); + handle_error(error_sink, cause, None, "wgpuTextureCreateView"); } Arc::into_raw(Arc::new(WGPUTextureViewImpl { @@ -4129,7 +4193,7 @@ pub unsafe extern "C" fn wgpuQueueSubmitForIndex( match gfx_select!(queue_id => context.queue_submit(queue_id, &command_buffers)) { Ok(submission_index) => submission_index.index, - Err(cause) => handle_error_fatal(context, cause, "wgpuQueueSubmitForIndex"), + Err(cause) => handle_error_fatal(cause, "wgpuQueueSubmitForIndex"), } } @@ -4165,7 +4229,7 @@ pub unsafe extern "C" fn wgpuDevicePoll( match gfx_select!(device_id => context.device_poll(device_id, maintain)) { Ok(queue_empty) => queue_empty, Err(cause) => { - handle_error_fatal(context, cause, "wgpuDevicePoll"); + handle_error_fatal(cause, "wgpuDevicePoll"); } } } @@ -4181,12 +4245,20 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetPushConstants( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_set_push_constants( - encoder, + match encoder.set_push_constants( + &pass.context, wgt::ShaderStages::from_bits(stages).expect("invalid shader stage"), offset, make_slice(data, size_bytes as usize), - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetPushConstants", + ), + } } #[no_mangle] @@ -4200,9 +4272,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderMultiDrawIndirect( let buffer_id = buffer.as_ref().expect("invalid buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_multi_draw_indirect( - encoder, buffer_id, offset, count, - ); + match encoder.multi_draw_indirect(&pass.context, buffer_id, offset, count) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderMultiDrawIndirect", + ), + } } #[no_mangle] @@ -4216,9 +4294,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderMultiDrawIndexedIndirect( let buffer_id = buffer.as_ref().expect("invalid buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_multi_draw_indexed_indirect( - encoder, buffer_id, offset, count, - ); + match encoder.multi_draw_indexed_indirect(&pass.context, buffer_id, offset, count) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderMultiDrawIndexedIndirect", + ), + } } #[no_mangle] @@ -4235,14 +4319,22 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderMultiDrawIndirectCount( let count_buffer_id = count_buffer.as_ref().expect("invalid count buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_multi_draw_indirect_count( - encoder, + match encoder.multi_draw_indexed_indirect_count( + &pass.context, buffer_id, offset, count_buffer_id, count_buffer_offset, max_count, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderMultiDrawIndirectCount", + ), + } } #[no_mangle] @@ -4259,14 +4351,22 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderMultiDrawIndexedIndirectCount( let count_buffer_id = count_buffer.as_ref().expect("invalid count buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_multi_draw_indexed_indirect_count( - encoder, + match encoder.multi_draw_indexed_indirect_count( + &pass.context, buffer_id, offset, count_buffer_id, count_buffer_offset, max_count, - ); + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderMultiDrawIndexedIndirectCount", + ), + } } #[no_mangle] @@ -4279,11 +4379,15 @@ pub unsafe extern "C" fn wgpuComputePassEncoderBeginPipelineStatisticsQuery( let query_set_id = query_set.as_ref().expect("invalid query set").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_begin_pipeline_statistics_query( - encoder, - query_set_id, - query_index, - ); + match encoder.begin_pipeline_statistics_query(&pass.context, query_set_id, query_index) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderBeginPipelineStatisticsQuery", + ), + } } #[no_mangle] @@ -4293,7 +4397,15 @@ pub unsafe extern "C" fn wgpuComputePassEncoderEndPipelineStatisticsQuery( let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::compute_commands::wgpu_compute_pass_end_pipeline_statistics_query(encoder); + match encoder.end_pipeline_statistics_query(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderEndPipelineStatisticsQuery", + ), + } } #[no_mangle] @@ -4306,11 +4418,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderBeginPipelineStatisticsQuery( let query_set_id = query_set.as_ref().expect("invalid query set").id; let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_begin_pipeline_statistics_query( - encoder, - query_set_id, - query_index, - ); + match encoder.begin_pipeline_statistics_query(&pass.context, query_set_id, query_index) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderBeginPipelineStatisticsQuery", + ), + } } #[no_mangle] @@ -4320,5 +4436,13 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderEndPipelineStatisticsQuery( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - wgc::command::render_commands::wgpu_render_pass_end_pipeline_statistics_query(encoder); + match encoder.end_pipeline_statistics_query(&pass.context) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderEndPipelineStatisticsQuery", + ), + } }