diff --git a/Cargo.lock b/Cargo.lock index d83e554c..97dbb4b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,11 +267,11 @@ dependencies = [ [[package]] name = "bit-set" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +checksum = "34ddef2995421ab6a5c779542c81ee77c115206f4ad9d5a8e05f4ff49716a3dd" dependencies = [ - "bit-vec", + "bit-vec 0.9.1", ] [[package]] @@ -280,6 +280,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + [[package]] name = "bitflags" version = "1.3.2" @@ -292,12 +298,6 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - [[package]] name = "block-sys" version = "0.2.1" @@ -564,9 +564,9 @@ dependencies = [ [[package]] name = "codespan-reporting" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" dependencies = [ "serde", "termcolor", @@ -613,16 +613,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-foundation" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -636,8 +626,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", - "core-foundation 0.9.4", - "core-graphics-types 0.1.3", + "core-foundation", + "core-graphics-types", "foreign-types", "libc", ] @@ -649,18 +639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ "bitflags 1.3.2", - "core-foundation 0.9.4", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" -dependencies = [ - "bitflags 2.10.0", - "core-foundation 0.10.1", + "core-foundation", "libc", ] @@ -1053,6 +1032,30 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ebd3504ad6116843b8375ad70df74e7bfe83cac77a1f3fe73200c844d43bfe0" +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + [[package]] name = "generational-arena" version = "0.2.8" @@ -1253,9 +1256,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "glow" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" +checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" dependencies = [ "js-sys", "slotmap", @@ -1470,12 +1473,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.9.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown 0.16.1", ] [[package]] @@ -1517,9 +1520,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -1734,9 +1737,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "mach2" @@ -1747,15 +1750,6 @@ dependencies = [ "libc", ] -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - [[package]] name = "matchers" version = "0.0.1" @@ -1827,21 +1821,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "metal" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7047791b5bc903b8cd963014b355f71dc9864a9a0b727057676c1dcae5cbc15" -dependencies = [ - "bitflags 2.10.0", - "block", - "core-graphics-types 0.2.0", - "foreign-types", - "log", - "objc", - "paste", -] - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1886,9 +1865,9 @@ dependencies = [ [[package]] name = "naga" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "618f667225063219ddfc61251087db8a9aec3c3f0950c916b614e403486f1135" +checksum = "85b4372fed0bd362d646d01b6926df0e837859ccc522fed720c395e0460f29c8" dependencies = [ "arrayvec", "bit-set", @@ -1899,7 +1878,7 @@ dependencies = [ "half", "hashbrown 0.16.1", "hexf-parse", - "indexmap 2.9.0", + "indexmap 2.13.0", "libm", "log", "num-traits", @@ -2136,15 +2115,6 @@ dependencies = [ "serde", ] -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - [[package]] name = "objc-sys" version = "0.3.5" @@ -2256,6 +2226,31 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-metal" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0125f776a10d00af4152d74616409f0d4a2053a6f57fa5b7d6aa2854ac04794" +dependencies = [ + "bitflags 2.10.0", + "block2 0.6.2", + "objc2 0.6.3", + "objc2-foundation", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f" +dependencies = [ + "bitflags 2.10.0", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-foundation", + "objc2-metal", +] + [[package]] name = "object" version = "0.27.1" @@ -2415,7 +2410,7 @@ checksum = "54acf3a685220b533e437e264e4d932cfbdc4cc7ec0cd232ed73c08d03b8a7ca" dependencies = [ "fixedbitset 0.5.7", "hashbrown 0.15.2", - "indexmap 2.9.0", + "indexmap 2.13.0", ] [[package]] @@ -2651,7 +2646,7 @@ checksum = "73edcbebd2c2a9eb0041e40b046b5136da32990fcd2ac76b9414ebff45908e18" dependencies = [ "approx", "arrayvec", - "bit-vec", + "bit-vec 0.8.0", "bitflags 2.10.0", "downcast-rs 2.0.2", "glamx", @@ -2676,6 +2671,18 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" +[[package]] +name = "raw-window-metal" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d213455a5f1dc59214213c7330e074ddf8114c9a42411eb890c767357ce135" +dependencies = [ + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-foundation", + "objc2-quartz-core", +] + [[package]] name = "rawpointer" version = "0.2.1" @@ -3093,9 +3100,9 @@ dependencies = [ [[package]] name = "spirv" -version = "0.3.0+sdk-1.3.268.0" +version = "0.4.0+sdk-1.4.341.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" +checksum = "d9571ea910ebd84c86af4b3ed27f9dbdc6ad06f17c5f96146b2b671e2976744f" dependencies = [ "bitflags 2.10.0", ] @@ -3598,37 +3605,25 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ "cfg-if 1.0.0", "once_cell", "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn 2.0.100", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" dependencies = [ "cfg-if 1.0.0", + "futures-util", "js-sys", "once_cell", "wasm-bindgen", @@ -3637,9 +3632,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3647,22 +3642,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn 2.0.100", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] @@ -3778,9 +3773,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.77" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" dependencies = [ "js-sys", "wasm-bindgen", @@ -3798,9 +3793,9 @@ dependencies = [ [[package]] name = "wgpu" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9cb534d5ffd109c7d1135f34cdae29e60eab94855a625dcfe1705f8bc7ad79f" +checksum = "78f9f386699b1fb8b8a05bfe82169b24d151f05702d2905a0bf93bc454fcc825" dependencies = [ "arrayvec", "bitflags 2.10.0", @@ -3828,19 +3823,19 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb4c8b5db5f00e56f1f08869d870a0dff7c8bc7ebc01091fec140b0cf0211a9" +checksum = "c7c34181b0acb8f98168f78f8e57ec66f57df5522b39143dbe5f2f45d7ca927c" dependencies = [ "arrayvec", "bit-set", - "bit-vec", + "bit-vec 0.9.1", "bitflags 2.10.0", "bytemuck", "cfg_aliases 0.2.1", "document-features", "hashbrown 0.16.1", - "indexmap 2.9.0", + "indexmap 2.13.0", "log", "naga", "once_cell", @@ -3856,61 +3851,61 @@ dependencies = [ "wgpu-core-deps-wasm", "wgpu-core-deps-windows-linux-android", "wgpu-hal", + "wgpu-naga-bridge", "wgpu-types", ] [[package]] name = "wgpu-core-deps-apple" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b7b696b918f337c486bf93142454080a32a37832ba8a31e4f48221890047da" +checksum = "43acd053312501689cd92a01a9638d37f3e41a5fd9534875efa8917ee2d11ac0" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-emscripten" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34b251c331f84feac147de3c4aa3aa45112622a95dd7ee1b74384fa0458dbd79" +checksum = "ef043bf135cc68b6f667c55ff4e345ce2b5924d75bad36a47921b0287ca4b24a" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-wasm" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12a2cf578ce8d7d50d0e63ddc2345c7dcb599f6eb90b888813406ea78b9b7010" +checksum = "2f7b75e72f49035f000dd5262e4126242e92a090a4fd75931ecfe7e60784e6fa" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-core-deps-windows-linux-android" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ca976e72b2c9964eb243e281f6ce7f14a514e409920920dcda12ae40febaae" +checksum = "725d5c006a8c02967b6d93ef04f6537ec4593313e330cfe86d9d3f946eb90f28" dependencies = [ "wgpu-hal", ] [[package]] name = "wgpu-hal" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "293080d77fdd14d6b08a67c5487dfddbf874534bb7921526db56a7b75d7e3bef" +checksum = "058b6047337cf323a4f092486443a9337f3d81325347e5d77deed7e563aeaedc" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set", "bitflags 2.10.0", - "block", + "block2 0.6.2", "bytemuck", "cfg-if 1.0.0", "cfg_aliases 0.2.1", - "core-graphics-types 0.2.0", "glow", "glutin_wgl_sys", "gpu-allocator", @@ -3921,10 +3916,13 @@ dependencies = [ "libc", "libloading", "log", - "metal", "naga", "ndk-sys 0.6.0+11769913", - "objc", + "objc2 0.6.3", + "objc2-core-foundation", + "objc2-foundation", + "objc2-metal", + "objc2-quartz-core", "once_cell", "ordered-float", "parking_lot", @@ -3933,26 +3931,40 @@ dependencies = [ "profiling", "range-alloc", "raw-window-handle", + "raw-window-metal", "renderdoc-sys", "smallvec 1.15.1", "thiserror 2.0.16", "wasm-bindgen", + "wayland-sys", "web-sys", + "wgpu-naga-bridge", "wgpu-types", "windows", "windows-core", ] +[[package]] +name = "wgpu-naga-bridge" +version = "29.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b8e1e505095f24cb4a578f04b1421d456257dca7fac114d9d9dd3d978c34b8" +dependencies = [ + "naga", + "wgpu-types", +] + [[package]] name = "wgpu-types" -version = "28.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e18308757e594ed2cd27dddbb16a139c42a683819d32a2e0b1b0167552f5840c" +checksum = "d15ece45db77dd5451f11c0ce898334317ce8502d304a20454b531fdc0652fae" dependencies = [ "bitflags 2.10.0", "bytemuck", "js-sys", "log", + "raw-window-handle", "web-sys", ] @@ -4334,7 +4346,7 @@ dependencies = [ "bytemuck", "calloop", "cfg_aliases 0.1.1", - "core-foundation 0.9.4", + "core-foundation", "core-graphics", "cursor-icon", "icrate", diff --git a/crates/lambda-rs-platform/Cargo.toml b/crates/lambda-rs-platform/Cargo.toml index f3e3fe62..4e865d9c 100644 --- a/crates/lambda-rs-platform/Cargo.toml +++ b/crates/lambda-rs-platform/Cargo.toml @@ -12,14 +12,14 @@ path = "src/lib.rs" [dependencies] winit = "=0.29.15" -naga = { version = "=28.0.0", optional = true, default-features = false, features = [ +naga = { version = "=29.0.0", optional = true, default-features = false, features = [ "spv-out", "glsl-in", "wgsl-in", ] } rand = "=0.8.5" obj-rs = "=0.7.4" -wgpu = { version = "=28.0.0", optional = true, features = ["wgsl", "spirv"] } +wgpu = { version = "=29.0.0", optional = true, features = ["wgsl", "spirv"] } pollster = { version = "=0.4.0", optional = true } lambda-rs-logging = { path = "../lambda-rs-logging", version = "2023.1.30" } cpal = { version = "=0.17.2", optional = true } diff --git a/crates/lambda-rs-platform/src/wgpu/gpu.rs b/crates/lambda-rs-platform/src/wgpu/gpu.rs index 7262607a..8b8d09b0 100644 --- a/crates/lambda-rs-platform/src/wgpu/gpu.rs +++ b/crates/lambda-rs-platform/src/wgpu/gpu.rs @@ -246,8 +246,7 @@ impl Gpu { return GpuLimits { max_uniform_buffer_binding_size: self .limits - .max_uniform_buffer_binding_size - .into(), + .max_uniform_buffer_binding_size, max_bind_groups: self.limits.max_bind_groups, max_vertex_buffers: self.limits.max_vertex_buffers, max_vertex_attributes: self.limits.max_vertex_attributes, diff --git a/crates/lambda-rs-platform/src/wgpu/instance.rs b/crates/lambda-rs-platform/src/wgpu/instance.rs index 484dda90..43a4e028 100644 --- a/crates/lambda-rs-platform/src/wgpu/instance.rs +++ b/crates/lambda-rs-platform/src/wgpu/instance.rs @@ -167,11 +167,12 @@ impl InstanceBuilder { flags: self.flags.to_wgpu(), memory_budget_thresholds: self.memory_budget_thresholds, backend_options: self.backend_options, + display: None, }; Instance { label: self.label, - instance: wgpu::Instance::new(&descriptor), + instance: wgpu::Instance::new(descriptor), } } } diff --git a/crates/lambda-rs-platform/src/wgpu/pipeline.rs b/crates/lambda-rs-platform/src/wgpu/pipeline.rs index 2cae4bf8..f44ae197 100644 --- a/crates/lambda-rs-platform/src/wgpu/pipeline.rs +++ b/crates/lambda-rs-platform/src/wgpu/pipeline.rs @@ -305,7 +305,7 @@ fn align_up_u32(value: u32, alignment: u32) -> u32 { /// Validate immediate ranges and calculate the minimum allocation size. /// -/// wgpu v28 uses a single byte region of size `immediate_size`, addressed by +/// wgpu uses a single byte region of size `immediate_size`, addressed by /// `set_immediates(offset, data)`. This function enforces that the provided /// ranges: /// - Start at byte offset 0 (as a union) @@ -408,10 +408,13 @@ impl<'a> PipelineLayoutBuilder<'a> { /// Build the layout. pub fn build(self, gpu: &Gpu) -> PipelineLayout { - let layouts_raw: Vec<&wgpu::BindGroupLayout> = - self.layouts.iter().map(|l| l.raw()).collect(); + let layouts_raw: Vec> = self + .layouts + .iter() + .map(|layout| Some(layout.raw())) + .collect(); - // wgpu v28 allocates a single immediate byte region sized by + // wgpu allocates a single immediate byte region sized by // `PipelineLayoutDescriptor::immediate_size`. If callers provide multiple // ranges, they are treated as sub-ranges of the same contiguous allocation. // @@ -442,7 +445,7 @@ impl<'a> PipelineLayoutBuilder<'a> { .device() .create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: self.label.as_deref(), - bind_group_layouts: &layouts_raw, + bind_group_layouts: layouts_raw.as_slice(), immediate_size, }); if fallback_used { @@ -625,8 +628,8 @@ impl<'a> RenderPipelineBuilder<'a> { pub fn with_depth_stencil(mut self, format: DepthFormat) -> Self { self.depth_stencil = Some(wgpu::DepthStencilState { format: format.to_wgpu(), - depth_write_enabled: true, - depth_compare: wgpu::CompareFunction::Less, + depth_write_enabled: Some(true), + depth_compare: Some(wgpu::CompareFunction::Less), stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), }); @@ -637,12 +640,12 @@ impl<'a> RenderPipelineBuilder<'a> { pub fn with_depth_compare(mut self, compare: CompareFunction) -> Self { let ds = self.depth_stencil.get_or_insert(wgpu::DepthStencilState { format: wgpu::TextureFormat::Depth32Float, - depth_write_enabled: true, - depth_compare: wgpu::CompareFunction::Less, + depth_write_enabled: Some(true), + depth_compare: Some(wgpu::CompareFunction::Less), stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), }); - ds.depth_compare = compare.to_wgpu(); + ds.depth_compare = Some(compare.to_wgpu()); return self; } @@ -650,12 +653,12 @@ impl<'a> RenderPipelineBuilder<'a> { pub fn with_depth_write_enabled(mut self, enabled: bool) -> Self { let ds = self.depth_stencil.get_or_insert(wgpu::DepthStencilState { format: wgpu::TextureFormat::Depth32Float, - depth_write_enabled: true, - depth_compare: wgpu::CompareFunction::Less, + depth_write_enabled: Some(true), + depth_compare: Some(wgpu::CompareFunction::Less), stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), }); - ds.depth_write_enabled = enabled; + ds.depth_write_enabled = Some(enabled); return self; } @@ -663,8 +666,8 @@ impl<'a> RenderPipelineBuilder<'a> { pub fn with_stencil(mut self, stencil: StencilState) -> Self { let ds = self.depth_stencil.get_or_insert(wgpu::DepthStencilState { format: wgpu::TextureFormat::Depth24PlusStencil8, - depth_write_enabled: true, - depth_compare: wgpu::CompareFunction::Less, + depth_write_enabled: Some(true), + depth_compare: Some(wgpu::CompareFunction::Less), stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), }); diff --git a/crates/lambda-rs-platform/src/wgpu/render_pass.rs b/crates/lambda-rs-platform/src/wgpu/render_pass.rs index df5cd5ce..a4847e52 100644 --- a/crates/lambda-rs-platform/src/wgpu/render_pass.rs +++ b/crates/lambda-rs-platform/src/wgpu/render_pass.rs @@ -431,7 +431,7 @@ impl<'a> RenderPass<'a> { /// Set immediate data for subsequent draw calls. /// - /// This is the wgpu v28 replacement for push constants. The `offset` and + /// This is the current wgpu replacement for push constants. The `offset` and /// `data` length MUST be multiples of 4 bytes (IMMEDIATE_DATA_ALIGNMENT). pub fn set_immediates(&mut self, offset: u32, data: &[u8]) { self.raw.set_immediates(offset, data); diff --git a/crates/lambda-rs-platform/src/wgpu/surface.rs b/crates/lambda-rs-platform/src/wgpu/surface.rs index 0c0008ac..c4ad6afc 100644 --- a/crates/lambda-rs-platform/src/wgpu/surface.rs +++ b/crates/lambda-rs-platform/src/wgpu/surface.rs @@ -97,23 +97,14 @@ pub enum SurfaceError { OutOfMemory, /// Timed out waiting for a frame. Timeout, + /// The window is occluded and cannot currently present. + Occluded, + /// Surface acquisition triggered a validation error. + Validation, /// Other/unclassified error (opaque). Other(String), } -impl From for SurfaceError { - fn from(error: wgpu::SurfaceError) -> Self { - use wgpu::SurfaceError as We; - match error { - We::Lost => return SurfaceError::Lost, - We::Outdated => return SurfaceError::Outdated, - We::OutOfMemory => return SurfaceError::OutOfMemory, - We::Timeout => return SurfaceError::Timeout, - _ => return SurfaceError::Other(format!("{:?}", error)), - } - } -} - /// Builder for creating a `Surface` bound to a `winit` window. #[derive(Debug, Clone)] pub struct SurfaceBuilder { @@ -160,7 +151,7 @@ impl SurfaceBuilder { instance .raw() .create_surface_unsafe(wgpu::SurfaceTargetUnsafe::RawHandle { - raw_display_handle, + raw_display_handle: Some(raw_display_handle), raw_window_handle, }) .map_err(CreateSurfaceError::from)? @@ -298,15 +289,34 @@ impl<'window> Surface<'window> { /// Acquire the next swapchain texture and a default view. pub fn acquire_next_frame(&self) -> Result { - let texture = match self.surface.get_current_texture() { - Ok(t) => t, - Err(e) => return Err(SurfaceError::from(e)), + let (texture, suboptimal) = match self.surface.get_current_texture() { + wgpu::CurrentSurfaceTexture::Success(texture) => (texture, false), + wgpu::CurrentSurfaceTexture::Suboptimal(texture) => (texture, true), + wgpu::CurrentSurfaceTexture::Timeout => { + return Err(SurfaceError::Timeout); + } + wgpu::CurrentSurfaceTexture::Outdated => { + return Err(SurfaceError::Outdated); + } + wgpu::CurrentSurfaceTexture::Lost => { + return Err(SurfaceError::Lost); + } + wgpu::CurrentSurfaceTexture::Occluded => { + return Err(SurfaceError::Occluded); + } + wgpu::CurrentSurfaceTexture::Validation => { + return Err(SurfaceError::Validation); + } }; let view = texture .texture .create_view(&wgpu::TextureViewDescriptor::default()); - return Ok(Frame { texture, view }); + return Ok(Frame { + texture, + view, + suboptimal, + }); } } @@ -383,6 +393,7 @@ fn select_present_mode( pub struct Frame { texture: wgpu::SurfaceTexture, view: wgpu::TextureView, + suboptimal: bool, } /// Borrowed reference to a texture view used for render passes. @@ -397,6 +408,11 @@ impl Frame { return TextureViewRef { raw: &self.view }; } + /// Whether this frame was acquired in a suboptimal surface state. + pub fn is_suboptimal(&self) -> bool { + return self.suboptimal; + } + /// Present the frame to the swapchain. pub fn present(self) { self.texture.present(); diff --git a/crates/lambda-rs/src/render/surface.rs b/crates/lambda-rs/src/render/surface.rs index 948fe964..c2a27db8 100644 --- a/crates/lambda-rs/src/render/surface.rs +++ b/crates/lambda-rs/src/render/surface.rs @@ -177,6 +177,10 @@ pub enum SurfaceError { OutOfMemory, /// Timed out waiting for a frame. Timeout, + /// The window is occluded and cannot currently present. + Occluded, + /// Surface acquisition triggered a validation error. + Validation, /// Other/unclassified error. Other(String), } @@ -188,6 +192,8 @@ impl From for SurfaceError { platform_surface::SurfaceError::Outdated => SurfaceError::Outdated, platform_surface::SurfaceError::OutOfMemory => SurfaceError::OutOfMemory, platform_surface::SurfaceError::Timeout => SurfaceError::Timeout, + platform_surface::SurfaceError::Occluded => SurfaceError::Occluded, + platform_surface::SurfaceError::Validation => SurfaceError::Validation, platform_surface::SurfaceError::Other(msg) => SurfaceError::Other(msg), }; } @@ -236,6 +242,14 @@ mod tests { SurfaceError::from(platform_surface::SurfaceError::Timeout), SurfaceError::Timeout )); + assert!(matches!( + SurfaceError::from(platform_surface::SurfaceError::Occluded), + SurfaceError::Occluded + )); + assert!(matches!( + SurfaceError::from(platform_surface::SurfaceError::Validation), + SurfaceError::Validation + )); let other = SurfaceError::from(platform_surface::SurfaceError::Other( "opaque".to_string(), diff --git a/crates/lambda-rs/src/render/targets/surface.rs b/crates/lambda-rs/src/render/targets/surface.rs index 92053f95..63f32dcd 100644 --- a/crates/lambda-rs/src/render/targets/surface.rs +++ b/crates/lambda-rs/src/render/targets/surface.rs @@ -199,6 +199,10 @@ pub enum SurfaceError { OutOfMemory, /// Timed out waiting for a frame. Timeout, + /// The window is occluded and cannot currently present. + Occluded, + /// Surface acquisition triggered a validation error. + Validation, /// Other/unclassified error. Other(String), } @@ -210,6 +214,8 @@ impl From for SurfaceError { platform::surface::SurfaceError::Outdated => SurfaceError::Outdated, platform::surface::SurfaceError::OutOfMemory => SurfaceError::OutOfMemory, platform::surface::SurfaceError::Timeout => SurfaceError::Timeout, + platform::surface::SurfaceError::Occluded => SurfaceError::Occluded, + platform::surface::SurfaceError::Validation => SurfaceError::Validation, platform::surface::SurfaceError::Other(msg) => SurfaceError::Other(msg), }; } @@ -415,6 +421,14 @@ mod tests { SurfaceError::from(platform::surface::SurfaceError::Timeout), SurfaceError::Timeout )); + assert!(matches!( + SurfaceError::from(platform::surface::SurfaceError::Occluded), + SurfaceError::Occluded + )); + assert!(matches!( + SurfaceError::from(platform::surface::SurfaceError::Validation), + SurfaceError::Validation + )); let other = SurfaceError::from(platform::surface::SurfaceError::Other( "opaque".to_string(), ));