From 342a7b793e614b79ccf0c27554c0c9cc5bfd7e51 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Fri, 19 Jul 2024 23:31:01 +0200 Subject: [PATCH] Update the cli app to wgpu 22.0 --- Cargo.lock | 1191 +++---------------------------- cli/Cargo.toml | 4 +- cli/src/show.rs | 1240 ++++++++++++++++++--------------- examples/wgpu_svg/src/main.rs | 2 +- 4 files changed, 765 insertions(+), 1672 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 104ca804..ad8f74b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,10 +66,10 @@ dependencies = [ "jni-sys", "libc", "log", - "ndk 0.9.0", + "ndk", "ndk-context", "ndk-sys 0.6.0+11769913", - "num_enum 0.7.2", + "num_enum", "thiserror", ] @@ -151,12 +151,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "arrayvec" version = "0.7.4" @@ -169,22 +163,13 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" -[[package]] -name = "ash" -version = "0.37.3+1.3.251" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" -dependencies = [ - "libloading 0.7.4", -] - [[package]] name = "ash" version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "libloading 0.8.3", + "libloading", ] [[package]] @@ -231,30 +216,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dfdb4953a096c551ce9ace855a604d702e6e62d77fac690575ae347571717f5" -[[package]] -name = "bit-set" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" -dependencies = [ - "bit-vec 0.6.3", -] - [[package]] name = "bit-set" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f" dependencies = [ - "bit-vec 0.7.0", + "bit-vec", ] -[[package]] -name = "bit-vec" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" - [[package]] name = "bit-vec" version = "0.7.0" @@ -314,32 +284,12 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" -[[package]] -name = "calloop" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e0d00eb1ea24371a97d2da6201c6747a633dc6dc1988ef503403b4c59504a8" -dependencies = [ - "bitflags 1.3.2", - "log", - "nix 0.25.1", - "slotmap", - "thiserror", - "vec_map", -] - [[package]] name = "calloop" version = "0.12.4" @@ -360,10 +310,10 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ - "calloop 0.12.4", + "calloop", "rustix", "wayland-backend", - "wayland-client 0.31.2", + "wayland-client", ] [[package]] @@ -449,61 +399,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - -[[package]] -name = "cocoa" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a" -dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics 0.22.3", - "foreign-types 0.3.2", - "libc", - "objc", -] - -[[package]] -name = "cocoa" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c" -dependencies = [ - "bitflags 1.3.2", - "block", - "cocoa-foundation", - "core-foundation", - "core-graphics 0.23.2", - "foreign-types 0.5.0", - "libc", - "objc", -] - -[[package]] -name = "cocoa-foundation" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" -dependencies = [ - "bitflags 1.3.2", - "block", - "core-foundation", - "core-graphics-types", - "libc", - "objc", -] - [[package]] name = "codespan-reporting" version = "0.11.1" @@ -570,12 +465,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "copyless" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" - [[package]] name = "core-foundation" version = "0.9.4" @@ -592,19 +481,6 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" -[[package]] -name = "core-graphics" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.3.2", - "libc", -] - [[package]] name = "core-graphics" version = "0.23.2" @@ -614,7 +490,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types 0.5.0", + "foreign-types", "libc", ] @@ -629,18 +505,6 @@ dependencies = [ "libc", ] -[[package]] -name = "core-text" -version = "20.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5" -dependencies = [ - "core-foundation", - "core-graphics 0.23.2", - "foreign-types 0.5.0", - "libc", -] - [[package]] name = "crc32fast" version = "1.4.0" @@ -656,52 +520,12 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" -[[package]] -name = "crossfont" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb5a3822b594afc99b503cc1859b94686d3c3efdd60507a28587dab80ee1071" -dependencies = [ - "cocoa 0.25.0", - "core-foundation", - "core-foundation-sys", - "core-graphics 0.23.2", - "core-text", - "dwrote", - "foreign-types 0.5.0", - "freetype-rs", - "libc", - "log", - "objc", - "once_cell", - "pkg-config", - "servo-fontconfig", - "winapi", -] - -[[package]] -name = "cty" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" - [[package]] name = "cursor-icon" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" -[[package]] -name = "d3d12" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "827914e1f53b1e0e025ecd3d967a7836b7bcb54520f90e21ef8df7b4d88a2759" -dependencies = [ - "bitflags 1.3.2", - "libloading 0.7.4", - "winapi", -] - [[package]] name = "d3d12" version = "22.0.0" @@ -709,45 +533,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017" dependencies = [ "bitflags 2.6.0", - "libloading 0.8.3", + "libloading", "winapi", ] -[[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "data-url" version = "0.3.1" @@ -766,7 +555,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.3", + "libloading", ] [[package]] @@ -790,20 +579,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" -[[package]] -name = "dwrote" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b" -dependencies = [ - "lazy_static", - "libc", - "serde", - "serde_derive", - "winapi", - "wio", -] - [[package]] name = "either" version = "1.11.0" @@ -872,25 +647,6 @@ dependencies = [ "serde", ] -[[package]] -name = "expat-sys" -version = "2.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" -dependencies = [ - "cmake", - "pkg-config", -] - -[[package]] -name = "fdeflate" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" -dependencies = [ - "simd-adler32", -] - [[package]] name = "flate2" version = "1.0.29" @@ -913,12 +669,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "fontconfig-parser" version = "0.5.6" @@ -936,21 +686,12 @@ checksum = "b0299020c3ef3f60f526a4f64ab4a3d4ce116b1acbf24cdd22da0068e5d81dc3" dependencies = [ "fontconfig-parser", "log", - "memmap2 0.9.4", + "memmap2", "slotmap", "tinyvec", "ttf-parser", ] -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared 0.1.1", -] - [[package]] name = "foreign-types" version = "0.5.0" @@ -958,7 +699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared 0.3.1", + "foreign-types-shared", ] [[package]] @@ -972,40 +713,12 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "foreign-types-shared" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" -[[package]] -name = "freetype-rs" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb" -dependencies = [ - "bitflags 1.3.2", - "freetype-sys", - "libc", -] - -[[package]] -name = "freetype-sys" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a" -dependencies = [ - "cmake", - "libc", - "pkg-config", -] - [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -1101,15 +814,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "gcc" version = "0.3.55" @@ -1156,18 +860,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "glow" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bd5877156a19b8ac83a29b2306fe20537429d318f3ff0a1a2119f8d9c61919" -dependencies = [ - "js-sys", - "slotmap", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "glow" version = "0.13.1" @@ -1189,16 +881,6 @@ dependencies = [ "gl_generator", ] -[[package]] -name = "gpu-alloc" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22beaafc29b38204457ea030f6fb7a84c9e4dd1b86e311ba0542533453d87f62" -dependencies = [ - "bitflags 1.3.2", - "gpu-alloc-types 0.2.0", -] - [[package]] name = "gpu-alloc" version = "0.6.0" @@ -1206,16 +888,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ "bitflags 2.6.0", - "gpu-alloc-types 0.3.0", -] - -[[package]] -name = "gpu-alloc-types" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54804d0d6bc9d7f26db4eaec1ad10def69b599315f487d32c334a80d1efe67a5" -dependencies = [ - "bitflags 1.3.2", + "gpu-alloc-types", ] [[package]] @@ -1240,17 +913,6 @@ dependencies = [ "windows", ] -[[package]] -name = "gpu-descriptor" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" -dependencies = [ - "bitflags 2.6.0", - "gpu-descriptor-types 0.1.2", - "hashbrown 0.14.5", -] - [[package]] name = "gpu-descriptor" version = "0.3.0" @@ -1258,19 +920,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c08c1f623a8d0b722b8b99f821eb0ba672a1618f0d3b16ddbee1cedd2dd8557" dependencies = [ "bitflags 2.6.0", - "gpu-descriptor-types 0.2.0", + "gpu-descriptor-types", "hashbrown 0.14.5", ] -[[package]] -name = "gpu-descriptor-types" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" -dependencies = [ - "bitflags 2.6.0", -] - [[package]] name = "gpu-descriptor-types" version = "0.2.0" @@ -1305,7 +958,7 @@ dependencies = [ "bitflags 2.6.0", "com", "libc", - "libloading 0.8.3", + "libloading", "thiserror", "widestring", "winapi", @@ -1347,12 +1000,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "imagesize" version = "0.12.0" @@ -1379,24 +1026,6 @@ dependencies = [ "hashbrown 0.14.5", ] -[[package]] -name = "inplace_it" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e567468c50f3d4bc7397702e09b380139f9b9288b4e909b070571007f8b5bf78" - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "itertools" version = "0.7.11" @@ -1446,17 +1075,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "khronos-egl" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3" -dependencies = [ - "libc", - "libloading 0.7.4", - "pkg-config", -] - [[package]] name = "khronos-egl" version = "6.0.0" @@ -1464,7 +1082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.8.3", + "libloading", "pkg-config", ] @@ -1480,7 +1098,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd85a5776cd9500c2e2059c8c76c3b01528566b7fcbaf8098b55a33fc298849b" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", ] [[package]] @@ -1489,32 +1107,16 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1618d4ebd923e97d67e7cd363d80aef35fe961005cbbbb3d2dad8bdd1bc63440" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "smallvec", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - [[package]] name = "libloading" version = "0.8.3" @@ -1600,8 +1202,8 @@ dependencies = [ "lyon", "rand", "regex", - "wgpu 0.13.1", - "winit 0.27.5", + "wgpu", + "winit", ] [[package]] @@ -1616,7 +1218,7 @@ dependencies = [ name = "lyon_geom" version = "1.0.5" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "euclid", "num-traits", "serde", @@ -1664,15 +1266,6 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.9.4" @@ -1682,29 +1275,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg 1.2.0", -] - -[[package]] -name = "metal" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de11355d1f6781482d027a3b4d4de7825dcedb197bf573e0596d00008402d060" -dependencies = [ - "bitflags 1.3.2", - "block", - "core-graphics-types", - "foreign-types 0.3.2", - "log", - "objc", -] - [[package]] name = "metal" version = "0.29.0" @@ -1714,7 +1284,7 @@ dependencies = [ "bitflags 2.6.0", "block", "core-graphics-types", - "foreign-types 0.5.0", + "foreign-types", "log", "objc", "paste", @@ -1727,39 +1297,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", - "simd-adler32", -] - -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - -[[package]] -name = "naga" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f50357e1167a3ab92d6b3c7f4bf5f7fd13fde3f4b28bf0d5ea07b5100fdb6c0" -dependencies = [ - "bit-set 0.5.3", - "bitflags 1.3.2", - "codespan-reporting", - "hexf-parse", - "indexmap 1.9.3", - "log", - "num-traits", - "rustc-hash", - "spirv 0.2.0+1.5.4", - "termcolor", - "thiserror", - "unicode-xid", ] [[package]] @@ -1768,8 +1305,8 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09eeccb9b50f4f7839b214aa3e08be467159506a986c18e0702170ccf720a453" dependencies = [ - "arrayvec 0.7.4", - "bit-set 0.6.0", + "arrayvec", + "bit-set", "bitflags 2.6.0", "cfg_aliases 0.1.1", "codespan-reporting", @@ -1777,26 +1314,12 @@ dependencies = [ "indexmap 2.2.6", "log", "rustc-hash", - "spirv 0.3.0+sdk-1.3.268.0", + "spirv", "termcolor", "thiserror", "unicode-xid", ] -[[package]] -name = "ndk" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" -dependencies = [ - "bitflags 1.3.2", - "jni-sys", - "ndk-sys 0.4.1+23.1.7779620", - "num_enum 0.5.11", - "raw-window-handle 0.5.2", - "thiserror", -] - [[package]] name = "ndk" version = "0.9.0" @@ -1807,8 +1330,8 @@ dependencies = [ "jni-sys", "log", "ndk-sys 0.6.0+11769913", - "num_enum 0.7.2", - "raw-window-handle 0.6.1", + "num_enum", + "raw-window-handle", "thiserror", ] @@ -1818,44 +1341,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" -[[package]] -name = "ndk-glue" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f" -dependencies = [ - "libc", - "log", - "ndk 0.7.0", - "ndk-context", - "ndk-macro", - "ndk-sys 0.4.1+23.1.7779620", - "once_cell", - "parking_lot", -] - -[[package]] -name = "ndk-macro" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c" -dependencies = [ - "darling", - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ndk-sys" -version = "0.4.1+23.1.7779620" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" -dependencies = [ - "jni-sys", -] - [[package]] name = "ndk-sys" version = "0.5.0+25.2.9519653" @@ -1874,31 +1359,6 @@ dependencies = [ "jni-sys", ] -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset", -] - -[[package]] -name = "nix" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" -dependencies = [ - "autocfg 1.2.0", - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset", -] - [[package]] name = "num-traits" version = "0.2.18" @@ -1909,34 +1369,13 @@ dependencies = [ "libm", ] -[[package]] -name = "num_enum" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" -dependencies = [ - "num_enum_derive 0.5.11", -] - [[package]] name = "num_enum" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ - "num_enum_derive 0.7.2", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 1.0.109", + "num_enum_derive", ] [[package]] @@ -1945,7 +1384,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate", "proc-macro2", "quote", "syn 2.0.60", @@ -1958,7 +1397,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ "malloc_buf", - "objc_exception", ] [[package]] @@ -2017,15 +1455,6 @@ dependencies = [ "objc2", ] -[[package]] -name = "objc_exception" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" -dependencies = [ - "cc", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -2143,19 +1572,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "png" -version = "0.17.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" -dependencies = [ - "bitflags 1.3.2", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - [[package]] name = "polling" version = "3.7.0" @@ -2177,23 +1593,13 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit 0.19.15", -] - [[package]] name = "proc-macro-crate" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -2332,35 +1738,20 @@ dependencies = [ "rand_core 0.4.2", ] -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "range-alloc" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" - -[[package]] -name = "raw-window-handle" -version = "0.4.3" +[[package]] +name = "rand_xorshift" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" dependencies = [ - "cty", + "rand_core 0.3.1", ] [[package]] -name = "raw-window-handle" -version = "0.5.2" +name = "range-alloc" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" [[package]] name = "raw-window-handle" @@ -2424,12 +1815,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "renderdoc-sys" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157" - [[package]] name = "renderdoc-sys" version = "1.1.0" @@ -2477,15 +1862,6 @@ dependencies = [ "unicode-script", ] -[[package]] -name = "safe_arch" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05" -dependencies = [ - "bytemuck", -] - [[package]] name = "same-file" version = "1.0.6" @@ -2507,18 +1883,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sctk-adwaita" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61270629cc6b4d77ec1907db1033d5c2e1a404c412743621981a871dc9c12339" -dependencies = [ - "crossfont", - "log", - "smithay-client-toolkit 0.16.1", - "tiny-skia 0.7.0", -] - [[package]] name = "sctk-adwaita" version = "0.9.0" @@ -2527,9 +1891,9 @@ checksum = "7de61fa7334ee8ee1f5c3c58dcc414fb9361e7e8f5bff9d45f4d69eeb89a7169" dependencies = [ "ab_glyph", "log", - "memmap2 0.9.4", - "smithay-client-toolkit 0.18.1", - "tiny-skia 0.11.4", + "memmap2", + "smithay-client-toolkit", + "tiny-skia", ] [[package]] @@ -2552,33 +1916,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "servo-fontconfig" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" -dependencies = [ - "libc", - "servo-fontconfig-sys", -] - -[[package]] -name = "servo-fontconfig-sys" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" -dependencies = [ - "expat-sys", - "freetype-sys", - "pkg-config", -] - -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - [[package]] name = "simplecss" version = "0.2.1" @@ -2618,25 +1955,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "smithay-client-toolkit" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870427e30b8f2cbe64bf43ec4b86e88fe39b0a84b3f15efd9c9c2d020bc86eb9" -dependencies = [ - "bitflags 1.3.2", - "calloop 0.10.6", - "dlib", - "lazy_static", - "log", - "memmap2 0.5.10", - "nix 0.24.3", - "pkg-config", - "wayland-client 0.29.5", - "wayland-cursor 0.29.5", - "wayland-protocols 0.29.5", -] - [[package]] name = "smithay-client-toolkit" version = "0.18.1" @@ -2644,21 +1962,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" dependencies = [ "bitflags 2.6.0", - "calloop 0.12.4", + "calloop", "calloop-wayland-source", "cursor-icon", "libc", "log", - "memmap2 0.9.4", + "memmap2", "rustix", "thiserror", "wayland-backend", - "wayland-client 0.31.2", + "wayland-client", "wayland-csd-frame", - "wayland-cursor 0.31.1", - "wayland-protocols 0.31.2", + "wayland-cursor", + "wayland-protocols", "wayland-protocols-wlr", - "wayland-scanner 0.31.1", + "wayland-scanner", "xkeysym", ] @@ -2671,16 +1989,6 @@ dependencies = [ "serde", ] -[[package]] -name = "spirv" -version = "0.2.0+1.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" -dependencies = [ - "bitflags 1.3.2", - "num-traits", -] - [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" @@ -2726,10 +2034,10 @@ dependencies = [ "env_logger 0.11.3", "futures", "lyon", - "tiny-skia-path 0.11.4", + "tiny-skia-path", "usvg", - "wgpu 22.0.0", - "winit 0.30.0", + "wgpu", + "winit", ] [[package]] @@ -2826,21 +2134,6 @@ dependencies = [ "syn 2.0.60", ] -[[package]] -name = "tiny-skia" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642680569bb895b16e4b9d181c60be1ed136fa0c9c7f11d004daf053ba89bf82" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "bytemuck", - "cfg-if", - "png", - "safe_arch", - "tiny-skia-path 0.7.0", -] - [[package]] name = "tiny-skia" version = "0.11.4" @@ -2848,21 +2141,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" dependencies = [ "arrayref", - "arrayvec 0.7.4", + "arrayvec", "bytemuck", "cfg-if", "log", - "tiny-skia-path 0.11.4", -] - -[[package]] -name = "tiny-skia-path" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c114d32f0c2ee43d585367cb013dfaba967ab9f62b90d9af0d696e955e70fa6c" -dependencies = [ - "arrayref", - "bytemuck", + "tiny-skia-path", ] [[package]] @@ -2897,17 +2180,6 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow", -] - [[package]] name = "toml_edit" version = "0.21.1" @@ -3021,7 +2293,7 @@ dependencies = [ "siphasher", "strict-num", "svgtypes", - "tiny-skia-path 0.11.4", + "tiny-skia-path", "unicode-bidi", "unicode-script", "unicode-vo", @@ -3139,23 +2411,7 @@ dependencies = [ "rustix", "scoped-tls", "smallvec", - "wayland-sys 0.31.1", -] - -[[package]] -name = "wayland-client" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" -dependencies = [ - "bitflags 1.3.2", - "downcast-rs", - "libc", - "nix 0.24.3", - "scoped-tls", - "wayland-commons", - "wayland-scanner 0.29.5", - "wayland-sys 0.29.5", + "wayland-sys", ] [[package]] @@ -3167,19 +2423,7 @@ dependencies = [ "bitflags 2.6.0", "rustix", "wayland-backend", - "wayland-scanner 0.31.1", -] - -[[package]] -name = "wayland-commons" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" -dependencies = [ - "nix 0.24.3", - "once_cell", - "smallvec", - "wayland-sys 0.29.5", + "wayland-scanner", ] [[package]] @@ -3193,17 +2437,6 @@ dependencies = [ "wayland-backend", ] -[[package]] -name = "wayland-cursor" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" -dependencies = [ - "nix 0.24.3", - "wayland-client 0.29.5", - "xcursor", -] - [[package]] name = "wayland-cursor" version = "0.31.1" @@ -3211,22 +2444,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" dependencies = [ "rustix", - "wayland-client 0.31.2", + "wayland-client", "xcursor", ] -[[package]] -name = "wayland-protocols" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" -dependencies = [ - "bitflags 1.3.2", - "wayland-client 0.29.5", - "wayland-commons", - "wayland-scanner 0.29.5", -] - [[package]] name = "wayland-protocols" version = "0.31.2" @@ -3235,8 +2456,8 @@ checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ "bitflags 2.6.0", "wayland-backend", - "wayland-client 0.31.2", - "wayland-scanner 0.31.1", + "wayland-client", + "wayland-scanner", ] [[package]] @@ -3247,9 +2468,9 @@ checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ "bitflags 2.6.0", "wayland-backend", - "wayland-client 0.31.2", - "wayland-protocols 0.31.2", - "wayland-scanner 0.31.1", + "wayland-client", + "wayland-protocols", + "wayland-scanner", ] [[package]] @@ -3260,20 +2481,9 @@ checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ "bitflags 2.6.0", "wayland-backend", - "wayland-client 0.31.2", - "wayland-protocols 0.31.2", - "wayland-scanner 0.31.1", -] - -[[package]] -name = "wayland-scanner" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" -dependencies = [ - "proc-macro2", - "quote", - "xml-rs", + "wayland-client", + "wayland-protocols", + "wayland-scanner", ] [[package]] @@ -3287,17 +2497,6 @@ dependencies = [ "quote", ] -[[package]] -name = "wayland-sys" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" -dependencies = [ - "dlib", - "lazy_static", - "pkg-config", -] - [[package]] name = "wayland-sys" version = "0.31.1" @@ -3330,75 +2529,29 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "wgpu" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "277e967bf8b7820a76852645a6bce8bbd31c32fda2042e82d8e3ea75fda8892d" -dependencies = [ - "arrayvec 0.7.4", - "js-sys", - "log", - "naga 0.9.0", - "parking_lot", - "raw-window-handle 0.4.3", - "smallvec", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "wgpu-core 0.13.2", - "wgpu-hal 0.13.2", - "wgpu-types 0.13.2", -] - [[package]] name = "wgpu" version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87e07e87a179614940ad845397e03201847453a37b43a31a3b54eee2e6e32ce" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "cfg_aliases 0.1.1", "document-features", "js-sys", "log", - "naga 22.0.0", + "naga", "parking_lot", "profiling", - "raw-window-handle 0.6.1", + "raw-window-handle", "smallvec", "static_assertions", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "wgpu-core 22.0.0", - "wgpu-hal 22.0.0", - "wgpu-types 22.0.0", -] - -[[package]] -name = "wgpu-core" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b92788dec9d0c1bed849a1b83f01b2ee12819bf04a79c90f68e4173f7b5ba2" -dependencies = [ - "arrayvec 0.7.4", - "bit-vec 0.6.3", - "bitflags 1.3.2", - "cfg_aliases 0.1.1", - "codespan-reporting", - "copyless", - "fxhash", - "log", - "naga 0.9.0", - "parking_lot", - "profiling", - "raw-window-handle 0.4.3", - "smallvec", - "thiserror", - "web-sys", - "wgpu-hal 0.13.2", - "wgpu-types 0.13.2", + "wgpu-core", + "wgpu-hal", + "wgpu-types", ] [[package]] @@ -3407,23 +2560,23 @@ version = "22.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0f191908a21968991463fcf3b42cb6c9648c0fb7fa301b8fc733bc21a9ed9bd" dependencies = [ - "arrayvec 0.7.4", - "bit-vec 0.7.0", + "arrayvec", + "bit-vec", "bitflags 2.6.0", "cfg_aliases 0.1.1", "document-features", "indexmap 2.2.6", "log", - "naga 22.0.0", + "naga", "once_cell", "parking_lot", "profiling", - "raw-window-handle 0.6.1", + "raw-window-handle", "rustc-hash", "smallvec", "thiserror", - "wgpu-hal 22.0.0", - "wgpu-types 22.0.0", + "wgpu-hal", + "wgpu-types", ] [[package]] @@ -3434,47 +2587,8 @@ dependencies = [ "env_logger 0.11.3", "futures", "lyon", - "wgpu 22.0.0", - "winit 0.30.0", -] - -[[package]] -name = "wgpu-hal" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cbdfc3d0637dba3d5536b93adef3d26023a0b96f0e1ee5ee9560a401d9f646" -dependencies = [ - "android_system_properties", - "arrayvec 0.7.4", - "ash 0.37.3+1.3.251", - "bit-set 0.5.3", - "bitflags 1.3.2", - "block", - "core-graphics-types", - "d3d12 0.5.0", - "foreign-types 0.3.2", - "fxhash", - "glow 0.11.2", - "gpu-alloc 0.5.4", - "gpu-descriptor 0.2.4", - "inplace_it", - "js-sys", - "khronos-egl 4.1.0", - "libloading 0.7.4", - "log", - "metal 0.24.0", - "naga 0.9.0", - "objc", - "parking_lot", - "profiling", - "range-alloc", - "raw-window-handle 0.4.3", - "renderdoc-sys 0.7.1", - "thiserror", - "wasm-bindgen", - "web-sys", - "wgpu-types 0.13.2", - "winapi", + "wgpu", + "winit", ] [[package]] @@ -3484,53 +2598,44 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f" dependencies = [ "android_system_properties", - "arrayvec 0.7.4", - "ash 0.38.0+1.3.281", - "bit-set 0.6.0", + "arrayvec", + "ash", + "bit-set", "bitflags 2.6.0", "block", "cfg_aliases 0.1.1", "core-graphics-types", - "d3d12 22.0.0", - "glow 0.13.1", + "d3d12", + "glow", "glutin_wgl_sys", - "gpu-alloc 0.6.0", + "gpu-alloc", "gpu-allocator", - "gpu-descriptor 0.3.0", + "gpu-descriptor", "hassle-rs", "js-sys", - "khronos-egl 6.0.0", + "khronos-egl", "libc", - "libloading 0.8.3", + "libloading", "log", - "metal 0.29.0", - "naga 22.0.0", + "metal", + "naga", "ndk-sys 0.5.0+25.2.9519653", "objc", "once_cell", "parking_lot", "profiling", "range-alloc", - "raw-window-handle 0.6.1", - "renderdoc-sys 1.1.0", + "raw-window-handle", + "renderdoc-sys", "rustc-hash", "smallvec", "thiserror", "wasm-bindgen", "web-sys", - "wgpu-types 22.0.0", + "wgpu-types", "winapi", ] -[[package]] -name = "wgpu-types" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f762cbc08e1a51389859cf9c199c7aef544789cf3510889aab12c607f701604" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "wgpu-types" version = "22.0.0" @@ -3598,19 +2703,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "windows-sys" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" -dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", -] - [[package]] name = "windows-sys" version = "0.45.0" @@ -3620,15 +2712,6 @@ dependencies = [ "windows-targets 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" @@ -3702,12 +2785,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -3726,12 +2803,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -3756,12 +2827,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -3780,12 +2845,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -3822,12 +2881,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -3846,39 +2899,6 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" -[[package]] -name = "winit" -version = "0.27.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb796d6fbd86b2fd896c9471e6f04d39d750076ebe5680a3958f00f5ab97657c" -dependencies = [ - "bitflags 1.3.2", - "cocoa 0.24.1", - "core-foundation", - "core-graphics 0.22.3", - "dispatch", - "instant", - "libc", - "log", - "mio", - "ndk 0.7.0", - "ndk-glue", - "objc", - "once_cell", - "parking_lot", - "percent-encoding", - "raw-window-handle 0.4.3", - "raw-window-handle 0.5.2", - "sctk-adwaita 0.4.3", - "smithay-client-toolkit 0.16.1", - "wasm-bindgen", - "wayland-client 0.29.5", - "wayland-protocols 0.29.5", - "web-sys", - "windows-sys 0.36.1", - "x11-dl", -] - [[package]] name = "winit" version = "0.30.0" @@ -3890,36 +2910,36 @@ dependencies = [ "atomic-waker", "bitflags 2.6.0", "bytemuck", - "calloop 0.12.4", + "calloop", "cfg_aliases 0.2.0", "concurrent-queue", "core-foundation", - "core-graphics 0.23.2", + "core-graphics", "cursor-icon", "dpi", "js-sys", "libc", - "memmap2 0.9.4", - "ndk 0.9.0", + "memmap2", + "ndk", "objc2", "objc2-app-kit", "objc2-foundation", "orbclient", "percent-encoding", "pin-project", - "raw-window-handle 0.6.1", + "raw-window-handle", "redox_syscall 0.4.1", "rustix", - "sctk-adwaita 0.9.0", - "smithay-client-toolkit 0.18.1", + "sctk-adwaita", + "smithay-client-toolkit", "smol_str", "tracing", "unicode-segmentation", "wasm-bindgen", "wasm-bindgen-futures", "wayland-backend", - "wayland-client 0.31.2", - "wayland-protocols 0.31.2", + "wayland-client", + "wayland-protocols", "wayland-protocols-plasma", "web-sys", "web-time", @@ -3938,15 +2958,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "wio" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5" -dependencies = [ - "winapi", -] - [[package]] name = "x11-dl" version = "2.21.0" @@ -3967,7 +2978,7 @@ dependencies = [ "as-raw-xcb-connection", "gethostname", "libc", - "libloading 0.8.3", + "libloading", "once_cell", "rustix", "x11rb-protocol", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d2ce45cf..9d69e508 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -14,8 +14,8 @@ lyon = { path = "../crates/lyon", features = ["extra", "debugger"]} clap = "3.2.22" rand = "0.6" env_logger = "0.7" -wgpu = "0.13.1" -winit = "0.27.5" +wgpu = "22.0" +winit = "0.30.0" futures = "0.3.5" bytemuck = "1.2.0" itertools = "0.7.8" diff --git a/cli/src/show.rs b/cli/src/show.rs index 1a19de93..d7fe76d7 100644 --- a/cli/src/show.rs +++ b/cli/src/show.rs @@ -1,13 +1,16 @@ +use winit::application::ApplicationHandler; use winit::dpi::PhysicalSize; -use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent}; -use winit::event_loop::{ControlFlow, EventLoop}; -use winit::window::Window; +use winit::event::{ElementState, KeyEvent, WindowEvent}; +use winit::event_loop::{ActiveEventLoop, ControlFlow, EventLoop}; +use winit::keyboard::{KeyCode, PhysicalKey}; +use winit::window::{Window, WindowId}; // For create_buffer_init() use wgpu::util::DeviceExt; use futures::executor::block_on; use std::ops::Rem; +use std::sync::Arc; use crate::commands::{AntiAliasing, Background, RenderCmd, TessellateCmd}; use lyon::algorithms::aabb::bounding_box; @@ -67,6 +70,144 @@ unsafe impl bytemuck::Zeroable for BgVertex {} const DEFAULT_WINDOW_WIDTH: f32 = 800.0; const DEFAULT_WINDOW_HEIGHT: f32 = 800.0; +struct App { + window: Arc, + device: wgpu::Device, + queue: wgpu::Queue, + surface: wgpu::Surface<'static>, + surface_desc: wgpu::SurfaceConfiguration, + vbo: wgpu::Buffer, + ibo: wgpu::Buffer, + wireframe_ibo: wgpu::Buffer, + bg_vbo: wgpu::Buffer, + bg_ibo: wgpu::Buffer, + prims_ubo: wgpu::Buffer, + globals_ubo: wgpu::Buffer, + bind_group: wgpu::BindGroup, + render_pipeline: wgpu::RenderPipeline, + wireframe_render_pipeline: wgpu::RenderPipeline, + bg_pipeline: wgpu::RenderPipeline, + multisampled_render_target: Option, + geometry: VertexBuffers, + wireframe_indices: Vec, + cpu_primitives: Vec, + scene: SceneParams, + depth_texture_view: Option, + sample_count: u32, + frame_count: f32, + stroke_prim_id: usize, + num_instances: u32, + bg_color: [f32; 4], + vignette_color: [f32; 4], +} + +enum AppState { + Initializing { cmd: TessellateCmd, render_options: RenderCmd }, + Running(App), + Closing, +} + +impl ApplicationHandler for AppState { + fn resumed(&mut self, event_loop: &ActiveEventLoop) { + let win_attrs = Window::default_attributes() + .with_title("Basic SVG example"); + let window = Arc::new(event_loop.create_window(win_attrs).unwrap()); + + match self { + AppState::Initializing { cmd, render_options } => { + if let Some(app) = App::init(window, cmd, render_options) { + *self = AppState::Running(app); + return; + } + } + _ => { + // TODO + } + } + + event_loop.exit(); + } + + fn window_event(&mut self, event_loop: &ActiveEventLoop, id: WindowId, event: WindowEvent) { + let this = match self { + AppState::Running(this) => this, + _ => { + event_loop.exit(); + return; + } + }; + + this.update_inputs(event_loop, id, event); + + if this.scene.render { + this.render(); + } + + if event_loop.exiting() { + *self = AppState::Closing; + } + } +} + +impl App { + fn update_inputs(&mut self, event_loop: &ActiveEventLoop, _id: WindowId, event: WindowEvent) { + let scene = &mut self.scene; + let initial_scroll = scene.scroll; + let initial_zoom = scene.zoom; + match event { + WindowEvent::RedrawRequested => { + scene.render = true; + } + WindowEvent::Destroyed | WindowEvent::CloseRequested => event_loop.exit(), + WindowEvent::Resized(size) => { + scene.window_size = size; + scene.size_changed = true; + scene.render = true; + } + WindowEvent::KeyboardInput { + event: + KeyEvent { + physical_key: PhysicalKey::Code(key_code), + state: ElementState::Pressed, + .. + }, + .. + } => match key_code { + KeyCode::Escape => event_loop.exit(), + KeyCode::PageDown => scene.target_zoom *= 0.8, + KeyCode::PageUp => scene.target_zoom *= 1.25, + KeyCode::ArrowLeft => scene.target_scroll.x += 50.0 / scene.target_zoom, + KeyCode::ArrowRight => scene.target_scroll.x -= 50.0 / scene.target_zoom, + KeyCode::ArrowUp => scene.target_scroll.y -= 50.0 / scene.target_zoom, + KeyCode::ArrowDown => scene.target_scroll.y += 50.0 / scene.target_zoom, + KeyCode::KeyP => scene.show_points = !scene.show_points, + KeyCode::KeyW => scene.show_wireframe = !scene.show_wireframe, + KeyCode::KeyB => scene.draw_background = !scene.draw_background, + KeyCode::KeyA => scene.target_stroke_width /= 0.8, + KeyCode::KeyZ => scene.target_stroke_width *= 0.8, + _key => {} + }, + _evt => {} + }; + + if event_loop.exiting() { + scene.render = false; + return; + } + + scene.zoom += (scene.target_zoom - scene.zoom) / 3.0; + scene.scroll = scene.scroll + (scene.target_scroll - scene.scroll) / 3.0; + scene.stroke_width = + scene.stroke_width + (scene.target_stroke_width - scene.stroke_width) / 5.0; + + scene.render |= scene.scroll != initial_scroll || scene.zoom != initial_zoom; + + if scene.render { + self.window.request_redraw(); + } + } +} + /// Creates a texture that uses MSAA and fits a given swap chain fn create_multisampled_framebuffer( device: &wgpu::Device, @@ -85,6 +226,7 @@ fn create_multisampled_framebuffer( dimension: wgpu::TextureDimension::D2, format: desc.format, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, + view_formats: &[], }; device @@ -93,498 +235,535 @@ fn create_multisampled_framebuffer( } pub fn show_path(cmd: TessellateCmd, render_options: RenderCmd) { - let mut geometry: VertexBuffers = VertexBuffers::new(); + let event_loop = EventLoop::new().unwrap(); + event_loop.set_control_flow(ControlFlow::Wait); - let fill_prim_id = 0; - let stroke_prim_id = 1; + let mut app = AppState::Initializing { cmd, render_options }; + event_loop.run_app(&mut app).unwrap(); +} - let mut fill = FillTessellator::new(); - let mut stroke = StrokeTessellator::new(); +impl App { + fn init(window: Arc, cmd: &TessellateCmd, render_options: &RenderCmd) -> Option { + let mut geometry: VertexBuffers = VertexBuffers::new(); - if let Some(options) = cmd.fill { - fill.tessellate( - &cmd.path, - &options, - &mut BuffersBuilder::new(&mut geometry, WithId(fill_prim_id)), - ) - .unwrap(); + let fill_prim_id = 0; + let stroke_prim_id = 1; - //for (i, v) in geometry.vertices.iter().enumerate() { - // println!("{}: {:?}", i, v.position); - //} - //for i in 0..(geometry.indices.len() / 3) { - // println!( - // "{}/{}/{}", - // geometry.indices[i * 3], - // geometry.indices[i * 3 + 1], - // geometry.indices[i * 3 + 2], - // ); - //} - } + let mut fill = FillTessellator::new(); + let mut stroke = StrokeTessellator::new(); - if let Some(options) = cmd.stroke { - stroke - .tessellate_path( + if let Some(options) = cmd.fill { + fill.tessellate( &cmd.path, &options, - &mut BuffersBuilder::new(&mut geometry, WithId(stroke_prim_id)), + &mut BuffersBuilder::new(&mut geometry, WithId(fill_prim_id)), ) .unwrap(); - } - if let Some(hatch) = cmd.hatch { - let mut path = Path::builder(); - let mut hatcher = Hatcher::new(); - hatcher.hatch_path( - cmd.path.iter(), - &hatch.options, - &mut RegularHatchingPattern { - interval: hatch.spacing, - callback: &mut |segment: &HatchSegment| { - path.add_line_segment(&LineSegment { - from: segment.a.position, - to: segment.b.position, - }); - }, - }, - ); - let hatched_path = path.build(); + //for (i, v) in geometry.vertices.iter().enumerate() { + // println!("{}: {:?}", i, v.position); + //} + //for i in 0..(geometry.indices.len() / 3) { + // println!( + // "{}/{}/{}", + // geometry.indices[i * 3], + // geometry.indices[i * 3 + 1], + // geometry.indices[i * 3 + 2], + // ); + //} + } - stroke - .tessellate( - hatched_path.iter(), - &hatch.stroke, - &mut BuffersBuilder::new(&mut geometry, WithId(stroke_prim_id)), - ) - .unwrap(); - } + if let Some(options) = cmd.stroke { + stroke + .tessellate_path( + &cmd.path, + &options, + &mut BuffersBuilder::new(&mut geometry, WithId(stroke_prim_id)), + ) + .unwrap(); + } - if let Some(dots) = cmd.dots { - let mut path = Path::builder(); - let mut hatcher = Hatcher::new(); - hatcher.dot_path( - cmd.path.iter(), - &dots.options, - &mut RegularDotPattern { - row_interval: dots.spacing, - column_interval: dots.spacing, - callback: &mut |dot: &Dot| { - path.add_point(dot.position); + if let Some(hatch) = &cmd.hatch { + let mut path = Path::builder(); + let mut hatcher = Hatcher::new(); + hatcher.hatch_path( + cmd.path.iter(), + &hatch.options, + &mut RegularHatchingPattern { + interval: hatch.spacing, + callback: &mut |segment: &HatchSegment| { + path.add_line_segment(&LineSegment { + from: segment.a.position, + to: segment.b.position, + }); + }, }, - }, - ); - let dotted_path = path.build(); + ); + let hatched_path = path.build(); + + stroke + .tessellate( + hatched_path.iter(), + &hatch.stroke, + &mut BuffersBuilder::new(&mut geometry, WithId(stroke_prim_id)), + ) + .unwrap(); + } - stroke - .tessellate( - dotted_path.iter(), - &dots.stroke, - &mut BuffersBuilder::new(&mut geometry, WithId(stroke_prim_id)), - ) - .unwrap(); - } + if let Some(dots) = &cmd.dots { + let mut path = Path::builder(); + let mut hatcher = Hatcher::new(); + hatcher.dot_path( + cmd.path.iter(), + &dots.options, + &mut RegularDotPattern { + row_interval: dots.spacing, + column_interval: dots.spacing, + callback: &mut |dot: &Dot| { + path.add_point(dot.position); + }, + }, + ); + let dotted_path = path.build(); + + stroke + .tessellate( + dotted_path.iter(), + &dots.stroke, + &mut BuffersBuilder::new(&mut geometry, WithId(stroke_prim_id)), + ) + .unwrap(); + } - let (bg_color, vignette_color) = match render_options.background { - Background::Blue => ([0.0, 0.47, 0.9, 1.0], [0.0, 0.1, 0.64, 1.0]), - Background::Clear => ([0.9, 0.9, 0.9, 1.0], [0.5, 0.5, 0.5, 1.0]), - Background::Dark => ([0.05, 0.05, 0.05, 1.0], [0.0, 0.0, 0.0, 1.0]), - }; + let (bg_color, vignette_color) = match render_options.background { + Background::Blue => ([0.0, 0.47, 0.9, 1.0], [0.0, 0.1, 0.64, 1.0]), + Background::Clear => ([0.9, 0.9, 0.9, 1.0], [0.5, 0.5, 0.5, 1.0]), + Background::Dark => ([0.05, 0.05, 0.05, 1.0], [0.0, 0.0, 0.0, 1.0]), + }; - if geometry.vertices.is_empty() { - println!("No geometry to show"); - return; - } + if geometry.vertices.is_empty() { + println!("No geometry to show"); + return None; + } - let mut bg_geometry: VertexBuffers = VertexBuffers::new(); + let mut bg_geometry: VertexBuffers = VertexBuffers::new(); - fill.tessellate_rectangle( - &Box2D { - min: point(-1.0, -1.0), - max: point(1.0, 1.0), - }, - &FillOptions::DEFAULT, - &mut BuffersBuilder::new(&mut bg_geometry, BgVertexCtor), - ) - .unwrap(); - - let sample_count = match render_options.aa { - AntiAliasing::Msaa(samples) => samples as u32, - _ => 1, - }; + fill.tessellate_rectangle( + &Box2D { + min: point(-1.0, -1.0), + max: point(1.0, 1.0), + }, + &FillOptions::DEFAULT, + &mut BuffersBuilder::new(&mut bg_geometry, BgVertexCtor), + ) + .unwrap(); + + let sample_count = match render_options.aa { + AntiAliasing::Msaa(samples) => samples as u32, + _ => 1, + }; + + let num_instances: u32 = PRIM_BUFFER_LEN as u32 - 1; - let num_instances: u32 = PRIM_BUFFER_LEN as u32 - 1; + let mut cpu_primitives = Vec::with_capacity(PRIM_BUFFER_LEN); + for _ in 0..PRIM_BUFFER_LEN { + cpu_primitives.push(Primitive { + color: [1.0, 0.0, 0.0, 1.0], + z_index: 0, + width: 0.0, + translate: [0.0, 0.0], + }); + } - let mut cpu_primitives = Vec::with_capacity(PRIM_BUFFER_LEN); - for _ in 0..PRIM_BUFFER_LEN { - cpu_primitives.push(Primitive { - color: [1.0, 0.0, 0.0, 1.0], - z_index: 0, + // Stroke primitive + cpu_primitives[stroke_prim_id] = Primitive { + color: [0.0, 0.0, 0.0, 1.0], + z_index: num_instances as i32 + 2, + width: 1.0, + translate: [0.0, 0.0], + }; + // Main fill primitive + cpu_primitives[fill_prim_id] = Primitive { + color: [1.0, 1.0, 1.0, 1.0], + z_index: num_instances as i32 + 1, width: 0.0, translate: [0.0, 0.0], + }; + // Instance primitives + for (idx, cpu_prim) in cpu_primitives + .iter_mut() + .enumerate() + .skip(fill_prim_id + 1) + .take(num_instances as usize - 1) + { + cpu_prim.z_index = (idx as u32 + 1) as i32; + cpu_prim.color = [ + (0.1 * idx as f32).rem(1.0), + (0.5 * idx as f32).rem(1.0), + (0.9 * idx as f32).rem(1.0), + 1.0, + ]; + } + + let aabb = bounding_box(cmd.path.iter()); + let center = aabb.center().to_vector(); + + let scene = SceneParams { + target_zoom: 5.0, + zoom: 5.0, + target_scroll: center, + scroll: center, + show_points: false, + show_wireframe: false, + stroke_width: 1.0, + target_stroke_width: 1.0, + draw_background: true, + cursor_position: (0.0, 0.0), + window_size: PhysicalSize::new(DEFAULT_WINDOW_WIDTH as u32, DEFAULT_WINDOW_HEIGHT as u32), + size_changed: true, + render: true, + }; + + + let instance = wgpu::Instance::default(); + let surface = instance.create_surface(window.clone()).unwrap(); + let adapter = block_on(instance.request_adapter(&wgpu::RequestAdapterOptions { + power_preference: wgpu::PowerPreference::LowPower, + compatible_surface: Some(&surface), + force_fallback_adapter: false, + })) + .unwrap(); + + // create a device and a queue + let (device, queue) = block_on(adapter.request_device( + &wgpu::DeviceDescriptor { + label: None, + required_features: wgpu::Features::default(), + required_limits: wgpu::Limits::default(), + memory_hints: wgpu::MemoryHints::MemoryUsage, + }, + None, + )) + .unwrap(); + + let vbo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: bytemuck::cast_slice(&geometry.vertices), + usage: wgpu::BufferUsages::VERTEX, }); - } - // Stroke primitive - cpu_primitives[stroke_prim_id] = Primitive { - color: [0.0, 0.0, 0.0, 1.0], - z_index: num_instances as i32 + 2, - width: 1.0, - translate: [0.0, 0.0], - }; - // Main fill primitive - cpu_primitives[fill_prim_id] = Primitive { - color: [1.0, 1.0, 1.0, 1.0], - z_index: num_instances as i32 + 1, - width: 0.0, - translate: [0.0, 0.0], - }; - // Instance primitives - for (idx, cpu_prim) in cpu_primitives - .iter_mut() - .enumerate() - .skip(fill_prim_id + 1) - .take(num_instances as usize - 1) - { - cpu_prim.z_index = (idx as u32 + 1) as i32; - cpu_prim.color = [ - (0.1 * idx as f32).rem(1.0), - (0.5 * idx as f32).rem(1.0), - (0.9 * idx as f32).rem(1.0), - 1.0, - ]; - } + let ibo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: bytemuck::cast_slice(&geometry.indices), + usage: wgpu::BufferUsages::INDEX, + }); - let aabb = bounding_box(cmd.path.iter()); - let center = aabb.center().to_vector(); - - let mut scene = SceneParams { - target_zoom: 5.0, - zoom: 5.0, - target_scroll: center, - scroll: center, - show_points: false, - show_wireframe: false, - stroke_width: 1.0, - target_stroke_width: 1.0, - draw_background: true, - cursor_position: (0.0, 0.0), - window_size: PhysicalSize::new(DEFAULT_WINDOW_WIDTH as u32, DEFAULT_WINDOW_HEIGHT as u32), - size_changed: true, - }; + let bg_vbo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: bytemuck::cast_slice(&bg_geometry.vertices), + usage: wgpu::BufferUsages::VERTEX, + }); - let event_loop = EventLoop::new(); - let window = Window::new(&event_loop).unwrap(); - - // create an instance - let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY); - - // create an surface - let surface = unsafe { instance.create_surface(&window) }; - - // create an adapter - let adapter = block_on(instance.request_adapter(&wgpu::RequestAdapterOptions { - power_preference: wgpu::PowerPreference::LowPower, - compatible_surface: Some(&surface), - force_fallback_adapter: false, - })) - .unwrap(); - // create a device and a queue - let (device, queue) = block_on(adapter.request_device( - &wgpu::DeviceDescriptor { + let bg_ibo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { label: None, - features: wgpu::Features::default(), - limits: wgpu::Limits::default(), - }, - None, - )) - .unwrap(); - - let vbo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: bytemuck::cast_slice(&geometry.vertices), - usage: wgpu::BufferUsages::VERTEX, - }); - - let ibo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: bytemuck::cast_slice(&geometry.indices), - usage: wgpu::BufferUsages::INDEX, - }); - - let bg_vbo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: bytemuck::cast_slice(&bg_geometry.vertices), - usage: wgpu::BufferUsages::VERTEX, - }); - - let bg_ibo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: bytemuck::cast_slice(&bg_geometry.indices), - usage: wgpu::BufferUsages::INDEX, - }); - - let prim_buffer_byte_size = (PRIM_BUFFER_LEN * std::mem::size_of::()) as u64; - let globals_buffer_byte_size = std::mem::size_of::() as u64; - - let prims_ubo = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("Prims ubo"), - size: prim_buffer_byte_size, - usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, - mapped_at_creation: false, - }); - - let globals_ubo = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("Globals ubo"), - size: globals_buffer_byte_size, - usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, - mapped_at_creation: false, - }); - - let vs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("Geometry vs"), - source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/geometry.vs.wgsl").into()), - }); - let fs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("Geometry fs"), - source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/geometry.fs.wgsl").into()), - }); - let bg_vs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("Background vs"), - source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/background.vs.wgsl").into()), - }); - let bg_fs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { - label: Some("Background fs"), - source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/background.fs.wgsl").into()), - }); - - let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: Some("Bind group layout"), - entries: &[ - wgpu::BindGroupLayoutEntry { - binding: 0, - visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT, - ty: wgpu::BindingType::Buffer { - ty: wgpu::BufferBindingType::Uniform, - has_dynamic_offset: false, - min_binding_size: wgpu::BufferSize::new(globals_buffer_byte_size), + contents: bytemuck::cast_slice(&bg_geometry.indices), + usage: wgpu::BufferUsages::INDEX, + }); + + let prim_buffer_byte_size = (PRIM_BUFFER_LEN * std::mem::size_of::()) as u64; + let globals_buffer_byte_size = std::mem::size_of::() as u64; + + let prims_ubo = device.create_buffer(&wgpu::BufferDescriptor { + label: Some("Prims ubo"), + size: prim_buffer_byte_size, + usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, + mapped_at_creation: false, + }); + + let globals_ubo = device.create_buffer(&wgpu::BufferDescriptor { + label: Some("Globals ubo"), + size: globals_buffer_byte_size, + usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST, + mapped_at_creation: false, + }); + + let vs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: Some("Geometry vs"), + source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/geometry.vs.wgsl").into()), + }); + let fs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: Some("Geometry fs"), + source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/geometry.fs.wgsl").into()), + }); + let bg_vs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: Some("Background vs"), + source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/background.vs.wgsl").into()), + }); + let bg_fs_module = &device.create_shader_module(wgpu::ShaderModuleDescriptor { + label: Some("Background fs"), + source: wgpu::ShaderSource::Wgsl(include_str!("./../shaders/background.fs.wgsl").into()), + }); + + let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { + label: Some("Bind group layout"), + entries: &[ + wgpu::BindGroupLayoutEntry { + binding: 0, + visibility: wgpu::ShaderStages::VERTEX | wgpu::ShaderStages::FRAGMENT, + ty: wgpu::BindingType::Buffer { + ty: wgpu::BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: wgpu::BufferSize::new(globals_buffer_byte_size), + }, + count: None, }, - count: None, - }, - wgpu::BindGroupLayoutEntry { - binding: 1, - visibility: wgpu::ShaderStages::VERTEX, - ty: wgpu::BindingType::Buffer { - ty: wgpu::BufferBindingType::Uniform, - has_dynamic_offset: false, - min_binding_size: wgpu::BufferSize::new(prim_buffer_byte_size), + wgpu::BindGroupLayoutEntry { + binding: 1, + visibility: wgpu::ShaderStages::VERTEX, + ty: wgpu::BindingType::Buffer { + ty: wgpu::BufferBindingType::Uniform, + has_dynamic_offset: false, + min_binding_size: wgpu::BufferSize::new(prim_buffer_byte_size), + }, + count: None, }, - count: None, - }, - ], - }); - let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { - label: Some("Bind group"), - layout: &bind_group_layout, - entries: &[ - wgpu::BindGroupEntry { - binding: 0, - resource: wgpu::BindingResource::Buffer(globals_ubo.as_entire_buffer_binding()), - }, - wgpu::BindGroupEntry { - binding: 1, - resource: wgpu::BindingResource::Buffer(prims_ubo.as_entire_buffer_binding()), + ], + }); + let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor { + label: Some("Bind group"), + layout: &bind_group_layout, + entries: &[ + wgpu::BindGroupEntry { + binding: 0, + resource: wgpu::BindingResource::Buffer(globals_ubo.as_entire_buffer_binding()), + }, + wgpu::BindGroupEntry { + binding: 1, + resource: wgpu::BindingResource::Buffer(prims_ubo.as_entire_buffer_binding()), + }, + ], + }); + + let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { + bind_group_layouts: &[&bind_group_layout], + push_constant_ranges: &[], + label: None, + }); + + let depth_stencil_state = Some(wgpu::DepthStencilState { + format: wgpu::TextureFormat::Depth32Float, + depth_write_enabled: true, + depth_compare: wgpu::CompareFunction::Greater, + stencil: wgpu::StencilState { + front: wgpu::StencilFaceState::IGNORE, + back: wgpu::StencilFaceState::IGNORE, + read_mask: 0, + write_mask: 0, }, - ], - }); - - let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - bind_group_layouts: &[&bind_group_layout], - push_constant_ranges: &[], - label: None, - }); - - let depth_stencil_state = Some(wgpu::DepthStencilState { - format: wgpu::TextureFormat::Depth32Float, - depth_write_enabled: true, - depth_compare: wgpu::CompareFunction::Greater, - stencil: wgpu::StencilState { - front: wgpu::StencilFaceState::IGNORE, - back: wgpu::StencilFaceState::IGNORE, - read_mask: 0, - write_mask: 0, - }, - bias: wgpu::DepthBiasState::default(), - }); - - let mut render_pipeline_descriptor = wgpu::RenderPipelineDescriptor { - label: None, - layout: Some(&pipeline_layout), - vertex: wgpu::VertexState { - module: vs_module, - entry_point: "main", - buffers: &[wgpu::VertexBufferLayout { - array_stride: std::mem::size_of::() as u64, - step_mode: wgpu::VertexStepMode::Vertex, - attributes: &[ - wgpu::VertexAttribute { - offset: 0, - format: wgpu::VertexFormat::Float32x2, - shader_location: 0, - }, - wgpu::VertexAttribute { - offset: 8, - format: wgpu::VertexFormat::Float32x2, - shader_location: 1, - }, - wgpu::VertexAttribute { - offset: 16, - format: wgpu::VertexFormat::Uint32, - shader_location: 2, - }, - ], - }], - }, - fragment: Some(wgpu::FragmentState { - module: fs_module, - entry_point: "main", - targets: &[Some(wgpu::ColorTargetState { - format: wgpu::TextureFormat::Bgra8Unorm, - blend: None, - write_mask: wgpu::ColorWrites::ALL, - })], - }), - primitive: wgpu::PrimitiveState { - topology: wgpu::PrimitiveTopology::TriangleList, - polygon_mode: wgpu::PolygonMode::Fill, - front_face: wgpu::FrontFace::Ccw, - strip_index_format: None, - cull_mode: Some(wgpu::Face::Back), - unclipped_depth: false, - conservative: false, - }, - depth_stencil: depth_stencil_state.clone(), - multisample: wgpu::MultisampleState { - count: sample_count, - mask: !0, - alpha_to_coverage_enabled: false, - }, - multiview: None, - }; + bias: wgpu::DepthBiasState::default(), + }); - let render_pipeline = device.create_render_pipeline(&render_pipeline_descriptor); - - render_pipeline_descriptor.primitive.topology = wgpu::PrimitiveTopology::LineList; - let wireframe_render_pipeline = device.create_render_pipeline(&render_pipeline_descriptor); - - let wireframe_indices = build_wireframe_indices(&geometry.indices); - let wireframe_ibo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { - label: None, - contents: bytemuck::cast_slice(&wireframe_indices), - usage: wgpu::BufferUsages::INDEX, - }); - - let bg_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: None, - layout: Some(&pipeline_layout), - vertex: wgpu::VertexState { - module: bg_vs_module, - entry_point: "main", - buffers: &[wgpu::VertexBufferLayout { - array_stride: std::mem::size_of::() as u64, - step_mode: wgpu::VertexStepMode::Vertex, - attributes: &[wgpu::VertexAttribute { - offset: 0, - format: wgpu::VertexFormat::Float32x2, - shader_location: 0, + let mut render_pipeline_descriptor = wgpu::RenderPipelineDescriptor { + label: None, + layout: Some(&pipeline_layout), + vertex: wgpu::VertexState { + module: vs_module, + entry_point: "main", + buffers: &[wgpu::VertexBufferLayout { + array_stride: std::mem::size_of::() as u64, + step_mode: wgpu::VertexStepMode::Vertex, + attributes: &[ + wgpu::VertexAttribute { + offset: 0, + format: wgpu::VertexFormat::Float32x2, + shader_location: 0, + }, + wgpu::VertexAttribute { + offset: 8, + format: wgpu::VertexFormat::Float32x2, + shader_location: 1, + }, + wgpu::VertexAttribute { + offset: 16, + format: wgpu::VertexFormat::Uint32, + shader_location: 2, + }, + ], }], - }], - }, - fragment: Some(wgpu::FragmentState { - module: bg_fs_module, - entry_point: "main", - targets: &[Some(wgpu::ColorTargetState { - format: wgpu::TextureFormat::Bgra8Unorm, - blend: None, - write_mask: wgpu::ColorWrites::ALL, - })], - }), - primitive: wgpu::PrimitiveState { - topology: wgpu::PrimitiveTopology::TriangleList, - polygon_mode: wgpu::PolygonMode::Fill, - front_face: wgpu::FrontFace::Ccw, - strip_index_format: None, - cull_mode: None, - unclipped_depth: false, - conservative: false, - }, - depth_stencil: depth_stencil_state, - multisample: wgpu::MultisampleState { - count: sample_count, - mask: !0, - alpha_to_coverage_enabled: false, - }, - multiview: None, - }); + compilation_options: wgpu::PipelineCompilationOptions::default(), + }, + fragment: Some(wgpu::FragmentState { + module: fs_module, + entry_point: "main", + targets: &[Some(wgpu::ColorTargetState { + format: wgpu::TextureFormat::Bgra8Unorm, + blend: None, + write_mask: wgpu::ColorWrites::ALL, + })], + compilation_options: wgpu::PipelineCompilationOptions::default(), + }), + primitive: wgpu::PrimitiveState { + topology: wgpu::PrimitiveTopology::TriangleList, + polygon_mode: wgpu::PolygonMode::Fill, + front_face: wgpu::FrontFace::Ccw, + strip_index_format: None, + cull_mode: Some(wgpu::Face::Back), + unclipped_depth: false, + conservative: false, + }, + depth_stencil: depth_stencil_state.clone(), + multisample: wgpu::MultisampleState { + count: sample_count, + mask: !0, + alpha_to_coverage_enabled: false, + }, + multiview: None, + cache: None, + }; - let size = window.inner_size(); + let render_pipeline = device.create_render_pipeline(&render_pipeline_descriptor); - let mut surface_desc = wgpu::SurfaceConfiguration { - usage: wgpu::TextureUsages::RENDER_ATTACHMENT, - format: wgpu::TextureFormat::Bgra8Unorm, - width: size.width, - height: size.height, - present_mode: wgpu::PresentMode::AutoVsync, - }; + render_pipeline_descriptor.primitive.topology = wgpu::PrimitiveTopology::LineList; + let wireframe_render_pipeline = device.create_render_pipeline(&render_pipeline_descriptor); - let mut multisampled_render_target = None; + let wireframe_indices = build_wireframe_indices(&geometry.indices); + let wireframe_ibo = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: bytemuck::cast_slice(&wireframe_indices), + usage: wgpu::BufferUsages::INDEX, + }); - surface.configure(&device, &surface_desc); + let bg_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { + label: None, + layout: Some(&pipeline_layout), + vertex: wgpu::VertexState { + module: bg_vs_module, + entry_point: "main", + buffers: &[wgpu::VertexBufferLayout { + array_stride: std::mem::size_of::() as u64, + step_mode: wgpu::VertexStepMode::Vertex, + attributes: &[wgpu::VertexAttribute { + offset: 0, + format: wgpu::VertexFormat::Float32x2, + shader_location: 0, + }], + }], + compilation_options: wgpu::PipelineCompilationOptions::default(), + }, + fragment: Some(wgpu::FragmentState { + module: bg_fs_module, + entry_point: "main", + targets: &[Some(wgpu::ColorTargetState { + format: wgpu::TextureFormat::Bgra8Unorm, + blend: None, + write_mask: wgpu::ColorWrites::ALL, + })], + compilation_options: wgpu::PipelineCompilationOptions::default(), + }), + primitive: wgpu::PrimitiveState { + topology: wgpu::PrimitiveTopology::TriangleList, + polygon_mode: wgpu::PolygonMode::Fill, + front_face: wgpu::FrontFace::Ccw, + strip_index_format: None, + cull_mode: None, + unclipped_depth: false, + conservative: false, + }, + depth_stencil: depth_stencil_state, + multisample: wgpu::MultisampleState { + count: sample_count, + mask: !0, + alpha_to_coverage_enabled: false, + }, + multiview: None, + cache: None, + }); - let mut depth_texture_view = None; + let size = window.inner_size(); + + let surface_desc = wgpu::SurfaceConfiguration { + usage: wgpu::TextureUsages::RENDER_ATTACHMENT, + format: wgpu::TextureFormat::Bgra8Unorm, + width: size.width, + height: size.height, + present_mode: wgpu::PresentMode::AutoVsync, + desired_maximum_frame_latency: 2, + alpha_mode: wgpu::CompositeAlphaMode::Auto, + view_formats: vec![], + }; - let mut frame_count: f32 = 0.0; - event_loop.run(move |event, _, control_flow| { - if update_inputs(event, control_flow, &mut scene) { - // keep polling inputs. - return; - } + surface.configure(&device, &surface_desc); + + Some(App { + window, + scene, + device, + queue, + surface, + surface_desc, + vbo, + ibo, + wireframe_ibo, + bg_vbo, + bg_ibo, + wireframe_indices, + prims_ubo, + globals_ubo, + bind_group, + render_pipeline, + wireframe_render_pipeline, + bg_pipeline, + multisampled_render_target: None, + geometry, + cpu_primitives, + depth_texture_view: None, + frame_count: 0.0, + sample_count, + stroke_prim_id, + num_instances, + bg_color, + vignette_color, + }) + } - if scene.size_changed { - scene.size_changed = false; - let physical = scene.window_size; - surface_desc.width = physical.width; - surface_desc.height = physical.height; - surface.configure(&device, &surface_desc); + fn render(&mut self) { + if self.scene.size_changed { + self.scene.size_changed = false; + let physical = self.scene.window_size; + self.surface_desc.width = physical.width; + self.surface_desc.height = physical.height; + self.surface.configure(&self.device, &self.surface_desc); - let depth_texture = device.create_texture(&wgpu::TextureDescriptor { + let depth_texture = self.device.create_texture(&wgpu::TextureDescriptor { label: Some("Depth texture"), size: wgpu::Extent3d { - width: surface_desc.width, - height: surface_desc.height, + width: self.surface_desc.width, + height: self.surface_desc.height, depth_or_array_layers: 1, }, mip_level_count: 1, - sample_count, + sample_count: self.sample_count, dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Depth32Float, usage: wgpu::TextureUsages::RENDER_ATTACHMENT, + view_formats: &[], }); - depth_texture_view = + self.depth_texture_view = Some(depth_texture.create_view(&wgpu::TextureViewDescriptor::default())); - multisampled_render_target = if sample_count > 1 { + self.multisampled_render_target = if self.sample_count > 1 { Some(create_multisampled_framebuffer( - &device, - &surface_desc, - sample_count, + &self.device, + &self.surface_desc, + self.sample_count, )) } else { None }; } - let frame = match surface.get_current_texture() { + let frame = match self.surface.get_current_texture() { Ok(frame) => frame, Err(e) => { println!("Swap-chain error: {e:?}"); @@ -596,52 +775,52 @@ pub fn show_path(cmd: TessellateCmd, render_options: RenderCmd) { .texture .create_view(&wgpu::TextureViewDescriptor::default()); - let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { + let mut encoder = self.device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("Encoder"), }); - cpu_primitives[stroke_prim_id].width = scene.stroke_width; - cpu_primitives[stroke_prim_id].color = [ - (frame_count * 0.008 - 1.6).sin() * 0.1 + 0.1, - (frame_count * 0.005 - 1.6).sin() * 0.1 + 0.1, - (frame_count * 0.01 - 1.6).sin() * 0.1 + 0.1, + self.cpu_primitives[self.stroke_prim_id].width = self.scene.stroke_width; + self.cpu_primitives[self.stroke_prim_id].color = [ + (self.frame_count * 0.008 - 1.6).sin() * 0.1 + 0.1, + (self.frame_count * 0.005 - 1.6).sin() * 0.1 + 0.1, + (self.frame_count * 0.01 - 1.6).sin() * 0.1 + 0.1, 1.0, ]; - for idx in 2..(num_instances + 1) { - cpu_primitives[idx as usize].translate = [ - (frame_count * 0.001 * idx as f32).sin() * (100.0 + idx as f32 * 10.0), - (frame_count * 0.002 * idx as f32).sin() * (100.0 + idx as f32 * 10.0), + for idx in 2..(self.num_instances + 1) { + self.cpu_primitives[idx as usize].translate = [ + (self.frame_count * 0.001 * idx as f32).sin() * (100.0 + idx as f32 * 10.0), + (self.frame_count * 0.002 * idx as f32).sin() * (100.0 + idx as f32 * 10.0), ]; } - queue.write_buffer( - &globals_ubo, + self.queue.write_buffer( + &self.globals_ubo, 0, bytemuck::cast_slice(&[Globals { resolution: [ - scene.window_size.width as f32, - scene.window_size.height as f32, + self.scene.window_size.width as f32, + self.scene.window_size.height as f32, ], - zoom: scene.zoom, - scroll_offset: scene.scroll.to_array(), - bg_color, - vignette_color, + zoom: self.scene.zoom, + scroll_offset: self.scene.scroll.to_array(), + bg_color: self.bg_color, + vignette_color: self.vignette_color, _pad: [0.0; 3], }]), ); - queue.write_buffer(&prims_ubo, 0, bytemuck::cast_slice(&cpu_primitives)); + self.queue.write_buffer(&self.prims_ubo, 0, bytemuck::cast_slice(&self.cpu_primitives)); { // A resolve target is only supported if the attachment actually uses anti-aliasing // So if sample_count == 1 then we must render directly to the swapchain's buffer - let color_attachment = if let Some(msaa_target) = &multisampled_render_target { + let color_attachment = if let Some(msaa_target) = &self.multisampled_render_target { wgpu::RenderPassColorAttachment { view: msaa_target, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::WHITE), - store: true, + store: wgpu::StoreOp::Store, }, resolve_target: Some(&frame_view), } @@ -650,7 +829,7 @@ pub fn show_path(cmd: TessellateCmd, render_options: RenderCmd) { view: &frame_view, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::WHITE), - store: true, + store: wgpu::StoreOp::Store, }, resolve_target: None, } @@ -660,48 +839,51 @@ pub fn show_path(cmd: TessellateCmd, render_options: RenderCmd) { label: None, color_attachments: &[Some(color_attachment)], depth_stencil_attachment: Some(wgpu::RenderPassDepthStencilAttachment { - view: depth_texture_view.as_ref().unwrap(), + view: self.depth_texture_view.as_ref().unwrap(), depth_ops: Some(wgpu::Operations { load: wgpu::LoadOp::Clear(0.0), - store: true, + store: wgpu::StoreOp::Store, }), stencil_ops: Some(wgpu::Operations { load: wgpu::LoadOp::Clear(0), - store: true, + store: wgpu::StoreOp::Store, }), }), + timestamp_writes: None, + occlusion_query_set: None, }); - let index_range = if scene.show_wireframe { - pass.set_pipeline(&wireframe_render_pipeline); - pass.set_index_buffer(wireframe_ibo.slice(..), wgpu::IndexFormat::Uint32); - 0..(wireframe_indices.len() as u32) + let index_range = if self.scene.show_wireframe { + pass.set_pipeline(&self.wireframe_render_pipeline); + pass.set_index_buffer(self.wireframe_ibo.slice(..), wgpu::IndexFormat::Uint32); + 0..(self.wireframe_indices.len() as u32) } else { - pass.set_pipeline(&render_pipeline); - pass.set_index_buffer(ibo.slice(..), wgpu::IndexFormat::Uint32); - 0..(geometry.indices.len() as u32) + pass.set_pipeline(&self.render_pipeline); + pass.set_index_buffer(self.ibo.slice(..), wgpu::IndexFormat::Uint32); + 0..(self.geometry.indices.len() as u32) }; - pass.set_bind_group(0, &bind_group, &[]); - pass.set_vertex_buffer(0, vbo.slice(..)); + pass.set_bind_group(0, &self.bind_group, &[]); + pass.set_vertex_buffer(0, self.vbo.slice(..)); pass.draw_indexed(index_range, 0, 0..1); - if scene.draw_background { - pass.set_pipeline(&bg_pipeline); - pass.set_bind_group(0, &bind_group, &[]); - pass.set_index_buffer(bg_ibo.slice(..), wgpu::IndexFormat::Uint32); - pass.set_vertex_buffer(0, bg_vbo.slice(..)); + if self.scene.draw_background { + pass.set_pipeline(&self.bg_pipeline); + pass.set_bind_group(0, &self.bind_group, &[]); + pass.set_index_buffer(self.bg_ibo.slice(..), wgpu::IndexFormat::Uint32); + pass.set_vertex_buffer(0, self.bg_vbo.slice(..)); pass.draw_indexed(0..6, 0, 0..1); } } - queue.submit(Some(encoder.finish())); + self.queue.submit(Some(encoder.finish())); frame.present(); - frame_count += 1.0; - }); + self.frame_count += 1.0; + self.scene.render = false; + } } fn build_wireframe_indices(indices: &[u32]) -> Vec { @@ -783,105 +965,5 @@ struct SceneParams { cursor_position: (f32, f32), window_size: PhysicalSize, size_changed: bool, -} - -fn update_inputs( - event: Event<()>, - control_flow: &mut ControlFlow, - scene: &mut SceneParams, -) -> bool { - match event { - Event::MainEventsCleared => { - return false; - } - Event::WindowEvent { - event: WindowEvent::Destroyed, - .. - } - | Event::WindowEvent { - event: WindowEvent::CloseRequested, - .. - } => { - *control_flow = ControlFlow::Exit; - return false; - } - Event::WindowEvent { - event: WindowEvent::CursorMoved { position, .. }, - .. - } => { - scene.cursor_position = (position.x as f32, position.y as f32); - } - Event::WindowEvent { - event: WindowEvent::Resized(size), - .. - } => { - scene.window_size = size; - scene.size_changed = true - } - Event::WindowEvent { - event: - WindowEvent::KeyboardInput { - input: - KeyboardInput { - state: ElementState::Pressed, - virtual_keycode: Some(key), - .. - }, - .. - }, - .. - } => match key { - VirtualKeyCode::Escape => { - *control_flow = ControlFlow::Exit; - return false; - } - VirtualKeyCode::PageDown => { - scene.target_zoom *= 0.8; - } - VirtualKeyCode::PageUp => { - scene.target_zoom *= 1.25; - } - VirtualKeyCode::Left => { - scene.target_scroll.x -= 50.0 / scene.target_zoom; - } - VirtualKeyCode::Right => { - scene.target_scroll.x += 50.0 / scene.target_zoom; - } - VirtualKeyCode::Up => { - scene.target_scroll.y -= 50.0 / scene.target_zoom; - } - VirtualKeyCode::Down => { - scene.target_scroll.y += 50.0 / scene.target_zoom; - } - VirtualKeyCode::P => { - scene.show_points = !scene.show_points; - } - VirtualKeyCode::W => { - scene.show_wireframe = !scene.show_wireframe; - } - VirtualKeyCode::B => { - scene.draw_background = !scene.draw_background; - } - VirtualKeyCode::A => { - scene.target_stroke_width /= 0.8; - } - VirtualKeyCode::Z => { - scene.target_stroke_width *= 0.8; - } - _key => {} - }, - _evt => { - //println!("{:?}", _evt); - } - } - //println!(" -- zoom: {}, scroll: {:?}", scene.target_zoom, scene.target_scroll); - - scene.zoom += (scene.target_zoom - scene.zoom) / 3.0; - scene.scroll = scene.scroll + (scene.target_scroll - scene.scroll) / 3.0; - scene.stroke_width = - scene.stroke_width + (scene.target_stroke_width - scene.stroke_width) / 5.0; - - *control_flow = ControlFlow::Poll; - - true + render: bool, } diff --git a/examples/wgpu_svg/src/main.rs b/examples/wgpu_svg/src/main.rs index f8036f33..4b342348 100644 --- a/examples/wgpu_svg/src/main.rs +++ b/examples/wgpu_svg/src/main.rs @@ -129,7 +129,7 @@ fn main() { env_logger::init(); let event_loop = EventLoop::new().unwrap(); - event_loop.set_control_flow(ControlFlow::Poll); + event_loop.set_control_flow(ControlFlow::Wait); let mut app = App { window: None,