From 2202274abec7f5e020f2e2f432f7eaf862809db0 Mon Sep 17 00:00:00 2001 From: Rajesh Malviya Date: Mon, 26 Aug 2024 09:36:39 +0530 Subject: [PATCH] Update wgpu to v22.1.0 (#402) * Update wgpu to v0.20.0 * Update wgpu to v22.1.0 * Cargo.toml: use git `tag` instead of `rev`+`version` --- Cargo.lock | 541 +++++++++-------- Cargo.toml | 51 +- 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 | 11 +- src/lib.rs | 1013 +++++++++++++++++++------------- 9 files changed, 990 insertions(+), 733 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 51ae60e2..c34bb257 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,24 +49,18 @@ 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]] name = "autocfg" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" - -[[package]] -name = "base64" -version = "0.21.7" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bindgen" @@ -74,7 +68,7 @@ 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", + "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", ] @@ -134,10 +128,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] -name = "cc" -version = "1.0.94" +name = "bytemuck" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +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]] @@ -181,6 +175,37 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "com" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6" +dependencies = [ + "com_macros", +] + +[[package]] +name = "com_macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5" +dependencies = [ + "com_macros_support", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "com_macros_support" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -210,19 +235,28 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.19.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "22.0.0" +source = "git+https://github.com/gfx-rs/wgpu?tag=v22.1.0#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ - "bitflags 2.5.0", - "libloading 0.8.3", + "bitflags 2.6.0", + "libloading", "winapi", ] +[[package]] +name = "document-features" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +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" @@ -232,12 +266,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -264,7 +298,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] @@ -304,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", ] @@ -317,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", ] @@ -327,39 +361,67 @@ 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.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7" +dependencies = [ + "log", + "presser", + "thiserror", + "winapi", + "windows", ] [[package]] name = "gpu-descriptor" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" +checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "gpu-descriptor-types", "hashbrown", ] [[package]] name = "gpu-descriptor-types" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" +checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", ] +[[package]] +name = "hassle-rs" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" +dependencies = [ + "bitflags 2.6.0", + "com", + "libc", + "libloading", + "thiserror", + "widestring", + "winapi", +] + [[package]] name = "hexf-parse" version = "0.2.1" @@ -372,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", @@ -417,7 +479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.8.3", + "libloading", "pkg-config", ] @@ -429,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" @@ -441,41 +503,37 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +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" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "winapi", + "windows-targets", ] [[package]] -name = "libloading" -version = "0.8.3" +name = "linux-raw-sys" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" -dependencies = [ - "cfg-if", - "windows-targets 0.52.5", -] +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] -name = "linux-raw-sys" -version = "0.4.13" +name = "litrs" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -483,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" @@ -498,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.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25" +checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block", "core-graphics-types", "foreign-types", @@ -525,16 +583,17 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "naga" -version = "0.19.2" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "22.1.0" +source = "git+https://github.com/gfx-rs/wgpu?tag=v22.1.0#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", @@ -564,15 +623,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num-traits" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" -dependencies = [ - "autocfg", -] - [[package]] name = "objc" version = "0.2.7" @@ -580,16 +630,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ "malloc_buf", - "objc_exception", -] - -[[package]] -name = "objc_exception" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" -dependencies = [ - "cc", ] [[package]] @@ -600,9 +640,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -610,28 +650,28 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets", ] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap", @@ -652,21 +692,27 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + [[package]] name = "prettyplease" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.72", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -694,24 +740,24 @@ checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" [[package]] name = "raw-window-handle" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 1.3.2", + "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", @@ -721,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", @@ -732,21 +778,15 @@ 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 = "ron" -version = "0.8.1" +name = "renderdoc-sys" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" -dependencies = [ - "base64", - "bitflags 2.5.0", - "serde", - "serde_derive", -] +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "rustc-hash" @@ -756,15 +796,15 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -775,22 +815,22 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] @@ -820,14 +860,25 @@ 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]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "2.0.60" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -845,22 +896,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] @@ -871,9 +922,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -883,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" @@ -908,7 +959,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -930,7 +981,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -953,14 +1004,15 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.19.4" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "22.1.0" +source = "git+https://github.com/gfx-rs/wgpu?tag=v22.1.0#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ "arrayvec", "bit-vec", - "bitflags 2.5.0", + "bitflags 2.6.0", + "bytemuck", "cfg_aliases", - "codespan-reporting", + "document-features", "indexmap", "log", "naga", @@ -968,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.19.4" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "22.0.0" +source = "git+https://github.com/gfx-rs/wgpu?tag=v22.1.0#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set", - "bitflags 2.5.0", + "bitflags 2.6.0", "block", "cfg_aliases", "core-graphics-types", @@ -995,11 +1045,13 @@ dependencies = [ "glow", "glutin_wgl_sys", "gpu-alloc", + "gpu-allocator", "gpu-descriptor", + "hassle-rs", "js-sys", "khronos-egl", "libc", - "libloading 0.8.3", + "libloading", "log", "metal", "naga", @@ -1010,6 +1062,7 @@ dependencies = [ "profiling", "range-alloc", "raw-window-handle", + "renderdoc-sys", "rustc-hash", "smallvec", "thiserror", @@ -1034,15 +1087,16 @@ dependencies = [ "smallvec", "thiserror", "wgpu-core", + "wgpu-hal", "wgpu-types", ] [[package]] name = "wgpu-types" -version = "0.19.2" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "22.0.0" +source = "git+https://github.com/gfx-rs/wgpu?tag=v22.1.0#5c5c8b1d4d2d965fbd10b290ee26f4e7eb158d7c" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "js-sys", "serde", "web-sys", @@ -1060,6 +1114,12 @@ dependencies = [ "rustix", ] +[[package]] +name = "widestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" + [[package]] name = "winapi" version = "0.3.9" @@ -1078,11 +1138,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1092,134 +1152,105 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "windows-sys" +name = "windows" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ - "windows-targets 0.52.5", + "windows-core", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-core" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.52.5" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows-targets", ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] [[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" +name = "windows_aarch64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +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.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -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.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +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" @@ -1229,20 +1260,20 @@ checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] diff --git a/Cargo.toml b/Cargo.toml index 3d71b915..f30dc7a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,20 +23,22 @@ resolver = "2" [workspace.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "87576b72b37c6b78b41104eb25fc31893af94092" -version = "0.19" +tag = "v22.1.0" [workspace.dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "87576b72b37c6b78b41104eb25fc31893af94092" -version = "0.19" +tag = "v22.1.0" + +[workspace.dependencies.hal] +package = "wgpu-hal" +git = "https://github.com/gfx-rs/wgpu" +tag = "v22.1.0" [workspace.dependencies.naga] package = "naga" git = "https://github.com/gfx-rs/wgpu" -rev = "87576b72b37c6b78b41104eb25fc31893af94092" -version = "0.19" +tag = "v22.1.0" [lib] crate-type = ["cdylib", "staticlib"] @@ -47,7 +49,7 @@ default = ["wgsl", "spirv", "glsl", "dx12", "metal"] #! ### Backends # -------------------------------------------------------------------- #! ⚠️ WIP: Not all backends can be manually configured today. -#! On Windows & Linux the Vulkan & GLES backends are always enabled. +#! On Windows, Linux & Android the Vulkan & GLES backends are always enabled. #! See [#3514](https://github.com/gfx-rs/wgpu/issues/3514) for more details. ## Enables the DX12 backend on Windows. @@ -62,14 +64,18 @@ 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 # -------------------------------------------------------------------- ## Enable accepting SPIR-V shaders as input. -spirv = ["naga/spv-in"] +spirv = ["naga/spv-in", "wgc/spirv"] ## Enable accepting GLSL shaders as input. -glsl = ["naga/glsl-in"] +glsl = ["naga/glsl-in", "wgc/glsl"] ## Enable accepting WGSL shaders as input. wgsl = ["wgc/wgsl"] @@ -85,9 +91,12 @@ strict_asserts = ["wgc/strict_asserts", "wgt/strict_asserts"] ## Log all API entry points at info instead of trace level. api_log_info = ["wgc/api_log_info"] -## Allow writing of trace capture files. -## See [`Adapter::request_device`]. -trace = ["serde", "wgc/trace"] +## Enables serialization via `serde` on common wgpu types. +serde = ["dep:serde", "wgc/serde"] + +# 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). @@ -107,8 +116,8 @@ workspace = true workspace = true features = ["gles"] -# We want the wgpu-core Vulkan backend on Unix (but not emscripten, macOS, iOS) and Windows. -[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc] +# We want the wgpu-core Vulkan backend on Unix (but not macOS, iOS) and Windows. +[target.'cfg(any(windows, all(unix, not(target_os = "ios"), not(target_os = "macos"))))'.dependencies.wgc] workspace = true features = ["vulkan"] @@ -117,11 +126,25 @@ features = ["vulkan"] workspace = true features = ["gles"] +[dependencies.hal] +workspace = true + +[target.'cfg(all(unix, not(target_os = "ios"), not(target_os = "macos")))'.dependencies] +hal = { workspace = true, features = ["renderdoc"] } + +[target.'cfg(windows)'.dependencies] +hal = { workspace = true, features = [ + "dxc_shader_compiler", + "renderdoc", + "windows_rs", +] } + [dependencies.wgt] workspace = true [dependencies.naga] workspace = true +optional = true [dependencies.serde] version = "1" 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 48738396..28a51f62 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 aeb38fbd..bb7be4d4 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, @@ -567,8 +569,8 @@ pub enum ShaderParseError { #[error(transparent)] Spirv(#[from] naga::front::spv::Error), #[cfg(feature = "glsl")] - #[error("GLSL Parse Error: {0:?}")] - Glsl(Vec), + #[error(transparent)] + 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), @@ -1646,6 +1644,7 @@ pub unsafe fn map_surface( panic!("Error: Unsupported Surface"); } +#[inline] pub fn map_surface_configuration( config: &native::WGPUSurfaceConfiguration, extras: Option<&native::WGPUSurfaceConfigurationExtras>, diff --git a/src/lib.rs b/src/lib.rs index 2a0befee..49f557ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,15 +14,14 @@ use std::{ fmt::Display, mem, num::NonZeroU64, - sync::atomic, - sync::Arc, + sync::{atomic, Arc}, thread, }; use utils::{ get_base_device_limits_from_adapter_limits, make_slice, ptr_into_label, ptr_into_path, }; use wgc::{ - command::{bundle_ffi, compute_ffi, render_ffi}, + command::{bundle_ffi, DynComputePass, DynRenderPass}, gfx_select, id, resource, Label, }; @@ -39,9 +38,7 @@ pub mod native { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); } -const LABEL: &str = "label"; - -pub type Context = wgc::global::Global; +pub type Context = wgc::global::Global; pub struct WGPUAdapterImpl { context: Arc, @@ -132,7 +129,7 @@ impl Drop for WGPUCommandEncoderImpl { pub struct WGPUComputePassEncoderImpl { context: Arc, - encoder: id::ComputePassEncoderId, + encoder: *mut dyn DynComputePass, error_sink: ErrorSink, } impl Drop for WGPUComputePassEncoderImpl { @@ -186,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)); @@ -249,7 +246,7 @@ impl Drop for WGPURenderBundleImpl { pub struct WGPURenderBundleEncoderImpl { context: Arc, - encoder: *mut Option, + encoder: *mut Option<*mut wgc::command::RenderBundleEncoder>, } impl Drop for WGPURenderBundleEncoderImpl { fn drop(&mut self) { @@ -267,7 +264,7 @@ unsafe impl Sync for WGPURenderBundleEncoderImpl {} pub struct WGPURenderPassEncoderImpl { context: Arc, - encoder: id::RenderPassEncoderId, + encoder: *mut dyn DynRenderPass, error_sink: ErrorSink, } impl Drop for WGPURenderPassEncoderImpl { @@ -374,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"), } } } @@ -549,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); @@ -613,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), }); } @@ -633,11 +634,7 @@ pub unsafe extern "C" fn wgpuCreateInstance( }; Arc::into_raw(Arc::new(WGPUInstanceImpl { - context: Arc::new(Context::new( - "wgpu", - wgc::identity::IdentityManagerFactory, - instance_desc, - )), + context: Arc::new(Context::new("wgpu", instance_desc)), })) } @@ -654,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); @@ -680,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 @@ -699,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)) @@ -727,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) { @@ -770,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(), @@ -810,8 +807,8 @@ pub unsafe extern "C" fn wgpuAdapterRequestDevice( adapter_id, &desc, ptr_into_path(trace_str), - (), - () + None, + None ) ); match err { @@ -838,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(), @@ -907,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) @@ -922,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] @@ -933,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) @@ -948,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] @@ -1000,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, @@ -1014,9 +1011,13 @@ pub unsafe extern "C" fn wgpuBufferMapAsync( ))), }; - if let Err(cause) = gfx_select!(buffer_id => context.buffer_map_async(buffer_id, offset as u64 .. (offset + size) as u64, operation)) - { - handle_error(context, error_sink, cause, "", None, "wgpuBufferMapAsync"); + if let Err(cause) = gfx_select!(buffer_id => context.buffer_map_async( + buffer_id, + offset as wgt::BufferAddress, + Some(size as wgt::BufferAddress), + operation, + )) { + handle_error(error_sink, cause, None, "wgpuBufferMapAsync"); }; } @@ -1028,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"); } } @@ -1074,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() @@ -1096,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(), })) } @@ -1145,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() @@ -1190,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(), })) } @@ -1225,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"); } } @@ -1265,10 +1275,8 @@ pub unsafe extern "C" fn wgpuCommandEncoderCopyBufferToBuffer( size )) { handle_error( - context, error_sink, cause, - "", None, "wgpuCommandEncoderCopyBufferToBuffer", ); @@ -1298,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", ); @@ -1331,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", ); @@ -1364,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", ); @@ -1396,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 { @@ -1430,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", ); @@ -1455,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"); } } @@ -1482,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"); } } @@ -1521,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"); } } @@ -1553,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"); } } @@ -1587,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(); - compute_ffi::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] @@ -1609,31 +1582,25 @@ pub unsafe extern "C" fn wgpuComputePassEncoderDispatchWorkgroupsIndirect( let encoder = pass.encoder.as_mut().unwrap(); - compute_ffi::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)); - 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"), } } @@ -1645,7 +1612,19 @@ pub unsafe extern "C" fn wgpuComputePassEncoderInsertDebugMarker( let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - compute_ffi::wgpu_compute_pass_insert_debug_marker(encoder, marker_label, 0); + 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(); - compute_ffi::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,7 +1651,19 @@ pub unsafe extern "C" fn wgpuComputePassEncoderPushDebugGroup( let pass = pass.as_ref().expect("invalid compute pass"); let encoder = pass.encoder.as_mut().unwrap(); - compute_ffi::wgpu_compute_pass_push_debug_group(encoder, group_label, 0); + 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] @@ -1680,13 +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(); - compute_ffi::wgpu_compute_pass_set_bind_group( - encoder, + match encoder.set_bind_group( + &pass.context, group_index, bind_group_id, - dynamic_offsets, - dynamic_offset_count, - ); + make_slice(dynamic_offsets, dynamic_offset_count), + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuComputePassEncoderSetBindGroup", + ), + } } #[no_mangle] @@ -1701,7 +1707,15 @@ pub unsafe extern "C" fn wgpuComputePassEncoderSetPipeline( .id; let encoder = pass.encoder.as_mut().unwrap(); - compute_ffi::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] @@ -1737,13 +1751,11 @@ pub unsafe extern "C" fn wgpuComputePipelineGetBindGroupLayout( (pipeline.id, &pipeline.context, &pipeline.error_sink) }; - let (bind_group_layout_id, error) = gfx_select!(pipeline_id => context.compute_pipeline_get_bind_group_layout(pipeline_id, group_index, ())); + 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", ); @@ -1801,16 +1813,9 @@ pub unsafe extern "C" fn wgpuDeviceCreateBindGroup( entries: Cow::Borrowed(&entries), }; let (bind_group_id, error) = - gfx_select!(device_id => context.device_create_bind_group(device_id, &desc, ())); + 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 { @@ -1844,13 +1849,11 @@ pub unsafe extern "C" fn wgpuDeviceCreateBindGroupLayout( entries: Cow::Borrowed(&entries), }; let (bind_group_layout_id, error) = - gfx_select!(device_id => context.device_create_bind_group_layout(device_id, &desc, ())); + 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", ); @@ -1881,16 +1884,9 @@ pub unsafe extern "C" fn wgpuDeviceCreateBuffer( }; let (buffer_id, error) = - gfx_select!(device_id => context.device_create_buffer(device_id, &desc, ())); + 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 { @@ -1920,13 +1916,11 @@ pub unsafe extern "C" fn wgpuDeviceCreateCommandEncoder( None => wgt::CommandEncoderDescriptor::default(), }; let (command_encoder_id, error) = - gfx_select!(device_id => context.device_create_command_encoder(device_id, &desc, ())); + 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", ); @@ -1951,37 +1945,46 @@ pub unsafe extern "C" fn wgpuDeviceCreateComputePipeline( }; let descriptor = descriptor.expect("invalid descriptor"); - let stage = wgc::pipeline::ProgrammableStageDescriptor { - module: descriptor - .compute - .module - .as_ref() - .expect("invalid shader module for compute pipeline descriptor") - .id - .expect("invalid shader module for compute pipeline descriptor"), - // TODO: wgpu-core should allow 'None' here - entry_point: ptr_into_label(descriptor.compute.entryPoint) - .expect("invalid entry point for compute pipeline descriptor"), - }; let desc = wgc::pipeline::ComputePipelineDescriptor { label: ptr_into_label(descriptor.label), layout: descriptor.layout.as_ref().map(|v| v.id), - stage, - }; - - let implicit_pipeline_ids = match desc.layout { - Some(_) => None, - None => Some(wgc::device::ImplicitPipelineIds { - root_id: (), - group_ids: &[(); wgc::MAX_BIND_GROUPS], - }), + stage: wgc::pipeline::ProgrammableStageDescriptor { + module: descriptor + .compute + .module + .as_ref() + .expect("invalid fragment shader module for render pipeline descriptor") + .id + .expect("invalid fragment shader module for render pipeline descriptor"), + entry_point: ptr_into_label(descriptor.compute.entryPoint), + constants: Cow::Owned( + make_slice( + descriptor.compute.constants, + descriptor.compute.constantCount, + ) + .iter() + .map(|entry| { + ( + CStr::from_ptr(entry.key).to_str().unwrap().to_string(), + entry.value, + ) + }) + .collect(), + ), + // TODO(wgpu.h) + zero_initialize_workgroup_memory: false, + // TODO(wgpu.h) + vertex_pulling_transform: false, + }, + // TODO(wgpu.h) + cache: None, }; let (compute_pipeline_id, error) = gfx_select!(device_id => context.device_create_compute_pipeline( device_id, &desc, - (), - implicit_pipeline_ids + None, + None )); if let Some(cause) = error { if let wgc::pipeline::CreateComputePipelineError::Internal(ref error) = cause { @@ -1993,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", ); @@ -2026,13 +2027,11 @@ pub unsafe extern "C" fn wgpuDeviceCreatePipelineLayout( WGPUSType_PipelineLayoutExtras => native::WGPUPipelineLayoutExtras) ); let (pipeline_layout_id, error) = - gfx_select!(device_id => context.device_create_pipeline_layout(device_id, &desc, ())); + 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", ); @@ -2062,16 +2061,9 @@ pub unsafe extern "C" fn wgpuDeviceCreateQuerySet( ); let (query_set_id, error) = - gfx_select!(device_id => context.device_create_query_set(device_id, &desc, ())); + 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 { @@ -2118,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"); } } } @@ -2146,9 +2138,22 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline( .expect("invalid vertex shader module for vertex state") .id .expect("invalid vertex shader module for vertex state"), - // TODO: wgpu-core should allow 'None' here - entry_point: ptr_into_label(descriptor.vertex.entryPoint) - .expect("invalid entry point for vertex state"), + entry_point: ptr_into_label(descriptor.vertex.entryPoint), + constants: Cow::Owned( + make_slice(descriptor.vertex.constants, descriptor.vertex.constantCount) + .iter() + .map(|entry| { + ( + CStr::from_ptr(entry.key).to_str().unwrap().to_string(), + entry.value, + ) + }) + .collect(), + ), + // 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) @@ -2235,9 +2240,22 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline( .expect("invalid fragment shader module for render pipeline descriptor") .id .expect("invalid fragment shader module for render pipeline descriptor"), - // TODO: wgpu-core should allow 'None' here - entry_point: ptr_into_label(fragment.entryPoint) - .expect("invalid entry point for fragment state"), + entry_point: ptr_into_label(fragment.entryPoint), + constants: Cow::Owned( + make_slice(fragment.constants, fragment.constantCount) + .iter() + .map(|entry| { + ( + CStr::from_ptr(entry.key).to_str().unwrap().to_string(), + entry.value, + ) + }) + .collect(), + ), + // TODO(wgpu.h) + zero_initialize_workgroup_memory: false, + // TODO(wgpu.h) + vertex_pulling_transform: false, }, targets: Cow::Owned( make_slice(fragment.targets, fragment.targetCount) @@ -2260,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: (), - group_ids: &[(); wgc::MAX_BIND_GROUPS], - }), - }; - - let (render_pipeline_id, error) = gfx_select!(device_id => context.device_create_render_pipeline(device_id, &desc, (), 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", ); @@ -2319,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, @@ -2343,16 +2355,9 @@ pub unsafe extern "C" fn wgpuDeviceCreateSampler( }; let (sampler_id, error) = - gfx_select!(device_id => context.device_create_sampler(device_id, &desc, ())); + 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 { @@ -2386,10 +2391,8 @@ pub unsafe extern "C" fn wgpuDeviceCreateShaderModule( Ok(source) => source, Err(cause) => { handle_error( - context, error_sink, cause, - LABEL, desc.label, "wgpuDeviceCreateShaderModule", ); @@ -2401,14 +2404,11 @@ pub unsafe extern "C" fn wgpuDeviceCreateShaderModule( } }; - let (shader_module_id, error) = - gfx_select!(device_id => context.device_create_shader_module(device_id, &desc, source, ())); + 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", ); @@ -2450,16 +2450,9 @@ pub unsafe extern "C" fn wgpuDeviceCreateTexture( }; let (texture_id, error) = - gfx_select!(device_id => context.device_create_texture(device_id, &desc, ())); + 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 { @@ -2495,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); @@ -2521,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 @@ -2551,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) { @@ -2647,13 +2640,18 @@ pub unsafe extern "C" fn wgpuInstanceCreateSurface( let surface_id = match create_surface_params { CreateSurfaceParams::Raw((rdh, rwh)) => { - match context.instance_create_surface(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) => context.instance_create_surface_metal(layer, ()), + CreateSurfaceParams::Metal(layer) => { + match context.instance_create_surface_metal(layer, None) { + Ok(surface_id) => surface_id, + Err(cause) => handle_error_fatal(cause, "wgpuInstanceCreateSurface"), + } + } }; Arc::into_raw(Arc::new(WGPUSurfaceImpl { @@ -2675,12 +2673,8 @@ pub unsafe extern "C" fn wgpuInstanceRequestAdapter( let context = &instance.context; let callback = callback.expect("invalid callback"); - let desc = match options { - Some(options) => { - if options.backendType != native::WGPUBackendType_Undefined { - eprintln!("WARN: [wgpu-native]: WGPURequestAdapterOptions.backendType is unsupported, use WGPUInstanceExtras.backends extension for WGPUInstanceDescriptor instead") - } - + let (desc, inputs) = match options { + Some(options) => ( wgt::RequestAdapterOptions { power_preference: match options.powerPreference { native::WGPUPowerPreference_LowPower => wgt::PowerPreference::LowPower, @@ -2691,15 +2685,38 @@ pub unsafe extern "C" fn wgpuInstanceRequestAdapter( }, force_fallback_adapter: options.forceFallbackAdapter != 0, compatible_surface: options.compatibleSurface.as_ref().map(|surface| surface.id), - } - } - None => wgt::RequestAdapterOptions::default(), + }, + wgc::instance::AdapterInputs::Mask( + match options.backendType { + native::WGPUBackendType_Undefined => wgt::Backends::all(), + native::WGPUBackendType_Null => wgt::Backends::empty(), + native::WGPUBackendType_WebGPU => wgt::Backends::BROWSER_WEBGPU, + native::WGPUBackendType_D3D12 => wgt::Backends::DX12, + native::WGPUBackendType_Metal => wgt::Backends::METAL, + native::WGPUBackendType_Vulkan => wgt::Backends::VULKAN, + native::WGPUBackendType_OpenGL => wgt::Backends::GL, + native::WGPUBackendType_OpenGLES => wgt::Backends::GL, + native::WGPUBackendType_D3D11 => { + callback( + native::WGPURequestAdapterStatus_Error, + std::ptr::null_mut(), + "unsupported backend type: d3d11".as_ptr() as _, + userdata, + ); + return; + } + backend_type => panic!("invalid backend type: 0x{backend_type:08X}"), + }, + |_| None, + ), + ), + None => ( + wgt::RequestAdapterOptions::default(), + wgc::instance::AdapterInputs::Mask(wgt::Backends::all(), |_| None), + ), }; - match context.request_adapter( - &desc, - wgc::instance::AdapterInputs::Mask(wgt::Backends::all(), |_| ()), - ) { + match context.request_adapter(&desc, inputs) { Ok(adapter_id) => { let message = CString::default(); callback( @@ -2713,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 => { @@ -2744,9 +2761,9 @@ pub unsafe extern "C" fn wgpuInstanceEnumerateAdapters( let inputs = match options { Some(options) => wgc::instance::AdapterInputs::Mask( map_instance_backend_flags(options.backends as native::WGPUInstanceBackend), - |_| (), + |_| None, ), - None => wgc::instance::AdapterInputs::Mask(wgt::Backends::all(), |_| ()), + None => wgc::instance::AdapterInputs::Mask(wgt::Backends::all(), |_| None), }; let result = context.enumerate_adapters(inputs); @@ -2853,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"); }; } @@ -2878,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"); } } @@ -2902,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"); } } @@ -2927,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"); } } @@ -3068,10 +3078,9 @@ pub unsafe extern "C" fn wgpuRenderBundleEncoderFinish( None => wgt::RenderBundleDescriptor::default(), }; - let (render_bundle_id, error) = - gfx_select!(encoder.parent() => context.render_bundle_encoder_finish(*encoder, &desc, ())); + 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 { @@ -3242,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(); - render_ffi::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] @@ -3256,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(); - render_ffi::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] @@ -3271,67 +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(); - render_ffi::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(); - render_ffi::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(); - render_ffi::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)); - 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"), } } @@ -3342,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(); - render_ffi::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] @@ -3358,7 +3405,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderExecuteBundles( .collect::>(); let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_execute_bundles(encoder, bundle_ids.as_ptr(), bundle_ids.len()); + match encoder.execute_bundles(&pass.context, &bundle_ids) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderExecuteBundles", + ), + } } #[no_mangle] @@ -3369,7 +3424,19 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderInsertDebugMarker( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_insert_debug_marker(encoder, marker_label, 0); + 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] @@ -3377,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(); - render_ffi::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] @@ -3388,7 +3463,19 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderPushDebugGroup( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_push_debug_group(encoder, group_label, 0); + 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] @@ -3404,13 +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(); - render_ffi::wgpu_render_pass_set_bind_group( - encoder, + match encoder.set_bind_group( + &pass.context, group_index, bind_group_id, - dynamic_offsets, - dynamic_offset_count, - ); + make_slice(dynamic_offsets, dynamic_offset_count), + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetBindGroup", + ), + } } #[no_mangle] @@ -3421,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(); - render_ffi::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] @@ -3439,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] @@ -3463,7 +3574,15 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetPipeline( .id; let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::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] @@ -3471,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(); - render_ffi::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] @@ -3488,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(); - render_ffi::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] @@ -3504,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(); - render_ffi::wgpu_render_pass_set_vertex_buffer( - encoder, + match encoder.set_vertex_buffer( + &pass.context, slot, buffer_id, offset, @@ -3514,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] @@ -3522,15 +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(); - render_ffi::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] @@ -3569,13 +3720,11 @@ pub unsafe extern "C" fn wgpuRenderPipelineGetBindGroupLayout( &render_pipeline.error_sink, ) }; - let (bind_group_layout_id, error) = gfx_select!(render_pipeline_id => context.render_pipeline_get_bind_group_layout(render_pipeline_id, group_index, ())); + 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", ); @@ -3646,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 { @@ -3691,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 = @@ -3762,13 +3911,12 @@ 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", ), }; - match wgc::gfx_select!(surface_data.device_id => context.surface_get_current_texture(surface.id, ())) + match wgc::gfx_select!(surface_data.device_id => context.surface_get_current_texture(surface.id, None)) { Ok(wgc::present::SurfaceOutput { status, texture_id }) => { surface @@ -3799,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"), }; } @@ -3811,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", ), @@ -3821,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"), }; } @@ -3912,16 +4059,9 @@ pub unsafe extern "C" fn wgpuTextureCreateView( }; let (texture_view_id, error) = - gfx_select!(texture_id => context.texture_create_view(texture_id, &desc, ())); + 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 { @@ -4053,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"), } } @@ -4089,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"); } } } @@ -4105,13 +4245,20 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetPushConstants( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_set_push_constants( - encoder, + match encoder.set_push_constants( + &pass.context, wgt::ShaderStages::from_bits(stages).expect("invalid shader stage"), offset, - size_bytes, - data, - ); + make_slice(data, size_bytes as usize), + ) { + Ok(()) => (), + Err(cause) => handle_error( + &pass.error_sink, + cause, + None, + "wgpuRenderPassEncoderSetPushConstants", + ), + } } #[no_mangle] @@ -4125,7 +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(); - render_ffi::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] @@ -4139,7 +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(); - render_ffi::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] @@ -4156,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(); - render_ffi::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] @@ -4180,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(); - render_ffi::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] @@ -4200,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(); - compute_ffi::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] @@ -4214,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(); - compute_ffi::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] @@ -4227,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(); - render_ffi::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] @@ -4241,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(); - render_ffi::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", + ), + } }