diff --git a/Cargo.lock b/Cargo.lock index 8c881d41067..230e6f41654 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ab_glyph" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225" +checksum = "8e08104bebc65a46f8bc7aa733d39ea6874bfa7156f41a46b805785e3af1587d" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -48,9 +48,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -68,7 +68,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", - "bitflags 2.4.2", + "bitflags 2.5.0", "cc", "cesu8", "jni", @@ -185,7 +185,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -235,13 +235,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -252,15 +252,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -328,9 +328,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "arbitrary", "serde", @@ -363,9 +363,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" @@ -384,7 +384,7 @@ checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -395,9 +395,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "calloop" @@ -419,7 +419,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "log", "polling", "rustix", @@ -447,9 +447,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -511,9 +511,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.2" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -521,14 +521,14 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] @@ -540,7 +540,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -584,7 +584,7 @@ dependencies = [ "block", "cocoa-foundation", "core-foundation", - "core-graphics 0.23.1", + "core-graphics 0.23.2", "foreign-types 0.5.0", "libc", "objc", @@ -745,9 +745,9 @@ dependencies = [ [[package]] name = "core-graphics" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -774,7 +774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5" dependencies = [ "core-foundation", - "core-graphics 0.23.1", + "core-graphics 0.23.2", "foreign-types 0.5.0", "libc", ] @@ -858,7 +858,7 @@ dependencies = [ "cocoa 0.25.0", "core-foundation", "core-foundation-sys", - "core-graphics 0.23.1", + "core-graphics 0.23.2", "core-text", "dwrote", "foreign-types 0.5.0", @@ -885,7 +885,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad291aa74992b9b7a7e88c38acbbf6ad7e107f1d90ee8775b7bc1fc3394f485c" dependencies = [ "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -918,7 +918,7 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" name = "d3d12" version = "0.19.0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libloading 0.8.3", "winapi", ] @@ -1032,7 +1032,7 @@ dependencies = [ "quote", "strum", "strum_macros", - "syn 2.0.52", + "syn 2.0.58", "thiserror", ] @@ -1105,7 +1105,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1153,9 +1153,9 @@ dependencies = [ [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "dwrote" @@ -1206,7 +1206,7 @@ checksum = "92959a9e8d13eaa13b8ae8c7b583c3bf1669ca7a8e7708a088d12587ba86effc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1269,9 +1269,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "fdeflate" @@ -1352,7 +1352,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1458,9 +1458,9 @@ checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "fastrand", "futures-core", @@ -1477,7 +1477,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -1522,9 +1522,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -1648,7 +1648,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gpu-alloc-types", ] @@ -1658,7 +1658,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -1680,7 +1680,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "gpu-descriptor-types", "hashbrown", ] @@ -1691,7 +1691,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -1705,9 +1705,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ "cfg-if", "crunchy", @@ -1729,7 +1729,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "com", "libc", "libloading 0.8.3", @@ -1827,9 +1827,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "arbitrary", "equivalent", @@ -1871,9 +1871,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jni" @@ -1981,7 +1981,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.4", + "windows-targets 0.48.5", ] [[package]] @@ -1990,7 +1990,7 @@ version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall 0.4.1", ] @@ -2045,9 +2045,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "memmap2" @@ -2090,7 +2090,7 @@ name = "metal" version = "0.27.0" source = "git+https://github.com/gfx-rs/metal-rs?rev=ff8fd3d6dc7792852f8a015458d7e6d42d7fb352#ff8fd3d6dc7792852f8a015458d7e6d42d7fb352" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "block", "core-graphics-types", "foreign-types 0.5.0", @@ -2123,13 +2123,13 @@ dependencies = [ [[package]] name = "naga" -version = "0.19.0" +version = "0.19.2" dependencies = [ "arbitrary", "arrayvec 0.7.4", "bincode", "bit-set", - "bitflags 2.4.2", + "bitflags 2.5.0", "codespan-reporting", "criterion", "diff", @@ -2216,7 +2216,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "jni-sys", "log", "ndk-sys 0.5.0+25.2.9519653", @@ -2392,7 +2392,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2587,14 +2587,14 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -2610,7 +2610,7 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "player" -version = "0.19.0" +version = "0.19.3" dependencies = [ "env_logger", "log", @@ -2665,12 +2665,13 @@ dependencies = [ [[package]] name = "polling" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9" +checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" dependencies = [ "cfg-if", "concurrent-queue", + "hermit-abi", "pin-project-lite", "rustix", "tracing", @@ -2725,7 +2726,7 @@ checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" dependencies = [ "proc-macro-rules-macros", "proc-macro2", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2737,7 +2738,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -2826,9 +2827,9 @@ checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -2864,9 +2865,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -2887,9 +2888,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "renderdoc-sys" @@ -2904,7 +2905,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64", - "bitflags 2.4.2", + "bitflags 2.5.0", "serde", "serde_derive", ] @@ -2950,11 +2951,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -2963,9 +2964,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -3066,14 +3067,14 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "indexmap", "itoa", @@ -3170,9 +3171,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smithay-client-toolkit" @@ -3199,7 +3200,7 @@ version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "calloop 0.12.4", "calloop-wayland-source", "cursor-icon", @@ -3277,7 +3278,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "serde", ] @@ -3301,9 +3302,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -3324,7 +3325,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3340,9 +3341,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -3375,7 +3376,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3474,9 +3475,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -3499,7 +3500,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3671,9 +3672,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom", "serde", @@ -3685,7 +3686,7 @@ version = "0.89.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe2197fbef82c98f7953d13568a961d4e1c663793b5caf3c74455a13918cdf33" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "fslock", "gzip-header", "home", @@ -3749,7 +3750,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -3783,7 +3784,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3816,7 +3817,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] @@ -3855,7 +3856,7 @@ version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "rustix", "wayland-backend", "wayland-scanner 0.31.1", @@ -3879,7 +3880,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cursor-icon", "wayland-backend", ] @@ -3934,7 +3935,7 @@ version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "wayland-backend", "wayland-client 0.31.2", "wayland-scanner 0.31.1", @@ -3946,7 +3947,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "wayland-backend", "wayland-client 0.31.2", "wayland-protocols 0.31.2", @@ -3959,7 +3960,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "wayland-backend", "wayland-client 0.31.2", "wayland-protocols 0.31.2", @@ -4033,7 +4034,7 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.19.0" +version = "0.19.3" dependencies = [ "arrayvec 0.7.4", "cfg-if", @@ -4058,11 +4059,11 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.19.0" +version = "0.19.3" dependencies = [ "arrayvec 0.7.4", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytemuck", "cfg_aliases", "codespan-reporting", @@ -4086,7 +4087,7 @@ dependencies = [ [[package]] name = "wgpu-examples" -version = "0.19.0" +version = "0.19.3" dependencies = [ "bytemuck", "cfg-if", @@ -4119,13 +4120,13 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.19.0" +version = "0.19.3" dependencies = [ "android_system_properties", "arrayvec 0.7.4", "ash", "bit-set", - "bitflags 2.4.2", + "bitflags 2.5.0", "block", "cfg-if", "cfg_aliases", @@ -4143,7 +4144,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.3", + "libloading 0.7.4", "log", "metal", "naga", @@ -4167,10 +4168,10 @@ dependencies = [ [[package]] name = "wgpu-info" -version = "0.19.0" +version = "0.19.3" dependencies = [ "anyhow", - "bitflags 2.4.2", + "bitflags 2.5.0", "env_logger", "pico-args", "serde", @@ -4181,20 +4182,20 @@ dependencies = [ [[package]] name = "wgpu-macros" -version = "0.19.0" +version = "0.19.3" dependencies = [ "heck", "quote", - "syn 2.0.52", + "syn 2.0.58", ] [[package]] name = "wgpu-test" -version = "0.19.0" +version = "0.19.3" dependencies = [ "anyhow", "arrayvec 0.7.4", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytemuck", "cfg-if", "console_log", @@ -4226,9 +4227,9 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.19.0" +version = "0.19.2" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "js-sys", "serde", "serde_json", @@ -4250,9 +4251,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" @@ -4587,12 +4588,12 @@ dependencies = [ "ahash", "android-activity", "atomic-waker", - "bitflags 2.4.2", + "bitflags 2.5.0", "bytemuck", "calloop 0.12.4", "cfg_aliases", "core-foundation", - "core-graphics 0.23.1", + "core-graphics 0.23.2", "cursor-icon", "icrate", "js-sys", @@ -4688,7 +4689,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "dlib", "log", "once_cell", @@ -4703,9 +4704,9 @@ checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" [[package]] name = "xml-rs" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "zerocopy" @@ -4724,5 +4725,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.58", ] diff --git a/Cargo.toml b/Cargo.toml index d44b9d74c41..c992222cf4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,27 +45,27 @@ keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" repository = "https://github.com/gfx-rs/wgpu" -version = "0.19.0" +version = "0.19.3" authors = ["gfx-rs developers"] [workspace.dependencies.wgc] package = "wgpu-core" path = "./wgpu-core" -version = "0.19.0" +version = "0.19.3" [workspace.dependencies.wgt] package = "wgpu-types" path = "./wgpu-types" -version = "0.19.0" +version = "0.19.2" [workspace.dependencies.hal] package = "wgpu-hal" path = "./wgpu-hal" -version = "0.19.0" +version = "0.19.3" [workspace.dependencies.naga] path = "./naga" -version = "0.19.0" +version = "0.19.2" [workspace.dependencies] anyhow = "1.0" @@ -114,16 +114,16 @@ renderdoc-sys = "1.1.0" ron = "0.8" rustc-hash = "1.1.0" serde = "1" -serde_json = "1.0.113" +serde_json = "1.0.115" smallvec = "1" static_assertions = "1.1.0" thiserror = "1" -wgpu = { version = "0.19.0", path = "./wgpu" } -wgpu-core = { version = "0.19.0", path = "./wgpu-core" } +wgpu = { version = "0.19.3", path = "./wgpu" } +wgpu-core = { version = "0.19.3", path = "./wgpu-core" } wgpu-example = { version = "0.19.0", path = "./examples/common" } wgpu-macros = { version = "0.19.0", path = "./wgpu-macros" } wgpu-test = { version = "0.19.0", path = "./tests" } -wgpu-types = { version = "0.19.0", path = "./wgpu-types" } +wgpu-types = { version = "0.19.2", path = "./wgpu-types" } winit = { version = "0.29", features = ["android-native-activity"] } # Metal dependencies @@ -171,7 +171,7 @@ deno_url = "0.143.0" deno_web = "0.174.0" deno_webidl = "0.143.0" deno_webgpu = { version = "0.110.0", path = "./deno_webgpu" } -tokio = "1.36.0" +tokio = "1.37.0" termcolor = "1.4.1" [patch."https://github.com/gfx-rs/naga"] diff --git a/examples/src/water/mod.rs b/examples/src/water/mod.rs index 0cd00aac54a..6bc3824e73f 100644 --- a/examples/src/water/mod.rs +++ b/examples/src/water/mod.rs @@ -834,18 +834,8 @@ static TEST: crate::framework::ExampleTestParams = crate::framework::ExampleTest // To be fixed in . .expect_fail(wgpu_test::FailureCase { backends: Some(wgpu::Backends::VULKAN), - reasons: vec![ - wgpu_test::FailureReason::validation_error().with_message(concat!( - "vkCmdEndRenderPass: ", - "Hazard WRITE_AFTER_READ in subpass 0 for attachment 1 depth aspect ", - "during store with storeOp VK_ATTACHMENT_STORE_OP_STORE. ", - "Access info (", - "usage: SYNC_LATE_FRAGMENT_TESTS_DEPTH_STENCIL_ATTACHMENT_WRITE, ", - "prior_usage: SYNC_FRAGMENT_SHADER_SHADER_SAMPLED_READ, ", - "read_barriers: VkPipelineStageFlags2(0), ", - "command: vkCmdDraw" - )), - ], + reasons: vec![wgpu_test::FailureReason::validation_error() + .with_message(concat!("Hazard WRITE_AFTER_"))], behavior: wgpu_test::FailureBehavior::AssertFailure, ..Default::default() }), diff --git a/naga/Cargo.toml b/naga/Cargo.toml index df71664ea41..5cc078ad993 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "naga" -version = "0.19.0" +version = "0.19.2" authors = ["gfx-rs developers"] edition = "2021" description = "Shader translation infrastructure" @@ -41,7 +41,7 @@ harness = false [dependencies] arbitrary = { version = "1.3", features = ["derive"], optional = true } -bitflags = "2.4" +bitflags = "2.5" bit-set = "0.5" termcolor = { version = "1.4.1" } # remove termcolor dep when updating to the next version of codespan-reporting diff --git a/naga/src/front/spv/error.rs b/naga/src/front/spv/error.rs index af025636c0e..2825a44a003 100644 --- a/naga/src/front/spv/error.rs +++ b/naga/src/front/spv/error.rs @@ -118,8 +118,8 @@ pub enum Error { ControlFlowGraphCycle(crate::front::spv::BlockId), #[error("recursive function call %{0}")] FunctionCallCycle(spirv::Word), - #[error("invalid array size {0:?}")] - InvalidArraySize(Handle), + #[error("invalid array size %{0}")] + InvalidArraySize(spirv::Word), #[error("invalid barrier scope %{0}")] InvalidBarrierScope(spirv::Word), #[error("invalid barrier memory semantics %{0}")] @@ -130,6 +130,8 @@ pub enum Error { come from a binding)" )] NonBindingArrayOfImageOrSamplers, + #[error("naga only supports specialization constant IDs up to 65535 but was given {0}")] + SpecIdTooHigh(u32), } impl Error { diff --git a/naga/src/front/spv/function.rs b/naga/src/front/spv/function.rs index 5f8dd09608d..113ca56313b 100644 --- a/naga/src/front/spv/function.rs +++ b/naga/src/front/spv/function.rs @@ -59,8 +59,11 @@ impl> super::Frontend { }) }, local_variables: Arena::new(), - expressions: self - .make_expression_storage(&module.global_variables, &module.constants), + expressions: self.make_expression_storage( + &module.global_variables, + &module.constants, + &module.overrides, + ), named_expressions: crate::NamedExpressions::default(), body: crate::Block::new(), } diff --git a/naga/src/front/spv/image.rs b/naga/src/front/spv/image.rs index 21fff3f4af5..284c4cf7fdf 100644 --- a/naga/src/front/spv/image.rs +++ b/naga/src/front/spv/image.rs @@ -507,11 +507,14 @@ impl> super::Frontend { } spirv::ImageOperands::CONST_OFFSET => { let offset_constant = self.next()?; - let offset_handle = self.lookup_constant.lookup(offset_constant)?.handle; - let offset_handle = ctx.global_expressions.append( - crate::Expression::Constant(offset_handle), - Default::default(), - ); + let offset_expr = self + .lookup_constant + .lookup(offset_constant)? + .inner + .to_expr(); + let offset_handle = ctx + .global_expressions + .append(offset_expr, Default::default()); offset = Some(offset_handle); words_left -= 1; } diff --git a/naga/src/front/spv/mod.rs b/naga/src/front/spv/mod.rs index 24053cf26bb..2ad40677fbb 100644 --- a/naga/src/front/spv/mod.rs +++ b/naga/src/front/spv/mod.rs @@ -196,6 +196,7 @@ struct Decoration { location: Option, desc_set: Option, desc_index: Option, + specialization_constant_id: Option, storage_buffer: bool, offset: Option, array_stride: Option, @@ -277,9 +278,24 @@ struct LookupType { base_id: Option, } +#[derive(Debug)] +enum Constant { + Constant(Handle), + Override(Handle), +} + +impl Constant { + const fn to_expr(&self) -> crate::Expression { + match *self { + Self::Constant(c) => crate::Expression::Constant(c), + Self::Override(o) => crate::Expression::Override(o), + } + } +} + #[derive(Debug)] struct LookupConstant { - handle: Handle, + inner: Constant, type_id: spirv::Word, } @@ -751,6 +767,9 @@ impl> Frontend { spirv::Decoration::RowMajor => { dec.matrix_major = Some(Majority::Row); } + spirv::Decoration::SpecId => { + dec.specialization_constant_id = Some(self.next()?); + } other => { log::warn!("Unknown decoration {:?}", other); for _ in base_words + 1..inst.wc { @@ -1385,10 +1404,7 @@ impl> Frontend { inst.expect(5)?; let init_id = self.next()?; let lconst = self.lookup_constant.lookup(init_id)?; - Some( - ctx.expressions - .append(crate::Expression::Constant(lconst.handle), span), - ) + Some(ctx.expressions.append(lconst.inner.to_expr(), span)) } else { None }; @@ -3642,9 +3658,9 @@ impl> Frontend { let exec_scope_const = self.lookup_constant.lookup(exec_scope_id)?; let semantics_const = self.lookup_constant.lookup(semantics_id)?; - let exec_scope = resolve_constant(ctx.gctx(), exec_scope_const.handle) + let exec_scope = resolve_constant(ctx.gctx(), &exec_scope_const.inner) .ok_or(Error::InvalidBarrierScope(exec_scope_id))?; - let semantics = resolve_constant(ctx.gctx(), semantics_const.handle) + let semantics = resolve_constant(ctx.gctx(), &semantics_const.inner) .ok_or(Error::InvalidBarrierMemorySemantics(semantics_id))?; if exec_scope == spirv::Scope::Workgroup as u32 { @@ -3705,6 +3721,7 @@ impl> Frontend { &mut self, globals: &Arena, constants: &Arena, + overrides: &Arena, ) -> Arena { let mut expressions = Arena::new(); #[allow(clippy::panic)] @@ -3729,8 +3746,11 @@ impl> Frontend { } // register constants for (&id, con) in self.lookup_constant.iter() { - let span = constants.get_span(con.handle); - let handle = expressions.append(crate::Expression::Constant(con.handle), span); + let (expr, span) = match con.inner { + Constant::Constant(c) => (crate::Expression::Constant(c), constants.get_span(c)), + Constant::Override(o) => (crate::Expression::Override(o), overrides.get_span(o)), + }; + let handle = expressions.append(expr, span); self.lookup_expression.insert( id, LookupExpression { @@ -3935,11 +3955,17 @@ impl> Frontend { Op::TypeImage => self.parse_type_image(inst, &mut module), Op::TypeSampledImage => self.parse_type_sampled_image(inst), Op::TypeSampler => self.parse_type_sampler(inst, &mut module), - Op::Constant => self.parse_constant(inst, &mut module), - Op::ConstantComposite => self.parse_composite_constant(inst, &mut module), + Op::Constant | Op::SpecConstant => self.parse_constant(inst, &mut module), + Op::ConstantComposite | Op::SpecConstantComposite => { + self.parse_composite_constant(inst, &mut module) + } Op::ConstantNull | Op::Undef => self.parse_null_constant(inst, &mut module), - Op::ConstantTrue => self.parse_bool_constant(inst, true, &mut module), - Op::ConstantFalse => self.parse_bool_constant(inst, false, &mut module), + Op::ConstantTrue | Op::SpecConstantTrue => { + self.parse_bool_constant(inst, true, &mut module) + } + Op::ConstantFalse | Op::SpecConstantFalse => { + self.parse_bool_constant(inst, false, &mut module) + } Op::Variable => self.parse_global_variable(inst, &mut module), Op::Function => { self.switch(ModuleState::Function, inst.op)?; @@ -4496,9 +4522,9 @@ impl> Frontend { let length_id = self.next()?; let length_const = self.lookup_constant.lookup(length_id)?; - let size = resolve_constant(module.to_ctx(), length_const.handle) + let size = resolve_constant(module.to_ctx(), &length_const.inner) .and_then(NonZeroU32::new) - .ok_or(Error::InvalidArraySize(length_const.handle))?; + .ok_or(Error::InvalidArraySize(length_id))?; let decor = self.future_decor.remove(&id).unwrap_or_default(); let base = self.lookup_type.lookup(type_id)?.handle; @@ -4911,28 +4937,13 @@ impl> Frontend { _ => return Err(Error::UnsupportedType(type_lookup.handle)), }; - let decor = self.future_decor.remove(&id).unwrap_or_default(); - let span = self.span_from_with_op(start); let init = module .global_expressions .append(crate::Expression::Literal(literal), span); - self.lookup_constant.insert( - id, - LookupConstant { - handle: module.constants.append( - crate::Constant { - name: decor.name, - ty, - init, - }, - span, - ), - type_id, - }, - ); - Ok(()) + + self.insert_parsed_constant(module, id, type_id, ty, init, span) } fn parse_composite_constant( @@ -4957,32 +4968,17 @@ impl> Frontend { let constant = self.lookup_constant.lookup(component_id)?; let expr = module .global_expressions - .append(crate::Expression::Constant(constant.handle), span); + .append(constant.inner.to_expr(), span); components.push(expr); } - let decor = self.future_decor.remove(&id).unwrap_or_default(); - let span = self.span_from_with_op(start); let init = module .global_expressions .append(crate::Expression::Compose { ty, components }, span); - self.lookup_constant.insert( - id, - LookupConstant { - handle: module.constants.append( - crate::Constant { - name: decor.name, - ty, - init, - }, - span, - ), - type_id, - }, - ); - Ok(()) + + self.insert_parsed_constant(module, id, type_id, ty, init, span) } fn parse_null_constant( @@ -5000,22 +4996,11 @@ impl> Frontend { let type_lookup = self.lookup_type.lookup(type_id)?; let ty = type_lookup.handle; - let decor = self.future_decor.remove(&id).unwrap_or_default(); - let init = module .global_expressions .append(crate::Expression::ZeroValue(ty), span); - let handle = module.constants.append( - crate::Constant { - name: decor.name, - ty, - init, - }, - span, - ); - self.lookup_constant - .insert(id, LookupConstant { handle, type_id }); - Ok(()) + + self.insert_parsed_constant(module, id, type_id, ty, init, span) } fn parse_bool_constant( @@ -5034,26 +5019,44 @@ impl> Frontend { let type_lookup = self.lookup_type.lookup(type_id)?; let ty = type_lookup.handle; - let decor = self.future_decor.remove(&id).unwrap_or_default(); - let init = module.global_expressions.append( crate::Expression::Literal(crate::Literal::Bool(value)), span, ); - self.lookup_constant.insert( - id, - LookupConstant { - handle: module.constants.append( - crate::Constant { - name: decor.name, - ty, - init, - }, - span, - ), - type_id, - }, - ); + + self.insert_parsed_constant(module, id, type_id, ty, init, span) + } + + fn insert_parsed_constant( + &mut self, + module: &mut crate::Module, + id: u32, + type_id: u32, + ty: Handle, + init: Handle, + span: crate::Span, + ) -> Result<(), Error> { + let decor = self.future_decor.remove(&id).unwrap_or_default(); + + let inner = if let Some(id) = decor.specialization_constant_id { + let o = crate::Override { + name: decor.name, + id: Some(id.try_into().map_err(|_| Error::SpecIdTooHigh(id))?), + ty, + init: Some(init), + }; + Constant::Override(module.overrides.append(o, span)) + } else { + let c = crate::Constant { + name: decor.name, + ty, + init, + }; + Constant::Constant(module.constants.append(c, span)) + }; + + self.lookup_constant + .insert(id, LookupConstant { inner, type_id }); Ok(()) } @@ -5076,7 +5079,7 @@ impl> Frontend { let lconst = self.lookup_constant.lookup(init_id)?; let expr = module .global_expressions - .append(crate::Expression::Constant(lconst.handle), span); + .append(lconst.inner.to_expr(), span); Some(expr) } else { None @@ -5291,10 +5294,11 @@ fn make_index_literal( Ok(expr) } -fn resolve_constant( - gctx: crate::proc::GlobalCtx, - constant: Handle, -) -> Option { +fn resolve_constant(gctx: crate::proc::GlobalCtx, constant: &Constant) -> Option { + let constant = match *constant { + Constant::Constant(constant) => constant, + Constant::Override(_) => return None, + }; match gctx.global_expressions[gctx.constants[constant].init] { crate::Expression::Literal(crate::Literal::U32(id)) => Some(id), crate::Expression::Literal(crate::Literal::I32(id)) => Some(id as u32), diff --git a/naga/tests/in/spv/spec-constants.spv b/naga/tests/in/spv/spec-constants.spv new file mode 100644 index 00000000000..2029bfecb76 Binary files /dev/null and b/naga/tests/in/spv/spec-constants.spv differ diff --git a/naga/tests/in/spv/spec-constants.spvasm b/naga/tests/in/spv/spec-constants.spvasm new file mode 100644 index 00000000000..df8e40cecdf --- /dev/null +++ b/naga/tests/in/spv/spec-constants.spvasm @@ -0,0 +1,143 @@ +; SPIR-V +; Version: 1.0 +; Generator: Google Shaderc over Glslang; 11 +; Bound: 74 +; Schema: 0 + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %main "main" %v_Uv %Vertex_Uv %Vertex_Position %__0 %Vertex_Normal + OpSource GLSL 450 + OpSourceExtension "GL_GOOGLE_cpp_style_line_directive" + OpSourceExtension "GL_GOOGLE_include_directive" + OpName %main "main" + OpName %test_constant "test_constant" + OpName %TEST_CONSTANT "TEST_CONSTANT" + OpName %TEST_CONSTANT_TRUE "TEST_CONSTANT_TRUE" + OpName %TEST_CONSTANT_FALSE "TEST_CONSTANT_FALSE" + OpName %v_Uv "v_Uv" + OpName %Vertex_Uv "Vertex_Uv" + OpName %position "position" + OpName %Vertex_Position "Vertex_Position" + OpName %Sprite_size "Sprite_size" + OpMemberName %Sprite_size 0 "size" + OpName %_ "" + OpName %gl_PerVertex "gl_PerVertex" + OpMemberName %gl_PerVertex 0 "gl_Position" + OpMemberName %gl_PerVertex 1 "gl_PointSize" + OpMemberName %gl_PerVertex 2 "gl_ClipDistance" + OpMemberName %gl_PerVertex 3 "gl_CullDistance" + OpName %__0 "" + OpName %Camera "Camera" + OpMemberName %Camera 0 "ViewProj" + OpName %__1 "" + OpName %Transform "Transform" + OpMemberName %Transform 0 "Model" + OpName %__2 "" + OpName %Vertex_Normal "Vertex_Normal" + OpDecorate %TEST_CONSTANT SpecId 0 + OpDecorate %TEST_CONSTANT_TRUE SpecId 1 + OpDecorate %TEST_CONSTANT_FALSE SpecId 2 + OpDecorate %v_Uv Location 0 + OpDecorate %Vertex_Uv Location 2 + OpDecorate %Vertex_Position Location 0 + OpMemberDecorate %Sprite_size 0 Offset 0 + OpDecorate %Sprite_size Block + OpDecorate %_ DescriptorSet 2 + OpDecorate %_ Binding 1 + OpMemberDecorate %gl_PerVertex 0 BuiltIn Position + OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize + OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance + OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance + OpDecorate %gl_PerVertex Block + OpMemberDecorate %Camera 0 ColMajor + OpMemberDecorate %Camera 0 Offset 0 + OpMemberDecorate %Camera 0 MatrixStride 16 + OpDecorate %Camera Block + OpDecorate %__1 DescriptorSet 0 + OpDecorate %__1 Binding 0 + OpMemberDecorate %Transform 0 ColMajor + OpMemberDecorate %Transform 0 Offset 0 + OpMemberDecorate %Transform 0 MatrixStride 16 + OpDecorate %Transform Block + OpDecorate %__2 DescriptorSet 2 + OpDecorate %__2 Binding 0 + OpDecorate %Vertex_Normal Location 1 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 +%_ptr_Function_float = OpTypePointer Function %float +%TEST_CONSTANT = OpSpecConstant %float 64 + %bool = OpTypeBool +%TEST_CONSTANT_TRUE = OpSpecConstantTrue %bool + %float_0 = OpConstant %float 0 + %float_1 = OpConstant %float 1 +%TEST_CONSTANT_FALSE = OpSpecConstantFalse %bool + %v2float = OpTypeVector %float 2 +%_ptr_Output_v2float = OpTypePointer Output %v2float + %v_Uv = OpVariable %_ptr_Output_v2float Output +%_ptr_Input_v2float = OpTypePointer Input %v2float + %Vertex_Uv = OpVariable %_ptr_Input_v2float Input + %v3float = OpTypeVector %float 3 +%_ptr_Function_v3float = OpTypePointer Function %v3float +%_ptr_Input_v3float = OpTypePointer Input %v3float +%Vertex_Position = OpVariable %_ptr_Input_v3float Input +%Sprite_size = OpTypeStruct %v2float +%_ptr_Uniform_Sprite_size = OpTypePointer Uniform %Sprite_size + %_ = OpVariable %_ptr_Uniform_Sprite_size Uniform + %int = OpTypeInt 32 1 + %int_0 = OpConstant %int 0 +%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float + %v4float = OpTypeVector %float 4 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_float_uint_1 = OpTypeArray %float %uint_1 +%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 +%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex + %__0 = OpVariable %_ptr_Output_gl_PerVertex Output +%mat4v4float = OpTypeMatrix %v4float 4 + %Camera = OpTypeStruct %mat4v4float +%_ptr_Uniform_Camera = OpTypePointer Uniform %Camera + %__1 = OpVariable %_ptr_Uniform_Camera Uniform +%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float + %Transform = OpTypeStruct %mat4v4float +%_ptr_Uniform_Transform = OpTypePointer Uniform %Transform + %__2 = OpVariable %_ptr_Uniform_Transform Uniform +%_ptr_Output_v4float = OpTypePointer Output %v4float +%Vertex_Normal = OpVariable %_ptr_Input_v3float Input + %main = OpFunction %void None %3 + %5 = OpLabel +%test_constant = OpVariable %_ptr_Function_float Function + %position = OpVariable %_ptr_Function_v3float Function + %14 = OpSelect %float %TEST_CONSTANT_TRUE %float_1 %float_0 + %15 = OpFMul %float %TEST_CONSTANT %14 + %17 = OpSelect %float %TEST_CONSTANT_FALSE %float_1 %float_0 + %18 = OpFMul %float %15 %17 + OpStore %test_constant %18 + %24 = OpLoad %v2float %Vertex_Uv + OpStore %v_Uv %24 + %30 = OpLoad %v3float %Vertex_Position + %37 = OpAccessChain %_ptr_Uniform_v2float %_ %int_0 + %38 = OpLoad %v2float %37 + %39 = OpCompositeExtract %float %38 0 + %40 = OpCompositeExtract %float %38 1 + %41 = OpCompositeConstruct %v3float %39 %40 %float_1 + %42 = OpFMul %v3float %30 %41 + OpStore %position %42 + %55 = OpAccessChain %_ptr_Uniform_mat4v4float %__1 %int_0 + %56 = OpLoad %mat4v4float %55 + %60 = OpAccessChain %_ptr_Uniform_mat4v4float %__2 %int_0 + %61 = OpLoad %mat4v4float %60 + %62 = OpMatrixTimesMatrix %mat4v4float %56 %61 + %63 = OpLoad %v3float %position + %64 = OpCompositeExtract %float %63 0 + %65 = OpCompositeExtract %float %63 1 + %66 = OpCompositeExtract %float %63 2 + %67 = OpCompositeConstruct %v4float %64 %65 %66 %float_1 + %68 = OpMatrixTimesVector %v4float %62 %67 + %69 = OpLoad %float %test_constant + %70 = OpVectorTimesScalar %v4float %68 %69 + %72 = OpAccessChain %_ptr_Output_v4float %__0 %int_0 + OpStore %72 %70 + OpReturn + OpFunctionEnd diff --git a/naga/tests/in/spv/spec-constants.vert b/naga/tests/in/spv/spec-constants.vert new file mode 100644 index 00000000000..87d9aadf1ed --- /dev/null +++ b/naga/tests/in/spv/spec-constants.vert @@ -0,0 +1,31 @@ +#version 450 + +layout (constant_id = 0) const float TEST_CONSTANT = 64.0; +layout (constant_id = 1) const bool TEST_CONSTANT_TRUE = true; +layout (constant_id = 2) const bool TEST_CONSTANT_FALSE = false; +// layout (constant_id = 3) const vec2 TEST_CONSTANT_COMPOSITE = vec2(TEST_CONSTANT, 3.0); +// glslc error: 'constant_id' : can only be applied to a scalar + +layout(location = 0) in vec3 Vertex_Position; +layout(location = 1) in vec3 Vertex_Normal; +layout(location = 2) in vec2 Vertex_Uv; + +layout(location = 0) out vec2 v_Uv; + +layout(set = 0, binding = 0) uniform Camera { + mat4 ViewProj; +}; +layout(set = 2, binding = 0) uniform Transform { + mat4 Model; +}; +layout(set = 2, binding = 1) uniform Sprite_size { + vec2 size; +}; + +void main() { + float test_constant = TEST_CONSTANT * float(TEST_CONSTANT_TRUE) * float(TEST_CONSTANT_FALSE) + ;//* TEST_CONSTANT_COMPOSITE.x * TEST_CONSTANT_COMPOSITE.y; + v_Uv = Vertex_Uv; + vec3 position = Vertex_Position * vec3(size, 1.0); + gl_Position = ViewProj * Model * vec4(position, 1.0) * test_constant; +} diff --git a/naga/tests/out/ir/spec-constants.compact.ron b/naga/tests/out/ir/spec-constants.compact.ron new file mode 100644 index 00000000000..f06417b2e9e --- /dev/null +++ b/naga/tests/out/ir/spec-constants.compact.ron @@ -0,0 +1,612 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Scalar(( + kind: Bool, + width: 1, + )), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Vector( + size: Tri, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: Some("Sprite_size"), + inner: Struct( + members: [ + ( + name: Some("size"), + ty: 3, + binding: None, + offset: 0, + ), + ], + span: 8, + ), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Array( + base: 1, + size: Constant(1), + stride: 4, + ), + ), + ( + name: Some("gl_PerVertex"), + inner: Struct( + members: [ + ( + name: Some("gl_Position"), + ty: 6, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + offset: 0, + ), + ( + name: Some("gl_PointSize"), + ty: 1, + binding: None, + offset: 16, + ), + ( + name: Some("gl_ClipDistance"), + ty: 7, + binding: None, + offset: 20, + ), + ( + name: Some("gl_CullDistance"), + ty: 7, + binding: None, + offset: 24, + ), + ], + span: 32, + ), + ), + ( + name: None, + inner: Matrix( + columns: Quad, + rows: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: Some("Camera"), + inner: Struct( + members: [ + ( + name: Some("ViewProj"), + ty: 9, + binding: None, + offset: 0, + ), + ], + span: 64, + ), + ), + ( + name: Some("Transform"), + inner: Struct( + members: [ + ( + name: Some("Model"), + ty: 9, + binding: None, + offset: 0, + ), + ], + span: 64, + ), + ), + ( + name: None, + inner: Struct( + members: [ + ( + name: None, + ty: 3, + binding: Some(Location( + location: 0, + second_blend_source: false, + interpolation: Some(Perspective), + sampling: Some(Center), + )), + offset: 0, + ), + ( + name: Some("gl_Position"), + ty: 6, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + offset: 0, + ), + ], + span: 65535, + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + predeclared_types: {}, + ), + constants: [ + ( + name: None, + ty: 1, + init: 3, + ), + ( + name: None, + ty: 1, + init: 4, + ), + ], + overrides: [ + ( + name: Some("TEST_CONSTANT"), + id: Some(0), + ty: 1, + init: Some(1), + ), + ( + name: Some("TEST_CONSTANT_TRUE"), + id: Some(1), + ty: 2, + init: Some(2), + ), + ( + name: Some("TEST_CONSTANT_FALSE"), + id: Some(2), + ty: 2, + init: Some(5), + ), + ], + global_variables: [ + ( + name: Some("v_Uv"), + space: Private, + binding: None, + ty: 3, + init: None, + ), + ( + name: Some("Vertex_Uv"), + space: Private, + binding: None, + ty: 3, + init: None, + ), + ( + name: Some("Vertex_Position"), + space: Private, + binding: None, + ty: 4, + init: None, + ), + ( + name: Some(""), + space: Uniform, + binding: Some(( + group: 2, + binding: 1, + )), + ty: 5, + init: None, + ), + ( + name: Some(""), + space: Private, + binding: None, + ty: 8, + init: Some(12), + ), + ( + name: Some(""), + space: Uniform, + binding: Some(( + group: 0, + binding: 0, + )), + ty: 10, + init: None, + ), + ( + name: Some(""), + space: Uniform, + binding: Some(( + group: 2, + binding: 0, + )), + ty: 11, + init: None, + ), + ( + name: Some("Vertex_Normal"), + space: Private, + binding: None, + ty: 4, + init: None, + ), + ], + global_expressions: [ + Literal(F32(64.0)), + Literal(Bool(true)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(Bool(false)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 6, + components: [ + 6, + 6, + 6, + 7, + ], + ), + Literal(F32(1.0)), + ZeroValue(7), + ZeroValue(7), + Compose( + ty: 8, + components: [ + 8, + 9, + 10, + 11, + ], + ), + ], + functions: [ + ( + name: Some("main"), + arguments: [], + result: None, + local_variables: [ + ( + name: Some("test_constant"), + ty: 1, + init: None, + ), + ( + name: Some("position"), + ty: 4, + init: None, + ), + ], + expressions: [ + GlobalVariable(3), + GlobalVariable(2), + GlobalVariable(4), + GlobalVariable(5), + GlobalVariable(7), + GlobalVariable(1), + GlobalVariable(6), + Override(3), + Constant(2), + Constant(1), + Override(1), + Override(2), + LocalVariable(1), + LocalVariable(2), + Select( + condition: 12, + accept: 9, + reject: 10, + ), + Binary( + op: Multiply, + left: 11, + right: 15, + ), + Select( + condition: 8, + accept: 9, + reject: 10, + ), + Binary( + op: Multiply, + left: 16, + right: 17, + ), + Load( + pointer: 2, + ), + Load( + pointer: 1, + ), + AccessIndex( + base: 3, + index: 0, + ), + Load( + pointer: 21, + ), + AccessIndex( + base: 22, + index: 0, + ), + AccessIndex( + base: 22, + index: 1, + ), + Compose( + ty: 4, + components: [ + 23, + 24, + 9, + ], + ), + Binary( + op: Multiply, + left: 20, + right: 25, + ), + AccessIndex( + base: 7, + index: 0, + ), + Load( + pointer: 27, + ), + AccessIndex( + base: 5, + index: 0, + ), + Load( + pointer: 29, + ), + Binary( + op: Multiply, + left: 28, + right: 30, + ), + Load( + pointer: 14, + ), + AccessIndex( + base: 32, + index: 0, + ), + AccessIndex( + base: 32, + index: 1, + ), + AccessIndex( + base: 32, + index: 2, + ), + Compose( + ty: 6, + components: [ + 33, + 34, + 35, + 9, + ], + ), + Binary( + op: Multiply, + left: 31, + right: 36, + ), + Load( + pointer: 13, + ), + Binary( + op: Multiply, + left: 37, + right: 38, + ), + AccessIndex( + base: 4, + index: 0, + ), + ], + named_expressions: {}, + body: [ + Emit(( + start: 14, + end: 18, + )), + Store( + pointer: 13, + value: 18, + ), + Emit(( + start: 18, + end: 19, + )), + Store( + pointer: 6, + value: 19, + ), + Emit(( + start: 19, + end: 26, + )), + Store( + pointer: 14, + value: 26, + ), + Emit(( + start: 26, + end: 40, + )), + Store( + pointer: 40, + value: 39, + ), + Return( + value: None, + ), + ], + ), + ], + entry_points: [ + ( + name: "main", + stage: Vertex, + early_depth_test: None, + workgroup_size: (0, 0, 0), + function: ( + name: Some("main_wrap"), + arguments: [ + ( + name: Some("Vertex_Uv"), + ty: 3, + binding: Some(Location( + location: 2, + second_blend_source: false, + interpolation: None, + sampling: None, + )), + ), + ( + name: Some("Vertex_Position"), + ty: 4, + binding: Some(Location( + location: 0, + second_blend_source: false, + interpolation: None, + sampling: None, + )), + ), + ( + name: Some("Vertex_Normal"), + ty: 4, + binding: Some(Location( + location: 1, + second_blend_source: false, + interpolation: None, + sampling: None, + )), + ), + ], + result: Some(( + ty: 12, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + GlobalVariable(2), + FunctionArgument(1), + GlobalVariable(3), + FunctionArgument(2), + GlobalVariable(8), + GlobalVariable(1), + GlobalVariable(5), + AccessIndex( + base: 8, + index: 0, + ), + AccessIndex( + base: 9, + index: 1, + ), + Load( + pointer: 10, + ), + Unary( + op: Negate, + expr: 11, + ), + Load( + pointer: 7, + ), + Load( + pointer: 9, + ), + Compose( + ty: 12, + components: [ + 13, + 14, + ], + ), + ], + named_expressions: {}, + body: [ + Store( + pointer: 2, + value: 1, + ), + Store( + pointer: 4, + value: 3, + ), + Store( + pointer: 6, + value: 5, + ), + Call( + function: 1, + arguments: [], + result: None, + ), + Emit(( + start: 9, + end: 12, + )), + Store( + pointer: 10, + value: 12, + ), + Emit(( + start: 12, + end: 15, + )), + Return( + value: Some(15), + ), + ], + ), + ), + ], +) \ No newline at end of file diff --git a/naga/tests/out/ir/spec-constants.ron b/naga/tests/out/ir/spec-constants.ron new file mode 100644 index 00000000000..1459daf9f4a --- /dev/null +++ b/naga/tests/out/ir/spec-constants.ron @@ -0,0 +1,718 @@ +( + types: [ + ( + name: None, + inner: Scalar(( + kind: Float, + width: 4, + )), + ), + ( + name: None, + inner: Pointer( + base: 1, + space: Function, + ), + ), + ( + name: None, + inner: Scalar(( + kind: Bool, + width: 1, + )), + ), + ( + name: None, + inner: Vector( + size: Bi, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Pointer( + base: 4, + space: Private, + ), + ), + ( + name: None, + inner: Vector( + size: Tri, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Pointer( + base: 6, + space: Function, + ), + ), + ( + name: None, + inner: Pointer( + base: 6, + space: Private, + ), + ), + ( + name: Some("Sprite_size"), + inner: Struct( + members: [ + ( + name: Some("size"), + ty: 4, + binding: None, + offset: 0, + ), + ], + span: 8, + ), + ), + ( + name: None, + inner: Pointer( + base: 9, + space: Uniform, + ), + ), + ( + name: None, + inner: Scalar(( + kind: Sint, + width: 4, + )), + ), + ( + name: None, + inner: Pointer( + base: 4, + space: Uniform, + ), + ), + ( + name: None, + inner: Vector( + size: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: None, + inner: Scalar(( + kind: Uint, + width: 4, + )), + ), + ( + name: None, + inner: Array( + base: 1, + size: Constant(1), + stride: 4, + ), + ), + ( + name: Some("gl_PerVertex"), + inner: Struct( + members: [ + ( + name: Some("gl_Position"), + ty: 13, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + offset: 0, + ), + ( + name: Some("gl_PointSize"), + ty: 1, + binding: None, + offset: 16, + ), + ( + name: Some("gl_ClipDistance"), + ty: 15, + binding: None, + offset: 20, + ), + ( + name: Some("gl_CullDistance"), + ty: 15, + binding: None, + offset: 24, + ), + ], + span: 32, + ), + ), + ( + name: None, + inner: Pointer( + base: 16, + space: Private, + ), + ), + ( + name: None, + inner: Matrix( + columns: Quad, + rows: Quad, + scalar: ( + kind: Float, + width: 4, + ), + ), + ), + ( + name: Some("Camera"), + inner: Struct( + members: [ + ( + name: Some("ViewProj"), + ty: 18, + binding: None, + offset: 0, + ), + ], + span: 64, + ), + ), + ( + name: None, + inner: Pointer( + base: 19, + space: Uniform, + ), + ), + ( + name: None, + inner: Pointer( + base: 18, + space: Uniform, + ), + ), + ( + name: Some("Transform"), + inner: Struct( + members: [ + ( + name: Some("Model"), + ty: 18, + binding: None, + offset: 0, + ), + ], + span: 64, + ), + ), + ( + name: None, + inner: Pointer( + base: 22, + space: Uniform, + ), + ), + ( + name: None, + inner: Pointer( + base: 13, + space: Private, + ), + ), + ( + name: None, + inner: Struct( + members: [ + ( + name: None, + ty: 4, + binding: Some(Location( + location: 0, + second_blend_source: false, + interpolation: Some(Perspective), + sampling: Some(Center), + )), + offset: 0, + ), + ( + name: Some("gl_Position"), + ty: 13, + binding: Some(BuiltIn(Position( + invariant: false, + ))), + offset: 0, + ), + ], + span: 65535, + ), + ), + ], + special_types: ( + ray_desc: None, + ray_intersection: None, + predeclared_types: {}, + ), + constants: [ + ( + name: None, + ty: 1, + init: 3, + ), + ( + name: None, + ty: 1, + init: 4, + ), + ( + name: None, + ty: 11, + init: 6, + ), + ( + name: None, + ty: 14, + init: 7, + ), + ], + overrides: [ + ( + name: Some("TEST_CONSTANT"), + id: Some(0), + ty: 1, + init: Some(1), + ), + ( + name: Some("TEST_CONSTANT_TRUE"), + id: Some(1), + ty: 3, + init: Some(2), + ), + ( + name: Some("TEST_CONSTANT_FALSE"), + id: Some(2), + ty: 3, + init: Some(5), + ), + ], + global_variables: [ + ( + name: Some("v_Uv"), + space: Private, + binding: None, + ty: 4, + init: None, + ), + ( + name: Some("Vertex_Uv"), + space: Private, + binding: None, + ty: 4, + init: None, + ), + ( + name: Some("Vertex_Position"), + space: Private, + binding: None, + ty: 6, + init: None, + ), + ( + name: Some(""), + space: Uniform, + binding: Some(( + group: 2, + binding: 1, + )), + ty: 9, + init: None, + ), + ( + name: Some(""), + space: Private, + binding: None, + ty: 16, + init: Some(14), + ), + ( + name: Some(""), + space: Uniform, + binding: Some(( + group: 0, + binding: 0, + )), + ty: 19, + init: None, + ), + ( + name: Some(""), + space: Uniform, + binding: Some(( + group: 2, + binding: 0, + )), + ty: 22, + init: None, + ), + ( + name: Some("Vertex_Normal"), + space: Private, + binding: None, + ty: 6, + init: None, + ), + ], + global_expressions: [ + Literal(F32(64.0)), + Literal(Bool(true)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(Bool(false)), + Literal(I32(0)), + Literal(U32(1)), + Literal(F32(0.0)), + Literal(F32(1.0)), + Compose( + ty: 13, + components: [ + 8, + 8, + 8, + 9, + ], + ), + Literal(F32(1.0)), + ZeroValue(15), + ZeroValue(15), + Compose( + ty: 16, + components: [ + 10, + 11, + 12, + 13, + ], + ), + ], + functions: [ + ( + name: Some("main"), + arguments: [], + result: None, + local_variables: [ + ( + name: Some("test_constant"), + ty: 1, + init: None, + ), + ( + name: Some("position"), + ty: 6, + init: None, + ), + ], + expressions: [ + GlobalVariable(3), + GlobalVariable(2), + GlobalVariable(4), + GlobalVariable(5), + GlobalVariable(7), + GlobalVariable(1), + GlobalVariable(6), + GlobalVariable(8), + Override(3), + Constant(2), + Constant(3), + Constant(4), + Constant(1), + Override(1), + Override(2), + LocalVariable(1), + LocalVariable(2), + Select( + condition: 15, + accept: 10, + reject: 13, + ), + Binary( + op: Multiply, + left: 14, + right: 18, + ), + Select( + condition: 9, + accept: 10, + reject: 13, + ), + Binary( + op: Multiply, + left: 19, + right: 20, + ), + Load( + pointer: 2, + ), + Load( + pointer: 1, + ), + AccessIndex( + base: 3, + index: 0, + ), + Load( + pointer: 24, + ), + AccessIndex( + base: 25, + index: 0, + ), + AccessIndex( + base: 25, + index: 1, + ), + Compose( + ty: 6, + components: [ + 26, + 27, + 10, + ], + ), + Binary( + op: Multiply, + left: 23, + right: 28, + ), + AccessIndex( + base: 7, + index: 0, + ), + Load( + pointer: 30, + ), + AccessIndex( + base: 5, + index: 0, + ), + Load( + pointer: 32, + ), + Binary( + op: Multiply, + left: 31, + right: 33, + ), + Load( + pointer: 17, + ), + AccessIndex( + base: 35, + index: 0, + ), + AccessIndex( + base: 35, + index: 1, + ), + AccessIndex( + base: 35, + index: 2, + ), + Compose( + ty: 13, + components: [ + 36, + 37, + 38, + 10, + ], + ), + Binary( + op: Multiply, + left: 34, + right: 39, + ), + Load( + pointer: 16, + ), + Binary( + op: Multiply, + left: 40, + right: 41, + ), + AccessIndex( + base: 4, + index: 0, + ), + ], + named_expressions: {}, + body: [ + Emit(( + start: 17, + end: 21, + )), + Store( + pointer: 16, + value: 21, + ), + Emit(( + start: 21, + end: 22, + )), + Store( + pointer: 6, + value: 22, + ), + Emit(( + start: 22, + end: 29, + )), + Store( + pointer: 17, + value: 29, + ), + Emit(( + start: 29, + end: 43, + )), + Store( + pointer: 43, + value: 42, + ), + Return( + value: None, + ), + ], + ), + ], + entry_points: [ + ( + name: "main", + stage: Vertex, + early_depth_test: None, + workgroup_size: (0, 0, 0), + function: ( + name: Some("main_wrap"), + arguments: [ + ( + name: Some("Vertex_Uv"), + ty: 4, + binding: Some(Location( + location: 2, + second_blend_source: false, + interpolation: None, + sampling: None, + )), + ), + ( + name: Some("Vertex_Position"), + ty: 6, + binding: Some(Location( + location: 0, + second_blend_source: false, + interpolation: None, + sampling: None, + )), + ), + ( + name: Some("Vertex_Normal"), + ty: 6, + binding: Some(Location( + location: 1, + second_blend_source: false, + interpolation: None, + sampling: None, + )), + ), + ], + result: Some(( + ty: 25, + binding: None, + )), + local_variables: [], + expressions: [ + FunctionArgument(0), + GlobalVariable(2), + FunctionArgument(1), + GlobalVariable(3), + FunctionArgument(2), + GlobalVariable(8), + GlobalVariable(1), + GlobalVariable(5), + AccessIndex( + base: 8, + index: 0, + ), + AccessIndex( + base: 9, + index: 1, + ), + Load( + pointer: 10, + ), + Unary( + op: Negate, + expr: 11, + ), + Load( + pointer: 7, + ), + Load( + pointer: 9, + ), + Compose( + ty: 25, + components: [ + 13, + 14, + ], + ), + ], + named_expressions: {}, + body: [ + Store( + pointer: 2, + value: 1, + ), + Store( + pointer: 4, + value: 3, + ), + Store( + pointer: 6, + value: 5, + ), + Call( + function: 1, + arguments: [], + result: None, + ), + Emit(( + start: 9, + end: 12, + )), + Store( + pointer: 10, + value: 12, + ), + Emit(( + start: 12, + end: 15, + )), + Return( + value: Some(15), + ), + ], + ), + ), + ], +) \ No newline at end of file diff --git a/naga/tests/snapshots.rs b/naga/tests/snapshots.rs index f7eb01789e7..3e45faeb166 100644 --- a/naga/tests/snapshots.rs +++ b/naga/tests/snapshots.rs @@ -956,6 +956,7 @@ fn convert_spv_all() { Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ); convert_spv("builtin-accessed-outside-entrypoint", true, Targets::WGSL); + convert_spv("spec-constants", true, Targets::IR); } #[cfg(feature = "glsl-in")] diff --git a/player/src/bin/play.rs b/player/src/bin/play.rs index 7e3cbad11bd..5c438dd20da 100644 --- a/player/src/bin/play.rs +++ b/player/src/bin/play.rs @@ -87,7 +87,7 @@ fn main() { &desc, None, Some(id), - Some(id.transmute()) + Some(id.into_queue_id()) )); if let Some(e) = error { panic!("{:?}", e); diff --git a/player/src/lib.rs b/player/src/lib.rs index eb89e43f734..ca3a4b6a579 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -336,7 +336,7 @@ impl GlobalPlay for wgc::global::Global { let bin = std::fs::read(dir.join(data)).unwrap(); let size = (range.end - range.start) as usize; if queued { - self.queue_write_buffer::(device.transmute(), id, range.start, &bin) + self.queue_write_buffer::(device.into_queue_id(), id, range.start, &bin) .unwrap(); } else { self.device_wait_for_buffer::(device, id).unwrap(); @@ -351,23 +351,27 @@ impl GlobalPlay for wgc::global::Global { size, } => { let bin = std::fs::read(dir.join(data)).unwrap(); - self.queue_write_texture::(device.transmute(), &to, &bin, &layout, &size) + self.queue_write_texture::(device.into_queue_id(), &to, &bin, &layout, &size) .unwrap(); } Action::Submit(_index, ref commands) if commands.is_empty() => { - self.queue_submit::(device.transmute(), &[]).unwrap(); + self.queue_submit::(device.into_queue_id(), &[]).unwrap(); } Action::Submit(_index, commands) => { let (encoder, error) = self.device_create_command_encoder::( device, &wgt::CommandEncoderDescriptor { label: None }, - Some(comb_manager.process(device.backend()).transmute()), + Some( + comb_manager + .process(device.backend()) + .into_command_encoder_id(), + ), ); if let Some(e) = error { panic!("{e}"); } let cmdbuf = self.encode_commands::(encoder, commands); - self.queue_submit::(device.transmute(), &[cmdbuf]) + self.queue_submit::(device.into_queue_id(), &[cmdbuf]) .unwrap(); } } diff --git a/player/tests/test.rs b/player/tests/test.rs index c04622b42ec..a6c7222b610 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -115,7 +115,7 @@ impl Test<'_> { }, None, Some(device_id), - Some(device_id.transmute()) + Some(device_id.into_queue_id()) )); if let Some(e) = error { panic!("{:?}", e); diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index c5149053c5f..ef5f56d0676 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-core" -version = "0.19.0" +version = "0.19.3" authors = ["gfx-rs developers"] edition = "2021" description = "WebGPU core logic on wgpu-hal" @@ -117,17 +117,17 @@ thiserror = "1" [dependencies.naga] path = "../naga" -version = "0.19.0" +version = "0.19.2" [dependencies.wgt] package = "wgpu-types" path = "../wgpu-types" -version = "0.19.0" +version = "0.19.2" [dependencies.hal] package = "wgpu-hal" path = "../wgpu-hal" -version = "0.19.0" +version = "0.19.3" default_features = false [target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 8689af2ac15..bea63b0ba48 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -462,8 +462,6 @@ pub struct BindGroupLayoutDescriptor<'a> { pub entries: Cow<'a, [wgt::BindGroupLayoutEntry]>, } -pub type BindGroupLayouts = crate::storage::Storage>; - /// Bind group layout. #[derive(Debug)] pub struct BindGroupLayout { diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index b38324984ca..98f4360a653 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -36,6 +36,7 @@ use serde::Serialize; use thiserror::Error; +use std::sync::Arc; use std::{fmt, mem, str}; #[doc(hidden)] @@ -365,7 +366,8 @@ impl Global { let hub = A::hub(self); - let cmd_buf = CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(pass_scope)?; + let cmd_buf: Arc> = + CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(pass_scope)?; let device = &cmd_buf.device; if !device.is_valid() { return Err(ComputePassErrorInner::InvalidDevice( diff --git a/wgpu-core/src/command/mod.rs b/wgpu-core/src/command/mod.rs index ab413db737f..8d5d8b64d23 100644 --- a/wgpu-core/src/command/mod.rs +++ b/wgpu-core/src/command/mod.rs @@ -253,7 +253,7 @@ impl CommandBuffer { id: id::CommandEncoderId, ) -> Result, CommandEncoderError> { let storage = hub.command_buffers.read(); - match storage.get(id.transmute()) { + match storage.get(id.into_command_buffer_id()) { Ok(cmd_buf) => match cmd_buf.data.lock().as_ref().unwrap().status { CommandEncoderStatus::Recording => Ok(cmd_buf.clone()), CommandEncoderStatus::Finished => Err(CommandEncoderError::NotRecording), @@ -286,11 +286,9 @@ impl CommandBuffer { } pub(crate) fn from_arc_into_baked(self: Arc) -> BakedCommands { - if let Some(mut command_buffer) = Arc::into_inner(self) { - command_buffer.extract_baked_commands() - } else { - panic!("CommandBuffer cannot be destroyed because is still in use"); - } + let mut command_buffer = Arc::into_inner(self) + .expect("CommandBuffer cannot be destroyed because is still in use"); + command_buffer.extract_baked_commands() } } @@ -418,7 +416,7 @@ impl Global { let hub = A::hub(self); - let error = match hub.command_buffers.get(encoder_id.transmute()) { + let error = match hub.command_buffers.get(encoder_id.into_command_buffer_id()) { Ok(cmd_buf) => { let mut cmd_buf_data = cmd_buf.data.lock(); let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); @@ -444,7 +442,7 @@ impl Global { Err(_) => Some(CommandEncoderError::Invalid), }; - (encoder_id.transmute(), error) + (encoder_id.into_command_buffer_id(), error) } pub fn command_encoder_push_debug_group( @@ -700,7 +698,7 @@ impl PrettyError for PassErrorScope { // This error is not in the error chain, only notes are needed match *self { Self::Pass(id) => { - fmt.command_buffer_label(&id.transmute()); + fmt.command_buffer_label(&id.into_command_buffer_id()); } Self::SetBindGroup(id) => { fmt.bind_group_label(&id); diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 7e859e3cc89..f4db9aaf34d 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -1343,7 +1343,8 @@ impl Global { let hub = A::hub(self); - let cmd_buf = CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(pass_scope)?; + let cmd_buf: Arc> = + CommandBuffer::get_encoder(hub, encoder_id).map_pass_err(pass_scope)?; let device = &cmd_buf.device; let snatch_guard = device.snatchable_lock.read(); @@ -2409,7 +2410,10 @@ impl Global { (trackers, pending_discard_init_fixups) }; - let cmd_buf = hub.command_buffers.get(encoder_id.transmute()).unwrap(); + let cmd_buf = hub + .command_buffers + .get(encoder_id.into_command_buffer_id()) + .unwrap(); let mut cmd_buf_data = cmd_buf.data.lock(); let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 7f682f55599..9c54dfc193f 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -1334,7 +1334,9 @@ impl Global { profiling::scope!("Device::create_command_encoder"); let hub = A::hub(self); - let fid = hub.command_buffers.prepare(id_in.map(|id| id.transmute())); + let fid = hub + .command_buffers + .prepare(id_in.map(|id| id.into_command_buffer_id())); let error = loop { let device = match hub.devices.get(device_id) { @@ -1369,11 +1371,11 @@ impl Global { let (id, _) = fid.assign(Arc::new(command_buffer)); api_log!("Device::create_command_encoder -> {id:?}"); - return (id.transmute(), None); + return (id.into_command_encoder_id(), None); }; let id = fid.assign_error(desc.label.borrow_or_default()); - (id.transmute(), Some(error)) + (id.into_command_encoder_id(), Some(error)) } pub fn command_buffer_label(&self, id: id::CommandBufferId) -> String { @@ -1388,7 +1390,7 @@ impl Global { if let Some(cmd_buf) = hub .command_buffers - .unregister(command_encoder_id.transmute()) + .unregister(command_encoder_id.into_command_buffer_id()) { cmd_buf.data.lock().as_mut().unwrap().encoder.discard(); cmd_buf @@ -1400,7 +1402,7 @@ impl Global { pub fn command_buffer_drop(&self, command_buffer_id: id::CommandBufferId) { profiling::scope!("CommandBuffer::drop"); api_log!("CommandBuffer::drop {command_buffer_id:?}"); - self.command_encoder_drop::(command_buffer_id.transmute()) + self.command_encoder_drop::(command_buffer_id.into_command_encoder_id()) } pub fn device_create_render_bundle_encoder( @@ -2121,7 +2123,7 @@ impl Global { .map_err(|_| DeviceError::Invalid)?; if let wgt::Maintain::WaitForSubmissionIndex(submission_index) = maintain { - if submission_index.queue_id != device_id.transmute() { + if submission_index.queue_id != device_id.into_queue_id() { return Err(WaitIdleError::WrongSubmissionIndex( submission_index.queue_id, device_id, diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index 26d6c8b519b..075cd30e604 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -34,9 +34,9 @@ use thiserror::Error; use super::Device; pub struct Queue { - pub device: Option>>, - pub raw: Option, - pub info: ResourceInfo>, + pub(crate) device: Option>>, + pub(crate) raw: Option, + pub(crate) info: ResourceInfo>, } impl Resource for Queue { @@ -707,7 +707,7 @@ impl Global { .get(destination.texture) .map_err(|_| TransferError::InvalidTexture(destination.texture))?; - if dst.device.as_info().id() != queue_id.transmute() { + if dst.device.as_info().id().into_queue_id() != queue_id { return Err(DeviceError::WrongDevice.into()); } @@ -1191,7 +1191,7 @@ impl Global { Err(_) => continue, }; - if cmdbuf.device.as_info().id() != queue_id.transmute() { + if cmdbuf.device.as_info().id().into_queue_id() != queue_id { return Err(DeviceError::WrongDevice.into()); } @@ -1210,13 +1210,10 @@ impl Global { )); } if !cmdbuf.is_finished() { - if let Some(cmdbuf) = Arc::into_inner(cmdbuf) { - device.destroy_command_buffer(cmdbuf); - } else { - panic!( - "Command buffer cannot be destroyed because is still in use" - ); - } + let cmdbuf = Arc::into_inner(cmdbuf).expect( + "Command buffer cannot be destroyed because is still in use", + ); + device.destroy_command_buffer(cmdbuf); continue; } diff --git a/wgpu-core/src/global.rs b/wgpu-core/src/global.rs index 9a8c43bf338..6f6756a88cc 100644 --- a/wgpu-core/src/global.rs +++ b/wgpu-core/src/global.rs @@ -45,7 +45,7 @@ impl GlobalReport { pub struct Global { pub instance: Instance, - pub surfaces: Registry, + pub(crate) surfaces: Registry, pub(crate) hubs: Hubs, } @@ -155,11 +155,9 @@ impl Drop for Global { // destroy surfaces for element in surfaces_locked.map.drain(..) { if let Element::Occupied(arc_surface, _) = element { - if let Some(surface) = Arc::into_inner(arc_surface) { - self.instance.destroy_surface(surface); - } else { - panic!("Surface cannot be destroyed because is still in use"); - } + let surface = Arc::into_inner(arc_surface) + .expect("Surface cannot be destroyed because is still in use"); + self.instance.destroy_surface(surface); } } } diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 0f4589c8b33..6fdc0c2e57e 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -169,23 +169,23 @@ impl HubReport { /// /// [`A::hub(global)`]: HalApi::hub pub struct Hub { - pub adapters: Registry>, - pub devices: Registry>, - pub queues: Registry>, - pub pipeline_layouts: Registry>, - pub shader_modules: Registry>, - pub bind_group_layouts: Registry>, - pub bind_groups: Registry>, - pub command_buffers: Registry>, - pub render_bundles: Registry>, - pub render_pipelines: Registry>, - pub compute_pipelines: Registry>, - pub query_sets: Registry>, - pub buffers: Registry>, - pub staging_buffers: Registry>, - pub textures: Registry>, - pub texture_views: Registry>, - pub samplers: Registry>, + pub(crate) adapters: Registry>, + pub(crate) devices: Registry>, + pub(crate) queues: Registry>, + pub(crate) pipeline_layouts: Registry>, + pub(crate) shader_modules: Registry>, + pub(crate) bind_group_layouts: Registry>, + pub(crate) bind_groups: Registry>, + pub(crate) command_buffers: Registry>, + pub(crate) render_bundles: Registry>, + pub(crate) render_pipelines: Registry>, + pub(crate) compute_pipelines: Registry>, + pub(crate) query_sets: Registry>, + pub(crate) buffers: Registry>, + pub(crate) staging_buffers: Registry>, + pub(crate) textures: Registry>, + pub(crate) texture_views: Registry>, + pub(crate) samplers: Registry>, } impl Hub { diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index 72b74218d0e..1fa89f2bf09 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -91,8 +91,7 @@ pub fn as_option_slice(ids: &[Id]) -> &[Option>] { /// An identifier for a wgpu object. /// -/// An `Id` value identifies a value stored in a [`Global`]'s [`Hub`]'s [`Storage`]. -/// `Storage` implements [`Index`] and [`IndexMut`], accepting `Id` values as indices. +/// An `Id` value identifies a value stored in a [`Global`]'s [`Hub`]. /// /// ## Note on `Id` typing /// @@ -112,10 +111,7 @@ pub fn as_option_slice(ids: &[Id]) -> &[Option>] { /// [`Global`]: crate::global::Global /// [`Hub`]: crate::hub::Hub /// [`Hub`]: crate::hub::Hub -/// [`Storage`]: crate::storage::Storage /// [`Texture`]: crate::resource::Texture -/// [`Index`]: std::ops::Index -/// [`IndexMut`]: std::ops::IndexMut /// [`Registry`]: crate::hub::Registry /// [`Empty`]: hal::api::Empty #[repr(transparent)] @@ -182,15 +178,6 @@ where self.0.backend() } - /// Transmute this identifier to one with a different marker trait. - /// - /// Legal use is governed through a sealed trait, however it's correctness - /// depends on the current implementation of `wgpu-core`. - #[inline] - pub const fn transmute>(self) -> Id { - Id(self.0, PhantomData) - } - #[inline] pub fn zip(index: Index, epoch: Epoch, backend: Backend) -> Self { Id(RawId::zip(index, epoch, backend), PhantomData) @@ -202,20 +189,6 @@ where } } -pub(crate) mod transmute { - // This trait is effectively sealed to prevent illegal transmutes. - pub trait Transmute: super::Marker {} - - // Self-transmute is always legal. - impl Transmute for T where T: super::Marker {} - - // TODO: Remove these once queues have their own identifiers. - impl Transmute for super::markers::Device {} - impl Transmute for super::markers::Queue {} - impl Transmute for super::markers::CommandEncoder {} - impl Transmute for super::markers::CommandBuffer {} -} - impl Copy for Id where T: Marker {} impl Clone for Id @@ -349,6 +322,24 @@ ids! { pub type QuerySetId QuerySet; } +impl CommandEncoderId { + pub fn into_command_buffer_id(self) -> CommandBufferId { + Id(self.0, PhantomData) + } +} + +impl CommandBufferId { + pub fn into_command_encoder_id(self) -> CommandEncoderId { + Id(self.0, PhantomData) + } +} + +impl DeviceId { + pub fn into_queue_id(self) -> QueueId { + Id(self.0, PhantomData) + } +} + #[test] fn test_id_backend() { for &b in &[ diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 55c7b581e97..20e67d5f71b 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -667,22 +667,19 @@ impl Global { } let surface = self.surfaces.unregister(id); - if let Some(surface) = Arc::into_inner(surface.unwrap()) { - if let Some(present) = surface.presentation.lock().take() { - #[cfg(vulkan)] - unconfigure::(self, &surface.raw, &present); - #[cfg(metal)] - unconfigure::(self, &surface.raw, &present); - #[cfg(dx12)] - unconfigure::(self, &surface.raw, &present); - #[cfg(gles)] - unconfigure::(self, &surface.raw, &present); - } - - self.instance.destroy_surface(surface); - } else { - panic!("Surface cannot be destroyed because is still in use"); + let surface = Arc::into_inner(surface.unwrap()) + .expect("Surface cannot be destroyed because is still in use"); + if let Some(present) = surface.presentation.lock().take() { + #[cfg(vulkan)] + unconfigure::(self, &surface.raw, &present); + #[cfg(metal)] + unconfigure::(self, &surface.raw, &present); + #[cfg(dx12)] + unconfigure::(self, &surface.raw, &present); + #[cfg(gles)] + unconfigure::(self, &surface.raw, &present); } + self.instance.destroy_surface(surface); } fn enumerate( diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index 878d6145372..f78abcaa6a8 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -37,7 +37,7 @@ impl RegistryReport { /// any other dependent resource /// #[derive(Debug)] -pub struct Registry { +pub(crate) struct Registry { identity: Arc>, storage: RwLock>, backend: Backend, @@ -146,16 +146,20 @@ impl Registry { pub(crate) fn write<'a>(&'a self) -> RwLockWriteGuard<'a, Storage> { self.storage.write() } - pub fn unregister_locked(&self, id: Id, storage: &mut Storage) -> Option> { + pub(crate) fn unregister_locked( + &self, + id: Id, + storage: &mut Storage, + ) -> Option> { self.identity.free(id); storage.remove(id) } - pub fn force_replace(&self, id: Id, mut value: T) { + pub(crate) fn force_replace(&self, id: Id, mut value: T) { let mut storage = self.storage.write(); value.as_info_mut().set_id(id); storage.force_replace(id, value) } - pub fn force_replace_with_error(&self, id: Id, label: &str) { + pub(crate) fn force_replace_with_error(&self, id: Id, label: &str) { let mut storage = self.storage.write(); storage.remove(id); storage.insert_error(id, label); @@ -167,7 +171,7 @@ impl Registry { value } - pub fn label_for_resource(&self, id: Id) -> String { + pub(crate) fn label_for_resource(&self, id: Id) -> String { let guard = self.storage.read(); let type_name = guard.kind(); diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 8256b95539a..0c5f7123268 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -58,7 +58,7 @@ use std::{ /// [`Device`]: crate::device::resource::Device /// [`Buffer`]: crate::resource::Buffer #[derive(Debug)] -pub struct ResourceInfo { +pub(crate) struct ResourceInfo { id: Option>, tracker_index: TrackerIndex, tracker_indices: Option>, @@ -144,7 +144,7 @@ impl ResourceInfo { pub(crate) type ResourceType = &'static str; -pub trait Resource: 'static + Sized + WasmNotSendSync { +pub(crate) trait Resource: 'static + Sized + WasmNotSendSync { type Marker: Marker; const TYPE: ResourceType; fn as_info(&self) -> &ResourceInfo; @@ -373,10 +373,10 @@ pub type BufferAccessResult = Result<(), BufferAccessError>; #[derive(Debug)] pub(crate) struct BufferPendingMapping { - pub range: Range, - pub op: BufferMapOperation, + pub(crate) range: Range, + pub(crate) op: BufferMapOperation, // hold the parent alive while the mapping is active - pub _parent_buffer: Arc>, + pub(crate) _parent_buffer: Arc>, } pub type BufferDescriptor<'a> = wgt::BufferDescriptor>; @@ -737,7 +737,7 @@ pub(crate) enum TextureInner { } impl TextureInner { - pub fn raw(&self) -> Option<&A::Texture> { + pub(crate) fn raw(&self) -> Option<&A::Texture> { match self { Self::Native { raw } => Some(raw), Self::Surface { raw: Some(tex), .. } => Some(tex.borrow()), @@ -1043,7 +1043,10 @@ impl Global { profiling::scope!("CommandEncoder::as_hal"); let hub = A::hub(self); - let cmd_buf = hub.command_buffers.get(id.transmute()).unwrap(); + let cmd_buf = hub + .command_buffers + .get(id.into_command_buffer_id()) + .unwrap(); let mut cmd_buf_data = cmd_buf.data.lock(); let cmd_buf_data = cmd_buf_data.as_mut().unwrap(); let cmd_buf_raw = cmd_buf_data.encoder.open().ok(); diff --git a/wgpu-core/src/storage.rs b/wgpu-core/src/storage.rs index 554ced8b7d5..03874b81048 100644 --- a/wgpu-core/src/storage.rs +++ b/wgpu-core/src/storage.rs @@ -29,11 +29,14 @@ pub(crate) struct InvalidId; /// A table of `T` values indexed by the id type `I`. /// +/// `Storage` implements [`std::ops::Index`], accepting `Id` values as +/// indices. +/// /// The table is represented as a vector indexed by the ids' index /// values, so you should use an id allocator like `IdentityManager` /// that keeps the index values dense and close to zero. #[derive(Debug)] -pub struct Storage +pub(crate) struct Storage where T: Resource, { diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 71342a0b74d..ab21c6dfe36 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-hal" -version = "0.19.0" +version = "0.19.3" authors = ["gfx-rs developers"] edition = "2021" description = "WebGPU hardware abstraction layer" @@ -110,7 +110,7 @@ glow = { version = "0.13.1", optional = true } [dependencies.wgt] package = "wgpu-types" path = "../wgpu-types" -version = "0.19.0" +version = "0.19.2" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] # backend: Vulkan @@ -178,7 +178,7 @@ ndk-sys = { version = "0.5.0", optional = true } [dependencies.naga] path = "../naga" -version = "0.19.0" +version = "0.19.2" [build-dependencies] cfg_aliases.workspace = true @@ -186,7 +186,7 @@ cfg_aliases.workspace = true # DEV dependencies [dev-dependencies.naga] path = "../naga" -version = "0.19.0" +version = "0.19.2" features = ["wgsl-in"] [dev-dependencies] diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index b54e5ce48d3..f8024f516e7 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wgpu-types" -version = "0.19.0" +version = "0.19.2" authors = ["gfx-rs developers"] edition = "2021" description = "WebGPU types" @@ -46,4 +46,4 @@ web-sys = { version = "0.3.69", features = [ [dev-dependencies] serde = { version = "1", features = ["serde_derive"] } -serde_json = "1.0.113" +serde_json = "1.0.115" diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index c73b0fbd1dd..edc24cee381 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -631,7 +631,7 @@ impl crate::Context for ContextWgpuCore { id: queue_id, error_sink, }; - ready(Ok((device_id, device, device_id.transmute(), queue))) + ready(Ok((device_id, device, device_id.into_queue_id(), queue))) } fn instance_poll_all_devices(&self, force_wait: bool) -> bool { @@ -1839,8 +1839,7 @@ impl crate::Context for ContextWgpuCore { if let Err(cause) = wgc::gfx_select!( encoder => self.0.command_encoder_run_compute_pass(*encoder, pass_data) ) { - let name = - wgc::gfx_select!(encoder => self.0.command_buffer_label(encoder.transmute())); + let name = wgc::gfx_select!(encoder => self.0.command_buffer_label(encoder.into_command_buffer_id())); self.handle_error( &encoder_data.error_sink, cause, @@ -1923,8 +1922,7 @@ impl crate::Context for ContextWgpuCore { if let Err(cause) = wgc::gfx_select!(encoder => self.0.command_encoder_run_render_pass(*encoder, pass_data)) { - let name = - wgc::gfx_select!(encoder => self.0.command_buffer_label(encoder.transmute())); + let name = wgc::gfx_select!(encoder => self.0.command_buffer_label(encoder.into_command_buffer_id())); self.handle_error( &encoder_data.error_sink, cause,