From 017b0ff3d9f60bafbba78cff7da2e7cfaa76ae6f Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Mon, 24 Apr 2023 17:07:29 +0200 Subject: [PATCH 01/10] always build with unstable web sys apis --- .cargo/config.toml | 7 +++++++ .github/workflows/rust.yml | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index b44a938e2904..a3e208841411 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -7,3 +7,10 @@ run-wasm = "run --release --package run_wasm --" # Some of our build.rs files only run if this is set, # so that we don't run them on cargo publish or on users machines. IS_IN_RERUN_WORKSPACE = "yes" + +# web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses, +# https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html +# as well as WebGPU apis. +# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html +[target.wasm32-unknown-unknown] +rustflags = ["--cfg=web_sys_unstable_apis"] diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f48703b53395..64b76c92b410 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,10 +23,7 @@ concurrency: cancel-in-progress: true env: - # web_sys_unstable_apis is required to enable the web_sys clipboard API which egui_web uses - # https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html - # https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html - RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings + RUSTFLAGS: ${{env.RUSTFLAGS}} --deny warnings # See https://github.com/ericseppanen/cargo-cranky/issues/8 RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs From fbdc3d0ebad4ba33df35404969fbb37451097dd8 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Mon, 24 Apr 2023 18:18:03 +0200 Subject: [PATCH 02/10] Make shader Tint friendly --- crates/re_renderer/shader/colormap.wgsl | 8 ++------ crates/re_renderer/shader/lines.wgsl | 2 +- crates/re_renderer/shader/screen_triangle_vertex.wgsl | 10 ++++++++-- crates/re_renderer/shader/types.wgsl | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/re_renderer/shader/colormap.wgsl b/crates/re_renderer/shader/colormap.wgsl index 59be61afdfe4..d31b36a3b60a 100644 --- a/crates/re_renderer/shader/colormap.wgsl +++ b/crates/re_renderer/shader/colormap.wgsl @@ -12,7 +12,8 @@ const COLORMAP_VIRIDIS: u32 = 6u; /// Returns a gamma-space sRGB in 0-1 range. /// /// The input will be saturated to [0, 1] range. -fn colormap_srgb(which: u32, t: f32) -> Vec3 { +fn colormap_srgb(which: u32, t_unsaturated: f32) -> Vec3 { + let t = saturate(t_unsaturated); if which == COLORMAP_GRAYSCALE { return linear_from_srgb(Vec3(t)); } else if which == COLORMAP_INFERNO { @@ -61,7 +62,6 @@ fn colormap_turbo_srgb(t: f32) -> Vec3 { let g2 = Vec2(4.27729857, 2.82956604); let b2 = Vec2(-89.90310912, 27.34824973); - let t = saturate(t); let v4 = vec4(1.0, t, t * t, t * t * t); let v2 = v4.zw * v4.z; @@ -97,7 +97,6 @@ fn colormap_viridis_srgb(t: f32) -> Vec3 { let c4 = Vec3(6.228269936347081, 14.17993336680509, 56.69055260068105); let c5 = Vec3(4.776384997670288, -13.74514537774601, -65.35303263337234); let c6 = Vec3(-5.435455855934631, 4.645852612178535, 26.3124352495832); - let t = saturate(t); return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); } @@ -112,7 +111,6 @@ fn colormap_plasma_srgb(t: f32) -> Vec3 { let c4 = Vec3(-11.10743619062271, -82.66631109428045, 60.13984767418263); let c5 = Vec3(10.02306557647065, 71.41361770095349, -54.07218655560067); let c6 = Vec3(-3.658713842777788, -22.93153465461149, 18.19190778539828); - let t = saturate(t); return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); } @@ -127,7 +125,6 @@ fn colormap_magma_srgb(t: f32) -> Vec3 { let c4 = Vec3(52.17613981234068, -27.94360607168351, 12.94416944238394); let c5 = Vec3(-50.76852536473588, 29.04658282127291, 4.23415299384598); let c6 = Vec3(18.65570506591883, -11.48977351997711, -5.601961508734096); - let t = saturate(t); return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); } @@ -142,6 +139,5 @@ fn colormap_inferno_srgb(t: f32) -> Vec3 { let c4 = Vec3(77.162935699427, -33.40235894210092, -81.80730925738993); let c5 = Vec3(-71.31942824499214, 32.62606426397723, 73.20951985803202); let c6 = Vec3(25.13112622477341, -12.24266895238567, -23.07032500287172); - let t = saturate(t); return c0 + t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * (c5 + t * c6))))); } diff --git a/crates/re_renderer/shader/lines.wgsl b/crates/re_renderer/shader/lines.wgsl index b52c844c1bcc..6a143a8233c8 100644 --- a/crates/re_renderer/shader/lines.wgsl +++ b/crates/re_renderer/shader/lines.wgsl @@ -191,7 +191,7 @@ fn vs_main(@builtin(vertex_index) vertex_idx: u32) -> VertexOut { quad_dir = pos_data_quad_after.pos - pos_data_quad_end.pos; // Go one pos data forward. } else if is_cap_triangle { // Discard vertex. - center_position = Vec3(0.0/0.0, 0.0/0.0, 0.0/0.0); + center_position = Vec3(f32max); } else { quad_dir = pos_data_quad_end.pos - pos_data_quad_begin.pos; } diff --git a/crates/re_renderer/shader/screen_triangle_vertex.wgsl b/crates/re_renderer/shader/screen_triangle_vertex.wgsl index 224da3317d4b..539419e67bcb 100644 --- a/crates/re_renderer/shader/screen_triangle_vertex.wgsl +++ b/crates/re_renderer/shader/screen_triangle_vertex.wgsl @@ -4,8 +4,14 @@ struct VertexOutput { // Mark output position as invariant so it's safe to use it with depth test Equal. // Without @invariant, different usages in different render pipelines might optimize differently, // causing slightly different results. - @invariant @builtin(position) position: Vec4, - @location(0) texcoord: Vec2, + // + // TODO(andreas): Chrome/Tint does not support `@invariant` + // https://bugs.chromium.org/p/chromium/issues/detail?id=1439273 + //@invariant + @builtin(position) + position: Vec4, + @location(0) + texcoord: Vec2, }; // Workaround for https://github.com/gfx-rs/naga/issues/2252 diff --git a/crates/re_renderer/shader/types.wgsl b/crates/re_renderer/shader/types.wgsl index 804ae78a0626..12d2bcfb6f97 100644 --- a/crates/re_renderer/shader/types.wgsl +++ b/crates/re_renderer/shader/types.wgsl @@ -22,7 +22,7 @@ const f32min_normal = 0x1p-126f; // Smallest positive normal float value. //const f16max = 0x1.ffcp+15h; // Largest positive float value. //const f16min_normal = 0x1p-14h; // Smallest positive normal float value. // https://www.w3.org/TR/WGSL/#integer-types -const i32min = -0x80000000i; +const i32min = -2147483648; // Tint can't handle this being represented as `-0x80000000i`, see https://bugs.chromium.org/p/chromium/issues/detail?id=1439274 const i32max = 0x7fffffffi; const u32min = 0u; const u32max = 0xffffffffu; From 57218f10fb7ffc83b9a0e605d1a819495bc38a45 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 10:05:32 +0200 Subject: [PATCH 03/10] expose webgl feature flag on re_renderer & re_viewer --- Cargo.toml | 4 ++-- crates/re_renderer/Cargo.toml | 16 +++++----------- crates/re_viewer/Cargo.toml | 4 +++- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fa16ca53e147..8a2c36ee21bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,8 +85,8 @@ thiserror = "1.0" time = { version = "0.3", features = ["wasm-bindgen"] } tinyvec = { version = "1.6", features = ["alloc", "rustc_1_55"] } tokio = "1.24" -wgpu = { version = "0.16", default-features = false } -wgpu-core = { version = "0.16", default-features = false } +wgpu = { version = "0.16" } +wgpu-core = { version = "0.16" } [profile.dev] diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index 30c83c411ef4..c5a2fb1df2b7 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -24,7 +24,7 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] [features] -default = ["arrow", "import-obj", "import-gltf"] +default = ["import-obj", "import-gltf"] ## Support for Arrow datatypes for end-to-end zero-copy. arrow = ["dep:arrow2"] @@ -38,6 +38,8 @@ import-gltf = ["dep:gltf"] ## Enable (de)serialization using serde. serde = ["dep:serde"] +## Render using webgl instead of webgpu on wasm builds. +webgl = ["wgpu/webgl"] [dependencies] re_error.workspace = true @@ -63,6 +65,7 @@ smallvec.workspace = true static_assertions = "1.1" thiserror.workspace = true type-map = "0.5" +wgpu.workspace = true # optional arrow2 = { workspace = true, optional = true } @@ -75,17 +78,8 @@ tobj = { version = "3.2", optional = true } crossbeam = "0.8" notify = "5.0" puffin.workspace = true -wgpu = { workspace = true, default-features = false, features = ["wgsl"] } wgpu-core.workspace = true -# wasm -[target.'cfg(target_arch = "wasm32")'.dependencies] -wgpu = { workspace = true, default-features = false, features = [ - "webgl", - "wgsl", -] } - - # For examples: [dev-dependencies] image = { workspace = true, default-features = false, features = ["png"] } @@ -109,7 +103,7 @@ console_error_panic_hook = "0.1.6" # required to make rand work on wasm, see https://github.com/rust-random/rand#wasm-support getrandom = { version = "0.2", features = ["js"] } wasm-bindgen-futures = "0.4.33" -web-sys = { version = "0.3.60", features = [ +web-sys = { version = "0.3.61", features = [ "Location", "Blob", "RequestInit", diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index da75d90e84e5..e6a6f00bce48 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -28,11 +28,13 @@ crate-type = ["cdylib", "rlib"] [features] -default = ["analytics"] +default = ["analytics", "webgl"] ## 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: From af55ac12af89ac74bb0322218c2d0222aa6441ae Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 10:41:52 +0200 Subject: [PATCH 04/10] fix bug link on negative hexadecimal --- crates/re_renderer/shader/types.wgsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/re_renderer/shader/types.wgsl b/crates/re_renderer/shader/types.wgsl index 12d2bcfb6f97..6355bcc668b5 100644 --- a/crates/re_renderer/shader/types.wgsl +++ b/crates/re_renderer/shader/types.wgsl @@ -22,7 +22,7 @@ const f32min_normal = 0x1p-126f; // Smallest positive normal float value. //const f16max = 0x1.ffcp+15h; // Largest positive float value. //const f16min_normal = 0x1p-14h; // Smallest positive normal float value. // https://www.w3.org/TR/WGSL/#integer-types -const i32min = -2147483648; // Tint can't handle this being represented as `-0x80000000i`, see https://bugs.chromium.org/p/chromium/issues/detail?id=1439274 +const i32min = -2147483648; // Naga has some issues with correct negative hexadecimal numbers https://github.com/gfx-rs/naga/issues/2314 const i32max = 0x7fffffffi; const u32min = 0u; const u32max = 0xffffffffu; From 27a387476acabd7618dec5e21a4947031f94316f Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 14:14:11 +0200 Subject: [PATCH 05/10] hardware tier is now created from wgpu adapter --- Cargo.lock | 19 ++++++++++--------- Cargo.toml | 14 +++++++------- crates/re_renderer/examples/framework.rs | 2 +- crates/re_renderer/src/config.rs | 23 ++++++++++++----------- crates/re_viewer/src/lib.rs | 14 +++++--------- crates/re_viewer/src/web.rs | 1 + 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6e4b02a3c72..078929b8d15a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1309,7 +1309,7 @@ checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" [[package]] name = "ecolor" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "bytemuck", "serde", @@ -1318,7 +1318,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.21.3" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "bytemuck", "cocoa", @@ -1349,7 +1349,7 @@ dependencies = [ [[package]] name = "egui" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "accesskit", "ahash 0.8.2", @@ -1363,12 +1363,13 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "bytemuck", "epaint", "log", "puffin", + "thiserror", "type-map", "wgpu", "winit", @@ -1377,7 +1378,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.21.1" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "arboard", "egui", @@ -1404,7 +1405,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "egui", "log", @@ -1414,7 +1415,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "bytemuck", "egui", @@ -1449,7 +1450,7 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "emath" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "bytemuck", "serde", @@ -1530,7 +1531,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=0e6d69d#0e6d69d4c460c288a257f47cd007c5131a1d61de" +source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" dependencies = [ "ab_glyph", "ahash 0.8.2", diff --git a/Cargo.toml b/Cargo.toml index 8a2c36ee21bd..e7e8769ff0ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,13 +113,13 @@ debug = true # ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk. # TODO(andreas/emilk): Update to a stable egui version -# wgpu 0.16 support. -ecolor = { git = "https://github.com/emilk/egui", rev = "0e6d69d" } -eframe = { git = "https://github.com/emilk/egui", rev = "0e6d69d" } -egui = { git = "https://github.com/emilk/egui", rev = "0e6d69d" } -egui-wgpu = { git = "https://github.com/emilk/egui", rev = "0e6d69d" } -egui_extras = { git = "https://github.com/emilk/egui", rev = "0e6d69d" } -emath = { git = "https://github.com/emilk/egui", rev = "0e6d69d" } +# wgpu 0.16 support, device configuration dependent on adapter +ecolor = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } +eframe = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } +egui = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } +egui-wgpu = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } +egui_extras = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } +emath = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } # TODO(andreas): Either work around this issue in wgpu-egui (never discard command buffers) or wait for wgpu patch release. # Fix for command buffer dropping crash https://github.com/gfx-rs/wgpu/pull/3726 diff --git a/crates/re_renderer/examples/framework.rs b/crates/re_renderer/examples/framework.rs index fef6e7544b5b..a1a1eb5b0572 100644 --- a/crates/re_renderer/examples/framework.rs +++ b/crates/re_renderer/examples/framework.rs @@ -125,7 +125,7 @@ impl Application { .await .context("failed to find an appropriate adapter")?; - let hardware_tier = HardwareTier::default(); + let hardware_tier = HardwareTier::from_adapter(&adapter); hardware_tier.check_downlevel_capabilities(&adapter.get_downlevel_capabilities())?; let (device, queue) = adapter .request_device( diff --git a/crates/re_renderer/src/config.rs b/crates/re_renderer/src/config.rs index 91e0315d401d..3ffa7aabdd06 100644 --- a/crates/re_renderer/src/config.rs +++ b/crates/re_renderer/src/config.rs @@ -34,18 +34,19 @@ impl HardwareTier { } } -impl Default for HardwareTier { - fn default() -> Self { - // Use "Basic" tier for actual web but also if someone forces the GL backend! - if supported_backends() == wgpu::Backends::GL { - HardwareTier::Gles - } else { - HardwareTier::FullWebGpuSupport +impl HardwareTier { + pub fn from_adapter(adapter: &wgpu::Adapter) -> Self { + match adapter.get_info().backend { + wgpu::Backend::Vulkan + | wgpu::Backend::Metal + | wgpu::Backend::Dx12 + | wgpu::Backend::BrowserWebGpu => HardwareTier::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 => HardwareTier::Gles, } } -} -impl HardwareTier { /// Wgpu limits required by the given hardware tier. pub fn limits(self) -> wgpu::Limits { wgpu::Limits { @@ -140,9 +141,9 @@ pub fn supported_backends() -> wgpu::Backends { wgpu::util::backend_bits_from_env() .unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL) } - // Web - we support only WebGL right now, WebGPU should work but hasn't been tested. + // Web - WebGL is used automatically when wgpu is compiled with `webgl` feature. #[cfg(target_arch = "wasm32")] { - wgpu::Backends::GL + wgpu::Backends::GL | wgpu::Backends::BROWSER_WEBGPU } } diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index 85a2939b3160..f68655df39f9 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -117,10 +117,6 @@ impl AppEnvironment { #[allow(dead_code)] const APPLICATION_NAME: &str = "Rerun Viewer"; -pub(crate) fn hardware_tier() -> re_renderer::config::HardwareTier { - re_renderer::config::HardwareTier::default() -} - pub(crate) fn wgpu_options() -> egui_wgpu::WgpuConfiguration { egui_wgpu::WgpuConfiguration { // When running wgpu on native debug builds, we want some extra control over how @@ -141,10 +137,8 @@ pub(crate) fn wgpu_options() -> egui_wgpu::WgpuConfiguration { egui_wgpu::SurfaceErrorAction::SkipFrame } }), - backends: re_renderer::config::supported_backends(), - device_descriptor: crate::hardware_tier().device_descriptor(), - // TODO(andreas): This should be the default for egui-wgpu. - power_preference: wgpu::util::power_preference_from_env().unwrap_or(wgpu::PowerPreference::HighPerformance), + supported_backends: re_renderer::config::supported_backends(), + device_descriptor: std::sync::Arc::new(|adapter| re_renderer::config::HardwareTier::from_adapter(adapter).device_descriptor()), ..Default::default() } } @@ -161,7 +155,9 @@ pub(crate) fn customize_eframe(cc: &eframe::CreationContext<'_>) -> re_ui::ReUi render_state.queue.clone(), RenderContextConfig { output_format_color: render_state.target_format, - hardware_tier: crate::hardware_tier(), + hardware_tier: re_renderer::config::HardwareTier::from_adapter( + &render_state.adapter, + ), }, )); } diff --git a/crates/re_viewer/src/web.rs b/crates/re_viewer/src/web.rs index 01e33d523548..66196359d057 100644 --- a/crates/re_viewer/src/web.rs +++ b/crates/re_viewer/src/web.rs @@ -26,6 +26,7 @@ pub async fn start( follow_system_theme: false, default_theme: eframe::Theme::Dark, wgpu_options: crate::wgpu_options(), + depth_buffer: 0, }; eframe::start_web( From b83a4811a70a8274686c1fd2ace19748cce82278 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 17:16:25 +0200 Subject: [PATCH 06/10] sort out build flags for webgpu & document building webviewer --- BUILD.md | 31 ++++++++++++++++++++++++++ Cargo.toml | 4 ++-- crates/re_build_web_viewer/src/lib.rs | 9 +++++++- crates/re_build_web_viewer/src/main.rs | 7 +++++- crates/re_renderer/Cargo.toml | 2 +- crates/re_viewer/Cargo.toml | 7 +++++- crates/re_web_viewer_server/build.rs | 20 ++++++++++++----- 7 files changed, 69 insertions(+), 11 deletions(-) diff --git a/BUILD.md b/BUILD.md index 011e4d29b023..84d9d0f58631 100644 --- a/BUILD.md +++ b/BUILD.md @@ -76,6 +76,37 @@ pip install ./rerun_py > Note: If you are unable to upgrade pip to version `>=21.3`, you need to pass `--use-feature=in-tree-build` to the `pip install` command. +## Building for the Web + +Python builds come with the web-viewer by default. If you however want to build a standalone rerun executable +that contains the web-viewer and a websocket server, you need to ensure the `web_viewer` feature flag is set: +``` +cargo build -p rerun --features web_viewer +``` + +Rerun uses a standalone tool to build the web-viewer without a server. You can invoke it directly as well: +``` +cargo run -p re_build_web_viewer -- --release +``` + + +### 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.toml b/Cargo.toml index e7e8769ff0ad..2473d09826fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ re_log_encoding = { path = "crates/re_log_encoding", version = "=0.6.0-alpha.0" re_log_types = { path = "crates/re_log_types", version = "=0.6.0-alpha.0" } re_memory = { path = "crates/re_memory", version = "=0.6.0-alpha.0" } re_query = { path = "crates/re_query", version = "=0.6.0-alpha.0" } -re_renderer = { path = "crates/re_renderer", version = "=0.6.0-alpha.0" } +re_renderer = { path = "crates/re_renderer", version = "=0.6.0-alpha.0", default-features = false } re_sdk = { path = "crates/re_sdk", version = "=0.6.0-alpha.0" } re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.6.0-alpha.0" } re_smart_channel = { path = "crates/re_smart_channel", version = "=0.6.0-alpha.0" } @@ -45,7 +45,7 @@ re_string_interner = { path = "crates/re_string_interner", version = "=0.6.0-alp re_tensor_ops = { path = "crates/re_tensor_ops", version = "=0.6.0-alpha.0" } re_tuid = { path = "crates/re_tuid", version = "=0.6.0-alpha.0" } re_ui = { path = "crates/re_ui", version = "=0.6.0-alpha.0" } -re_viewer = { path = "crates/re_viewer", version = "=0.6.0-alpha.0" } +re_viewer = { path = "crates/re_viewer", version = "=0.6.0-alpha.0", default-features = false } re_web_viewer_server = { path = "crates/re_web_viewer_server", version = "=0.6.0-alpha.0" } re_ws_comms = { path = "crates/re_ws_comms", version = "=0.6.0-alpha.0" } rerun = { path = "crates/rerun", version = "=0.6.0-alpha.0" } diff --git a/crates/re_build_web_viewer/src/lib.rs b/crates/re_build_web_viewer/src/lib.rs index 8ec1d53f0a88..c5f1c179f10a 100644 --- a/crates/re_build_web_viewer/src/lib.rs +++ b/crates/re_build_web_viewer/src/lib.rs @@ -12,7 +12,7 @@ fn target_directory() -> Utf8PathBuf { } /// Build `re_viewer` as Wasm, generate .js bindings for it, and place it all into the `./web_viewer` folder. -pub fn build(release: bool) { +pub fn build(release: bool, webgpu: bool) { eprintln!("Building web viewer wasm…"); eprintln!("We assume you've already run ./scripts/setup_web.sh"); @@ -63,7 +63,13 @@ pub fn build(release: bool) { "wasm32-unknown-unknown", "--target-dir", target_wasm_dir.as_str(), + "--no-default-features", ]); + if webgpu { + cmd.arg("--features=analytics"); + } else { + cmd.arg("--features=analytics,webgl"); + } if release { cmd.arg("--release"); } @@ -71,6 +77,7 @@ pub fn build(release: bool) { // This is required to enable the web_sys clipboard API which egui_web uses // https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Clipboard.html // https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html + // Furthermore, it's necessary for unstable WebGPU apis to work. cmd.env("RUSTFLAGS", "--cfg=web_sys_unstable_apis"); // When executing this script from a Rust build script, do _not_, under any circumstances, diff --git a/crates/re_build_web_viewer/src/main.rs b/crates/re_build_web_viewer/src/main.rs index 137cd401a742..1c3d2249d26f 100644 --- a/crates/re_build_web_viewer/src/main.rs +++ b/crates/re_build_web_viewer/src/main.rs @@ -2,6 +2,7 @@ use std::process::ExitCode; fn main() -> ExitCode { let mut release = None; + let mut webgpu = false; for arg in std::env::args().skip(1) { match arg.as_str() { @@ -17,6 +18,9 @@ fn main() -> ExitCode { assert!(release.is_none(), "Can't set both --release and --debug"); release = Some(true); } + "--webgpu" => { + webgpu = true; + } _ => { print_help(); return ExitCode::FAILURE; @@ -29,7 +33,7 @@ fn main() -> ExitCode { return ExitCode::FAILURE; }; - re_build_web_viewer::build(release); + re_build_web_viewer::build(release, webgpu); ExitCode::SUCCESS } @@ -41,6 +45,7 @@ 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. " ); } diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index c5a2fb1df2b7..6ca86c05b744 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -24,7 +24,7 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] [features] -default = ["import-obj", "import-gltf"] +default = ["webgl", "import-obj", "import-gltf"] ## Support for Arrow datatypes for end-to-end zero-copy. arrow = ["dep:arrow2"] diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index e6a6f00bce48..a0e65d963311 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -48,7 +48,12 @@ re_log_types = { workspace = true, features = ["ecolor", "glam", "image"] } re_log.workspace = true re_memory.workspace = true re_query.workspace = true -re_renderer = { workspace = true, features = ["arrow", "serde"] } +re_renderer = { workspace = true, default-features = false, features = [ + "arrow", + "import-gltf", + "import-obj", + "serde", +] } re_smart_channel.workspace = true re_tensor_ops.workspace = true re_ui.workspace = true diff --git a/crates/re_web_viewer_server/build.rs b/crates/re_web_viewer_server/build.rs index b072925e41e5..79b8fe048136 100644 --- a/crates/re_web_viewer_server/build.rs +++ b/crates/re_web_viewer_server/build.rs @@ -89,19 +89,29 @@ impl<'a> Packages<'a> { } } +fn get_and_track_env_var(env_var_name: &str) -> Result { + println!("cargo:rerun-if-env-changed={env_var_name}"); + std::env::var(env_var_name) +} + +fn is_tracked_env_var_set(env_var_name: &str) -> bool { + let var = get_and_track_env_var(env_var_name).map(|v| v.to_lowercase()); + var == Ok("1".to_owned()) || var == Ok("yes".to_owned()) || var == Ok("true".to_owned()) +} + fn main() { - if std::env::var("IS_IN_RERUN_WORKSPACE") != Ok("yes".to_owned()) { + if !is_tracked_env_var_set("IS_IN_RERUN_WORKSPACE") { // Only run if we are in the rerun workspace, not on users machines. return; } - if std::env::var("RERUN_IS_PUBLISHING") == Ok("yes".to_owned()) { + if is_tracked_env_var_set("RERUN_IS_PUBLISHING") { // We don't need to rebuild - we should have done so beforehand! // See `RELEASES.md` return; } // Rebuild the web-viewer Wasm, - // because the web_server library bundles it with `include_bytes!` + // because the web_server library bundles it with `include_bytes!`. let metadata = MetadataCommand::new() .features(CargoOpt::AllFeatures) @@ -118,12 +128,12 @@ fn main() { // or patched!). pkgs.track_implicit_dep("re_viewer"); - if std::env::var("CARGO_FEATURE___CI").is_ok() { + if get_and_track_env_var("CARGO_FEATURE___CI").is_ok() { // If the `__ci` feature is set we skip building the web viewer wasm, saving a lot of time. // This feature is set on CI (hence the name), but also with `--all-features`, which is set by rust analyzer, bacon, etc. eprintln!("__ci feature detected: Skipping building of web viewer wasm."); } else { let release = std::env::var("PROFILE").unwrap() == "release"; - re_build_web_viewer::build(release); + re_build_web_viewer::build(release, is_tracked_env_var_set("RERUN_BUILD_WEBGPU")); } } From 114d7fef3d6ab14bf36bcc334d439e3b3853c60d Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 17:40:44 +0200 Subject: [PATCH 07/10] introduce shader text replacement workarounds to workaround current chrome issue --- crates/re_renderer/Cargo.toml | 2 +- crates/re_renderer/examples/framework.rs | 1 + .../shader/screen_triangle_vertex.wgsl | 6 +---- crates/re_renderer/src/config.rs | 8 ++++++ crates/re_renderer/src/context.rs | 27 ++++++++++++++++++- .../src/wgpu_resources/shader_module_pool.rs | 23 +++++++++++++--- crates/re_viewer/src/lib.rs | 1 + 7 files changed, 57 insertions(+), 11 deletions(-) diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index 6ca86c05b744..c5a2fb1df2b7 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -24,7 +24,7 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] [features] -default = ["webgl", "import-obj", "import-gltf"] +default = ["import-obj", "import-gltf"] ## Support for Arrow datatypes for end-to-end zero-copy. arrow = ["dep:arrow2"] diff --git a/crates/re_renderer/examples/framework.rs b/crates/re_renderer/examples/framework.rs index a1a1eb5b0572..2575f9d82463 100644 --- a/crates/re_renderer/examples/framework.rs +++ b/crates/re_renderer/examples/framework.rs @@ -159,6 +159,7 @@ impl Application { surface.configure(&device, &surface_config); let mut re_ctx = RenderContext::new( + &adapter, device, queue, RenderContextConfig { diff --git a/crates/re_renderer/shader/screen_triangle_vertex.wgsl b/crates/re_renderer/shader/screen_triangle_vertex.wgsl index 539419e67bcb..e42fac7827a6 100644 --- a/crates/re_renderer/shader/screen_triangle_vertex.wgsl +++ b/crates/re_renderer/shader/screen_triangle_vertex.wgsl @@ -4,11 +4,7 @@ struct VertexOutput { // Mark output position as invariant so it's safe to use it with depth test Equal. // Without @invariant, different usages in different render pipelines might optimize differently, // causing slightly different results. - // - // TODO(andreas): Chrome/Tint does not support `@invariant` - // https://bugs.chromium.org/p/chromium/issues/detail?id=1439273 - //@invariant - @builtin(position) + @invariant @builtin(position) position: Vec4, @location(0) texcoord: Vec2, diff --git a/crates/re_renderer/src/config.rs b/crates/re_renderer/src/config.rs index 3ffa7aabdd06..f559e9e3a02a 100644 --- a/crates/re_renderer/src/config.rs +++ b/crates/re_renderer/src/config.rs @@ -2,6 +2,11 @@ /// /// To reduce complexity, we don't do fine-grained feature checks, /// but instead support set of features, each a superset of the next. +/// +/// Tiers are sorted from lowest to highest. Certain tiers may not be possible on a given machine/setup, +/// but choosing lower tiers is always possible. +/// Tiers may loosely relate to quality settings, but their primary function is an easier way to +/// do bundle feature *support* checks. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum HardwareTier { /// Limited feature support as provided by WebGL and native GLES2/OpenGL3(ish). @@ -35,6 +40,9 @@ impl HardwareTier { } impl HardwareTier { + /// Picks the highest possible tier for a given adapter. + /// + /// Note that it is always possible to pick a lower tier! pub fn from_adapter(adapter: &wgpu::Adapter) -> Self { match adapter.get_info().backend { wgpu::Backend::Vulkan diff --git a/crates/re_renderer/src/context.rs b/crates/re_renderer/src/context.rs index 701d1800d561..a2c8d032b819 100644 --- a/crates/re_renderer/src/context.rs +++ b/crates/re_renderer/src/context.rs @@ -106,6 +106,7 @@ impl RenderContext { const MAX_NUM_INFLIGHT_QUEUE_SUBMISSIONS: usize = 4; pub fn new( + adapter: &wgpu::Adapter, device: Arc, queue: Arc, config: RenderContextConfig, @@ -138,7 +139,16 @@ impl RenderContext { config.hardware_tier.features(), device.features(), ); - // Can't check downlevel feature flags since they sit on the adapter, not on the device. + assert!(adapter.get_downlevel_capabilities().flags.contains(config.hardware_tier.required_downlevel_capabilities().flags), + "The given device doesn't support the required downlevel capabilities for the given hardware tier {:?}. + Required: + {:?} + Actual: + {:?}", + config.hardware_tier, + config.hardware_tier.required_downlevel_capabilities(), + adapter.get_downlevel_capabilities(), + ); // In debug builds, make sure to catch all errors, never crash, and try to // always let the user find a way to return a poisoned pipeline back into a @@ -178,6 +188,21 @@ impl RenderContext { frame_index: 0, }; + // Register shader workarounds for the current device. + if adapter.get_info().backend == wgpu::Backend::BrowserWebGpu { + // Chrome/Tint does not support `@invariant` when targeting Metal. + // https://bugs.chromium.org/p/chromium/issues/detail?id=1439273 + // (bug is fixed as of writing, but hasn't hit any public released version yet) + // Ignoring it is fine in the cases we use it, it's mostly there to avoid a (correct!) warning in wgpu. + gpu_resources + .shader_modules + .shader_text_workaround_replacements + .push(( + "@invariant @builtin(position)".to_owned(), + "@builtin(position)".to_owned(), + )); + } + RenderContext { device, queue, diff --git a/crates/re_renderer/src/wgpu_resources/shader_module_pool.rs b/crates/re_renderer/src/wgpu_resources/shader_module_pool.rs index 1fb291f47f05..9b42f87d1788 100644 --- a/crates/re_renderer/src/wgpu_resources/shader_module_pool.rs +++ b/crates/re_renderer/src/wgpu_resources/shader_module_pool.rs @@ -54,13 +54,18 @@ impl ShaderModuleDesc { &self, device: &wgpu::Device, resolver: &mut FileResolver, + shader_text_workaround_replacements: &[(String, String)], ) -> wgpu::ShaderModule { - let source_interpolated = resolver + let mut source_interpolated = resolver .populate(&self.source) .context("couldn't resolve shader module's contents") .map_err(|err| re_log::error!(err=%re_error::format(err))) .unwrap_or_default(); + for (from, to) in shader_text_workaround_replacements { + source_interpolated.contents = source_interpolated.contents.replace(from, to); + } + // All wgpu errors come asynchronously: this call will succeed whether the given // source is valid or not. // Only when actually submitting passes that make use of this shader will we know if @@ -78,6 +83,11 @@ impl ShaderModuleDesc { #[derive(Default)] pub struct GpuShaderModulePool { pool: StaticResourcePool, + + /// Workarounds via text replacement in shader source code. + /// + /// TODO(andreas): These should be solved with a pre-processor. + pub shader_text_workaround_replacements: Vec<(String, String)>, } impl GpuShaderModulePool { @@ -87,8 +97,9 @@ impl GpuShaderModulePool { resolver: &mut FileResolver, desc: &ShaderModuleDesc, ) -> GpuShaderModuleHandle { - self.pool - .get_or_create(desc, |desc| desc.create_shader_module(device, resolver)) + self.pool.get_or_create(desc, |desc| { + desc.create_shader_module(device, resolver, &self.shader_text_workaround_replacements) + }) } pub fn begin_frame( @@ -115,7 +126,11 @@ impl GpuShaderModulePool { } paths.iter().any(|p| updated_paths.contains(p)).then(|| { - let shader_module = desc.create_shader_module(device, resolver); + let shader_module = desc.create_shader_module( + device, + resolver, + &self.shader_text_workaround_replacements, + ); re_log::debug!(?desc.source, label = desc.label.get(), "recompiled shader module"); shader_module }) diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index f68655df39f9..3d762465ef03 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -151,6 +151,7 @@ pub(crate) fn customize_eframe(cc: &eframe::CreationContext<'_>) -> re_ui::ReUi let paint_callback_resources = &mut render_state.renderer.write().paint_callback_resources; paint_callback_resources.insert(RenderContext::new( + &render_state.adapter, render_state.device.clone(), render_state.queue.clone(), RenderContextConfig { From f7257a7007e1bc0366bea6267fca0e1fe50a7b3c Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 17:42:57 +0200 Subject: [PATCH 08/10] latest egui master --- Cargo.toml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2473d09826fa..1ec0785825de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ version = "0.6.0-alpha.0" # This is because we treat alpha-releases as incompatible, but semver doesn't. # In particular: if we compile rerun 0.3.0-alpha.0 we only want it to use # re_log_types 0.3.0-alpha.0, NOT 0.3.0-alpha.4 even though it is newer and semver-compatible. +re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.6.0-alpha.0" }\ re_analytics = { path = "crates/re_analytics", version = "=0.6.0-alpha.0" } re_arrow_store = { path = "crates/re_arrow_store", version = "=0.6.0-alpha.0" } re_build_build_info = { path = "crates/re_build_build_info", version = "=0.6.0-alpha.0" } @@ -39,7 +40,6 @@ re_memory = { path = "crates/re_memory", version = "=0.6.0-alpha.0" } re_query = { path = "crates/re_query", version = "=0.6.0-alpha.0" } re_renderer = { path = "crates/re_renderer", version = "=0.6.0-alpha.0", default-features = false } re_sdk = { path = "crates/re_sdk", version = "=0.6.0-alpha.0" } -re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.6.0-alpha.0" } re_smart_channel = { path = "crates/re_smart_channel", version = "=0.6.0-alpha.0" } re_string_interner = { path = "crates/re_string_interner", version = "=0.6.0-alpha.0" } re_tensor_ops = { path = "crates/re_tensor_ops", version = "=0.6.0-alpha.0" } @@ -114,12 +114,12 @@ debug = true # TODO(andreas/emilk): Update to a stable egui version # wgpu 0.16 support, device configuration dependent on adapter -ecolor = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } -eframe = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } -egui = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } -egui-wgpu = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } -egui_extras = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } -emath = { git = "https://github.com/emilk/egui", rev = "f8ef210ab9989980651a160733641ffa1fe66bf4" } +ecolor = { git = "https://github.com/emilk/egui", rev = "f76eefb98d23cbf71989255aafe75a07d343f6ed" } +eframe = { git = "https://github.com/emilk/egui", rev = "f76eefb98d23cbf71989255aafe75a07d343f6ed" } +egui = { git = "https://github.com/emilk/egui", rev = "f76eefb98d23cbf71989255aafe75a07d343f6ed" } +egui-wgpu = { git = "https://github.com/emilk/egui", rev = "f76eefb98d23cbf71989255aafe75a07d343f6ed" } +egui_extras = { git = "https://github.com/emilk/egui", rev = "f76eefb98d23cbf71989255aafe75a07d343f6ed" } +emath = { git = "https://github.com/emilk/egui", rev = "f76eefb98d23cbf71989255aafe75a07d343f6ed" } # TODO(andreas): Either work around this issue in wgpu-egui (never discard command buffers) or wait for wgpu patch release. # Fix for command buffer dropping crash https://github.com/gfx-rs/wgpu/pull/3726 From 9ca713f0c7d83a2b571a01dccc38714048e3e20a Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 25 Apr 2023 17:48:07 +0200 Subject: [PATCH 09/10] typo fix --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 078929b8d15a..f112633a3352 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1309,7 +1309,7 @@ checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" [[package]] name = "ecolor" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "bytemuck", "serde", @@ -1318,7 +1318,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.21.3" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "bytemuck", "cocoa", @@ -1349,7 +1349,7 @@ dependencies = [ [[package]] name = "egui" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "accesskit", "ahash 0.8.2", @@ -1363,7 +1363,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "bytemuck", "epaint", @@ -1378,7 +1378,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.21.1" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "arboard", "egui", @@ -1405,7 +1405,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "egui", "log", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "bytemuck", "egui", @@ -1450,7 +1450,7 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "emath" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "bytemuck", "serde", @@ -1531,7 +1531,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.21.0" -source = "git+https://github.com/emilk/egui?rev=f8ef210ab9989980651a160733641ffa1fe66bf4#f8ef210ab9989980651a160733641ffa1fe66bf4" +source = "git+https://github.com/emilk/egui?rev=f76eefb98d23cbf71989255aafe75a07d343f6ed#f76eefb98d23cbf71989255aafe75a07d343f6ed" dependencies = [ "ab_glyph", "ahash 0.8.2", diff --git a/Cargo.toml b/Cargo.toml index 1ec0785825de..955953fc76c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ version = "0.6.0-alpha.0" # This is because we treat alpha-releases as incompatible, but semver doesn't. # In particular: if we compile rerun 0.3.0-alpha.0 we only want it to use # re_log_types 0.3.0-alpha.0, NOT 0.3.0-alpha.4 even though it is newer and semver-compatible. -re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.6.0-alpha.0" }\ +re_sdk_comms = { path = "crates/re_sdk_comms", version = "=0.6.0-alpha.0" } re_analytics = { path = "crates/re_analytics", version = "=0.6.0-alpha.0" } re_arrow_store = { path = "crates/re_arrow_store", version = "=0.6.0-alpha.0" } re_build_build_info = { path = "crates/re_build_build_info", version = "=0.6.0-alpha.0" } From 918e065dd55f82fcace4cab5d0221f5223fe4767 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 26 Apr 2023 09:14:07 +0200 Subject: [PATCH 10/10] doc fixes, use if cfg! instead of attribute cfg --- BUILD.md | 6 +++--- crates/re_renderer/src/config.rs | 27 ++++++++++++--------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/BUILD.md b/BUILD.md index 84d9d0f58631..bbe480485f3a 100644 --- a/BUILD.md +++ b/BUILD.md @@ -78,13 +78,13 @@ pip install ./rerun_py ## Building for the Web -Python builds come with the web-viewer by default. If you however want to build a standalone rerun executable -that contains the web-viewer and a websocket server, you need to ensure the `web_viewer` feature flag is set: +If you want to build a standalone rerun executable that contains the web-viewer and a websocket server, +you need to ensure the `web_viewer` feature flag is set: ``` cargo build -p rerun --features web_viewer ``` -Rerun uses a standalone tool to build the web-viewer without a server. You can invoke it directly as well: +Rerun uses a standalone tool to build the web-viewer. You can invoke it directly as well: ``` cargo run -p re_build_web_viewer -- --release ``` diff --git a/crates/re_renderer/src/config.rs b/crates/re_renderer/src/config.rs index f559e9e3a02a..7b85283b505f 100644 --- a/crates/re_renderer/src/config.rs +++ b/crates/re_renderer/src/config.rs @@ -136,22 +136,19 @@ pub struct RenderContextConfig { /// /// Other backend might work as well, but lack of support isn't regarded as a bug. pub fn supported_backends() -> wgpu::Backends { - // Native. - // Only use Vulkan & Metal unless explicitly told so since this reduces surfaces and thus surprises. - // - // Bunch of cases where it's still useful to switch though: - // * Some Windows VMs only provide DX12 drivers, observed with Parallels on Apple Silicon - // * May run into Linux issues that warrant trying out the GL backend. - // - // For changing the backend we use standard wgpu env var, i.e. WGPU_BACKEND. - #[cfg(not(target_arch = "wasm32"))] - { + if cfg!(target_arch = "wasm32") { + // Web - WebGL is used automatically when wgpu is compiled with `webgl` feature. + wgpu::Backends::GL | wgpu::Backends::BROWSER_WEBGPU + } else { + // Native. + // Only use Vulkan & Metal unless explicitly told so since this reduces surfaces and thus surprises. + // + // Bunch of cases where it's still useful to switch though: + // * Some Windows VMs only provide DX12 drivers, observed with Parallels on Apple Silicon + // * May run into Linux issues that warrant trying out the GL backend. + // + // For changing the backend we use standard wgpu env var, i.e. WGPU_BACKEND. wgpu::util::backend_bits_from_env() .unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL) } - // Web - WebGL is used automatically when wgpu is compiled with `webgl` feature. - #[cfg(target_arch = "wasm32")] - { - wgpu::Backends::GL | wgpu::Backends::BROWSER_WEBGPU - } }