summaryrefslogtreecommitdiffstats
path: root/third_party/rust/wgpu-hal
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/wgpu-hal
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/wgpu-hal')
-rw-r--r--third_party/rust/wgpu-hal/.cargo-checksum.json2
-rw-r--r--third_party/rust/wgpu-hal/Cargo.toml12
-rw-r--r--third_party/rust/wgpu-hal/src/dx12/adapter.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/dx12/command.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/dx12/device.rs15
-rw-r--r--third_party/rust/wgpu-hal/src/dx12/instance.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/dx12/mod.rs8
-rw-r--r--third_party/rust/wgpu-hal/src/empty.rs24
-rw-r--r--third_party/rust/wgpu-hal/src/gles/adapter.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/gles/command.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/gles/device.rs21
-rw-r--r--third_party/rust/wgpu-hal/src/gles/egl.rs8
-rw-r--r--third_party/rust/wgpu-hal/src/gles/queue.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/gles/web.rs8
-rw-r--r--third_party/rust/wgpu-hal/src/gles/wgl.rs8
-rw-r--r--third_party/rust/wgpu-hal/src/lib.rs253
-rw-r--r--third_party/rust/wgpu-hal/src/metal/adapter.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/metal/command.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/metal/device.rs15
-rw-r--r--third_party/rust/wgpu-hal/src/metal/mod.rs8
-rw-r--r--third_party/rust/wgpu-hal/src/metal/surface.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/vulkan/adapter.rs181
-rw-r--r--third_party/rust/wgpu-hal/src/vulkan/command.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/vulkan/device.rs4
-rw-r--r--third_party/rust/wgpu-hal/src/vulkan/instance.rs8
-rw-r--r--third_party/rust/wgpu-hal/src/vulkan/mod.rs6
26 files changed, 449 insertions, 172 deletions
diff --git a/third_party/rust/wgpu-hal/.cargo-checksum.json b/third_party/rust/wgpu-hal/.cargo-checksum.json
index de9bc38719..2cba88cfdf 100644
--- a/third_party/rust/wgpu-hal/.cargo-checksum.json
+++ b/third_party/rust/wgpu-hal/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"eaa7b2b51fbe98c0721dc52d94c64b48d2d6e351bf36da3e756378a8d8ebc1de","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","README.md":"099ee611a911dc19330a61bffcde13663929a51b25ac528ee33ea796d695491e","build.rs":"c80bdc0152a00471eec6ed0dd0f7d55d0b975498a00ba05e94100c84ad639a49","examples/halmark/main.rs":"4604737f714943383c57feac2b8468ecf15e9e60c54a5303455e9953ec5c79fb","examples/halmark/shader.wgsl":"26c256ec36d6f0e9a1647431ca772766bee4382d64eaa718ba7b488dcfb6bcca","examples/raw-gles.em.html":"70fbe68394a1a4522192de1dcfaf7d399f60d7bdf5de70b708f9bb0417427546","examples/raw-gles.rs":"095113a1ba0851652a77aabfc8fa6ea7edcc2d09e91fd1e5009ead87d5998ea9","examples/ray-traced-triangle/main.rs":"955c2b8700c3b2daf14e9ef963ff499ed185b6f349dbc63caa422b2cf4942a1f","examples/ray-traced-triangle/shader.wgsl":"cc10caf92746724a71f6dd0dbc3a71e57b37c7d1d83278556805a535c0728a9d","src/auxil/dxgi/conv.rs":"760cd4eaa79b530368a30140b96bf73ac4fbdb4025eb95f0bed581638c8bb1cb","src/auxil/dxgi/exception.rs":"f0cfb5a0adcdc3b6db909601fee51ad51368f5da269bcd46e4dbea45a3bec4b1","src/auxil/dxgi/factory.rs":"5f861fbfe2f4cce08722a95283549b8f62b96f24a306d080d9f1730ae53501d8","src/auxil/dxgi/mod.rs":"a202564d9ac97530b16a234b87d180cd345aae705e082a9b1177dcde813645f9","src/auxil/dxgi/result.rs":"79fe5aa17a2b21a7f06b1b604200c3c3e73fca31e8193aab80b5b15e7e9818a0","src/auxil/dxgi/time.rs":"b6f966b250e9424d5d7e4065f2108cba87197c1e30baae6d87083055d1bc5a4b","src/auxil/mod.rs":"720ef2aae258733322a3274fd858f91effb8951dabaf7bbfd8a9a0be2d2dba97","src/auxil/renderdoc.rs":"c2f849f70f576b0c9b0d32dd155b6a6353f74dff59cbeeaa994a12789d047c0f","src/dx12/adapter.rs":"7d647c9a1211e564fb1220c65df26fe2c519e5eddfa89291eaea45be4b60746a","src/dx12/command.rs":"6fe77b8b27c6428128ed0c3bcf7517e511c3c1eec8491a08936a696d5cb30751","src/dx12/conv.rs":"94d35f117ae003b07049f3a0bc6c45a0ffda9fb8053233d39c173cfb1b644403","src/dx12/descriptor.rs":"e06eb08bee4c805fa76b6ab791893b5b563ee60de9c8f8d8e0e21ab97ade5664","src/dx12/device.rs":"f7ca4a30085fdaecc321a01344f9d8cd907b7ba5a1b92f13a3bd9faad1934ed8","src/dx12/instance.rs":"351a4e0d526de8eafc74bf5f01a41da48efa39e0c66704a85da72e1140b159d4","src/dx12/mod.rs":"4b9d5e2414d628ed537f32f46604eeb95912ad9d5ee61cf4ce11c8dd6a88c8ab","src/dx12/shader_compilation.rs":"5087adb8576e2d7751619dfdf8b37c573bb4e494290c594077ca3208cce1e746","src/dx12/suballocation.rs":"6939fc36223a15cc070c744d0418f9ac6fa2829d794af17cdea7c61eb5f8d2c0","src/dx12/types.rs":"9573736baaa0ef607367c3b72144556d24faf677a26bb8df49a4372a1348e06b","src/dx12/view.rs":"792772e9c87840dcd045b7381a03162eb4a501492a95ca586e77e81aed621c67","src/empty.rs":"5c3a5e39d45b4522ff3496fe6ec3b4a7afd906b6095dff1cad113c826aa9ea62","src/gles/adapter.rs":"3175c86212b6c8caa099a3e34750c18251107461314c02f77c984e5b8301051a","src/gles/command.rs":"9f9ef3d97fcb2bc521b85141dee1ca9e8fe06b08d861766c3b3e9a2f3a53b494","src/gles/conv.rs":"5d15d3a33032d32ff99bc338fba0689fa54c76d0714e335fe48523d841df386f","src/gles/device.rs":"7ccd7aa3b878159190092bf279158289d754cc695bd27b9ec7177cd9b86b37c5","src/gles/egl.rs":"ad9b0ddc66877ae4088511283b8c860dd09b0b4d2c1fc51246c6935aa16703eb","src/gles/emscripten.rs":"19bb73a9d140645f3f32cd48b002151711a9b8456e213eab5f3a2be79239e147","src/gles/mod.rs":"b8999f76ad45e07312b291457100f12699ba6a2635c1f1913b0648e9a9394015","src/gles/queue.rs":"3ead252c54c673da6736a0c0c6b63c848791bc78042def3f3ffff8ffce2c6e64","src/gles/shaders/clear.frag":"9133ed8ed97d3641fbb6b5f5ea894a3554c629ccc1b80a5fc9221d7293aa1954","src/gles/shaders/clear.vert":"a543768725f4121ff2e9e1fb5b00644931e9d6f2f946c0ef01968afb5a135abd","src/gles/shaders/srgb_present.frag":"dd9a43c339a2fa4ccf7f6a1854c6f400cabf271a7d5e9230768e9f39d47f3ff5","src/gles/shaders/srgb_present.vert":"6e85d489403d80b81cc94790730bb53b309dfc5eeede8f1ea3412a660f31d357","src/gles/web.rs":"d263695d45736d3c6ec3528c8c33fe6cf3767d3429a13a92d88b4fdc7b6340fb","src/gles/wgl.rs":"06e947912c357c5275090b12b7e31e596ff264fd460e2449b6db4b79284eb74d","src/lib.rs":"c8b8a95f5bfd58eaada0af2cd0abc80f888aeea85969a1363f4061cc9b542ca4","src/metal/adapter.rs":"bb5d0ca1cecbd914cbb29487303be4ed69035469a8bc137784d5bbb6ab36cec7","src/metal/command.rs":"661b38a75d4f4cd1b0d6957f1f09db0743ec3a13bbafba9baa931894ee193f48","src/metal/conv.rs":"0bce6a8d0ccef16783475803d70d35e03ab7938c19374e22c9d253abe1f8b111","src/metal/device.rs":"c5deeecf475e0aa4b2027c656ea19207716f84b56cfa7c9132dca504d1abebfb","src/metal/mod.rs":"f6d12246a6c7e6d998db796a009702f289b5f56bd35f01c0a619f5345fb363c9","src/metal/surface.rs":"f2b9b65d4117db2b16c04469c573358eb65de104d5a72aa02da8483ee243cbd3","src/metal/time.rs":"c32d69f30e846dfcc0e39e01097fb80df63b2bebb6586143bb62494999850246","src/vulkan/adapter.rs":"ed980734c8239bad7f3371e0e778ec63ecea5fe971f04c3dcdd3fe55c359f63b","src/vulkan/command.rs":"e5a88eab59b3864cdf44ba2231270e16045505dc549b8b90251031de452ba826","src/vulkan/conv.rs":"7e6266e3a0b7d0b8d5d51362a0386a84bc047350eeac663b6352a94d5e5c0a87","src/vulkan/device.rs":"9824d597dbb51030bd337e80bb0f1eab6fdb6935fc87dfd8beae2c1f1048fbcf","src/vulkan/instance.rs":"cd4aa3a8ed343076446117bae21fc438fe8761054489ec7d1ed7c31512c2e5ec","src/vulkan/mod.rs":"0c6bfb321b693930bcae3e61d06ff7b71965a64761ce39d757fc609d4b46a03e"},"package":null} \ No newline at end of file
+{"files":{"Cargo.toml":"332863a1b354637fc62ff5729e7c2f5089fa65db05d330ec268a7aab04bb3d42","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","README.md":"099ee611a911dc19330a61bffcde13663929a51b25ac528ee33ea796d695491e","build.rs":"c80bdc0152a00471eec6ed0dd0f7d55d0b975498a00ba05e94100c84ad639a49","examples/halmark/main.rs":"4604737f714943383c57feac2b8468ecf15e9e60c54a5303455e9953ec5c79fb","examples/halmark/shader.wgsl":"26c256ec36d6f0e9a1647431ca772766bee4382d64eaa718ba7b488dcfb6bcca","examples/raw-gles.em.html":"70fbe68394a1a4522192de1dcfaf7d399f60d7bdf5de70b708f9bb0417427546","examples/raw-gles.rs":"095113a1ba0851652a77aabfc8fa6ea7edcc2d09e91fd1e5009ead87d5998ea9","examples/ray-traced-triangle/main.rs":"955c2b8700c3b2daf14e9ef963ff499ed185b6f349dbc63caa422b2cf4942a1f","examples/ray-traced-triangle/shader.wgsl":"cc10caf92746724a71f6dd0dbc3a71e57b37c7d1d83278556805a535c0728a9d","src/auxil/dxgi/conv.rs":"760cd4eaa79b530368a30140b96bf73ac4fbdb4025eb95f0bed581638c8bb1cb","src/auxil/dxgi/exception.rs":"f0cfb5a0adcdc3b6db909601fee51ad51368f5da269bcd46e4dbea45a3bec4b1","src/auxil/dxgi/factory.rs":"5f861fbfe2f4cce08722a95283549b8f62b96f24a306d080d9f1730ae53501d8","src/auxil/dxgi/mod.rs":"a202564d9ac97530b16a234b87d180cd345aae705e082a9b1177dcde813645f9","src/auxil/dxgi/result.rs":"79fe5aa17a2b21a7f06b1b604200c3c3e73fca31e8193aab80b5b15e7e9818a0","src/auxil/dxgi/time.rs":"b6f966b250e9424d5d7e4065f2108cba87197c1e30baae6d87083055d1bc5a4b","src/auxil/mod.rs":"720ef2aae258733322a3274fd858f91effb8951dabaf7bbfd8a9a0be2d2dba97","src/auxil/renderdoc.rs":"c2f849f70f576b0c9b0d32dd155b6a6353f74dff59cbeeaa994a12789d047c0f","src/dx12/adapter.rs":"2a90a4222702e50fabfc64339ac2aa667e1ee2d2bf801c3e2e59a91e261c7a04","src/dx12/command.rs":"e0675560784214a18e078062cbd0965c21a35c99eecf0e697d1badb9c692db35","src/dx12/conv.rs":"94d35f117ae003b07049f3a0bc6c45a0ffda9fb8053233d39c173cfb1b644403","src/dx12/descriptor.rs":"e06eb08bee4c805fa76b6ab791893b5b563ee60de9c8f8d8e0e21ab97ade5664","src/dx12/device.rs":"6a38dabd4db9d7ca79bfcfbeb3483320ad88f2db6e93a7210051bbf81acb1bbd","src/dx12/instance.rs":"030a86ac810d5ebf151328bbc06b9b5a89788721aa963cb4e0f3ff943b2c8633","src/dx12/mod.rs":"87e7012a113554c976abdbecd10b2fe6aab3ba695c88dc77d6beb3880d96ba54","src/dx12/shader_compilation.rs":"5087adb8576e2d7751619dfdf8b37c573bb4e494290c594077ca3208cce1e746","src/dx12/suballocation.rs":"6939fc36223a15cc070c744d0418f9ac6fa2829d794af17cdea7c61eb5f8d2c0","src/dx12/types.rs":"9573736baaa0ef607367c3b72144556d24faf677a26bb8df49a4372a1348e06b","src/dx12/view.rs":"792772e9c87840dcd045b7381a03162eb4a501492a95ca586e77e81aed621c67","src/empty.rs":"0849e0b7210d33145b3fb1368ed08b13fbc2144b1ccc0a1af913896e916bbe46","src/gles/adapter.rs":"22fe404177d4abb077f35a5be54295f81eacb021d448ad01aa96450ade8b089a","src/gles/command.rs":"788505168ae1af312781c86d31d5bc289fcc4e2b3cb047fb41deb62542db1a95","src/gles/conv.rs":"5d15d3a33032d32ff99bc338fba0689fa54c76d0714e335fe48523d841df386f","src/gles/device.rs":"e126042653b0651a12684504e19c05db3fe333bde3ac408063675eef6c27754a","src/gles/egl.rs":"72feefbcd399e686b5c210a67151ef040e45e123ad371539274d1d52b3dd162d","src/gles/emscripten.rs":"19bb73a9d140645f3f32cd48b002151711a9b8456e213eab5f3a2be79239e147","src/gles/mod.rs":"b8999f76ad45e07312b291457100f12699ba6a2635c1f1913b0648e9a9394015","src/gles/queue.rs":"7f62e9c1cb670f66ac8bb0d62cd531b9c11b2a29f8ed28736c40e21071fbe25d","src/gles/shaders/clear.frag":"9133ed8ed97d3641fbb6b5f5ea894a3554c629ccc1b80a5fc9221d7293aa1954","src/gles/shaders/clear.vert":"a543768725f4121ff2e9e1fb5b00644931e9d6f2f946c0ef01968afb5a135abd","src/gles/shaders/srgb_present.frag":"dd9a43c339a2fa4ccf7f6a1854c6f400cabf271a7d5e9230768e9f39d47f3ff5","src/gles/shaders/srgb_present.vert":"6e85d489403d80b81cc94790730bb53b309dfc5eeede8f1ea3412a660f31d357","src/gles/web.rs":"000ed39eae4a6442ca16bdca68e1e61459e6815a5db8eeec53e0ee0f5f14ae66","src/gles/wgl.rs":"78bfe5bcdacfde8d8df0d6f3987048f8ad8a2c2c93df6d607cf5a16795d3bb8e","src/lib.rs":"b80b7d14f524f25875b1d7e7ee67cd6057bbe9944ea92b59d5d4d08d7b17580d","src/metal/adapter.rs":"e473a1857817030ee5c5358e8387daff66d1aca1f5133224cc844ea4b17d3e49","src/metal/command.rs":"61640f2cb7269f44487df2d911771fbe1f78484d44a5363a6ddfce7d77143b02","src/metal/conv.rs":"0bce6a8d0ccef16783475803d70d35e03ab7938c19374e22c9d253abe1f8b111","src/metal/device.rs":"1343ad60a423b81649a6eaad69de743a2247234a75ec48c0698973af67592e48","src/metal/mod.rs":"3e3f69ac864cb6a96c5b9df551a934bbc4bf08503430b9507561eef973daf57f","src/metal/surface.rs":"397dab6726eead96f0be9ecb6686874e691079da94c072921a6422e9b1284fb5","src/metal/time.rs":"c32d69f30e846dfcc0e39e01097fb80df63b2bebb6586143bb62494999850246","src/vulkan/adapter.rs":"ac4525114d37d6ffa31f2c240b2bb9e1d97d19cd6d400598c2a1153d9144bd0f","src/vulkan/command.rs":"82060e8040eea27b717ec676525139a9c7238074ad5ce6902f5174ac5c7aa048","src/vulkan/conv.rs":"7e6266e3a0b7d0b8d5d51362a0386a84bc047350eeac663b6352a94d5e5c0a87","src/vulkan/device.rs":"24abe83a2cbe8fa3377d0fb8d64fcaac3a3e6b0521ec28143fa8b7dee0c1afee","src/vulkan/instance.rs":"60742c3c1feee63eca0953165dae57c86b0d58e496ad374743ff83ae50a4e8f1","src/vulkan/mod.rs":"dfd8e079b7b783de3dfdfbf2349d7283c1b9108242d1ffbb4e072376901c7bd1"},"package":null} \ No newline at end of file
diff --git a/third_party/rust/wgpu-hal/Cargo.toml b/third_party/rust/wgpu-hal/Cargo.toml
index 47195f996d..f601949231 100644
--- a/third_party/rust/wgpu-hal/Cargo.toml
+++ b/third_party/rust/wgpu-hal/Cargo.toml
@@ -11,7 +11,7 @@
[package]
edition = "2021"
-rust-version = "1.70"
+rust-version = "1.74"
name = "wgpu-hal"
version = "0.19.0"
authors = ["gfx-rs developers"]
@@ -78,7 +78,7 @@ package = "wgpu-types"
[dev-dependencies]
cfg-if = "1"
-env_logger = "0.10"
+env_logger = "0.11"
glam = "0.25.0"
[dev-dependencies.naga]
@@ -87,7 +87,7 @@ path = "../naga"
features = ["wgsl-in"]
[dev-dependencies.winit]
-version = "0.29.10"
+version = "0.29.14"
features = ["android-native-activity"]
[build-dependencies]
@@ -142,11 +142,11 @@ vulkan = [
windows_rs = ["gpu-allocator"]
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"emscripten\")))".dependencies]
-js-sys = "0.3.67"
+js-sys = "0.3.69"
wasm-bindgen = "0.2.87"
[target."cfg(all(target_arch = \"wasm32\", not(target_os = \"emscripten\")))".dependencies.web-sys]
-version = "0.3.67"
+version = "0.3.69"
features = [
"Window",
"HtmlCanvasElement",
@@ -185,7 +185,7 @@ version = ">=0.7, <0.9"
optional = true
[target."cfg(not(target_arch = \"wasm32\"))".dependencies.renderdoc-sys]
-version = "1.0.0"
+version = "1.1.0"
optional = true
[target."cfg(not(target_arch = \"wasm32\"))".dependencies.smallvec]
diff --git a/third_party/rust/wgpu-hal/src/dx12/adapter.rs b/third_party/rust/wgpu-hal/src/dx12/adapter.rs
index 960e1790a9..b417a88a6f 100644
--- a/third_party/rust/wgpu-hal/src/dx12/adapter.rs
+++ b/third_party/rust/wgpu-hal/src/dx12/adapter.rs
@@ -432,7 +432,9 @@ impl super::Adapter {
}
}
-impl crate::Adapter<super::Api> for super::Adapter {
+impl crate::Adapter for super::Adapter {
+ type A = super::Api;
+
unsafe fn open(
&self,
_features: wgt::Features,
diff --git a/third_party/rust/wgpu-hal/src/dx12/command.rs b/third_party/rust/wgpu-hal/src/dx12/command.rs
index 9d96d29cae..3c535b2234 100644
--- a/third_party/rust/wgpu-hal/src/dx12/command.rs
+++ b/third_party/rust/wgpu-hal/src/dx12/command.rs
@@ -249,7 +249,9 @@ impl super::CommandEncoder {
}
}
-impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
+impl crate::CommandEncoder for super::CommandEncoder {
+ type A = super::Api;
+
unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
let list = loop {
if let Some(list) = self.free_lists.pop() {
diff --git a/third_party/rust/wgpu-hal/src/dx12/device.rs b/third_party/rust/wgpu-hal/src/dx12/device.rs
index 3603b033b8..23bd409dc4 100644
--- a/third_party/rust/wgpu-hal/src/dx12/device.rs
+++ b/third_party/rust/wgpu-hal/src/dx12/device.rs
@@ -323,7 +323,9 @@ impl super::Device {
}
}
-impl crate::Device<super::Api> for super::Device {
+impl crate::Device for super::Device {
+ type A = super::Api;
+
unsafe fn exit(mut self, _queue: super::Queue) {
self.rtv_pool.lock().free_handle(self.null_rtv_handle);
self.mem_allocator = None;
@@ -1098,7 +1100,16 @@ impl crate::Device<super::Api> for super::Device {
}
let mut dynamic_buffers = Vec::new();
- for (layout, entry) in desc.layout.entries.iter().zip(desc.entries.iter()) {
+ let layout_and_entry_iter = desc.entries.iter().map(|entry| {
+ let layout = desc
+ .layout
+ .entries
+ .iter()
+ .find(|layout_entry| layout_entry.binding == entry.binding)
+ .expect("internal error: no layout entry found with binding slot");
+ (layout, entry)
+ });
+ for (layout, entry) in layout_and_entry_iter {
match layout.ty {
wgt::BindingType::Buffer {
has_dynamic_offset: true,
diff --git a/third_party/rust/wgpu-hal/src/dx12/instance.rs b/third_party/rust/wgpu-hal/src/dx12/instance.rs
index 020809328e..1dba7101df 100644
--- a/third_party/rust/wgpu-hal/src/dx12/instance.rs
+++ b/third_party/rust/wgpu-hal/src/dx12/instance.rs
@@ -13,7 +13,9 @@ impl Drop for super::Instance {
}
}
-impl crate::Instance<super::Api> for super::Instance {
+impl crate::Instance for super::Instance {
+ type A = super::Api;
+
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init DX12 Backend");
let lib_main = d3d12::D3D12Lib::new().map_err(|e| {
diff --git a/third_party/rust/wgpu-hal/src/dx12/mod.rs b/third_party/rust/wgpu-hal/src/dx12/mod.rs
index 13b43f8aca..4f958943ca 100644
--- a/third_party/rust/wgpu-hal/src/dx12/mod.rs
+++ b/third_party/rust/wgpu-hal/src/dx12/mod.rs
@@ -639,7 +639,9 @@ impl SwapChain {
}
}
-impl crate::Surface<Api> for Surface {
+impl crate::Surface for Surface {
+ type A = Api;
+
unsafe fn configure(
&self,
device: &Device,
@@ -884,7 +886,9 @@ impl crate::Surface<Api> for Surface {
}
}
-impl crate::Queue<Api> for Queue {
+impl crate::Queue for Queue {
+ type A = Api;
+
unsafe fn submit(
&self,
command_buffers: &[&CommandBuffer],
diff --git a/third_party/rust/wgpu-hal/src/empty.rs b/third_party/rust/wgpu-hal/src/empty.rs
index d58e779b96..ad00da1b7f 100644
--- a/third_party/rust/wgpu-hal/src/empty.rs
+++ b/third_party/rust/wgpu-hal/src/empty.rs
@@ -39,7 +39,9 @@ impl crate::Api for Api {
type ComputePipeline = Resource;
}
-impl crate::Instance<Api> for Context {
+impl crate::Instance for Context {
+ type A = Api;
+
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
Ok(Context)
}
@@ -56,7 +58,9 @@ impl crate::Instance<Api> for Context {
}
}
-impl crate::Surface<Api> for Context {
+impl crate::Surface for Context {
+ type A = Api;
+
unsafe fn configure(
&self,
device: &Context,
@@ -76,7 +80,9 @@ impl crate::Surface<Api> for Context {
unsafe fn discard_texture(&self, texture: Resource) {}
}
-impl crate::Adapter<Api> for Context {
+impl crate::Adapter for Context {
+ type A = Api;
+
unsafe fn open(
&self,
features: wgt::Features,
@@ -100,7 +106,9 @@ impl crate::Adapter<Api> for Context {
}
}
-impl crate::Queue<Api> for Context {
+impl crate::Queue for Context {
+ type A = Api;
+
unsafe fn submit(
&self,
command_buffers: &[&Resource],
@@ -122,7 +130,9 @@ impl crate::Queue<Api> for Context {
}
}
-impl crate::Device<Api> for Context {
+impl crate::Device for Context {
+ type A = Api;
+
unsafe fn exit(self, queue: Context) {}
unsafe fn create_buffer(&self, desc: &crate::BufferDescriptor) -> DeviceResult<Resource> {
Ok(Resource)
@@ -259,7 +269,9 @@ impl crate::Device<Api> for Context {
unsafe fn destroy_acceleration_structure(&self, _acceleration_structure: Resource) {}
}
-impl crate::CommandEncoder<Api> for Encoder {
+impl crate::CommandEncoder for Encoder {
+ type A = Api;
+
unsafe fn begin_encoding(&mut self, label: crate::Label) -> DeviceResult<()> {
Ok(())
}
diff --git a/third_party/rust/wgpu-hal/src/gles/adapter.rs b/third_party/rust/wgpu-hal/src/gles/adapter.rs
index c09725e85f..b9d044337c 100644
--- a/third_party/rust/wgpu-hal/src/gles/adapter.rs
+++ b/third_party/rust/wgpu-hal/src/gles/adapter.rs
@@ -922,7 +922,9 @@ impl super::Adapter {
}
}
-impl crate::Adapter<super::Api> for super::Adapter {
+impl crate::Adapter for super::Adapter {
+ type A = super::Api;
+
unsafe fn open(
&self,
features: wgt::Features,
diff --git a/third_party/rust/wgpu-hal/src/gles/command.rs b/third_party/rust/wgpu-hal/src/gles/command.rs
index 4385e2a31e..258dee76e5 100644
--- a/third_party/rust/wgpu-hal/src/gles/command.rs
+++ b/third_party/rust/wgpu-hal/src/gles/command.rs
@@ -250,7 +250,9 @@ impl super::CommandEncoder {
}
}
-impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
+impl crate::CommandEncoder for super::CommandEncoder {
+ type A = super::Api;
+
unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
self.state = State::default();
self.cmd_buffer.label = label.map(str::to_string);
diff --git a/third_party/rust/wgpu-hal/src/gles/device.rs b/third_party/rust/wgpu-hal/src/gles/device.rs
index 2678488cf8..50c07f3ff0 100644
--- a/third_party/rust/wgpu-hal/src/gles/device.rs
+++ b/third_party/rust/wgpu-hal/src/gles/device.rs
@@ -483,7 +483,9 @@ impl super::Device {
}
}
-impl crate::Device<super::Api> for super::Device {
+impl crate::Device for super::Device {
+ type A = super::Api;
+
unsafe fn exit(self, queue: super::Queue) {
let gl = &self.shared.context.lock();
unsafe { gl.delete_vertex_array(self.main_vao) };
@@ -1123,8 +1125,10 @@ impl crate::Device<super::Api> for super::Device {
!0;
bg_layout
.entries
- .last()
- .map_or(0, |b| b.binding as usize + 1)
+ .iter()
+ .map(|b| b.binding)
+ .max()
+ .map_or(0, |idx| idx as usize + 1)
]
.into_boxed_slice();
@@ -1177,7 +1181,16 @@ impl crate::Device<super::Api> for super::Device {
) -> Result<super::BindGroup, crate::DeviceError> {
let mut contents = Vec::new();
- for (entry, layout) in desc.entries.iter().zip(desc.layout.entries.iter()) {
+ let layout_and_entry_iter = desc.entries.iter().map(|entry| {
+ let layout = desc
+ .layout
+ .entries
+ .iter()
+ .find(|layout_entry| layout_entry.binding == entry.binding)
+ .expect("internal error: no layout entry found with binding slot");
+ (entry, layout)
+ });
+ for (entry, layout) in layout_and_entry_iter {
let binding = match layout.ty {
wgt::BindingType::Buffer { .. } => {
let bb = &desc.buffers[entry.resource_index as usize];
diff --git a/third_party/rust/wgpu-hal/src/gles/egl.rs b/third_party/rust/wgpu-hal/src/gles/egl.rs
index f4bfcf5487..b166f4f102 100644
--- a/third_party/rust/wgpu-hal/src/gles/egl.rs
+++ b/third_party/rust/wgpu-hal/src/gles/egl.rs
@@ -703,7 +703,9 @@ impl Instance {
unsafe impl Send for Instance {}
unsafe impl Sync for Instance {}
-impl crate::Instance<super::Api> for Instance {
+impl crate::Instance for Instance {
+ type A = super::Api;
+
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init OpenGL (EGL) Backend");
#[cfg(Emscripten)]
@@ -1165,7 +1167,9 @@ impl Surface {
}
}
-impl crate::Surface<super::Api> for Surface {
+impl crate::Surface for Surface {
+ type A = super::Api;
+
unsafe fn configure(
&self,
device: &super::Device,
diff --git a/third_party/rust/wgpu-hal/src/gles/queue.rs b/third_party/rust/wgpu-hal/src/gles/queue.rs
index 5db5af9a16..29dfb79d04 100644
--- a/third_party/rust/wgpu-hal/src/gles/queue.rs
+++ b/third_party/rust/wgpu-hal/src/gles/queue.rs
@@ -1748,7 +1748,9 @@ impl super::Queue {
}
}
-impl crate::Queue<super::Api> for super::Queue {
+impl crate::Queue for super::Queue {
+ type A = super::Api;
+
unsafe fn submit(
&self,
command_buffers: &[&super::CommandBuffer],
diff --git a/third_party/rust/wgpu-hal/src/gles/web.rs b/third_party/rust/wgpu-hal/src/gles/web.rs
index 797d6f91d7..ab2ccef8b6 100644
--- a/third_party/rust/wgpu-hal/src/gles/web.rs
+++ b/third_party/rust/wgpu-hal/src/gles/web.rs
@@ -116,7 +116,9 @@ unsafe impl Sync for Instance {}
#[cfg(send_sync)]
unsafe impl Send for Instance {}
-impl crate::Instance<super::Api> for Instance {
+impl crate::Instance for Instance {
+ type A = super::Api;
+
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init OpenGL (WebGL) Backend");
Ok(Instance {
@@ -309,7 +311,9 @@ impl Surface {
}
}
-impl crate::Surface<super::Api> for Surface {
+impl crate::Surface for Surface {
+ type A = super::Api;
+
unsafe fn configure(
&self,
device: &super::Device,
diff --git a/third_party/rust/wgpu-hal/src/gles/wgl.rs b/third_party/rust/wgpu-hal/src/gles/wgl.rs
index c9039090b7..2564892969 100644
--- a/third_party/rust/wgpu-hal/src/gles/wgl.rs
+++ b/third_party/rust/wgpu-hal/src/gles/wgl.rs
@@ -422,7 +422,9 @@ fn create_instance_device() -> Result<InstanceDevice, crate::InstanceError> {
Ok(InstanceDevice { dc, _tx: drop_tx })
}
-impl crate::Instance<super::Api> for Instance {
+impl crate::Instance for Instance {
+ type A = super::Api;
+
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init OpenGL (WGL) Backend");
let opengl_module = unsafe { LoadLibraryA("opengl32.dll\0".as_ptr() as *const _) };
@@ -676,7 +678,9 @@ impl Surface {
}
}
-impl crate::Surface<super::Api> for Surface {
+impl crate::Surface for Surface {
+ type A = super::Api;
+
unsafe fn configure(
&self,
device: &super::Device,
diff --git a/third_party/rust/wgpu-hal/src/lib.rs b/third_party/rust/wgpu-hal/src/lib.rs
index f1794a4a89..79bd54e66e 100644
--- a/third_party/rust/wgpu-hal/src/lib.rs
+++ b/third_party/rust/wgpu-hal/src/lib.rs
@@ -191,13 +191,13 @@ impl InstanceError {
}
pub trait Api: Clone + fmt::Debug + Sized {
- type Instance: Instance<Self>;
- type Surface: Surface<Self>;
- type Adapter: Adapter<Self>;
- type Device: Device<Self>;
+ type Instance: Instance<A = Self>;
+ type Surface: Surface<A = Self>;
+ type Adapter: Adapter<A = Self>;
+ type Device: Device<A = Self>;
- type Queue: Queue<Self>;
- type CommandEncoder: CommandEncoder<Self>;
+ type Queue: Queue<A = Self>;
+ type CommandEncoder: CommandEncoder<A = Self>;
type CommandBuffer: WasmNotSendSync + fmt::Debug;
type Buffer: fmt::Debug + WasmNotSendSync + 'static;
@@ -218,18 +218,22 @@ pub trait Api: Clone + fmt::Debug + Sized {
type AccelerationStructure: fmt::Debug + WasmNotSendSync + 'static;
}
-pub trait Instance<A: Api>: Sized + WasmNotSendSync {
+pub trait Instance: Sized + WasmNotSendSync {
+ type A: Api;
+
unsafe fn init(desc: &InstanceDescriptor) -> Result<Self, InstanceError>;
unsafe fn create_surface(
&self,
display_handle: raw_window_handle::RawDisplayHandle,
window_handle: raw_window_handle::RawWindowHandle,
- ) -> Result<A::Surface, InstanceError>;
- unsafe fn destroy_surface(&self, surface: A::Surface);
- unsafe fn enumerate_adapters(&self) -> Vec<ExposedAdapter<A>>;
+ ) -> Result<<Self::A as Api>::Surface, InstanceError>;
+ unsafe fn destroy_surface(&self, surface: <Self::A as Api>::Surface);
+ unsafe fn enumerate_adapters(&self) -> Vec<ExposedAdapter<Self::A>>;
}
-pub trait Surface<A: Api>: WasmNotSendSync {
+pub trait Surface: WasmNotSendSync {
+ type A: Api;
+
/// Configures the surface to use the given device.
///
/// # Safety
@@ -240,7 +244,7 @@ pub trait Surface<A: Api>: WasmNotSendSync {
/// - All surfaces created using other devices must have been unconfigured before this call.
unsafe fn configure(
&self,
- device: &A::Device,
+ device: &<Self::A as Api>::Device,
config: &SurfaceConfiguration,
) -> Result<(), SurfaceError>;
@@ -252,7 +256,7 @@ pub trait Surface<A: Api>: WasmNotSendSync {
/// - All [`AcquiredSurfaceTexture`]s must have been destroyed.
/// - All [`Api::TextureView`]s derived from the [`AcquiredSurfaceTexture`]s must have been destroyed.
/// - The surface must have been configured on the given device.
- unsafe fn unconfigure(&self, device: &A::Device);
+ unsafe fn unconfigure(&self, device: &<Self::A as Api>::Device);
/// Returns the next texture to be presented by the swapchain for drawing
///
@@ -267,16 +271,18 @@ pub trait Surface<A: Api>: WasmNotSendSync {
unsafe fn acquire_texture(
&self,
timeout: Option<std::time::Duration>,
- ) -> Result<Option<AcquiredSurfaceTexture<A>>, SurfaceError>;
- unsafe fn discard_texture(&self, texture: A::SurfaceTexture);
+ ) -> Result<Option<AcquiredSurfaceTexture<Self::A>>, SurfaceError>;
+ unsafe fn discard_texture(&self, texture: <Self::A as Api>::SurfaceTexture);
}
-pub trait Adapter<A: Api>: WasmNotSendSync {
+pub trait Adapter: WasmNotSendSync {
+ type A: Api;
+
unsafe fn open(
&self,
features: wgt::Features,
limits: &wgt::Limits,
- ) -> Result<OpenDevice<A>, DeviceError>;
+ ) -> Result<OpenDevice<Self::A>, DeviceError>;
/// Return the set of supported capabilities for a texture format.
unsafe fn texture_format_capabilities(
@@ -287,7 +293,10 @@ pub trait Adapter<A: Api>: WasmNotSendSync {
/// Returns the capabilities of working with a specified surface.
///
/// `None` means presentation is not supported for it.
- unsafe fn surface_capabilities(&self, surface: &A::Surface) -> Option<SurfaceCapabilities>;
+ unsafe fn surface_capabilities(
+ &self,
+ surface: &<Self::A as Api>::Surface,
+ ) -> Option<SurfaceCapabilities>;
/// Creates a [`PresentationTimestamp`] using the adapter's WSI.
///
@@ -295,97 +304,111 @@ pub trait Adapter<A: Api>: WasmNotSendSync {
unsafe fn get_presentation_timestamp(&self) -> wgt::PresentationTimestamp;
}
-pub trait Device<A: Api>: WasmNotSendSync {
+pub trait Device: WasmNotSendSync {
+ type A: Api;
+
/// Exit connection to this logical device.
- unsafe fn exit(self, queue: A::Queue);
+ unsafe fn exit(self, queue: <Self::A as Api>::Queue);
/// Creates a new buffer.
///
/// The initial usage is `BufferUses::empty()`.
- unsafe fn create_buffer(&self, desc: &BufferDescriptor) -> Result<A::Buffer, DeviceError>;
- unsafe fn destroy_buffer(&self, buffer: A::Buffer);
+ unsafe fn create_buffer(
+ &self,
+ desc: &BufferDescriptor,
+ ) -> Result<<Self::A as Api>::Buffer, DeviceError>;
+ unsafe fn destroy_buffer(&self, buffer: <Self::A as Api>::Buffer);
//TODO: clarify if zero-sized mapping is allowed
unsafe fn map_buffer(
&self,
- buffer: &A::Buffer,
+ buffer: &<Self::A as Api>::Buffer,
range: MemoryRange,
) -> Result<BufferMapping, DeviceError>;
- unsafe fn unmap_buffer(&self, buffer: &A::Buffer) -> Result<(), DeviceError>;
- unsafe fn flush_mapped_ranges<I>(&self, buffer: &A::Buffer, ranges: I)
+ unsafe fn unmap_buffer(&self, buffer: &<Self::A as Api>::Buffer) -> Result<(), DeviceError>;
+ unsafe fn flush_mapped_ranges<I>(&self, buffer: &<Self::A as Api>::Buffer, ranges: I)
where
I: Iterator<Item = MemoryRange>;
- unsafe fn invalidate_mapped_ranges<I>(&self, buffer: &A::Buffer, ranges: I)
+ unsafe fn invalidate_mapped_ranges<I>(&self, buffer: &<Self::A as Api>::Buffer, ranges: I)
where
I: Iterator<Item = MemoryRange>;
/// Creates a new texture.
///
/// The initial usage for all subresources is `TextureUses::UNINITIALIZED`.
- unsafe fn create_texture(&self, desc: &TextureDescriptor) -> Result<A::Texture, DeviceError>;
- unsafe fn destroy_texture(&self, texture: A::Texture);
+ unsafe fn create_texture(
+ &self,
+ desc: &TextureDescriptor,
+ ) -> Result<<Self::A as Api>::Texture, DeviceError>;
+ unsafe fn destroy_texture(&self, texture: <Self::A as Api>::Texture);
unsafe fn create_texture_view(
&self,
- texture: &A::Texture,
+ texture: &<Self::A as Api>::Texture,
desc: &TextureViewDescriptor,
- ) -> Result<A::TextureView, DeviceError>;
- unsafe fn destroy_texture_view(&self, view: A::TextureView);
- unsafe fn create_sampler(&self, desc: &SamplerDescriptor) -> Result<A::Sampler, DeviceError>;
- unsafe fn destroy_sampler(&self, sampler: A::Sampler);
+ ) -> Result<<Self::A as Api>::TextureView, DeviceError>;
+ unsafe fn destroy_texture_view(&self, view: <Self::A as Api>::TextureView);
+ unsafe fn create_sampler(
+ &self,
+ desc: &SamplerDescriptor,
+ ) -> Result<<Self::A as Api>::Sampler, DeviceError>;
+ unsafe fn destroy_sampler(&self, sampler: <Self::A as Api>::Sampler);
/// Create a fresh [`CommandEncoder`].
///
/// The new `CommandEncoder` is in the "closed" state.
unsafe fn create_command_encoder(
&self,
- desc: &CommandEncoderDescriptor<A>,
- ) -> Result<A::CommandEncoder, DeviceError>;
- unsafe fn destroy_command_encoder(&self, pool: A::CommandEncoder);
+ desc: &CommandEncoderDescriptor<Self::A>,
+ ) -> Result<<Self::A as Api>::CommandEncoder, DeviceError>;
+ unsafe fn destroy_command_encoder(&self, pool: <Self::A as Api>::CommandEncoder);
/// Creates a bind group layout.
unsafe fn create_bind_group_layout(
&self,
desc: &BindGroupLayoutDescriptor,
- ) -> Result<A::BindGroupLayout, DeviceError>;
- unsafe fn destroy_bind_group_layout(&self, bg_layout: A::BindGroupLayout);
+ ) -> Result<<Self::A as Api>::BindGroupLayout, DeviceError>;
+ unsafe fn destroy_bind_group_layout(&self, bg_layout: <Self::A as Api>::BindGroupLayout);
unsafe fn create_pipeline_layout(
&self,
- desc: &PipelineLayoutDescriptor<A>,
- ) -> Result<A::PipelineLayout, DeviceError>;
- unsafe fn destroy_pipeline_layout(&self, pipeline_layout: A::PipelineLayout);
+ desc: &PipelineLayoutDescriptor<Self::A>,
+ ) -> Result<<Self::A as Api>::PipelineLayout, DeviceError>;
+ unsafe fn destroy_pipeline_layout(&self, pipeline_layout: <Self::A as Api>::PipelineLayout);
unsafe fn create_bind_group(
&self,
- desc: &BindGroupDescriptor<A>,
- ) -> Result<A::BindGroup, DeviceError>;
- unsafe fn destroy_bind_group(&self, group: A::BindGroup);
+ desc: &BindGroupDescriptor<Self::A>,
+ ) -> Result<<Self::A as Api>::BindGroup, DeviceError>;
+ unsafe fn destroy_bind_group(&self, group: <Self::A as Api>::BindGroup);
unsafe fn create_shader_module(
&self,
desc: &ShaderModuleDescriptor,
shader: ShaderInput,
- ) -> Result<A::ShaderModule, ShaderError>;
- unsafe fn destroy_shader_module(&self, module: A::ShaderModule);
+ ) -> Result<<Self::A as Api>::ShaderModule, ShaderError>;
+ unsafe fn destroy_shader_module(&self, module: <Self::A as Api>::ShaderModule);
unsafe fn create_render_pipeline(
&self,
- desc: &RenderPipelineDescriptor<A>,
- ) -> Result<A::RenderPipeline, PipelineError>;
- unsafe fn destroy_render_pipeline(&self, pipeline: A::RenderPipeline);
+ desc: &RenderPipelineDescriptor<Self::A>,
+ ) -> Result<<Self::A as Api>::RenderPipeline, PipelineError>;
+ unsafe fn destroy_render_pipeline(&self, pipeline: <Self::A as Api>::RenderPipeline);
unsafe fn create_compute_pipeline(
&self,
- desc: &ComputePipelineDescriptor<A>,
- ) -> Result<A::ComputePipeline, PipelineError>;
- unsafe fn destroy_compute_pipeline(&self, pipeline: A::ComputePipeline);
+ desc: &ComputePipelineDescriptor<Self::A>,
+ ) -> Result<<Self::A as Api>::ComputePipeline, PipelineError>;
+ unsafe fn destroy_compute_pipeline(&self, pipeline: <Self::A as Api>::ComputePipeline);
unsafe fn create_query_set(
&self,
desc: &wgt::QuerySetDescriptor<Label>,
- ) -> Result<A::QuerySet, DeviceError>;
- unsafe fn destroy_query_set(&self, set: A::QuerySet);
- unsafe fn create_fence(&self) -> Result<A::Fence, DeviceError>;
- unsafe fn destroy_fence(&self, fence: A::Fence);
- unsafe fn get_fence_value(&self, fence: &A::Fence) -> Result<FenceValue, DeviceError>;
+ ) -> Result<<Self::A as Api>::QuerySet, DeviceError>;
+ unsafe fn destroy_query_set(&self, set: <Self::A as Api>::QuerySet);
+ unsafe fn create_fence(&self) -> Result<<Self::A as Api>::Fence, DeviceError>;
+ unsafe fn destroy_fence(&self, fence: <Self::A as Api>::Fence);
+ unsafe fn get_fence_value(
+ &self,
+ fence: &<Self::A as Api>::Fence,
+ ) -> Result<FenceValue, DeviceError>;
/// Calling wait with a lower value than the current fence value will immediately return.
unsafe fn wait(
&self,
- fence: &A::Fence,
+ fence: &<Self::A as Api>::Fence,
value: FenceValue,
timeout_ms: u32,
) -> Result<bool, DeviceError>;
@@ -396,22 +419,24 @@ pub trait Device<A: Api>: WasmNotSendSync {
unsafe fn create_acceleration_structure(
&self,
desc: &AccelerationStructureDescriptor,
- ) -> Result<A::AccelerationStructure, DeviceError>;
+ ) -> Result<<Self::A as Api>::AccelerationStructure, DeviceError>;
unsafe fn get_acceleration_structure_build_sizes(
&self,
- desc: &GetAccelerationStructureBuildSizesDescriptor<A>,
+ desc: &GetAccelerationStructureBuildSizesDescriptor<Self::A>,
) -> AccelerationStructureBuildSizes;
unsafe fn get_acceleration_structure_device_address(
&self,
- acceleration_structure: &A::AccelerationStructure,
+ acceleration_structure: &<Self::A as Api>::AccelerationStructure,
) -> wgt::BufferAddress;
unsafe fn destroy_acceleration_structure(
&self,
- acceleration_structure: A::AccelerationStructure,
+ acceleration_structure: <Self::A as Api>::AccelerationStructure,
);
}
-pub trait Queue<A: Api>: WasmNotSendSync {
+pub trait Queue: WasmNotSendSync {
+ type A: Api;
+
/// Submits the command buffers for execution on GPU.
///
/// Valid usage:
@@ -422,14 +447,14 @@ pub trait Queue<A: Api>: WasmNotSendSync {
/// passed to the surface_textures argument.
unsafe fn submit(
&self,
- command_buffers: &[&A::CommandBuffer],
- surface_textures: &[&A::SurfaceTexture],
- signal_fence: Option<(&mut A::Fence, FenceValue)>,
+ command_buffers: &[&<Self::A as Api>::CommandBuffer],
+ surface_textures: &[&<Self::A as Api>::SurfaceTexture],
+ signal_fence: Option<(&mut <Self::A as Api>::Fence, FenceValue)>,
) -> Result<(), DeviceError>;
unsafe fn present(
&self,
- surface: &A::Surface,
- texture: A::SurfaceTexture,
+ surface: &<Self::A as Api>::Surface,
+ texture: <Self::A as Api>::SurfaceTexture,
) -> Result<(), SurfaceError>;
unsafe fn get_timestamp_period(&self) -> f32;
}
@@ -472,7 +497,9 @@ pub trait Queue<A: Api>: WasmNotSendSync {
/// built it.
///
/// - A `CommandEncoder` must not outlive its `Device`.
-pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
+pub trait CommandEncoder: WasmNotSendSync + fmt::Debug {
+ type A: Api;
+
/// Begin encoding a new command buffer.
///
/// This puts this `CommandEncoder` in the "recording" state.
@@ -510,7 +537,7 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
///
/// [`CommandBuffer`]: Api::CommandBuffer
/// [`begin_encoding`]: CommandEncoder::begin_encoding
- unsafe fn end_encoding(&mut self) -> Result<A::CommandBuffer, DeviceError>;
+ unsafe fn end_encoding(&mut self) -> Result<<Self::A as Api>::CommandBuffer, DeviceError>;
/// Reclaim all resources belonging to this `CommandEncoder`.
///
@@ -525,22 +552,26 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// [`CommandBuffer`]: Api::CommandBuffer
unsafe fn reset_all<I>(&mut self, command_buffers: I)
where
- I: Iterator<Item = A::CommandBuffer>;
+ I: Iterator<Item = <Self::A as Api>::CommandBuffer>;
unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
where
- T: Iterator<Item = BufferBarrier<'a, A>>;
+ T: Iterator<Item = BufferBarrier<'a, Self::A>>;
unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
where
- T: Iterator<Item = TextureBarrier<'a, A>>;
+ T: Iterator<Item = TextureBarrier<'a, Self::A>>;
// copy operations
- unsafe fn clear_buffer(&mut self, buffer: &A::Buffer, range: MemoryRange);
+ unsafe fn clear_buffer(&mut self, buffer: &<Self::A as Api>::Buffer, range: MemoryRange);
- unsafe fn copy_buffer_to_buffer<T>(&mut self, src: &A::Buffer, dst: &A::Buffer, regions: T)
- where
+ unsafe fn copy_buffer_to_buffer<T>(
+ &mut self,
+ src: &<Self::A as Api>::Buffer,
+ dst: &<Self::A as Api>::Buffer,
+ regions: T,
+ ) where
T: Iterator<Item = BufferCopy>;
/// Copy from an external image to an internal texture.
@@ -551,7 +582,7 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
unsafe fn copy_external_image_to_texture<T>(
&mut self,
src: &wgt::ImageCopyExternalImage,
- dst: &A::Texture,
+ dst: &<Self::A as Api>::Texture,
dst_premultiplication: bool,
regions: T,
) where
@@ -563,9 +594,9 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// Note: the copy extent is in physical size (rounded to the block size)
unsafe fn copy_texture_to_texture<T>(
&mut self,
- src: &A::Texture,
+ src: &<Self::A as Api>::Texture,
src_usage: TextureUses,
- dst: &A::Texture,
+ dst: &<Self::A as Api>::Texture,
regions: T,
) where
T: Iterator<Item = TextureCopy>;
@@ -574,8 +605,12 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// Works with a single array layer.
/// Note: `dst` current usage has to be `TextureUses::COPY_DST`.
/// Note: the copy extent is in physical size (rounded to the block size)
- unsafe fn copy_buffer_to_texture<T>(&mut self, src: &A::Buffer, dst: &A::Texture, regions: T)
- where
+ unsafe fn copy_buffer_to_texture<T>(
+ &mut self,
+ src: &<Self::A as Api>::Buffer,
+ dst: &<Self::A as Api>::Texture,
+ regions: T,
+ ) where
T: Iterator<Item = BufferTextureCopy>;
/// Copy from texture to buffer.
@@ -583,9 +618,9 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// Note: the copy extent is in physical size (rounded to the block size)
unsafe fn copy_texture_to_buffer<T>(
&mut self,
- src: &A::Texture,
+ src: &<Self::A as Api>::Texture,
src_usage: TextureUses,
- dst: &A::Buffer,
+ dst: &<Self::A as Api>::Buffer,
regions: T,
) where
T: Iterator<Item = BufferTextureCopy>;
@@ -596,9 +631,9 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// of all the preceding groups to be taken from `layout`.
unsafe fn set_bind_group(
&mut self,
- layout: &A::PipelineLayout,
+ layout: &<Self::A as Api>::PipelineLayout,
index: u32,
- group: &A::BindGroup,
+ group: &<Self::A as Api>::BindGroup,
dynamic_offsets: &[wgt::DynamicOffset],
);
@@ -612,7 +647,7 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// - The range of push constants written must be valid for the pipeline layout at draw time.
unsafe fn set_push_constants(
&mut self,
- layout: &A::PipelineLayout,
+ layout: &<Self::A as Api>::PipelineLayout,
stages: wgt::ShaderStages,
offset_bytes: u32,
data: &[u32],
@@ -627,18 +662,18 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
/// # Safety:
///
/// - If `set` is an occlusion query set, it must be the same one as used in the [`RenderPassDescriptor::occlusion_query_set`] parameter.
- unsafe fn begin_query(&mut self, set: &A::QuerySet, index: u32);
+ unsafe fn begin_query(&mut self, set: &<Self::A as Api>::QuerySet, index: u32);
/// # Safety:
///
/// - If `set` is an occlusion query set, it must be the same one as used in the [`RenderPassDescriptor::occlusion_query_set`] parameter.
- unsafe fn end_query(&mut self, set: &A::QuerySet, index: u32);
- unsafe fn write_timestamp(&mut self, set: &A::QuerySet, index: u32);
- unsafe fn reset_queries(&mut self, set: &A::QuerySet, range: Range<u32>);
+ unsafe fn end_query(&mut self, set: &<Self::A as Api>::QuerySet, index: u32);
+ unsafe fn write_timestamp(&mut self, set: &<Self::A as Api>::QuerySet, index: u32);
+ unsafe fn reset_queries(&mut self, set: &<Self::A as Api>::QuerySet, range: Range<u32>);
unsafe fn copy_query_results(
&mut self,
- set: &A::QuerySet,
+ set: &<Self::A as Api>::QuerySet,
range: Range<u32>,
- buffer: &A::Buffer,
+ buffer: &<Self::A as Api>::Buffer,
offset: wgt::BufferAddress,
stride: wgt::BufferSize,
);
@@ -646,17 +681,17 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
// render passes
// Begins a render pass, clears all active bindings.
- unsafe fn begin_render_pass(&mut self, desc: &RenderPassDescriptor<A>);
+ unsafe fn begin_render_pass(&mut self, desc: &RenderPassDescriptor<Self::A>);
unsafe fn end_render_pass(&mut self);
- unsafe fn set_render_pipeline(&mut self, pipeline: &A::RenderPipeline);
+ unsafe fn set_render_pipeline(&mut self, pipeline: &<Self::A as Api>::RenderPipeline);
unsafe fn set_index_buffer<'a>(
&mut self,
- binding: BufferBinding<'a, A>,
+ binding: BufferBinding<'a, Self::A>,
format: wgt::IndexFormat,
);
- unsafe fn set_vertex_buffer<'a>(&mut self, index: u32, binding: BufferBinding<'a, A>);
+ unsafe fn set_vertex_buffer<'a>(&mut self, index: u32, binding: BufferBinding<'a, Self::A>);
unsafe fn set_viewport(&mut self, rect: &Rect<f32>, depth_range: Range<f32>);
unsafe fn set_scissor_rect(&mut self, rect: &Rect<u32>);
unsafe fn set_stencil_reference(&mut self, value: u32);
@@ -679,29 +714,29 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
);
unsafe fn draw_indirect(
&mut self,
- buffer: &A::Buffer,
+ buffer: &<Self::A as Api>::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
);
unsafe fn draw_indexed_indirect(
&mut self,
- buffer: &A::Buffer,
+ buffer: &<Self::A as Api>::Buffer,
offset: wgt::BufferAddress,
draw_count: u32,
);
unsafe fn draw_indirect_count(
&mut self,
- buffer: &A::Buffer,
+ buffer: &<Self::A as Api>::Buffer,
offset: wgt::BufferAddress,
- count_buffer: &A::Buffer,
+ count_buffer: &<Self::A as Api>::Buffer,
count_offset: wgt::BufferAddress,
max_count: u32,
);
unsafe fn draw_indexed_indirect_count(
&mut self,
- buffer: &A::Buffer,
+ buffer: &<Self::A as Api>::Buffer,
offset: wgt::BufferAddress,
- count_buffer: &A::Buffer,
+ count_buffer: &<Self::A as Api>::Buffer,
count_offset: wgt::BufferAddress,
max_count: u32,
);
@@ -709,13 +744,17 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
// compute passes
// Begins a compute pass, clears all active bindings.
- unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor<A>);
+ unsafe fn begin_compute_pass(&mut self, desc: &ComputePassDescriptor<Self::A>);
unsafe fn end_compute_pass(&mut self);
- unsafe fn set_compute_pipeline(&mut self, pipeline: &A::ComputePipeline);
+ unsafe fn set_compute_pipeline(&mut self, pipeline: &<Self::A as Api>::ComputePipeline);
unsafe fn dispatch(&mut self, count: [u32; 3]);
- unsafe fn dispatch_indirect(&mut self, buffer: &A::Buffer, offset: wgt::BufferAddress);
+ unsafe fn dispatch_indirect(
+ &mut self,
+ buffer: &<Self::A as Api>::Buffer,
+ offset: wgt::BufferAddress,
+ );
/// To get the required sizes for the buffer allocations use `get_acceleration_structure_build_sizes` per descriptor
/// All buffers must be synchronized externally
@@ -729,8 +768,8 @@ pub trait CommandEncoder<A: Api>: WasmNotSendSync + fmt::Debug {
descriptor_count: u32,
descriptors: T,
) where
- A: 'a,
- T: IntoIterator<Item = BuildAccelerationStructureDescriptor<'a, A>>;
+ Self::A: 'a,
+ T: IntoIterator<Item = BuildAccelerationStructureDescriptor<'a, Self::A>>;
unsafe fn place_acceleration_structure_barrier(
&mut self,
diff --git a/third_party/rust/wgpu-hal/src/metal/adapter.rs b/third_party/rust/wgpu-hal/src/metal/adapter.rs
index 9ec777b0f0..6211896838 100644
--- a/third_party/rust/wgpu-hal/src/metal/adapter.rs
+++ b/third_party/rust/wgpu-hal/src/metal/adapter.rs
@@ -18,7 +18,9 @@ impl super::Adapter {
}
}
-impl crate::Adapter<super::Api> for super::Adapter {
+impl crate::Adapter for super::Adapter {
+ type A = super::Api;
+
unsafe fn open(
&self,
features: wgt::Features,
diff --git a/third_party/rust/wgpu-hal/src/metal/command.rs b/third_party/rust/wgpu-hal/src/metal/command.rs
index 6f1a0d9c2f..341712c323 100644
--- a/third_party/rust/wgpu-hal/src/metal/command.rs
+++ b/third_party/rust/wgpu-hal/src/metal/command.rs
@@ -168,7 +168,9 @@ impl super::CommandState {
}
}
-impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
+impl crate::CommandEncoder for super::CommandEncoder {
+ type A = super::Api;
+
unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
let queue = &self.raw_queue.lock();
let retain_references = self.shared.settings.retain_command_buffer_references;
diff --git a/third_party/rust/wgpu-hal/src/metal/device.rs b/third_party/rust/wgpu-hal/src/metal/device.rs
index d7fd06c8f3..179429f5d7 100644
--- a/third_party/rust/wgpu-hal/src/metal/device.rs
+++ b/third_party/rust/wgpu-hal/src/metal/device.rs
@@ -273,7 +273,9 @@ impl super::Device {
}
}
-impl crate::Device<super::Api> for super::Device {
+impl crate::Device for super::Device {
+ type A = super::Api;
+
unsafe fn exit(self, _queue: super::Queue) {}
unsafe fn create_buffer(&self, desc: &crate::BufferDescriptor) -> DeviceResult<super::Buffer> {
@@ -706,7 +708,16 @@ impl crate::Device<super::Api> for super::Device {
for (&stage, counter) in super::NAGA_STAGES.iter().zip(bg.counters.iter_mut()) {
let stage_bit = map_naga_stage(stage);
let mut dynamic_offsets_count = 0u32;
- for (entry, layout) in desc.entries.iter().zip(desc.layout.entries.iter()) {
+ let layout_and_entry_iter = desc.entries.iter().map(|entry| {
+ let layout = desc
+ .layout
+ .entries
+ .iter()
+ .find(|layout_entry| layout_entry.binding == entry.binding)
+ .expect("internal error: no layout entry found with binding slot");
+ (entry, layout)
+ });
+ for (entry, layout) in layout_and_entry_iter {
let size = layout.count.map_or(1, |c| c.get());
if let wgt::BindingType::Buffer {
has_dynamic_offset: true,
diff --git a/third_party/rust/wgpu-hal/src/metal/mod.rs b/third_party/rust/wgpu-hal/src/metal/mod.rs
index 62fbf3d49d..6aeafb0f86 100644
--- a/third_party/rust/wgpu-hal/src/metal/mod.rs
+++ b/third_party/rust/wgpu-hal/src/metal/mod.rs
@@ -80,7 +80,9 @@ impl Instance {
}
}
-impl crate::Instance<Api> for Instance {
+impl crate::Instance for Instance {
+ type A = Api;
+
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init Metal Backend");
// We do not enable metal validation based on the validation flags as it affects the entire
@@ -365,7 +367,9 @@ impl std::borrow::Borrow<Texture> for SurfaceTexture {
unsafe impl Send for SurfaceTexture {}
unsafe impl Sync for SurfaceTexture {}
-impl crate::Queue<Api> for Queue {
+impl crate::Queue for Queue {
+ type A = Api;
+
unsafe fn submit(
&self,
command_buffers: &[&CommandBuffer],
diff --git a/third_party/rust/wgpu-hal/src/metal/surface.rs b/third_party/rust/wgpu-hal/src/metal/surface.rs
index a97eff0aae..889e319493 100644
--- a/third_party/rust/wgpu-hal/src/metal/surface.rs
+++ b/third_party/rust/wgpu-hal/src/metal/surface.rs
@@ -169,7 +169,9 @@ impl super::Surface {
}
}
-impl crate::Surface<super::Api> for super::Surface {
+impl crate::Surface for super::Surface {
+ type A = super::Api;
+
unsafe fn configure(
&self,
device: &super::Device,
diff --git a/third_party/rust/wgpu-hal/src/vulkan/adapter.rs b/third_party/rust/wgpu-hal/src/vulkan/adapter.rs
index 83b3dfa8e5..2665463792 100644
--- a/third_party/rust/wgpu-hal/src/vulkan/adapter.rs
+++ b/third_party/rust/wgpu-hal/src/vulkan/adapter.rs
@@ -20,25 +20,85 @@ fn indexing_features() -> wgt::Features {
| wgt::Features::PARTIALLY_BOUND_BINDING_ARRAY
}
-/// Aggregate of the `vk::PhysicalDevice*Features` structs used by `gfx`.
+/// Features supported by a [`vk::PhysicalDevice`] and its extensions.
+///
+/// This is used in two phases:
+///
+/// - When enumerating adapters, this represents the features offered by the
+/// adapter. [`Instance::expose_adapter`] calls `vkGetPhysicalDeviceFeatures2`
+/// (or `vkGetPhysicalDeviceFeatures` if that is not available) to collect
+/// this information about the `VkPhysicalDevice` represented by the
+/// `wgpu_hal::ExposedAdapter`.
+///
+/// - When opening a device, this represents the features we would like to
+/// enable. At `wgpu_hal::Device` construction time,
+/// [`PhysicalDeviceFeatures::from_extensions_and_requested_features`]
+/// constructs an value of this type indicating which Vulkan features to
+/// enable, based on the `wgpu_types::Features` requested.
#[derive(Debug, Default)]
pub struct PhysicalDeviceFeatures {
+ /// Basic Vulkan 1.0 features.
core: vk::PhysicalDeviceFeatures,
+
+ /// Features provided by `VK_EXT_descriptor_indexing`, promoted to Vulkan 1.2.
pub(super) descriptor_indexing: Option<vk::PhysicalDeviceDescriptorIndexingFeaturesEXT>,
+
+ /// Features provided by `VK_KHR_imageless_framebuffer`, promoted to Vulkan 1.2.
imageless_framebuffer: Option<vk::PhysicalDeviceImagelessFramebufferFeaturesKHR>,
+
+ /// Features provided by `VK_KHR_timeline_semaphore`, promoted to Vulkan 1.2
timeline_semaphore: Option<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>,
+
+ /// Features provided by `VK_EXT_image_robustness`, promoted to Vulkan 1.3
image_robustness: Option<vk::PhysicalDeviceImageRobustnessFeaturesEXT>,
+
+ /// Features provided by `VK_EXT_robustness2`.
robustness2: Option<vk::PhysicalDeviceRobustness2FeaturesEXT>,
+
+ /// Features provided by `VK_KHR_multiview`, promoted to Vulkan 1.1.
multiview: Option<vk::PhysicalDeviceMultiviewFeaturesKHR>,
+
+ /// Features provided by `VK_KHR_sampler_ycbcr_conversion`, promoted to Vulkan 1.1.
sampler_ycbcr_conversion: Option<vk::PhysicalDeviceSamplerYcbcrConversionFeatures>,
+
+ /// Features provided by `VK_EXT_texture_compression_astc_hdr`, promoted to Vulkan 1.3.
astc_hdr: Option<vk::PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT>,
+
+ /// Features provided by `VK_KHR_shader_float16_int8` (promoted to Vulkan
+ /// 1.2) and `VK_KHR_16bit_storage` (promoted to Vulkan 1.1). We use these
+ /// features together, or not at all.
shader_float16: Option<(
vk::PhysicalDeviceShaderFloat16Int8Features,
vk::PhysicalDevice16BitStorageFeatures,
)>,
+
+ /// Features provided by `VK_KHR_acceleration_structure`.
acceleration_structure: Option<vk::PhysicalDeviceAccelerationStructureFeaturesKHR>,
+
+ /// Features provided by `VK_KHR_buffer_device_address`, promoted to Vulkan 1.2.
+ ///
+ /// We only use this feature for
+ /// [`Features::RAY_TRACING_ACCELERATION_STRUCTURE`], which requires
+ /// `VK_KHR_acceleration_structure`, which depends on
+ /// `VK_KHR_buffer_device_address`, so [`Instance::expose_adapter`] only
+ /// bothers to check if `VK_KHR_acceleration_structure` is available,
+ /// leaving this `None`.
+ ///
+ /// However, we do populate this when creating a device if
+ /// [`Features::RAY_TRACING_ACCELERATION_STRUCTURE`] is requested.
buffer_device_address: Option<vk::PhysicalDeviceBufferDeviceAddressFeaturesKHR>,
+
+ /// Features provided by `VK_KHR_ray_query`,
+ ///
+ /// Vulkan requires that the feature be present if the `VK_KHR_ray_query`
+ /// extension is present, so [`Instance::expose_adapter`] doesn't bother retrieving
+ /// this from `vkGetPhysicalDeviceFeatures2`.
+ ///
+ /// However, we do populate this when creating a device if ray tracing is requested.
ray_query: Option<vk::PhysicalDeviceRayQueryFeaturesKHR>,
+
+ /// Features provided by `VK_KHR_zero_initialize_workgroup_memory`, promoted
+ /// to Vulkan 1.3.
zero_initialize_workgroup_memory:
Option<vk::PhysicalDeviceZeroInitializeWorkgroupMemoryFeatures>,
}
@@ -91,9 +151,32 @@ impl PhysicalDeviceFeatures {
info
}
- /// Create a `PhysicalDeviceFeatures` that will be used to create a logical device.
+ /// Create a `PhysicalDeviceFeatures` that can be used to create a logical
+ /// device.
///
- /// `requested_features` should be the same as what was used to generate `enabled_extensions`.
+ /// Return a `PhysicalDeviceFeatures` value capturing all the Vulkan
+ /// features needed for the given [`Features`], [`DownlevelFlags`], and
+ /// [`PrivateCapabilities`]. You can use the returned value's
+ /// [`add_to_device_create_builder`] method to configure a
+ /// [`DeviceCreateInfoBuilder`] to build a logical device providing those
+ /// features.
+ ///
+ /// To ensure that the returned value is able to select all the Vulkan
+ /// features needed to express `requested_features`, `downlevel_flags`, and
+ /// `private_caps`:
+ ///
+ /// - The given `enabled_extensions` set must include all the extensions
+ /// selected by [`Adapter::required_device_extensions`] when passed
+ /// `features`.
+ ///
+ /// - The given `device_api_version` must be the Vulkan API version of the
+ /// physical device we will use to create the logical device.
+ ///
+ /// [`Features`]: wgt::Features
+ /// [`DownlevelFlags`]: wgt::DownlevelFlags
+ /// [`PrivateCapabilities`]: super::PrivateCapabilities
+ /// [`DeviceCreateInfoBuilder`]: vk::DeviceCreateInfoBuilder
+ /// [`Adapter::required_device_extensions`]: super::Adapter::required_device_extensions
fn from_extensions_and_requested_features(
device_api_version: u32,
enabled_extensions: &[&'static CStr],
@@ -354,11 +437,16 @@ impl PhysicalDeviceFeatures {
}
}
+ /// Compute the wgpu [`Features`] and [`DownlevelFlags`] supported by a physical device.
+ ///
+ /// Given `self`, together with the instance and physical device it was
+ /// built from, and a `caps` also built from those, determine which wgpu
+ /// features and downlevel flags the device can support.
fn to_wgpu(
&self,
instance: &ash::Instance,
phd: vk::PhysicalDevice,
- caps: &PhysicalDeviceCapabilities,
+ caps: &PhysicalDeviceProperties,
) -> (wgt::Features, wgt::DownlevelFlags) {
use crate::auxil::db;
use wgt::{DownlevelFlags as Df, Features as F};
@@ -639,15 +727,52 @@ impl PhysicalDeviceFeatures {
}
}
-/// Information gathered about a physical device capabilities.
+/// Vulkan "properties" structures gathered about a physical device.
+///
+/// This structure holds the properties of a [`vk::PhysicalDevice`]:
+/// - the standard Vulkan device properties
+/// - the `VkExtensionProperties` structs for all available extensions, and
+/// - the per-extension properties structures for the available extensions that
+/// `wgpu` cares about.
+///
+/// Generally, if you get it from any of these functions, it's stored
+/// here:
+/// - `vkEnumerateDeviceExtensionProperties`
+/// - `vkGetPhysicalDeviceProperties`
+/// - `vkGetPhysicalDeviceProperties2`
+///
+/// This also includes a copy of the device API version, since we can
+/// use that as a shortcut for searching for an extension, if the
+/// extension has been promoted to core in the current version.
+///
+/// This does not include device features; for those, see
+/// [`PhysicalDeviceFeatures`].
#[derive(Default, Debug)]
-pub struct PhysicalDeviceCapabilities {
+pub struct PhysicalDeviceProperties {
+ /// Extensions supported by the `vk::PhysicalDevice`,
+ /// as returned by `vkEnumerateDeviceExtensionProperties`.
supported_extensions: Vec<vk::ExtensionProperties>,
+
+ /// Properties of the `vk::PhysicalDevice`, as returned by
+ /// `vkGetPhysicalDeviceProperties`.
properties: vk::PhysicalDeviceProperties,
+
+ /// Additional `vk::PhysicalDevice` properties from the
+ /// `VK_KHR_maintenance3` extension, promoted to Vulkan 1.1.
maintenance_3: Option<vk::PhysicalDeviceMaintenance3Properties>,
+
+ /// Additional `vk::PhysicalDevice` properties from the
+ /// `VK_EXT_descriptor_indexing` extension, promoted to Vulkan 1.2.
descriptor_indexing: Option<vk::PhysicalDeviceDescriptorIndexingPropertiesEXT>,
+
+ /// Additional `vk::PhysicalDevice` properties from the
+ /// `VK_KHR_acceleration_structure` extension.
acceleration_structure: Option<vk::PhysicalDeviceAccelerationStructurePropertiesKHR>,
+
+ /// Additional `vk::PhysicalDevice` properties from the
+ /// `VK_KHR_driver_properties` extension, promoted to Vulkan 1.2.
driver: Option<vk::PhysicalDeviceDriverPropertiesKHR>,
+
/// The device API version.
///
/// Which is the version of Vulkan supported for device-level functionality.
@@ -657,10 +782,10 @@ pub struct PhysicalDeviceCapabilities {
}
// This is safe because the structs have `p_next: *mut c_void`, which we null out/never read.
-unsafe impl Send for PhysicalDeviceCapabilities {}
-unsafe impl Sync for PhysicalDeviceCapabilities {}
+unsafe impl Send for PhysicalDeviceProperties {}
+unsafe impl Sync for PhysicalDeviceProperties {}
-impl PhysicalDeviceCapabilities {
+impl PhysicalDeviceProperties {
pub fn properties(&self) -> vk::PhysicalDeviceProperties {
self.properties
}
@@ -899,9 +1024,9 @@ impl super::InstanceShared {
fn inspect(
&self,
phd: vk::PhysicalDevice,
- ) -> (PhysicalDeviceCapabilities, PhysicalDeviceFeatures) {
+ ) -> (PhysicalDeviceProperties, PhysicalDeviceFeatures) {
let capabilities = {
- let mut capabilities = PhysicalDeviceCapabilities::default();
+ let mut capabilities = PhysicalDeviceProperties::default();
capabilities.supported_extensions =
unsafe { self.raw.enumerate_device_extension_properties(phd).unwrap() };
capabilities.properties = unsafe { self.raw.get_physical_device_properties(phd) };
@@ -923,9 +1048,10 @@ impl super::InstanceShared {
let mut builder = vk::PhysicalDeviceProperties2KHR::builder();
if supports_maintenance3 {
- capabilities.maintenance_3 =
- Some(vk::PhysicalDeviceMaintenance3Properties::default());
- builder = builder.push_next(capabilities.maintenance_3.as_mut().unwrap());
+ let next = capabilities
+ .maintenance_3
+ .insert(vk::PhysicalDeviceMaintenance3Properties::default());
+ builder = builder.push_next(next);
}
if supports_descriptor_indexing {
@@ -1001,7 +1127,8 @@ impl super::InstanceShared {
builder = builder.push_next(next);
}
- // `VK_KHR_imageless_framebuffer` is promoted to 1.2, but has no changes, so we can keep using the extension unconditionally.
+ // `VK_KHR_imageless_framebuffer` is promoted to 1.2, but has no
+ // changes, so we can keep using the extension unconditionally.
if capabilities.supports_extension(vk::KhrImagelessFramebufferFn::name()) {
let next = features
.imageless_framebuffer
@@ -1009,7 +1136,8 @@ impl super::InstanceShared {
builder = builder.push_next(next);
}
- // `VK_KHR_timeline_semaphore` is promoted to 1.2, but has no changes, so we can keep using the extension unconditionally.
+ // `VK_KHR_timeline_semaphore` is promoted to 1.2, but has no
+ // changes, so we can keep using the extension unconditionally.
if capabilities.supports_extension(vk::KhrTimelineSemaphoreFn::name()) {
let next = features
.timeline_semaphore
@@ -1295,7 +1423,7 @@ impl super::Adapter {
self.raw
}
- pub fn physical_device_capabilities(&self) -> &PhysicalDeviceCapabilities {
+ pub fn physical_device_capabilities(&self) -> &PhysicalDeviceProperties {
&self.phd_capabilities
}
@@ -1320,7 +1448,20 @@ impl super::Adapter {
supported_extensions
}
- /// `features` must be the same features used to create `enabled_extensions`.
+ /// Create a `PhysicalDeviceFeatures` for opening a logical device with
+ /// `features` from this adapter.
+ ///
+ /// The given `enabled_extensions` set must include all the extensions
+ /// selected by [`required_device_extensions`] when passed `features`.
+ /// Otherwise, the `PhysicalDeviceFeatures` value may not be able to select
+ /// all the Vulkan features needed to represent `features` and this
+ /// adapter's characteristics.
+ ///
+ /// Typically, you'd simply call `required_device_extensions`, and then pass
+ /// its return value and the feature set you gave it directly to this
+ /// function. But it's fine to add more extensions to the list.
+ ///
+ /// [`required_device_extensions`]: Self::required_device_extensions
pub fn physical_device_features(
&self,
enabled_extensions: &[&'static CStr],
@@ -1607,7 +1748,9 @@ impl super::Adapter {
}
}
-impl crate::Adapter<super::Api> for super::Adapter {
+impl crate::Adapter for super::Adapter {
+ type A = super::Api;
+
unsafe fn open(
&self,
features: wgt::Features,
diff --git a/third_party/rust/wgpu-hal/src/vulkan/command.rs b/third_party/rust/wgpu-hal/src/vulkan/command.rs
index 42ea907738..43a2471954 100644
--- a/third_party/rust/wgpu-hal/src/vulkan/command.rs
+++ b/third_party/rust/wgpu-hal/src/vulkan/command.rs
@@ -60,7 +60,9 @@ impl super::CommandEncoder {
}
}
-impl crate::CommandEncoder<super::Api> for super::CommandEncoder {
+impl crate::CommandEncoder for super::CommandEncoder {
+ type A = super::Api;
+
unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
if self.free.is_empty() {
let vk_info = vk::CommandBufferAllocateInfo::builder()
diff --git a/third_party/rust/wgpu-hal/src/vulkan/device.rs b/third_party/rust/wgpu-hal/src/vulkan/device.rs
index c00c3d1d43..70028cc700 100644
--- a/third_party/rust/wgpu-hal/src/vulkan/device.rs
+++ b/third_party/rust/wgpu-hal/src/vulkan/device.rs
@@ -830,7 +830,9 @@ impl super::Device {
}
}
-impl crate::Device<super::Api> for super::Device {
+impl crate::Device for super::Device {
+ type A = super::Api;
+
unsafe fn exit(self, queue: super::Queue) {
unsafe { self.mem_allocator.into_inner().cleanup(&*self.shared) };
unsafe { self.desc_allocator.into_inner().cleanup(&*self.shared) };
diff --git a/third_party/rust/wgpu-hal/src/vulkan/instance.rs b/third_party/rust/wgpu-hal/src/vulkan/instance.rs
index 771938b0b0..a0d29a13a3 100644
--- a/third_party/rust/wgpu-hal/src/vulkan/instance.rs
+++ b/third_party/rust/wgpu-hal/src/vulkan/instance.rs
@@ -579,7 +579,9 @@ impl Drop for super::InstanceShared {
}
}
-impl crate::Instance<super::Api> for super::Instance {
+impl crate::Instance for super::Instance {
+ type A = super::Api;
+
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
profiling::scope!("Init Vulkan Backend");
use crate::auxil::cstr_from_bytes_until_nul;
@@ -956,7 +958,9 @@ impl crate::Instance<super::Api> for super::Instance {
}
}
-impl crate::Surface<super::Api> for super::Surface {
+impl crate::Surface for super::Surface {
+ type A = super::Api;
+
unsafe fn configure(
&self,
device: &super::Device,
diff --git a/third_party/rust/wgpu-hal/src/vulkan/mod.rs b/third_party/rust/wgpu-hal/src/vulkan/mod.rs
index 1f922e83da..0cd385045c 100644
--- a/third_party/rust/wgpu-hal/src/vulkan/mod.rs
+++ b/third_party/rust/wgpu-hal/src/vulkan/mod.rs
@@ -189,7 +189,7 @@ pub struct Adapter {
instance: Arc<InstanceShared>,
//queue_families: Vec<vk::QueueFamilyProperties>,
known_memory_flags: vk::MemoryPropertyFlags,
- phd_capabilities: adapter::PhysicalDeviceCapabilities,
+ phd_capabilities: adapter::PhysicalDeviceProperties,
//phd_features: adapter::PhysicalDeviceFeatures,
downlevel_flags: wgt::DownlevelFlags,
private_caps: PrivateCapabilities,
@@ -594,7 +594,9 @@ impl Fence {
}
}
-impl crate::Queue<Api> for Queue {
+impl crate::Queue for Queue {
+ type A = Api;
+
unsafe fn submit(
&self,
command_buffers: &[&CommandBuffer],