diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 0388b6931f36..0ecc4a6c0737 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -46,7 +46,7 @@ In rust, we use the [`arrow2` crate](https://crates.io/crates/arrow2). ### `wgpu` The Rerun Viewer uses the [`wgpu`](https://github.com/gfx-rs/wgpu) graphics API. It provides a high-performance abstraction over Vulkan, Metal, D3D12, D3D11, OpenGLES, WebGL and [WebGPU](https://en.wikipedia.org/wiki/WebGPU). This lets us write the same code graphics code for native as for web. -We use the WebGL backend when compiling for web. Once WebGPU is available in most browsers, we can easily switch to it for a nice performance boost! +On web builds, we use WebGPU when available on the Web, but automatically fall back to a WebGL based emulation layer (with a more limited feature set). We have written our own high-level rendering crate on top of `wgpu`, called [`re_renderer`](crates/re_renderer/README.md). diff --git a/BUILD.md b/BUILD.md index 0b81a631b54e..4af0829dbf03 100644 --- a/BUILD.md +++ b/BUILD.md @@ -129,23 +129,6 @@ You may need to turn on Windows developer mode in order to give the `mklink` com See also this [Stack Overflow reply](https://stackoverflow.com/questions/5917249/git-symbolic-links-in-windows/59761201#59761201) on the issue. -### Building with WebGPU support - -By default, all web builds are using WebGL for rendering. -However, Rerun can also build with experimental WebGPU support! -Note that currently we can't build wasm files that support both WebGPU and WebGL. - -To build a standalone Rerun executable with a WebGPU web viewer, you need to set -the `RERUN_BUILD_WEBGPU` env variable and enable the `web_viewer` feature: -``` -RERUN_BUILD_WEBGPU=1 cargo build -p rerun --features web_viewer -``` - -And for building a WebGPU based web-viewer without the server: -``` -cargo run -p re_build_web_viewer -- --release --webgpu -``` - ## Improving compile times As of today, we link everything statically in both debug and release builds, which makes custom linkers and split debuginfo the two most impactful tools we have at our disposal in order to improve compile times. diff --git a/Cargo.lock b/Cargo.lock index 2dbbd8ea897b..b48b46d067cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,7 +272,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -540,7 +540,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -575,7 +575,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -822,7 +822,7 @@ checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1049,7 +1049,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1102,15 +1102,14 @@ dependencies = [ [[package]] name = "cocoa-foundation" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "931d3837c286f56e3c58423ce4eba12d08db2374461a785c86f672b08b5650d6" +checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7" dependencies = [ "bitflags 1.3.2", "block", "core-foundation", "core-graphics-types", - "foreign-types 0.3.2", "libc", "objc", ] @@ -1150,10 +1149,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] -name = "com-rs" -version = "0.2.1" +name = "com" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" +checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6" +dependencies = [ + "com_macros", +] + +[[package]] +name = "com_macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5" +dependencies = [ + "com_macros_support", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "com_macros_support" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] name = "combine" @@ -1262,13 +1286,12 @@ dependencies = [ [[package]] name = "core-graphics-types" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +checksum = "2bb142d41022986c1d8ff29103a1411c8a3dfad3552f87a4f8dc50d61d4f4e33" dependencies = [ "bitflags 1.3.2", "core-foundation", - "foreign-types 0.3.2", "libc", ] @@ -1469,9 +1492,9 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.7.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" +checksum = "3e3d747f100290a1ca24b752186f61f6637e1deffe3bf6320de6fcb29510a307" dependencies = [ "bitflags 2.4.1", "libloading 0.8.1", @@ -1498,7 +1521,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1509,7 +1532,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1608,8 +1631,7 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecolor" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57539aabcdbb733b6806ef421b66dec158dc1582107ad6d51913db3600303354" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "bytemuck", "serde", @@ -1618,8 +1640,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79c00143a1d564cf27570234c9a199cbe75dc3d43a135510fb2b93406a87ee8e" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "bytemuck", "cocoa", @@ -1636,7 +1657,7 @@ dependencies = [ "percent-encoding", "pollster", "puffin", - "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", "ron", "serde", "static_assertions", @@ -1652,8 +1673,7 @@ dependencies = [ [[package]] name = "egui" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0bf640ed7f3bf3d14ebf00d73bacc09c886443ee84ca6494bde37953012c9e3" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "accesskit", "ahash", @@ -1669,8 +1689,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c38c12e04316687dd1b74f3dfe83a885214dfe7f356118a2d3bee2b39740813" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "bytemuck", "egui", @@ -1686,15 +1705,14 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d95d9762056c541bd2724de02910d8bccf3af8e37689dc114b21730e64f80a0" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "accesskit_winit", "arboard", "egui", "log", "puffin", - "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", "serde", "smithay-clipboard", "web-time", @@ -1716,11 +1734,10 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "753c36d3e2f7a32425af5290af2e52efb3471ea3a263b87f003b5433351b0fd7" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "egui", - "ehttp 0.3.1", + "ehttp", "enum-map", "image", "log", @@ -1732,8 +1749,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb2ef815e80d117339c7d6b813f7678d23522d699ccd3243e267ef06166009b9" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "bytemuck", "egui", @@ -1742,6 +1758,7 @@ dependencies = [ "log", "memoffset 0.7.1", "puffin", + "raw-window-handle 0.5.2", "wasm-bindgen", "web-sys", ] @@ -1749,8 +1766,7 @@ dependencies = [ [[package]] name = "egui_plot" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a159fffebf052f79d1fd26d48e68906a21fec2fce808f7c0a982ec14ed506be" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "egui", ] @@ -1768,20 +1784,6 @@ dependencies = [ "serde", ] -[[package]] -name = "ehttp" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f88f45662356f96afc7d9e2bc9910ad8352ee01417f7c69b8b16a53c8767a75d" -dependencies = [ - "document-features", - "js-sys", - "ureq", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "ehttp" version = "0.4.0" @@ -1807,8 +1809,7 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "emath" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee58355767587db7ba3738930d93cad3052cd834c2b48b9ef6ef26fe4823b7e" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "bytemuck", "serde", @@ -1838,7 +1839,7 @@ checksum = "04d0b288e3bb1d861c4403c1774a6f7a798781dfc519b3647df2a3dd4ae95f25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1859,7 +1860,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1870,7 +1871,7 @@ checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1891,7 +1892,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -1909,8 +1910,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e638cb066bff0903bbb6143116cfd134a42279c7d68f19c0352a94f15a402de7" +source = "git+https://github.com/emilk/egui.git?rev=2f9a4ca6e8434aaee3569095c0743b73cba26c44#2f9a4ca6e8434aaee3569095c0743b73cba26c44" dependencies = [ "ab_glyph", "ahash", @@ -2109,18 +2109,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "flume" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" -dependencies = [ - "futures-core", - "futures-sink", - "nanorand", - "spin 0.9.8", -] - [[package]] name = "fnv" version = "1.0.7" @@ -2154,7 +2142,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -2277,7 +2265,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -2399,9 +2387,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "glow" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "886c2a30b160c4c6fec8f987430c26b526b7988ca71f664e6a699ddf6f9601e4" +checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1" dependencies = [ "js-sys", "slotmap", @@ -2432,7 +2420,7 @@ dependencies = [ "inflections", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -2477,11 +2465,10 @@ dependencies = [ [[package]] name = "gpu-allocator" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40fe17c8a05d60c38c0a4e5a3c802f2f1ceb66b76c67d96ffb34bef0475a7fad" +checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" dependencies = [ - "backtrace", "log", "presser", "thiserror", @@ -2579,14 +2566,14 @@ dependencies = [ [[package]] name = "hassle-rs" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1397650ee315e8891a0df210707f0fc61771b0cc518c3023896064c5407cb3b0" +checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" dependencies = [ - "bitflags 1.3.2", - "com-rs", + "bitflags 2.4.1", + "com", "libc", - "libloading 0.7.4", + "libloading 0.8.1", "thiserror", "widestring", "winapi", @@ -2944,9 +2931,9 @@ checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" dependencies = [ "wasm-bindgen", ] @@ -3385,9 +3372,9 @@ dependencies = [ [[package]] name = "naga" -version = "0.14.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61d829abac9f5230a85d8cc83ec0879b4c09790208ae25b5ea031ef84562e071" +checksum = "8878eb410fc90853da3908aebfe61d73d26d4437ef850b70050461f939509899" dependencies = [ "bit-set", "bitflags 2.4.1", @@ -3403,15 +3390,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "nanorand" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" -dependencies = [ - "getrandom", -] - [[package]] name = "natord" version = "1.0.9" @@ -3453,7 +3431,6 @@ dependencies = [ "log", "ndk-sys", "num_enum", - "raw-window-handle 0.5.2", "raw-window-handle 0.6.0", "thiserror", ] @@ -3543,7 +3520,7 @@ checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -3605,7 +3582,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -3735,9 +3712,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -4155,7 +4132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" dependencies = [ "proc-macro2", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -4170,9 +4147,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -4194,7 +4171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b322d7d65c1ab449be3c890fcbd0db6e1092d0dd05d79dba2dd28032cebeb05" dependencies = [ "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -4224,7 +4201,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.32", + "syn 2.0.48", "tempfile", "which", ] @@ -4239,7 +4216,7 @@ dependencies = [ "itertools 0.10.5", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -4346,7 +4323,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -4358,7 +4335,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -4372,9 +4349,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -4483,7 +4460,7 @@ version = "0.13.0-alpha.2" dependencies = [ "crossbeam", "directories-next", - "ehttp 0.4.0", + "ehttp", "re_build_info", "re_build_tools", "re_log", @@ -4711,7 +4688,7 @@ name = "re_log_encoding" version = "0.13.0-alpha.2" dependencies = [ "criterion", - "ehttp 0.4.0", + "ehttp", "js-sys", "lz4_flex", "mimalloc", @@ -4860,6 +4837,7 @@ dependencies = [ "document-features", "ecolor", "enumset", + "getrandom", "glam", "gltf", "half 2.3.1", @@ -5256,7 +5234,7 @@ dependencies = [ "re_log", "re_tracing", "rust-format", - "syn 2.0.32", + "syn 2.0.48", "tempfile", "unindent", "xshell", @@ -5315,7 +5293,7 @@ dependencies = [ "egui-wgpu", "egui_plot", "egui_tiles", - "ehttp 0.4.0", + "ehttp", "image", "itertools 0.12.0", "once_cell", @@ -5677,7 +5655,7 @@ dependencies = [ "cc", "libc", "once_cell", - "spin 0.5.2", + "spin", "untrusted", "web-sys", "winapi", @@ -6077,7 +6055,7 @@ checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -6099,7 +6077,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -6344,23 +6322,13 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "spirv" -version = "0.2.0+1.5.4" +version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" +checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 1.3.2", - "num-traits", + "bitflags 2.4.1", ] [[package]] @@ -6441,9 +6409,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -6498,9 +6466,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -6532,22 +6500,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -6662,7 +6630,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -6753,7 +6721,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] @@ -7025,9 +6993,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -7035,24 +7003,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-cli-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf8226e223e2dfbe8f921b7f20b82d1b5d86a6b143e9d6286cca8edd16695583" +checksum = "a875870b7b39024cbca8f61a0e1fc8edfe7ac02b484e5a9bcea64374050a850e" dependencies = [ "anyhow", "base64 0.9.3", @@ -7072,9 +7040,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-externref-xform" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a719be856d8b0802c7195ca26ee6eb02cb9639a12b80be32db960ce9640cb8" +checksum = "04c5d468dc79cfd824d181c386f34c2e7ea521ea5855ddd95af8f4cf3fa676f4" dependencies = [ "anyhow", "walrus", @@ -7082,9 +7050,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" dependencies = [ "cfg-if", "js-sys", @@ -7094,9 +7062,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7104,22 +7072,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-multi-value-xform" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12766255d4b9026700376cc81894eeb62903e4414cbc94675f6f9babd9cfb76" +checksum = "65f10c037dad45759d53b598d4737acdced90a0945023c8c6cd8d67b4b3e4eaf" dependencies = [ "anyhow", "walrus", @@ -7127,15 +7095,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" [[package]] name = "wasm-bindgen-threads-xform" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2b14c5b9c2c7aa9dd1eb7161857de9783f40e98582e7f41f2d7c04ffdc155" +checksum = "16ddf1a4beb1bceb2b73c2325581901ca2cd92af628f24389a678854dcd65b24" dependencies = [ "anyhow", "walrus", @@ -7144,9 +7112,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-wasm-conventions" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaedf88769cb23c6fd2e3bfed65bcbff6c5d92c8336afbd80d2dfcc8eb5cf047" +checksum = "93f13ed8ccdac31eadcfd4c9b2ec7bd43e77454b14acb1f43189f2875a9b0391" dependencies = [ "anyhow", "walrus", @@ -7154,9 +7122,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-wasm-interpreter" -version = "0.2.89" +version = "0.2.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a79039df1e0822e6d66508ec86052993deac201e26060f62abcd85e1daf951" +checksum = "c4282a271772a3063d4057c1144e118254f207fbbc1381b8d50b23c25585d893" dependencies = [ "anyhow", "log", @@ -7318,9 +7286,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" dependencies = [ "js-sys", "wasm-bindgen", @@ -7381,19 +7349,19 @@ checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" [[package]] name = "wgpu" -version = "0.18.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e7d227c9f961f2061c26f4cb0fbd4df0ef37e056edd0931783599d6c94ef24" +checksum = "0bfe9a310dcf2e6b85f00c46059aaeaf4184caa8e29a1ecd4b7a704c3482332d" dependencies = [ "arrayvec", "cfg-if", - "flume", + "cfg_aliases 0.1.1", "js-sys", "log", "naga", "parking_lot 0.12.1", "profiling", - "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", "smallvec", "static_assertions", "wasm-bindgen", @@ -7406,19 +7374,22 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "837e02ddcdc6d4a9b56ba4598f7fd4202a7699ab03f6ef4dcdebfad2c966aea6" +checksum = "6b15e451d4060ada0d99a64df44e4d590213496da7c4f245572d51071e8e30ed" dependencies = [ "arrayvec", "bit-vec", "bitflags 2.4.1", + "cfg_aliases 0.1.1", "codespan-reporting", + "indexmap 2.1.0", "log", "naga", + "once_cell", "parking_lot 0.12.1", "profiling", - "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", "rustc-hash", "smallvec", "thiserror", @@ -7429,9 +7400,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.18.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e30b9a8155c83868e82a8c5d3ce899de6c3961d2ef595de8fc168a1677fc2d8" +checksum = "e3bb47856236bfafc0bc591a925eb036ac19cd987624a447ff353e7a7e7e6f72" dependencies = [ "android_system_properties", "arrayvec", @@ -7439,6 +7410,7 @@ dependencies = [ "bit-set", "bitflags 2.4.1", "block", + "cfg_aliases 0.1.1", "core-graphics-types", "d3d12", "glow", @@ -7459,7 +7431,7 @@ dependencies = [ "parking_lot 0.12.1", "profiling", "range-alloc", - "raw-window-handle 0.5.2", + "raw-window-handle 0.6.0", "renderdoc-sys", "rustc-hash", "smallvec", @@ -7472,9 +7444,9 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd" +checksum = "895fcbeb772bfb049eb80b2d6e47f6c9af235284e9703c96fc0218a42ffd5af2" dependencies = [ "bitflags 2.4.1", "js-sys", @@ -7816,7 +7788,6 @@ dependencies = [ "once_cell", "orbclient", "percent-encoding", - "raw-window-handle 0.5.2", "raw-window-handle 0.6.0", "redox_syscall 0.3.5", "rustix 0.38.24", @@ -8054,7 +8025,7 @@ checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.48", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 33a76c5358de..5c7519f26eb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -235,8 +235,21 @@ webbrowser = "0.8" winit = { version = "0.29.9", default-features = false } # TODO(andreas): Try to get rid of `fragile-send-sync-non-atomic-wasm`. This requires re_renderer being aware of single-thread restriction on resources. # See also https://gpuweb.github.io/gpuweb/explainer/#multithreading-transfer (unsolved part of the Spec as of writing!) -wgpu = { version = "0.18.0", features = ["fragile-send-sync-non-atomic-wasm"] } -wgpu-core = "0.18.0" +wgpu = { version = "0.19.1", default-features = false, features = [ + # Backends (see https://docs.rs/wgpu/latest/wgpu/#feature-flags) + "webgl", + "metal", + "webgpu", + #"vulkan", # Does not yet exist, wgpu enables this automatically on Linux & Windows. + #"gl", # Does not yet exist, wgpu enables this automatically on Linux & Windows. + #"dx12", # DX12 backend on wgpu isn't as stable. Also, we want to reduce the number of backends on native. Ideally we only have Vulkan & Metal, but we also keep GL as a manual fallback. + #"angle", # As above, we want to limit the numbers of backends we support. GL support via angle isn't great and we didn't need it so far. + # Shader options: + "wgsl", + # Other: + "fragile-send-sync-non-atomic-wasm", +] } +wgpu-core = "0.19.0" xshell = "0.2" zip = { version = "0.6", default-features = false } zune-core = "0.4" @@ -268,12 +281,13 @@ debug = true # As a last resport, patch with a commit to our own repository. # ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk. -# ecolor = { git = "https://github.com/emilk/egui.git", rev = "a2b15b23ad26f077e229d492cd1571d97217d570" } # egui master 2023-11-23 -# eframe = { git = "https://github.com/emilk/egui.git", rev = "a2b15b23ad26f077e229d492cd1571d97217d570" } # egui master 2023-11-23 -# egui = { git = "https://github.com/emilk/egui.git", rev = "a2b15b23ad26f077e229d492cd1571d97217d570" } # egui master 2023-11-23 -# egui_extras = { git = "https://github.com/emilk/egui.git", rev = "a2b15b23ad26f077e229d492cd1571d97217d570" } # egui master 2023-11-23 -# egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "a2b15b23ad26f077e229d492cd1571d97217d570" } # egui master 2023-11-23 -# emath = { git = "https://github.com/emilk/egui.git", rev = "a2b15b23ad26f077e229d492cd1571d97217d570" } # egui master 2023-11-23 +ecolor = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 +eframe = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 +egui = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 +egui_extras = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 +egui_plot = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 +egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 +emath = { git = "https://github.com/emilk/egui.git", rev = "2f9a4ca6e8434aaee3569095c0743b73cba26c44" } # egui master 2024-01-23 # Useful while developing: # ecolor = { path = "../../egui/crates/ecolor" } diff --git a/crates/re_build_web_viewer/src/lib.rs b/crates/re_build_web_viewer/src/lib.rs index b94e2f87d0a1..bed3c234060c 100644 --- a/crates/re_build_web_viewer/src/lib.rs +++ b/crates/re_build_web_viewer/src/lib.rs @@ -43,12 +43,6 @@ impl Profile { } } -#[derive(Clone, Copy, PartialEq, Eq)] -pub enum Backend { - WebGL, - WebGPU, -} - #[derive(Clone, Copy, PartialEq, Eq)] pub enum Target { Browser, @@ -56,12 +50,7 @@ pub enum Target { } /// Build `re_viewer` as Wasm, generate .js bindings for it, and place it all into the `build_dir` folder. -pub fn build( - profile: Profile, - backend: Backend, - target: Target, - build_dir: &Utf8Path, -) -> anyhow::Result<()> { +pub fn build(profile: Profile, target: Target, build_dir: &Utf8Path) -> anyhow::Result<()> { std::env::set_current_dir(workspace_root())?; eprintln!("Building web viewer wasm…"); @@ -108,11 +97,8 @@ pub fn build( "--target-dir", target_wasm_dir.as_str(), "--no-default-features", + "--features=analytics", ]); - match backend { - Backend::WebGL => cmd.arg("--features=analytics,webgl"), - Backend::WebGPU => cmd.arg("--features=analytics"), - }; if profile == Profile::Release { cmd.arg("--release"); } diff --git a/crates/re_build_web_viewer/src/main.rs b/crates/re_build_web_viewer/src/main.rs index 005b7a1d2f47..cce54fad6dd1 100644 --- a/crates/re_build_web_viewer/src/main.rs +++ b/crates/re_build_web_viewer/src/main.rs @@ -1,10 +1,9 @@ use cargo_metadata::camino::Utf8PathBuf; -use re_build_web_viewer::{default_build_dir, Backend, Profile, Target}; +use re_build_web_viewer::{default_build_dir, Profile, Target}; use std::process::ExitCode; struct Opts { profile: Option, - backend: Backend, target: Target, build_dir: Utf8PathBuf, } @@ -13,7 +12,6 @@ impl Default for Opts { fn default() -> Self { Self { profile: None, - backend: Backend::WebGL, target: Target::Browser, build_dir: default_build_dir(), } @@ -44,9 +42,6 @@ fn main() -> ExitCode { ); opts.profile = Some(Profile::Release); } - "--webgpu" => { - opts.backend = Backend::WebGPU; - } "-o" | "--out" => match args.next() { Some(value) if !value.starts_with('-') => { opts.build_dir = Utf8PathBuf::from(value); @@ -68,9 +63,7 @@ fn main() -> ExitCode { return ExitCode::FAILURE; }; - if let Err(err) = - re_build_web_viewer::build(release, opts.backend, opts.target, &opts.build_dir) - { + if let Err(err) = re_build_web_viewer::build(release, opts.target, &opts.build_dir) { eprintln!("Failed to build web viewer: {}", re_error::format(err)); ExitCode::FAILURE } else { @@ -86,7 +79,6 @@ fn print_help() { --debug: Build a debug binary --release: Compile for release, and run wasm-opt. NOTE: --release also removes debug symbols which are otherwise useful for in-browser profiling. - --webgpu: Enable WebGPU support (experimental). If not set the viewer will use WebGL instead. -o, --out: Set the output directory. This is a path relative to the cargo workspace root. " ); diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index 0746e61d8932..3129ce1a26a2 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -38,9 +38,6 @@ import-gltf = ["dep:gltf"] ## Enable (de)serialization using serde. serde = ["dep:serde"] -## Render using webgl instead of webgpu on wasm builds. -webgl = ["wgpu/webgl", "dep:wgpu-core"] - [dependencies] re_error.workspace = true re_log.workspace = true @@ -71,24 +68,27 @@ static_assertions.workspace = true thiserror.workspace = true type-map.workspace = true wgpu.workspace = true +wgpu-core.workspace = true # Needed for error handling when wgpu-core implemented backend is used. # optional arrow2 = { workspace = true, optional = true } gltf = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"], optional = true } tobj = { workspace = true, optional = true } -wgpu-core = { workspace = true, optional = true } # Needed for error handling when wgpu-core implemented backend is used. # native [target.'cfg(not(target_arch = "wasm32"))'.dependencies] crossbeam.workspace = true notify.workspace = true -wgpu-core.workspace = true -# webgpu -[target.'cfg(all(target_arch = "wasm32", not(features = "webgl")))'.dependencies] +# web +[target.'cfg(target_arch = "wasm32")'.dependencies] +getrandom = { workspace = true, features = [ + "js", +] } # getrandom needs the `js` feature to be enabled. It is dragged in indirectly. wasm-bindgen-futures.workspace = true + [dev-dependencies] unindent.workspace = true diff --git a/crates/re_renderer/build.rs b/crates/re_renderer/build.rs index 4dd2f1d8e562..4745f1ffbec5 100644 --- a/crates/re_renderer/build.rs +++ b/crates/re_renderer/build.rs @@ -121,8 +121,7 @@ fn should_run() -> bool { fn main() { cfg_aliases::cfg_aliases! { native: { not(target_arch = "wasm32") }, - webgl: { all(not(native), feature = "webgl") }, - webgpu: { all(not(webgl), not(native)) }, + web: { target_arch = "wasm32" }, load_shaders_from_disk: { all(native, debug_assertions) } // Shader reloading is only supported on native-debug currently. } diff --git a/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs b/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs index 7e1c43c31c1b..49fbc4a9a39b 100644 --- a/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs +++ b/crates/re_renderer/src/allocator/cpu_write_gpu_read_belt.rs @@ -411,7 +411,9 @@ impl CpuWriteGpuReadBelt { ); // Largest uncompressed texture format (btw. many compressed texture format have the same block size!) debug_assert!( - wgpu::TextureFormat::Rgba32Uint.block_size(None).unwrap() as u64 + wgpu::TextureFormat::Rgba32Uint + .block_copy_size(None) + .unwrap() as u64 <= CpuWriteGpuReadBelt::MIN_OFFSET_ALIGNMENT ); diff --git a/crates/re_renderer/src/allocator/gpu_readback_belt.rs b/crates/re_renderer/src/allocator/gpu_readback_belt.rs index b314437ada98..d772128cf18a 100644 --- a/crates/re_renderer/src/allocator/gpu_readback_belt.rs +++ b/crates/re_renderer/src/allocator/gpu_readback_belt.rs @@ -68,7 +68,7 @@ impl GpuReadbackBuffer { source .texture .format() - .block_size(Some(source.aspect)) + .block_copy_size(Some(source.aspect)) .ok_or(GpuReadbackError::UnsupportedTextureFormatForReadback( source.texture.format(), ))? as u64, diff --git a/crates/re_renderer/src/config.rs b/crates/re_renderer/src/config.rs index f57c9f083593..e2408bce6b1c 100644 --- a/crates/re_renderer/src/config.rs +++ b/crates/re_renderer/src/config.rs @@ -12,6 +12,9 @@ #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum DeviceTier { /// Limited feature support as provided by WebGL and native GLES2/OpenGL3(ish). + /// + /// Note that we do not distinguish between WebGL & native GL here, + /// instead, we go with the lowest common denominator. Gles = 0, /// Full support of WebGPU spec without additional feature requirements. @@ -23,6 +26,22 @@ pub enum DeviceTier { //HighEnd } +/// Type of Wgpu backend. +/// +/// Used in the rare cases where it's necessary to be aware of the api differences between +/// wgpu-core and webgpu. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum WgpuBackendType { + /// Backend implemented via wgpu-core. + /// + /// This includes all native backends and WebGL. + WgpuCore, + + /// Backend implemented by the browser's WebGPU javascript api. + #[cfg(web)] + WebGpu, +} + #[derive(thiserror::Error, Debug)] pub enum InsufficientDeviceCapabilities { #[error("Adapter does not support the minimum shader model required. Supported is {actual:?} but required is {required:?}")] @@ -40,7 +59,7 @@ pub enum InsufficientDeviceCapabilities { /// Capabilities of a given device. /// -/// Generally, this is a higher level interpretation of [`wgpu::Limits`]. +/// Generally, this is a higher level interpretation of [`wgpu::Limits`] & [`wgpu::Features`]. /// /// We're trying to keep the number of fields in this struct to a minimum and associate /// as many as possible capabilities with the device tier. @@ -52,6 +71,12 @@ pub struct DeviceCaps { /// /// Since this has a direct effect on the image sizes & screen resolution a user can use, we always pick the highest possible. pub max_texture_dimension2d: u32, + + /// Wgpu backend type. + /// + /// Prefer using `tier` and other properties of this struct for distinguishing between abilities. + /// This is useful for making wgpu-core/webgpu api path decisions. + pub backend_type: WgpuBackendType, } impl DeviceCaps { @@ -75,19 +100,39 @@ impl DeviceCaps { /// /// Note that it is always possible to pick a lower tier! pub fn from_adapter(adapter: &wgpu::Adapter) -> Self { - let tier = match adapter.get_info().backend { + let backend = adapter.get_info().backend; + + let tier = match backend { wgpu::Backend::Vulkan | wgpu::Backend::Metal | wgpu::Backend::Dx12 | wgpu::Backend::BrowserWebGpu => DeviceTier::FullWebGpuSupport, - // Dx11 support in wgpu is sporadic, treat it like GLES to be on the safe side. - wgpu::Backend::Dx11 | wgpu::Backend::Gl | wgpu::Backend::Empty => DeviceTier::Gles, + wgpu::Backend::Gl | wgpu::Backend::Empty => DeviceTier::Gles, + }; + + let backend_type = match backend { + wgpu::Backend::Empty + | wgpu::Backend::Vulkan + | wgpu::Backend::Metal + | wgpu::Backend::Dx12 + | wgpu::Backend::Gl => WgpuBackendType::WgpuCore, + wgpu::Backend::BrowserWebGpu => { + #[cfg(web)] + { + WgpuBackendType::WebGpu + } + #[cfg(not(web))] + { + unreachable!("WebGPU backend is not supported on native platforms.") + } + } }; Self { tier, max_texture_dimension2d: adapter.limits().max_texture_dimension_2d, + backend_type, } } @@ -109,8 +154,8 @@ impl DeviceCaps { pub fn device_descriptor(&self) -> wgpu::DeviceDescriptor<'static> { wgpu::DeviceDescriptor { label: Some("re_renderer device"), - features: self.features(), - limits: self.limits(), + required_features: self.features(), + required_limits: self.limits(), } } @@ -182,7 +227,6 @@ pub fn supported_backends() -> wgpu::Backends { wgpu::util::backend_bits_from_env() .unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL) } else { - // Web - WebGL is used automatically when wgpu is compiled with `webgl` feature. wgpu::Backends::GL | wgpu::Backends::BROWSER_WEBGPU } } diff --git a/crates/re_renderer/src/context.rs b/crates/re_renderer/src/context.rs index 31781a316a6c..be796b62c34c 100644 --- a/crates/re_renderer/src/context.rs +++ b/crates/re_renderer/src/context.rs @@ -26,7 +26,7 @@ pub struct RenderContext { pub device: Arc, pub queue: Arc, - pub(crate) config: RenderContextConfig, + pub config: RenderContextConfig, /// Global bindings, always bound to 0 bind group slot zero. /// [`Renderer`] are not allowed to use bind group 0 themselves! @@ -323,6 +323,7 @@ This means, either a call to RenderContext::before_submit was omitted, or the pr if let Some(top_level_error_scope) = self.active_frame.top_level_error_scope.take() { let frame_index_for_uncaptured_errors = self.frame_index_for_uncaptured_errors.clone(); self.top_level_error_tracker.handle_error_future( + self.config.device_caps.backend_type, top_level_error_scope.end(), self.active_frame.frame_index, move |err_tracker, frame_index| { diff --git a/crates/re_renderer/src/draw_phases/picking_layer.rs b/crates/re_renderer/src/draw_phases/picking_layer.rs index 0904e0f6d2e8..0a9026eb1d1b 100644 --- a/crates/re_renderer/src/draw_phases/picking_layer.rs +++ b/crates/re_renderer/src/draw_phases/picking_layer.rs @@ -274,9 +274,9 @@ impl PickingLayerProcessor { // Offset of the depth buffer in the readback buffer needs to be aligned to size of a depth pixel. // This is "trivially true" if the size of the depth format is a multiple of the size of the id format. debug_assert!( - Self::PICKING_LAYER_FORMAT.block_size(None).unwrap() + Self::PICKING_LAYER_FORMAT.block_copy_size(None).unwrap() % Self::PICKING_LAYER_DEPTH_FORMAT - .block_size(Some(wgpu::TextureAspect::DepthOnly)) + .block_copy_size(Some(wgpu::TextureAspect::DepthOnly)) .unwrap() == 0 ); @@ -409,12 +409,12 @@ impl PickingLayerProcessor { // Assert that our texture data reinterpretation works out from a pixel size point of view. debug_assert_eq!( Self::PICKING_LAYER_DEPTH_FORMAT - .block_size(Some(wgpu::TextureAspect::DepthOnly)) + .block_copy_size(Some(wgpu::TextureAspect::DepthOnly)) .unwrap(), std::mem::size_of::() as u32 ); debug_assert_eq!( - Self::PICKING_LAYER_FORMAT.block_size(None).unwrap() as usize, + Self::PICKING_LAYER_FORMAT.block_copy_size(None).unwrap() as usize, std::mem::size_of::() ); @@ -441,7 +441,7 @@ impl PickingLayerProcessor { // See https://github.com/gfx-rs/wgpu/issues/3644 debug_assert_eq!( DepthReadbackWorkaround::READBACK_FORMAT - .block_size(None) + .block_copy_size(None) .unwrap() as usize, std::mem::size_of::() * 4 ); diff --git a/crates/re_renderer/src/error_handling/error_tracker.rs b/crates/re_renderer/src/error_handling/error_tracker.rs index 6e991a734ab4..c0dc8db2f9a3 100644 --- a/crates/re_renderer/src/error_handling/error_tracker.rs +++ b/crates/re_renderer/src/error_handling/error_tracker.rs @@ -1,6 +1,8 @@ use ahash::HashMap; use parking_lot::Mutex; +use crate::config::WgpuBackendType; + use super::handle_async_error; #[cfg(not(webgpu))] @@ -55,6 +57,7 @@ impl ErrorTracker { /// (by the time the scope finishes, the active frame index may have changed) pub fn handle_error_future( self: &std::sync::Arc, + backend_type: WgpuBackendType, error_scope_result: impl IntoIterator< Item = impl std::future::Future> + Send + 'static, >, @@ -66,6 +69,7 @@ impl ErrorTracker { if error_scope_result.peek().is_none() { let err_tracker = self.clone(); handle_async_error( + backend_type, move |error| { if let Some(error) = error { err_tracker.handle_error(error, frame_index); @@ -79,6 +83,7 @@ impl ErrorTracker { let err_tracker = self.clone(); handle_async_error( + backend_type, move |error| { if let Some(error) = error { err_tracker.handle_error(error, frame_index); diff --git a/crates/re_renderer/src/error_handling/mod.rs b/crates/re_renderer/src/error_handling/mod.rs index 6692e05808a3..96cd9f1af3a6 100644 --- a/crates/re_renderer/src/error_handling/mod.rs +++ b/crates/re_renderer/src/error_handling/mod.rs @@ -1,27 +1,26 @@ mod error_tracker; -mod wgpu_error_scope; - -#[cfg(not(webgpu))] -mod wgpu_core_error; - -#[cfg(not(webgpu))] mod now_or_never; +mod wgpu_core_error; +mod wgpu_error_scope; pub use error_tracker::ErrorTracker; pub use wgpu_error_scope::WgpuErrorScope; +use crate::config::WgpuBackendType; + // ------- fn handle_async_error( + backend_type: WgpuBackendType, resolve_callback: impl FnOnce(Option) + 'static, error_future: impl std::future::Future> + Send + 'static, ) { - cfg_if::cfg_if! { - if #[cfg(webgpu)] { - wasm_bindgen_futures::spawn_local(async move { - resolve_callback(error_future.await); - }); - } else { + match backend_type { + #[cfg(web)] + WgpuBackendType::WebGpu => wasm_bindgen_futures::spawn_local(async move { + resolve_callback(error_future.await); + }), + WgpuBackendType::WgpuCore => { if let Some(error) = now_or_never::now_or_never(error_future) { resolve_callback(error); } else { diff --git a/crates/re_renderer/src/renderer/debug_overlay.rs b/crates/re_renderer/src/renderer/debug_overlay.rs index 6b73b987df4f..12b6e844488e 100644 --- a/crates/re_renderer/src/renderer/debug_overlay.rs +++ b/crates/re_renderer/src/renderer/debug_overlay.rs @@ -81,7 +81,7 @@ impl DebugOverlayDrawData { let mode = match debug_texture .texture .format() - .sample_type(Some(wgpu::TextureAspect::All)) + .sample_type(Some(wgpu::TextureAspect::All), None) { Some(wgpu::TextureSampleType::Depth | wgpu::TextureSampleType::Float { .. }) => { gpu_data::DebugOverlayMode::ShowFloatTexture diff --git a/crates/re_renderer/src/renderer/depth_cloud.rs b/crates/re_renderer/src/renderer/depth_cloud.rs index 4d24320bed0b..7aa4f604a6b5 100644 --- a/crates/re_renderer/src/renderer/depth_cloud.rs +++ b/crates/re_renderer/src/renderer/depth_cloud.rs @@ -100,7 +100,7 @@ mod gpu_data { } = depth_cloud; let texture_format = depth_texture.texture.format(); - let sample_type = match texture_format.sample_type(None) { + let sample_type = match texture_format.sample_type(None, None) { Some(wgpu::TextureSampleType::Float { .. }) => SAMPLE_TYPE_FLOAT, Some(wgpu::TextureSampleType::Sint) => SAMPLE_TYPE_SINT, Some(wgpu::TextureSampleType::Uint) => SAMPLE_TYPE_UINT, @@ -278,7 +278,7 @@ impl DepthCloudDrawData { let mut texture_uint = ctx.texture_manager_2d.zeroed_texture_uint().handle; let texture_format = depth_cloud.depth_texture.format(); - match texture_format.sample_type(None) { + match texture_format.sample_type(None, None) { Some(wgpu::TextureSampleType::Float { .. }) => { texture_float = depth_cloud.depth_texture.handle; } diff --git a/crates/re_renderer/src/renderer/rectangles.rs b/crates/re_renderer/src/renderer/rectangles.rs index 72b75854a80d..95a96187d572 100644 --- a/crates/re_renderer/src/renderer/rectangles.rs +++ b/crates/re_renderer/src/renderer/rectangles.rs @@ -308,7 +308,7 @@ mod gpu_data { outline_mask, } = options; - let sample_type = match texture_format.sample_type(None) { + let sample_type = match texture_format.sample_type(None, None) { Some(wgpu::TextureSampleType::Float { .. }) => SAMPLE_TYPE_FLOAT, Some(wgpu::TextureSampleType::Sint) => SAMPLE_TYPE_SINT, Some(wgpu::TextureSampleType::Uint) => { @@ -432,7 +432,7 @@ impl RectangleDrawData { let mut texture_sint = ctx.texture_manager_2d.zeroed_texture_sint().handle; let mut texture_uint = ctx.texture_manager_2d.zeroed_texture_uint().handle; - match texture_format.sample_type(None) { + match texture_format.sample_type(None, None) { Some(wgpu::TextureSampleType::Float { .. }) => { texture_float = texture.handle; } diff --git a/crates/re_renderer/src/resource_managers/texture_manager.rs b/crates/re_renderer/src/resource_managers/texture_manager.rs index e92d7a8ce996..ffe1c1939e44 100644 --- a/crates/re_renderer/src/resource_managers/texture_manager.rs +++ b/crates/re_renderer/src/resource_managers/texture_manager.rs @@ -383,7 +383,7 @@ impl TextureManager2D { if !format.is_compressed() { if let Some(bytes_per_texel) = creation_desc .format - .block_size(Some(wgpu::TextureAspect::All)) + .block_copy_size(Some(wgpu::TextureAspect::All)) { let expected_bytes = width as usize * height as usize * bytes_per_texel as usize; @@ -421,7 +421,7 @@ impl TextureManager2D { let width_blocks = width / format.block_dimensions().0; let block_size = creation_desc .format - .block_size(Some(wgpu::TextureAspect::All)) + .block_copy_size(Some(wgpu::TextureAspect::All)) .ok_or_else(|| TextureCreationError::UnsupportedFormatForTransfer { label: label.clone(), format, diff --git a/crates/re_renderer/src/texture_info.rs b/crates/re_renderer/src/texture_info.rs index cfd241462344..d22e50d75fe4 100644 --- a/crates/re_renderer/src/texture_info.rs +++ b/crates/re_renderer/src/texture_info.rs @@ -29,7 +29,7 @@ impl Texture2DBufferInfo { let height_blocks = extent.y / block_dimensions.1; let block_size = format - .block_size(Some(wgpu::TextureAspect::All)) + .block_copy_size(Some(wgpu::TextureAspect::All)) .unwrap_or(0); // This happens if we can't have a single buffer. let bytes_per_row_unpadded = width_blocks * block_size; let bytes_per_row_padded = diff --git a/crates/re_renderer/src/wgpu_resources/texture_pool.rs b/crates/re_renderer/src/wgpu_resources/texture_pool.rs index b6a86936c513..a96bdedb80cf 100644 --- a/crates/re_renderer/src/wgpu_resources/texture_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/texture_pool.rs @@ -71,14 +71,14 @@ impl DynamicResourcesDesc for TextureDesc { let mut size_in_bytes = 0; let block_size = self .format - .block_size(Some(wgpu::TextureAspect::All)) + .block_copy_size(Some(wgpu::TextureAspect::All)) .unwrap_or_else(|| { self.format - .block_size(Some(wgpu::TextureAspect::DepthOnly)) + .block_copy_size(Some(wgpu::TextureAspect::DepthOnly)) .unwrap_or(0) + self .format - .block_size(Some(wgpu::TextureAspect::StencilOnly)) + .block_copy_size(Some(wgpu::TextureAspect::StencilOnly)) .unwrap_or(0) }); let block_dimension = self.format.block_dimensions(); diff --git a/crates/re_renderer_examples/Cargo.toml b/crates/re_renderer_examples/Cargo.toml index e136a9a87815..c6a1241f9b07 100644 --- a/crates/re_renderer_examples/Cargo.toml +++ b/crates/re_renderer_examples/Cargo.toml @@ -8,8 +8,6 @@ license.workspace = true publish = false [features] -webgl = ["re_renderer/webgl"] - [[bin]] name = "2d" @@ -37,7 +35,7 @@ path = "picking.rs" [dependencies] -re_log.workspace = true +re_log = { workspace = true, features = ["setup"] } re_renderer = { workspace = true, features = ["import-obj", "import-gltf"] } ahash.workspace = true @@ -52,7 +50,7 @@ pollster.workspace = true rand = { workspace = true, features = ["std", "std_rng"] } web-time.workspace = true wgpu.workspace = true -winit = { workspace = true, features = ["rwh_05"] } +winit = { workspace = true, features = ["rwh_06"] } zip = { workspace = true, default-features = false, features = ["deflate"] } [target.'cfg(target_arch = "wasm32")'.dependencies] diff --git a/crates/re_renderer_examples/README.md b/crates/re_renderer_examples/README.md index 7bb8c0a0b515..656c370382d2 100644 --- a/crates/re_renderer_examples/README.md +++ b/crates/re_renderer_examples/README.md @@ -10,11 +10,10 @@ E.g. to run the `multiview`` example run ``` cargo run -p re_renderer_examples --bin multiview ``` -To run the same example on the web using WebGPU: + + +To run the same example on the web: ``` cargo run-wasm -p re_renderer_examples --bin multiview ``` -To run the same example on the web using WebGL: -``` -cargo run-wasm -p re_renderer_examples --bin multiview --features "webgl" -``` +Note that this will try to use WebGPU and fall back to WebGL if WebGPU is not supported by your browser. diff --git a/crates/re_renderer_examples/framework.rs b/crates/re_renderer_examples/framework.rs index 783db5a243b0..d7f200073c3d 100644 --- a/crates/re_renderer_examples/framework.rs +++ b/crates/re_renderer_examples/framework.rs @@ -83,10 +83,9 @@ impl Time { } struct Application { - event_loop: EventLoop<()>, - window: Window, - surface: wgpu::Surface, - surface_config: wgpu::SurfaceConfiguration, + window: Arc, + adapter: wgpu::Adapter, + surface: wgpu::Surface<'static>, time: Time, example: E, @@ -108,16 +107,15 @@ fn preferred_framebuffer_format(formats: &[wgpu::TextureFormat]) -> wgpu::Textur } impl Application { - async fn new(event_loop: EventLoop<()>, window: Window) -> anyhow::Result { - let size = window.inner_size(); + async fn new(window: Window) -> anyhow::Result { + let window = Arc::new(window); let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { backends: supported_backends(), flags: wgpu::InstanceFlags::default(), dx12_shader_compiler: wgpu::Dx12Compiler::Fxc, gles_minor_version: wgpu::Gles3MinorVersion::Automatic, }); - #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] - let surface = unsafe { instance.create_surface(&window) }.unwrap(); + let surface = instance.create_surface(window.clone()).unwrap(); let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, @@ -133,8 +131,8 @@ impl Application { .request_device( &wgpu::DeviceDescriptor { label: None, - features: wgpu::Features::empty(), - limits: wgpu::Limits::downlevel_webgl2_defaults() + required_features: wgpu::Features::empty(), + required_limits: wgpu::Limits::downlevel_webgl2_defaults() .using_resolution(adapter.limits()), }, None, @@ -144,28 +142,15 @@ impl Application { let device = Arc::new(device); let queue = Arc::new(queue); - let swapchain_format = + let output_format_color = preferred_framebuffer_format(&surface.get_capabilities(&adapter).formats); - let surface_config = wgpu::SurfaceConfiguration { - usage: wgpu::TextureUsages::RENDER_ATTACHMENT, - format: swapchain_format, - width: size.width, - height: size.height, - // Not the best setting in general, but nice for quick & easy performance checking. - // TODO(andreas): It seems at least on Metal M1 this still does not discard command buffers that come in too fast (even when using `Immediate` explicitly). - // Quick look into wgpu looks like it does it correctly there. OS limitation? iOS has this limitation, so wouldn't be surprising! - present_mode: wgpu::PresentMode::AutoNoVsync, - alpha_mode: wgpu::CompositeAlphaMode::Auto, - view_formats: [swapchain_format].to_vec(), - }; - surface.configure(&device, &surface_config); let re_ctx = RenderContext::new( &adapter, device, queue, RenderContextConfig { - output_format_color: swapchain_format, + output_format_color, device_caps, }, ); @@ -173,10 +158,9 @@ impl Application { let example = E::new(&re_ctx); Ok(Self { - event_loop, window, + adapter, surface, - surface_config, re_ctx, time: Time { start_time: Instant::now(), @@ -188,8 +172,29 @@ impl Application { }) } - fn run(mut self) { - self.event_loop + fn configure_surface(&mut self, size: winit::dpi::PhysicalSize) { + if size.width == 0 || size.height == 0 { + return; + } + + let surface_config = wgpu::SurfaceConfiguration { + // Not the best setting in general, but nice for quick & easy performance checking. + // TODO(andreas): It seems at least on Metal M1 this still does not discard command buffers that come in too fast (even when using `Immediate` explicitly). + // Quick look into wgpu looks like it does it correctly there. OS limitation? iOS has this limitation, so wouldn't be surprising! + present_mode: wgpu::PresentMode::AutoNoVsync, + format: self.re_ctx.config.output_format_color, + view_formats: vec![self.re_ctx.config.output_format_color], + ..self + .surface + .get_default_config(&self.adapter, size.width, size.height) + .expect("The surface isn't supported by this adapter") + }; + self.surface.configure(&self.re_ctx.device, &surface_config); + self.window.request_redraw(); + } + + fn run(mut self, event_loop: EventLoop<()>) { + event_loop .run(move |event, event_loop_window_target| { // Keep our example busy. // Not how one should generally do it, but great for animated content and @@ -197,15 +202,15 @@ impl Application { event_loop_window_target.set_control_flow(ControlFlow::Poll); match event { + Event::NewEvents(winit::event::StartCause::Init) => { + self.configure_surface(self.window.inner_size()); + } + Event::WindowEvent { event: WindowEvent::Resized(size), .. } => { - self.surface_config.width = size.width; - self.surface_config.height = size.height; - self.surface - .configure(&self.re_ctx.device, &self.surface_config); - self.window.request_redraw(); + self.configure_surface(size); } Event::WindowEvent { @@ -236,8 +241,7 @@ impl Application { // a while, because the pipeline is poisoned. // Recreate a sane surface to restart the cycle and see if the // user has fixed the issue. - self.surface - .configure(&self.re_ctx.device, &self.surface_config); + self.configure_surface(self.window.inner_size()); return; } Err(err) => { @@ -257,7 +261,7 @@ impl Application { let draw_results = self.example.draw( &self.re_ctx, - [self.surface_config.width, self.surface_config.height], + [frame.texture.width(), frame.texture.height()], &self.time, self.window.scale_factor() as f32, ); @@ -365,8 +369,8 @@ pub fn load_rerun_mesh(re_ctx: &RenderContext) -> Vec(event_loop: EventLoop<()>, window: Window) { - let app = Application::::new(event_loop, window).await.unwrap(); - app.run(); + let app = Application::::new(window).await.unwrap(); + app.run(event_loop); } pub fn start() { @@ -394,14 +398,12 @@ pub fn start() { re_log::setup_web_logging(); use winit::platform::web::WindowExtWebSys; - // On wasm, append the canvas to the document body + let canvas = window.canvas().expect("Couldn't get canvas"); + canvas.style().set_css_text("height: 100%; width: 100%;"); web_sys::window() .and_then(|win| win.document()) .and_then(|doc| doc.body()) - .and_then(|body| { - body.append_child(&web_sys::Element::from(window.canvas().unwrap())) - .ok() - }) + .and_then(|body| body.append_child(&canvas).ok()) .expect("couldn't append canvas to document body"); wasm_bindgen_futures::spawn_local(run::(event_loop, window)); } diff --git a/crates/re_space_view_tensor/src/tensor_dimension_mapper.rs b/crates/re_space_view_tensor/src/tensor_dimension_mapper.rs index 40eeebf9d1fd..2790d1bca7a1 100644 --- a/crates/re_space_view_tensor/src/tensor_dimension_mapper.rs +++ b/crates/re_space_view_tensor/src/tensor_dimension_mapper.rs @@ -144,7 +144,7 @@ fn drop_target_ui( egui::Rect::from_min_max(outer_rect_bounds.min, content_ui.min_rect().max + margin); let (rect, response) = ui.allocate_at_least(outer_rect.size(), egui::Sense::hover()); - let style = if is_being_dragged && can_accept_dragged && response.hovered() { + let style = if is_being_dragged && can_accept_dragged && response.contains_pointer() { ui.visuals().widgets.active } else { ui.visuals().widgets.inactive diff --git a/crates/re_ui/src/list_item.rs b/crates/re_ui/src/list_item.rs index 195d85b0baa5..5ce6d546de25 100644 --- a/crates/re_ui/src/list_item.rs +++ b/crates/re_ui/src/list_item.rs @@ -372,11 +372,13 @@ impl<'a> ListItem<'a> { // update the response accordingly. let full_span_response = ui.interact(bg_rect, response.id, egui::Sense::click()); response.clicked = full_span_response.clicked; + response.contains_pointer = full_span_response.contains_pointer; response.hovered = full_span_response.hovered; // override_hover should not affect the returned response let mut style_response = response.clone(); if self.force_hovered { + style_response.contains_pointer = true; style_response.hovered = true; } @@ -427,15 +429,7 @@ impl<'a> ListItem<'a> { } // Handle buttons - let button_response = if self.active - && ui - .interact( - rect, - id.unwrap_or(ui.id()).with("buttons"), - egui::Sense::hover(), - ) - .hovered() - { + let button_response = if self.active && ui.rect_contains_pointer(rect) { if let Some(buttons) = self.buttons_fn { let mut ui = ui.child_ui(rect, egui::Layout::right_to_left(egui::Align::Center)); diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 37b44b8efaca..5cb35f9443aa 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -28,14 +28,11 @@ crate-type = ["cdylib", "rlib"] [features] -default = ["analytics", "webgl"] +default = ["analytics"] ## Enable telemetry using our analytics SDK. analytics = ["dep:re_analytics"] -## Render using webgl instead of webgpu on wasm builds. -webgl = ["re_renderer/webgl"] - [dependencies] # Internal: re_build_info.workspace = true diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index ffe442fd52d1..446fe48f973b 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -753,7 +753,14 @@ impl App { crate::ui::mobile_warning_ui(&self.re_ui, ui); - crate::ui::top_panel(self, app_blueprint, store_context, gpu_resource_stats, ui); + crate::ui::top_panel( + frame, + self, + app_blueprint, + store_context, + gpu_resource_stats, + ui, + ); self.memory_panel_ui(ui, gpu_resource_stats, store_stats, caches_stats); diff --git a/crates/re_viewer/src/ui/rerun_menu.rs b/crates/re_viewer/src/ui/rerun_menu.rs index f6a4fdcba111..20da00c57838 100644 --- a/crates/re_viewer/src/ui/rerun_menu.rs +++ b/crates/re_viewer/src/ui/rerun_menu.rs @@ -13,6 +13,7 @@ const SPACING: f32 = 12.0; impl App { pub fn rerun_menu_button_ui( &mut self, + frame: &eframe::Frame, _store_context: Option<&StoreContext<'_>>, ui: &mut egui::Ui, ) { @@ -23,10 +24,11 @@ impl App { let image = re_ui::icons::RERUN_MENU .as_image() .max_height(desired_icon_height); + ui.menu_image_button(image, |ui| { ui.set_min_width(220.0); - ui.menu_button("About", |ui| self.about_rerun_ui(ui)); + ui.menu_button("About", |ui| self.about_rerun_ui(frame, ui)); ui.add_space(SPACING); @@ -112,7 +114,7 @@ impl App { }); } - fn about_rerun_ui(&self, ui: &mut egui::Ui) { + fn about_rerun_ui(&self, frame: &eframe::Frame, ui: &mut egui::Ui) { let re_build_info::BuildInfo { crate_name, version, @@ -151,6 +153,10 @@ impl App { } ui.label(label); + + if let Some(render_state) = frame.wgpu_render_state() { + render_state_ui(ui, render_state); + } } // TODO(emilk): support saving data on web @@ -209,6 +215,90 @@ impl App { } } +fn render_state_ui(ui: &mut egui::Ui, render_state: &egui_wgpu::RenderState) { + let wgpu_adapter_details_ui = |ui: &mut egui::Ui, adapter: &eframe::wgpu::Adapter| { + let info = &adapter.get_info(); + + let wgpu::AdapterInfo { + name, + vendor, + device, + device_type, + driver, + driver_info, + backend, + } = &info; + + // Example values: + // > name: "llvmpipe (LLVM 16.0.6, 256 bits)", device_type: Cpu, backend: Vulkan, driver: "llvmpipe", driver_info: "Mesa 23.1.6-arch1.4 (LLVM 16.0.6)" + // > name: "Apple M1 Pro", device_type: IntegratedGpu, backend: Metal, driver: "", driver_info: "" + // > name: "ANGLE (Apple, Apple M1 Pro, OpenGL 4.1)", device_type: IntegratedGpu, backend: Gl, driver: "", driver_info: "" + + egui::Grid::new("adapter_info").show(ui, |ui| { + ui.label("Backend"); + ui.label(format!("{backend:?}")); + ui.end_row(); + + ui.label("Device Type"); + ui.label(format!("{device_type:?}")); + ui.end_row(); + + if !name.is_empty() { + ui.label("Name"); + ui.label(format!("{name:?}")); + ui.end_row(); + } + if !driver.is_empty() { + ui.label("Driver"); + ui.label(format!("{driver:?}")); + ui.end_row(); + } + if !driver_info.is_empty() { + ui.label("Driver info"); + ui.label(format!("{driver_info:?}")); + ui.end_row(); + } + if *vendor != 0 { + // TODO(emilk): decode using https://github.com/gfx-rs/wgpu/blob/767ac03245ee937d3dc552edc13fe7ab0a860eec/wgpu-hal/src/auxil/mod.rs#L7 + ui.label("Vendor"); + ui.label(format!("0x{vendor:04X}")); + ui.end_row(); + } + if *device != 0 { + ui.label("Device"); + ui.label(format!("0x{device:02X}")); + ui.end_row(); + } + }); + }; + + let wgpu_adapter_ui = |ui: &mut egui::Ui, adapter: &eframe::wgpu::Adapter| { + let info = &adapter.get_info(); + ui.label(format!("{:?}", info.backend)).on_hover_ui(|ui| { + wgpu_adapter_details_ui(ui, adapter); + }); + }; + + egui::Grid::new("wgpu_info").num_columns(2).show(ui, |ui| { + ui.label("Rendering backend:"); + wgpu_adapter_ui(ui, &render_state.adapter); + ui.end_row(); + + #[cfg(not(target_arch = "wasm32"))] + if 1 < render_state.available_adapters.len() { + ui.label("Other rendering backends:"); + ui.vertical(|ui| { + for adapter in &*render_state.available_adapters { + if adapter.get_info() != render_state.adapter.get_info() { + wgpu_adapter_ui(ui, adapter); + } + } + }); + ui.end_row(); + } + }); +} + fn options_menu_ui( command_sender: &re_viewer_context::CommandSender, re_ui: &ReUi, diff --git a/crates/re_viewer/src/ui/top_panel.rs b/crates/re_viewer/src/ui/top_panel.rs index 8bcbb5fde8a0..64f3b445b52c 100644 --- a/crates/re_viewer/src/ui/top_panel.rs +++ b/crates/re_viewer/src/ui/top_panel.rs @@ -9,6 +9,7 @@ use re_viewer_context::StoreContext; use crate::{app_blueprint::AppBlueprint, App}; pub fn top_panel( + frame: &eframe::Frame, app: &mut App, app_blueprint: &AppBlueprint<'_>, store_context: Option<&StoreContext<'_>>, @@ -28,7 +29,14 @@ pub fn top_panel( ui.set_height(top_bar_style.height); ui.add_space(top_bar_style.indent); - top_bar_ui(app, app_blueprint, store_context, ui, gpu_resource_stats); + top_bar_ui( + frame, + app, + app_blueprint, + store_context, + ui, + gpu_resource_stats, + ); }) .response; @@ -48,13 +56,14 @@ pub fn top_panel( } fn top_bar_ui( + frame: &eframe::Frame, app: &mut App, app_blueprint: &AppBlueprint<'_>, store_context: Option<&StoreContext<'_>>, ui: &mut egui::Ui, gpu_resource_stats: &WgpuResourcePoolStatistics, ) { - app.rerun_menu_button_ui(store_context, ui); + app.rerun_menu_button_ui(frame, store_context, ui); ui.add_space(12.0); website_link_ui(ui); diff --git a/crates/re_viewer/src/web.rs b/crates/re_viewer/src/web.rs index 3ffbdd21383d..6b0769d618c0 100644 --- a/crates/re_viewer/src/web.rs +++ b/crates/re_viewer/src/web.rs @@ -216,11 +216,6 @@ pub fn set_email(email: String) { config.save().unwrap(); } -#[wasm_bindgen] -pub fn is_webgpu_build() -> bool { - !cfg!(feature = "webgl") -} - enum EndpointCategory { /// Could be a local path (`/foo.rrd`) or a remote url (`http://foo.com/bar.rrd`). HttpRrd(String), diff --git a/crates/re_web_viewer_server/build.rs b/crates/re_web_viewer_server/build.rs index 322645a294ff..23349226682f 100644 --- a/crates/re_web_viewer_server/build.rs +++ b/crates/re_web_viewer_server/build.rs @@ -1,8 +1,6 @@ #![allow(clippy::unwrap_used)] -use re_build_tools::{ - get_and_track_env_var, is_tracked_env_var_set, rebuild_if_crate_changed, rerun_if_changed, -}; +use re_build_tools::{get_and_track_env_var, rebuild_if_crate_changed, rerun_if_changed}; fn should_run() -> bool { #![allow(clippy::match_same_arms)] @@ -51,14 +49,9 @@ fn main() { } else { re_build_web_viewer::Profile::Debug }; - let backend = if is_tracked_env_var_set("RERUN_BUILD_WEBGPU") { - re_build_web_viewer::Backend::WebGPU - } else { - re_build_web_viewer::Backend::WebGL - }; let target = re_build_web_viewer::Target::Browser; let build_dir = re_build_web_viewer::default_build_dir(); - if let Err(err) = re_build_web_viewer::build(release, backend, target, &build_dir) { + if let Err(err) = re_build_web_viewer::build(release, target, &build_dir) { panic!("Failed to build web viewer: {}", re_error::format(err)); } } diff --git a/deny.toml b/deny.toml index 2bd1672ba3f9..1870db027366 100644 --- a/deny.toml +++ b/deny.toml @@ -46,27 +46,24 @@ deny = [ ] skip = [ - { name = "ahash" }, # Popular crate + fast release schedule = lots of crates still using old versions - { name = "async-fs" }, # Old version via accesskit - { name = "base64" }, # Too popular - { name = "cargo_metadata" }, # Older version used by ply-rs. It's small, and it's build-time only! - { name = "cfg_aliases" }, # Tiny macro-only crate. Winit and other use older version than us. - { name = "core-graphics" }, # old version via arboard - { name = "ehttp" }, # Will go away with next egui update - { name = "foreign-types-shared" }, # used for cocoa bindings. wgpu uses newer than eframe. - { name = "foreign-types" }, # used for cocoa bindings. wgpu uses newer than eframe. - { name = "hashbrown" }, # Old version used by polar-rs - { name = "libloading" }, # Old version used by ash (vulkan binding), newer version used by khronos-egl - { name = "memoffset" }, # Small crate - { name = "prettyplease" }, # Old version being used by prost - { name = "raw-window-handle" }, # Awaiting new wgpu release - { name = "spin" }, # Old version used by rusttls - { name = "windows" }, # Old version used by accesskit_windows, newer version used by wgpu + { name = "ahash" }, # Popular crate + fast release schedule = lots of crates still using old versions + { name = "async-fs" }, # Old version via accesskit + { name = "base64" }, # Too popular + { name = "cargo_metadata" }, # Older version used by ply-rs. It's small, and it's build-time only! + { name = "cfg_aliases" }, # Tiny macro-only crate. Winit and other use older version than us. + { name = "hashbrown" }, # Old version used by polar-rs + { name = "libloading" }, # Old version used by ash (vulkan binding), newer version used by khronos-egl + { name = "memoffset" }, # Small crate + { name = "prettyplease" }, # Old version being used by prost + { name = "raw-window-handle" }, # Pretty small crate; some crates still on old version + { name = "spin" }, # Old version used by rusttls + { name = "windows" }, # Old version used by accesskit_windows, newer version used by wgpu ] skip-tree = [ { name = "async-io" }, # Old version via rfd { name = "cargo-run-wasm" }, # Dev-tool { name = "comfy-table" }, # arrow vs. polars use different major versions (polars' one is dev-dep only) + { name = "core-graphics" }, # old version via arboard { name = "criterion" }, # dev-dependency { name = "objc2" }, # old version via accesskit { name = "prost-build" }, # only used in objectron example diff --git a/examples/rust/extend_viewer_ui/Cargo.toml b/examples/rust/extend_viewer_ui/Cargo.toml index fc95441194d1..fc56fc1bc594 100644 --- a/examples/rust/extend_viewer_ui/Cargo.toml +++ b/examples/rust/extend_viewer_ui/Cargo.toml @@ -14,9 +14,7 @@ analytics = ["re_crash_handler/analytics", "re_viewer/analytics"] [dependencies] re_crash_handler = { path = "../../../crates/re_crash_handler" } -re_viewer = { path = "../../../crates/re_viewer", default-features = false, features = [ - "webgl", -] } +re_viewer = { path = "../../../crates/re_viewer", default-features = false } # We need re_sdk_comms to receive log events from and SDK: re_sdk_comms = { path = "../../../crates/re_sdk_comms", features = ["server"] } diff --git a/run_wasm/src/main.rs b/run_wasm/src/main.rs index b7c6bc2e49d0..7a57567ad4c8 100644 --- a/run_wasm/src/main.rs +++ b/run_wasm/src/main.rs @@ -5,7 +5,6 @@ use std::time::Duration; fn main() { - // TODO(cmc): Why is this not taking the full screen? const CSS: &str = r#" html { /* Remove touch delay: */ @@ -36,31 +35,6 @@ fn main() { width: 100%; } - /* Position canvas in center-top: */ - canvas { - margin-right: auto; - margin-left: auto; - display: block; - position: absolute; - top: 0%; - left: 50%; - transform: translate(-50%, 0%); - } - - .centered { - margin-right: auto; - margin-left: auto; - display: block; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - color: #f0f0f0; - font-size: 24px; - font-family: Ubuntu-Light, Helvetica, sans-serif; - text-align: center; - } - /* ---------------------------------------------- */ /* Loading animation from https://loading.io/css/ */ .lds-dual-ring { diff --git a/scripts/lint.py b/scripts/lint.py index ce46bbbeb954..b9e11e88bffc 100755 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -863,6 +863,7 @@ def main() -> None: "./rerun_cpp/docs/html", "./rerun_cpp/src/rerun/c/arrow_c_data_interface.h", # Not our code "./rerun_cpp/src/rerun/third_party/cxxopts.hpp", # vendored + "./rerun_py/site/", # is in `.gitignore` which this script doesn't fully respect "./scripts/lint.py", # we contain all the patterns we are linting against "./scripts/zombie_todos.py", "./web_viewer/re_viewer.js", # auto-generated by wasm_bindgen diff --git a/web_viewer/index.html b/web_viewer/index.html index 0bd637cad365..d49217b1279d 100644 --- a/web_viewer/index.html +++ b/web_viewer/index.html @@ -306,26 +306,6 @@ function on_wasm_loaded() { window.set_email = (value) => wasm_bindgen.set_email(value); - // WebGPU version is currently only supported on browsers with WebGPU support, there is no dynamic fallback to WebGL. - if ( - wasm_bindgen.is_webgpu_build() && - typeof navigator.gpu === "undefined" - ) { - console.debug( - "`navigator.gpu` is undefined. This indicates lack of WebGPU support.", - ); - show_center_html(` -

- Missing WebGPU support. -

-

- This version of Rerun requires WebGPU support which is not available in your browser. - Either try a different browser or use the WebGL version of Rerun. -

- `); - return; - } - console.debug("Wasm loaded. Starting app…"); let handle = new wasm_bindgen.WebHandle(); @@ -375,15 +355,6 @@ function on_wasm_error(error) { console.error("Failed to start: " + error); - let render_backend_name = "WebGPU/WebGL"; - try { - render_backend_name = wasm_bindgen.is_webgpu_build() - ? "WebGPU" - : "WebGL"; - } catch (e) { - // loading the wasm probably failed. - } - hide_canvas(); show_center_html(`

@@ -393,7 +364,7 @@ ${error}

- Make sure you use a modern browser with ${render_backend_name} and Wasm enabled. + Make sure you use a modern browser with either WebGL or WebGPU support enabled.

`); }