diff --git a/Cargo.lock b/Cargo.lock index 51ae60e2..e8596fb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,9 +58,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" @@ -87,7 +87,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 2.0.63", "which", ] @@ -134,10 +134,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] -name = "cc" -version = "1.0.94" +name = "bytemuck" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "cexpr" @@ -181,6 +181,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,14 +241,23 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.19.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "0.20.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" dependencies = [ "bitflags 2.5.0", "libloading 0.8.3", "winapi", ] +[[package]] +name = "document-features" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5282ad69563b5fc40319526ba27e0e7363d552a896f0297d54f767717f9b95" +dependencies = [ + "litrs", +] + [[package]] name = "either" version = "1.11.0" @@ -232,9 +272,9 @@ 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", @@ -264,7 +304,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.63", ] [[package]] @@ -330,11 +370,24 @@ dependencies = [ "bitflags 2.5.0", ] +[[package]] +name = "gpu-allocator" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" +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", "gpu-descriptor-types", @@ -343,23 +396,38 @@ dependencies = [ [[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", ] [[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.5.0", + "com", + "libc", + "libloading 0.8.3", + "thiserror", + "widestring", + "winapi", +] + [[package]] name = "hexf-parse" version = "0.2.1" @@ -441,9 +509,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libloading" @@ -462,7 +530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets", ] [[package]] @@ -471,11 +539,17 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +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", @@ -504,9 +578,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "metal" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25" +checksum = "5637e166ea14be6063a3f8ba5ccb9a4159df7d8f6d61c02fc3d480b1f90dcfcb" dependencies = [ "bitflags 2.5.0", "block", @@ -525,9 +599,10 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "naga" -version = "0.19.2" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "0.20.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" dependencies = [ + "arrayvec", "bit-set", "bitflags 2.5.0", "codespan-reporting", @@ -566,9 +641,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -580,16 +655,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 +665,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -610,28 +675,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 +717,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.63", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -694,17 +765,17 @@ checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" [[package]] name = "raw-window-handle" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" +checksum = "8cc3bcbdb1ddfc11e700e62968e6b4cc9c75bb466464ad28fb61c5b2c964418b" [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] @@ -736,6 +807,12 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + [[package]] name = "ron" version = "0.8.1" @@ -756,9 +833,9 @@ 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", "errno", @@ -775,22 +852,22 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.63", ] [[package]] @@ -825,9 +902,20 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", @@ -845,22 +933,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.63", ] [[package]] @@ -871,9 +959,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -908,7 +996,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.63", "wasm-bindgen-shared", ] @@ -930,7 +1018,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.63", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -953,14 +1041,16 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.19.4" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "0.20.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" dependencies = [ "arrayvec", "bit-vec", "bitflags 2.5.0", + "bytemuck", "cfg_aliases", "codespan-reporting", + "document-features", "indexmap", "log", "naga", @@ -980,8 +1070,8 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.19.4" -source = "git+https://github.com/gfx-rs/wgpu?rev=87576b72b37c6b78b41104eb25fc31893af94092#87576b72b37c6b78b41104eb25fc31893af94092" +version = "0.20.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" dependencies = [ "android_system_properties", "arrayvec", @@ -995,7 +1085,9 @@ dependencies = [ "glow", "glutin_wgl_sys", "gpu-alloc", + "gpu-allocator", "gpu-descriptor", + "hassle-rs", "js-sys", "khronos-egl", "libc", @@ -1010,6 +1102,7 @@ dependencies = [ "profiling", "range-alloc", "raw-window-handle", + "renderdoc-sys", "rustc-hash", "smallvec", "thiserror", @@ -1034,13 +1127,14 @@ 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 = "0.20.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=4521502da69bcf4f92c8350042c268573ef216d4#4521502da69bcf4f92c8350042c268573ef216d4" dependencies = [ "bitflags 2.5.0", "js-sys", @@ -1060,6 +1154,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 +1178,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -1092,27 +1192,31 @@ 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 = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 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]] @@ -1121,46 +1225,28 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "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_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.5" @@ -1173,48 +1259,24 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" -[[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.5" @@ -1229,20 +1291,20 @@ checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.63", ] diff --git a/Cargo.toml b/Cargo.toml index 3d71b915..c0bdeffa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,31 +23,37 @@ resolver = "2" [workspace.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "87576b72b37c6b78b41104eb25fc31893af94092" -version = "0.19" +rev = "4521502da69bcf4f92c8350042c268573ef216d4" +version = "0.20" [workspace.dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "87576b72b37c6b78b41104eb25fc31893af94092" -version = "0.19" +rev = "4521502da69bcf4f92c8350042c268573ef216d4" +version = "0.20" + +[workspace.dependencies.hal] +package = "wgpu-hal" +git = "https://github.com/gfx-rs/wgpu" +rev = "4521502da69bcf4f92c8350042c268573ef216d4" +version = "0.20" [workspace.dependencies.naga] package = "naga" git = "https://github.com/gfx-rs/wgpu" -rev = "87576b72b37c6b78b41104eb25fc31893af94092" -version = "0.19" +rev = "4521502da69bcf4f92c8350042c268573ef216d4" +version = "0.20" [lib] crate-type = ["cdylib", "staticlib"] [features] -default = ["wgsl", "spirv", "glsl", "dx12", "metal"] +default = ["wgsl", "spirv", "glsl", "dx12", "metal", "trace"] #! ### 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. @@ -66,14 +72,18 @@ vulkan-portability = ["wgc/vulkan"] # -------------------------------------------------------------------- ## 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"] +# TODO: needs to be exposed in wgpu.h +# ## Enable accepting naga IR shaders as input. +# naga-ir = ["naga"] + #! ### Logging & Tracing # -------------------------------------------------------------------- #! The following features do not have any effect on the WebGPU backend. @@ -85,8 +95,10 @@ 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`]. +## Enables serialization via `serde` on common wgpu types. +serde = ["dep:serde", "wgc/serde"] + +## Allow writing of trace capture files. See [`Adapter::request_device`]. trace = ["serde", "wgc/trace"] ## Allow deserializing of trace capture files that were written with the `trace` feature. @@ -107,8 +119,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 +129,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/src/conv.rs b/src/conv.rs index fccae55c..6234392c 100644 --- a/src/conv.rs +++ b/src/conv.rs @@ -1,6 +1,7 @@ use crate::native; use crate::utils::{make_slice, ptr_into_label, ptr_into_pathbuf}; use crate::{follow_chain, map_enum}; +use std::collections::HashMap; use std::num::{NonZeroIsize, NonZeroU32, NonZeroU64}; use std::ptr::NonNull; use std::{borrow::Cow, ffi::CStr}; @@ -559,8 +560,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::ParseError), } #[inline] @@ -1609,6 +1610,7 @@ pub unsafe fn map_surface( panic!("Error: Unsupported Surface"); } +#[inline] pub fn map_surface_configuration( config: &native::WGPUSurfaceConfiguration, extras: Option<&native::WGPUSurfaceConfigurationExtras>, @@ -1633,3 +1635,32 @@ pub fn map_surface_configuration( }, } } + +#[inline] +pub fn map_programmable_stage_descriptor( + desc: &native::WGPUProgrammableStageDescriptor, +) -> wgc::pipeline::ProgrammableStageDescriptor { + let mut constants = HashMap::new(); + make_slice(desc.constants, desc.constantCount) + .iter() + .for_each(|entry| { + constants.insert( + unsafe { CStr::from_ptr(entry.key) } + .to_str() + .unwrap() + .to_string(), + entry.value, + ); + }); + + wgc::pipeline::ProgrammableStageDescriptor { + module: unsafe { desc.module.as_ref() } + .expect("invalid shader module for compute pipeline descriptor") + .id + .expect("invalid shader module for compute pipeline descriptor"), + entry_point: ptr_into_label(desc.entryPoint), + constants: Cow::Owned(constants), + // TODO: expose in wgpu.h + zero_initialize_workgroup_memory: false, + } +} diff --git a/src/lib.rs b/src/lib.rs index 83b773a2..00be6da1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,17 +13,13 @@ use std::{ fmt::Display, mem, num::NonZeroU64, - sync::Arc, - sync::{atomic, OnceLock}, + sync::{atomic, Arc, OnceLock}, 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}, - gfx_select, id, resource, Label, -}; +use wgc::{command::bundle_ffi, gfx_select, id, resource, Label}; pub mod conv; pub mod logging; @@ -40,7 +36,7 @@ pub mod native { const LABEL: &str = "label"; -pub type Context = wgc::global::Global; +pub type Context = wgc::global::Global; struct AdapterProperties { vendor_id: u32, @@ -143,7 +139,7 @@ impl Drop for WGPUCommandEncoderImpl { pub struct WGPUComputePassEncoderImpl { context: Arc, - encoder: id::ComputePassEncoderId, + encoder: *mut wgc::command::ComputePass, error_sink: ErrorSink, } impl Drop for WGPUComputePassEncoderImpl { @@ -260,7 +256,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) { @@ -278,7 +274,7 @@ unsafe impl Sync for WGPURenderBundleEncoderImpl {} pub struct WGPURenderPassEncoderImpl { context: Arc, - encoder: id::RenderPassEncoderId, + encoder: *mut wgc::command::RenderPass, error_sink: ErrorSink, } impl Drop for WGPURenderPassEncoderImpl { @@ -644,11 +640,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)), })) } @@ -823,8 +815,8 @@ pub unsafe extern "C" fn wgpuAdapterRequestDevice( adapter_id, &desc, ptr_into_path(trace_str), - (), - () + None, + None ) ); match err { @@ -1022,8 +1014,12 @@ 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)) - { + 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(context, error_sink, cause, "", None, "wgpuBufferMapAsync"); }; } @@ -1595,7 +1591,7 @@ 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( + wgc::command::compute_commands::wgpu_compute_pass_dispatch_workgroups( encoder, workgroup_count_x, workgroup_count_y, @@ -1617,7 +1613,7 @@ pub unsafe extern "C" fn wgpuComputePassEncoderDispatchWorkgroupsIndirect( let encoder = pass.encoder.as_mut().unwrap(); - compute_ffi::wgpu_compute_pass_dispatch_workgroups_indirect( + wgc::command::compute_commands::wgpu_compute_pass_dispatch_workgroups_indirect( encoder, indirect_buffer_id, indirect_offset, @@ -1633,7 +1629,7 @@ pub unsafe extern "C" fn wgpuComputePassEncoderEnd(pass: native::WGPUComputePass 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)); + let name = wgc::gfx_select!(command_encoder_id => context.command_buffer_label(command_encoder_id.into_command_buffer_id())); handle_error( context, error_sink, @@ -1653,7 +1649,11 @@ 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); + wgc::command::compute_commands::wgpu_compute_pass_insert_debug_marker( + encoder, + CStr::from_ptr(marker_label).to_str().unwrap(), + 0, + ); } #[no_mangle] @@ -1661,7 +1661,7 @@ 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); + wgc::command::compute_commands::wgpu_compute_pass_pop_debug_group(encoder); } #[no_mangle] @@ -1672,7 +1672,11 @@ 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); + wgc::command::compute_commands::wgpu_compute_pass_push_debug_group( + encoder, + CStr::from_ptr(group_label).to_str().unwrap(), + 0, + ); } #[no_mangle] @@ -1688,12 +1692,11 @@ 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( + wgc::command::compute_commands::wgpu_compute_pass_set_bind_group( encoder, group_index, bind_group_id, - dynamic_offsets, - dynamic_offset_count, + make_slice(dynamic_offsets, dynamic_offset_count), ); } @@ -1709,7 +1712,7 @@ 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); + wgc::command::compute_commands::wgpu_compute_pass_set_pipeline(encoder, compute_pipeline_id); } #[no_mangle] @@ -1745,7 +1748,7 @@ 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, @@ -1809,7 +1812,7 @@ 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, @@ -1852,7 +1855,7 @@ 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, @@ -1889,7 +1892,7 @@ 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, @@ -1928,7 +1931,7 @@ 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, @@ -1959,36 +1962,24 @@ 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, + stage: conv::map_programmable_stage_descriptor(&descriptor.compute), }; let implicit_pipeline_ids = match desc.layout { Some(_) => None, None => Some(wgc::device::ImplicitPipelineIds { - root_id: (), - group_ids: &[(); wgc::MAX_BIND_GROUPS], + root_id: None, + group_ids: &[None; wgc::MAX_BIND_GROUPS], }), }; let (compute_pipeline_id, error) = gfx_select!(device_id => context.device_create_compute_pipeline( device_id, &desc, - (), + None, implicit_pipeline_ids )); if let Some(cause) = error { @@ -2034,7 +2025,7 @@ 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, @@ -2070,7 +2061,7 @@ 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, @@ -2154,9 +2145,20 @@ 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: expose via wgpu.h + zero_initialize_workgroup_memory: false, }, buffers: Cow::Owned( make_slice(descriptor.vertex.buffers, descriptor.vertex.bufferCount) @@ -2243,9 +2245,20 @@ 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: expose via wgpu.h + zero_initialize_workgroup_memory: false, }, targets: Cow::Owned( make_slice(fragment.targets, fragment.targetCount) @@ -2274,12 +2287,12 @@ pub unsafe extern "C" fn wgpuDeviceCreateRenderPipeline( let implicit_pipeline_ids = match desc.layout { Some(_) => None, None => Some(wgc::device::ImplicitPipelineIds { - root_id: (), - group_ids: &[(); wgc::MAX_BIND_GROUPS], + root_id: None, + group_ids: &[None; wgc::MAX_BIND_GROUPS], }), }; - let (render_pipeline_id, error) = gfx_select!(device_id => context.device_create_render_pipeline(device_id, &desc, (), implicit_pipeline_ids)); + let (render_pipeline_id, error) = gfx_select!(device_id => context.device_create_render_pipeline(device_id, &desc, None, implicit_pipeline_ids)); if let Some(cause) = error { if let wgc::pipeline::CreateRenderPipelineError::Internal { stage, ref error } = cause { log::error!("Shader translation error for stage {:?}: {}", stage, error); @@ -2351,7 +2364,7 @@ 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, @@ -2409,8 +2422,7 @@ 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, @@ -2458,7 +2470,7 @@ 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, @@ -2666,13 +2678,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"), } } #[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(context, cause, "wgpuInstanceCreateSurface"), + } + } }; Arc::into_raw(Arc::new(WGPUSurfaceImpl { @@ -2694,12 +2711,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, @@ -2710,15 +2723,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( @@ -2764,9 +2800,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); @@ -3089,8 +3125,7 @@ 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"); } @@ -3263,7 +3298,7 @@ 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); + wgc::command::render_commands::wgpu_render_pass_begin_occlusion_query(encoder, query_index); } #[no_mangle] @@ -3277,7 +3312,7 @@ 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( + wgc::command::render_commands::wgpu_render_pass_draw( encoder, vertex_count, instance_count, @@ -3298,7 +3333,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderDrawIndexed( let pass = pass.as_ref().expect("invalid render pass"); let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_draw_indexed( + wgc::command::render_commands::wgpu_render_pass_draw_indexed( encoder, index_count, instance_count, @@ -3318,7 +3353,11 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderDrawIndexedIndirect( let buffer_id = buffer.as_ref().expect("invalid buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_draw_indexed_indirect(encoder, buffer_id, indirect_offset); + wgc::command::render_commands::wgpu_render_pass_draw_indexed_indirect( + encoder, + buffer_id, + indirect_offset, + ); } #[no_mangle] @@ -3331,7 +3370,11 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderDrawIndirect( let buffer_id = buffer.as_ref().expect("invalid buffer").id; let encoder = pass.encoder.as_mut().unwrap(); - render_ffi::wgpu_render_pass_draw_indirect(encoder, buffer_id, indirect_offset); + wgc::command::render_commands::wgpu_render_pass_draw_indirect( + encoder, + buffer_id, + indirect_offset, + ); } #[no_mangle] @@ -3343,8 +3386,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderEnd(pass: native::WGPURenderPassEn 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)); + let name = gfx_select!(command_encoder_id => context.command_buffer_label(command_encoder_id.into_command_buffer_id())); handle_error( context, error_sink, @@ -3363,7 +3405,7 @@ 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); + wgc::command::render_commands::wgpu_render_pass_end_occlusion_query(encoder); } #[no_mangle] @@ -3379,7 +3421,7 @@ 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()); + wgc::command::render_commands::wgpu_render_pass_execute_bundles(encoder, &bundle_ids); } #[no_mangle] @@ -3390,7 +3432,11 @@ 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); + wgc::command::render_commands::wgpu_render_pass_insert_debug_marker( + encoder, + CStr::from_ptr(marker_label).to_str().unwrap(), + 0, + ); } #[no_mangle] @@ -3398,7 +3444,7 @@ 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); + wgc::command::render_commands::wgpu_render_pass_pop_debug_group(encoder); } #[no_mangle] @@ -3409,7 +3455,11 @@ 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); + wgc::command::render_commands::wgpu_render_pass_push_debug_group( + encoder, + CStr::from_ptr(group_label).to_str().unwrap(), + 0, + ); } #[no_mangle] @@ -3425,12 +3475,11 @@ 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( + wgc::command::render_commands::wgpu_render_pass_set_bind_group( encoder, group_index, bind_group_id, - dynamic_offsets, - dynamic_offset_count, + make_slice(dynamic_offsets, dynamic_offset_count), ); } @@ -3442,7 +3491,7 @@ 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( + wgc::command::render_commands::wgpu_render_pass_set_blend_constant( encoder, &conv::map_color(color.expect("invalid color")), ); @@ -3484,7 +3533,7 @@ 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); + wgc::command::render_commands::wgpu_render_pass_set_pipeline(encoder, render_pipeline_id); } #[no_mangle] @@ -3498,7 +3547,7 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetScissorRect( 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); + wgc::command::render_commands::wgpu_render_pass_set_scissor_rect(encoder, x, y, w, h); } #[no_mangle] @@ -3509,7 +3558,7 @@ 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); + wgc::command::render_commands::wgpu_render_pass_set_stencil_reference(encoder, reference); } #[no_mangle] @@ -3525,7 +3574,7 @@ 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( + wgc::command::render_commands::wgpu_render_pass_set_vertex_buffer( encoder, slot, buffer_id, @@ -3551,7 +3600,9 @@ pub unsafe extern "C" fn wgpuRenderPassEncoderSetViewport( 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); + wgc::command::render_commands::wgpu_render_pass_set_viewport( + encoder, x, y, w, h, depth_min, depth_max, + ); } #[no_mangle] @@ -3590,7 +3641,7 @@ 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, @@ -3786,7 +3837,7 @@ pub unsafe extern "C" fn 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 @@ -3963,7 +4014,7 @@ 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, @@ -4156,12 +4207,11 @@ 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( + wgc::command::render_commands::wgpu_render_pass_set_push_constants( encoder, wgt::ShaderStages::from_bits(stages).expect("invalid shader stage"), offset, - size_bytes, - data, + make_slice(data, size_bytes as usize), ); } @@ -4176,7 +4226,9 @@ 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); + wgc::command::render_commands::wgpu_render_pass_multi_draw_indirect( + encoder, buffer_id, offset, count, + ); } #[no_mangle] @@ -4190,7 +4242,9 @@ 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); + wgc::command::render_commands::wgpu_render_pass_multi_draw_indexed_indirect( + encoder, buffer_id, offset, count, + ); } #[no_mangle] @@ -4207,7 +4261,7 @@ 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( + wgc::command::render_commands::wgpu_render_pass_multi_draw_indirect_count( encoder, buffer_id, offset, @@ -4231,7 +4285,7 @@ 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( + wgc::command::render_commands::wgpu_render_pass_multi_draw_indexed_indirect_count( encoder, buffer_id, offset, @@ -4251,7 +4305,7 @@ 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( + wgc::command::compute_commands::wgpu_compute_pass_begin_pipeline_statistics_query( encoder, query_set_id, query_index, @@ -4265,7 +4319,7 @@ 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); + wgc::command::compute_commands::wgpu_compute_pass_end_pipeline_statistics_query(encoder); } #[no_mangle] @@ -4278,7 +4332,7 @@ 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( + wgc::command::render_commands::wgpu_render_pass_begin_pipeline_statistics_query( encoder, query_set_id, query_index, @@ -4292,5 +4346,5 @@ 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); + wgc::command::render_commands::wgpu_render_pass_end_pipeline_statistics_query(encoder); }