diff --git a/Cargo.lock b/Cargo.lock index fa0375e14bb5..0375bbf5d6dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,7 +288,7 @@ version = "0.37.3+1.3.251" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" dependencies = [ - "libloading 0.7.4", + "libloading", ] [[package]] @@ -872,7 +872,7 @@ dependencies = [ "cocoa-foundation", "core-foundation", "core-graphics", - "foreign-types", + "foreign-types 0.3.2", "libc", "objc", ] @@ -887,7 +887,7 @@ dependencies = [ "block", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", "objc", ] @@ -1027,7 +1027,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types", + "foreign-types 0.3.2", "libc", ] @@ -1039,7 +1039,7 @@ checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" dependencies = [ "bitflags 1.3.2", "core-foundation", - "foreign-types", + "foreign-types 0.3.2", "libc", ] @@ -1229,12 +1229,12 @@ dependencies = [ [[package]] name = "d3d12" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8f0de2f5a8e7bd4a9eec0e3c781992a4ce1724f68aec7d7a3715344de8b39da" +checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" dependencies = [ - "bitflags 1.3.2", - "libloading 0.7.4", + "bitflags 2.3.1", + "libloading", "winapi", ] @@ -1332,7 +1332,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" dependencies = [ - "libloading 0.7.4", + "libloading", ] [[package]] @@ -1368,7 +1368,7 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecolor" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "bytemuck", "serde", @@ -1377,7 +1377,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "bytemuck", "cocoa", @@ -1409,7 +1409,7 @@ dependencies = [ [[package]] name = "egui" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "accesskit", "ahash 0.8.3", @@ -1423,7 +1423,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "bytemuck", "epaint", @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "arboard", "egui", @@ -1455,7 +1455,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "egui", "log", @@ -1465,7 +1465,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "bytemuck", "egui", @@ -1515,7 +1515,7 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "emath" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "bytemuck", "serde", @@ -1596,7 +1596,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.22.0" -source = "git+https://github.com/emilk/egui?rev=dd417cfc1acdf7ac88f214015d4d8e7a21835d30#dd417cfc1acdf7ac88f214015d4d8e7a21835d30" +source = "git+https://github.com/emilk/egui?rev=f0addc339cd753f724253f37b37af6db1a84178b#f0addc339cd753f724253f37b37af6db1a84178b" dependencies = [ "ab_glyph", "ahash 0.8.3", @@ -1777,7 +1777,28 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" dependencies = [ - "foreign-types-shared", + "foreign-types-shared 0.1.1", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared 0.3.1", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", ] [[package]] @@ -1786,6 +1807,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + [[package]] name = "foreign_vec" version = "0.1.0" @@ -2033,21 +2060,21 @@ dependencies = [ [[package]] name = "gpu-alloc" -version = "0.5.4" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22beaafc29b38204457ea030f6fb7a84c9e4dd1b86e311ba0542533453d87f62" +checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.1", "gpu-alloc-types", ] [[package]] name = "gpu-alloc-types" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54804d0d6bc9d7f26db4eaec1ad10def69b599315f487d32c334a80d1efe67a5" +checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.1", ] [[package]] @@ -2153,7 +2180,7 @@ dependencies = [ "bitflags 1.3.2", "com-rs", "libc", - "libloading 0.7.4", + "libloading", "thiserror", "widestring", "winapi", @@ -2485,7 +2512,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c2352bd1d0bceb871cb9d40f24360c8133c11d7486b68b5381c1dd1a32015e3" dependencies = [ "libc", - "libloading 0.7.4", + "libloading", "pkg-config", ] @@ -2610,16 +2637,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libloading" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d580318f95776505201b28cf98eb1fa5e4be3b689633ba6a3e6cd880ff22d8cb" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "libm" version = "0.2.7" @@ -2785,16 +2802,17 @@ dependencies = [ [[package]] name = "metal" -version = "0.24.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de11355d1f6781482d027a3b4d4de7825dcedb197bf573e0596d00008402d060" +checksum = "623b5e6cefd76e58f774bd3cc0c6f5c7615c58c03a97815245a25c3c9bdee318" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.3.1", "block", "core-graphics-types", - "foreign-types", + "foreign-types 0.5.0", "log", "objc", + "paste", ] [[package]] @@ -2898,12 +2916,12 @@ dependencies = [ [[package]] name = "naga" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94d3edd593521f4a1dfd9b25193ed0224764572905f013d30ca5fbb85e010876" +checksum = "c1ceaaa4eedaece7e4ec08c55c640ba03dbb73fb812a6570a59bcf1930d0f70e" dependencies = [ "bit-set", - "bitflags 1.3.2", + "bitflags 2.3.1", "codespan-reporting", "hexf-parse", "indexmap", @@ -4276,7 +4294,6 @@ dependencies = [ "web-time", "wgpu", "wgpu-core", - "wgpu-hal", "winit", "zip", ] @@ -6474,9 +6491,9 @@ checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" [[package]] name = "wgpu" -version = "0.16.3" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "480c965c9306872eb6255fa55e4b4953be55a8b64d57e61d7ff840d3dcc051cd" +checksum = "7472f3b69449a8ae073f6ec41d05b6f846902d92a6c45313c50cb25857b736ce" dependencies = [ "arrayvec", "cfg-if", @@ -6498,9 +6515,9 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.16.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f478237b4bf0d5b70a39898a66fa67ca3a007d79f2520485b8b0c3dfc46f8c2" +checksum = "ecf7454d9386f602f7399225c92dd2fbdcde52c519bc8fb0bd6fbeb388075dc2" dependencies = [ "arrayvec", "bit-vec", @@ -6521,9 +6538,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.16.1" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74851c2c8e5d97652e74c241d41b0656b31c924a45dcdecde83975717362cfa4" +checksum = "6654a13885a17f475e8324efb46dc6986d7aaaa98353330f8de2077b153d0101" dependencies = [ "android_system_properties", "arrayvec", @@ -6533,7 +6550,6 @@ dependencies = [ "block", "core-graphics-types", "d3d12", - "foreign-types", "glow", "gpu-alloc", "gpu-allocator", @@ -6542,7 +6558,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.0", + "libloading", "log", "metal", "naga", @@ -6563,9 +6579,9 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd33a976130f03dcdcd39b3810c0c3fc05daf86f0aaf867db14bfb7c4a9a32b" +checksum = "ee64d7398d0c2f9ca48922c902ef69c42d000c759f3db41e355f4a570b052b67" dependencies = [ "bitflags 2.3.1", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 34b29dd9db27..18fecee6412a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,8 +122,10 @@ tokio = { version = "1.24", default-features = false } unindent = "0.1" vec1 = "1.8" web-time = "0.2.0" -wgpu = { version = "0.16.3" } -wgpu-core = { version = "0.16.1" } +# 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.17.0", features = ["fragile-send-sync-non-atomic-wasm"] } +wgpu-core = "0.17.0" [profile.dev] @@ -152,14 +154,14 @@ debug = true # ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk. # Temporary patch until next egui release -ecolor = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -eframe = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -egui-wgpu = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -egui-winit = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -egui = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -egui_extras = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -emath = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } -epaint = { git = "https://github.com/emilk/egui", rev = "dd417cfc1acdf7ac88f214015d4d8e7a21835d30" } +ecolor = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +eframe = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +egui-wgpu = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +egui-winit = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +egui = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +egui_extras = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +emath = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } +epaint = { git = "https://github.com/emilk/egui", rev = "f0addc339cd753f724253f37b37af6db1a84178b" } # Temporary patch until next egui_tiles release egui_tiles = { git = "https://github.com/rerun-io/egui_tiles", rev = "f835c4df1cc260a58122a8d37c7c3738902b9643" } diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index f22f576fe0d3..573ca9aac748 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -67,7 +67,7 @@ static_assertions = "1.1" thiserror.workspace = true type-map = "0.5" wgpu.workspace = true -wgpu-hal = "0.16.1" # wgpu-hal 0.16.1 contains a critical fix for mobile devices: https://github.com/gfx-rs/wgpu/pull/3780 +wgpu-core.workspace = true # optional arrow2 = { workspace = true, optional = true } diff --git a/crates/re_renderer/shader/rectangle_fs.wgsl b/crates/re_renderer/shader/rectangle_fs.wgsl index 58d84196e819..28a2801d39d5 100644 --- a/crates/re_renderer/shader/rectangle_fs.wgsl +++ b/crates/re_renderer/shader/rectangle_fs.wgsl @@ -25,7 +25,7 @@ fn decode_color(sampled_value: Vec4) -> Vec4 { // Convert to linear space if rect_info.decode_srgb != 0u { - if all(0.0 <= rgba.rgb) && all(rgba.rgb <= 1.0) { + if all(Vec3(0.0) <= rgba.rgb) && all(rgba.rgb <= Vec3(1.0)) { rgba = linear_from_srgba(rgba); } else { rgba = ERROR_RGBA; // out of range diff --git a/crates/re_renderer/shader/types.wgsl b/crates/re_renderer/shader/types.wgsl index 6355bcc668b5..ef2b2b4e79fe 100644 --- a/crates/re_renderer/shader/types.wgsl +++ b/crates/re_renderer/shader/types.wgsl @@ -14,7 +14,8 @@ alias Mat4 = mat4x4; // Extreme values as documented by the spec: // https://www.w3.org/TR/WGSL/#floating-point-types -const f32max = 0x1.fffffep+127f; // Largest positive float value. +//const f32max = 0x1.fffffep+127f; // Largest positive float value. +const f32max = 3.40282e38; // ⚠️ Should be above value, using a smaller one to work around https://github.com/gfx-rs/naga/issues/2436. const f32min = -0x0.fffffep+127f; // Smallest negative float value. const f32min_normal = 0x1p-126f; // Smallest positive normal float value. // F16 is not implemented yet in Naga https://github.com/gfx-rs/naga/issues/1884 diff --git a/crates/re_renderer/src/error_tracker.rs b/crates/re_renderer/src/error_tracker.rs index e6d4adf62798..131ac24c85a7 100644 --- a/crates/re_renderer/src/error_tracker.rs +++ b/crates/re_renderer/src/error_tracker.rs @@ -57,7 +57,7 @@ macro_rules! try_downcast { wgpu_core::binding_model::CreatePipelineLayoutError, wgpu_core::binding_model::GetBindGroupLayoutError, wgpu_core::binding_model::PushConstantUploadError, - wgpu_core::device::CreateDeviceError, + wgpu_core::device::resource::CreateDeviceError, wgpu_core::device::DeviceError, wgpu_core::device::RenderPassCompatibilityError, wgpu_core::pipeline::ColorStateError, @@ -129,7 +129,7 @@ impl_trait![ wgpu_core::binding_model::CreatePipelineLayoutError, wgpu_core::binding_model::GetBindGroupLayoutError, wgpu_core::binding_model::PushConstantUploadError, - wgpu_core::device::CreateDeviceError, + wgpu_core::device::resource::CreateDeviceError, wgpu_core::device::DeviceError, wgpu_core::device::RenderPassCompatibilityError, wgpu_core::pipeline::ColorStateError, diff --git a/crates/re_renderer/src/renderer/rectangles.rs b/crates/re_renderer/src/renderer/rectangles.rs index 3f86201ff2c0..a1fc42d25a39 100644 --- a/crates/re_renderer/src/renderer/rectangles.rs +++ b/crates/re_renderer/src/renderer/rectangles.rs @@ -188,7 +188,7 @@ pub enum RectangleError { } mod gpu_data { - use crate::{texture_info, wgpu_buffer_types}; + use crate::wgpu_buffer_types; use super::{ColorMapper, RectangleError, TexturedRect}; @@ -283,7 +283,7 @@ mod gpu_data { let mut colormap_function = 0; let color_mapper_int; - match texture_info::num_texture_components(texture_format) { + match texture_format.components() { 1 => match color_mapper { Some(ColorMapper::Function(colormap)) => { color_mapper_int = COLOR_MAPPER_FUNCTION; diff --git a/crates/re_renderer/src/texture_info.rs b/crates/re_renderer/src/texture_info.rs index 7982c61d90c2..cfd241462344 100644 --- a/crates/re_renderer/src/texture_info.rs +++ b/crates/re_renderer/src/texture_info.rs @@ -120,87 +120,3 @@ pub fn is_float_filterable(format: wgpu::TextureFormat, device_features: wgpu::F .flags .contains(wgpu::TextureFormatFeatureFlags::FILTERABLE) } - -pub fn num_texture_components(format: wgpu::TextureFormat) -> u8 { - #[allow(clippy::match_same_arms)] - match format { - wgpu::TextureFormat::R8Unorm - | wgpu::TextureFormat::R8Snorm - | wgpu::TextureFormat::R8Uint - | wgpu::TextureFormat::R8Sint - | wgpu::TextureFormat::R16Uint - | wgpu::TextureFormat::R16Sint - | wgpu::TextureFormat::R16Unorm - | wgpu::TextureFormat::R16Snorm - | wgpu::TextureFormat::R16Float - | wgpu::TextureFormat::R32Uint - | wgpu::TextureFormat::R32Sint - | wgpu::TextureFormat::R32Float => 1, - - wgpu::TextureFormat::Rg8Unorm - | wgpu::TextureFormat::Rg8Snorm - | wgpu::TextureFormat::Rg8Uint - | wgpu::TextureFormat::Rg8Sint - | wgpu::TextureFormat::Rg16Uint - | wgpu::TextureFormat::Rg16Sint - | wgpu::TextureFormat::Rg16Unorm - | wgpu::TextureFormat::Rg16Snorm - | wgpu::TextureFormat::Rg16Float - | wgpu::TextureFormat::Rg32Uint - | wgpu::TextureFormat::Rg32Sint - | wgpu::TextureFormat::Rg32Float => 2, - - wgpu::TextureFormat::Rgba8Unorm - | wgpu::TextureFormat::Rgba8UnormSrgb - | wgpu::TextureFormat::Rgba8Snorm - | wgpu::TextureFormat::Rgba8Uint - | wgpu::TextureFormat::Rgba8Sint - | wgpu::TextureFormat::Bgra8Unorm - | wgpu::TextureFormat::Bgra8UnormSrgb - | wgpu::TextureFormat::Rgba16Uint - | wgpu::TextureFormat::Rgba16Sint - | wgpu::TextureFormat::Rgba16Unorm - | wgpu::TextureFormat::Rgba16Snorm - | wgpu::TextureFormat::Rgba16Float - | wgpu::TextureFormat::Rgba32Uint - | wgpu::TextureFormat::Rgba32Sint - | wgpu::TextureFormat::Rgba32Float => 4, - - wgpu::TextureFormat::Rgb9e5Ufloat | wgpu::TextureFormat::Rg11b10Float => 3, - wgpu::TextureFormat::Rgb10a2Unorm => 4, - - wgpu::TextureFormat::Stencil8 - | wgpu::TextureFormat::Depth16Unorm - | wgpu::TextureFormat::Depth24Plus - | wgpu::TextureFormat::Depth32Float => 1, - - // It's complicated. Each aspect has actually only a single channel. - wgpu::TextureFormat::Depth24PlusStencil8 | wgpu::TextureFormat::Depth32FloatStencil8 => 2, - - wgpu::TextureFormat::Bc1RgbaUnorm - | wgpu::TextureFormat::Bc1RgbaUnormSrgb - | wgpu::TextureFormat::Bc2RgbaUnorm - | wgpu::TextureFormat::Bc2RgbaUnormSrgb - | wgpu::TextureFormat::Bc3RgbaUnorm - | wgpu::TextureFormat::Bc3RgbaUnormSrgb - | wgpu::TextureFormat::Bc4RUnorm - | wgpu::TextureFormat::Bc4RSnorm - | wgpu::TextureFormat::Bc5RgUnorm - | wgpu::TextureFormat::Bc5RgSnorm - | wgpu::TextureFormat::Bc6hRgbUfloat - | wgpu::TextureFormat::Bc6hRgbFloat - | wgpu::TextureFormat::Bc7RgbaUnorm - | wgpu::TextureFormat::Bc7RgbaUnormSrgb - | wgpu::TextureFormat::Etc2Rgb8Unorm - | wgpu::TextureFormat::Etc2Rgb8UnormSrgb - | wgpu::TextureFormat::Etc2Rgb8A1Unorm - | wgpu::TextureFormat::Etc2Rgb8A1UnormSrgb - | wgpu::TextureFormat::Etc2Rgba8Unorm - | wgpu::TextureFormat::Etc2Rgba8UnormSrgb - | wgpu::TextureFormat::EacR11Unorm - | wgpu::TextureFormat::EacR11Snorm - | wgpu::TextureFormat::EacRg11Unorm - | wgpu::TextureFormat::EacRg11Snorm - | wgpu::TextureFormat::Astc { .. } => 4, - } -} diff --git a/crates/re_space_view_spatial/src/ui_2d.rs b/crates/re_space_view_spatial/src/ui_2d.rs index 14a4c6bf42d2..5281be1ee26f 100644 --- a/crates/re_space_view_spatial/src/ui_2d.rs +++ b/crates/re_space_view_spatial/src/ui_2d.rs @@ -357,23 +357,12 @@ pub fn view_2d( // Draw a re_renderer driven view. // Camera & projection are configured to ingest space coordinates directly. - { - let command_buffer = - match view_builder.draw(ctx.render_ctx, ui.visuals().extreme_bg_color.into()) { - Ok(command_buffer) => command_buffer, - Err(err) => { - re_log::error_once!("Failed to fill view builder: {err}"); - return Ok(()); // TODO(andreas): Should make it possible to pass the error on. - } - }; - painter.add(gpu_bridge::renderer_paint_callback( - ctx.render_ctx, - command_buffer, - view_builder, - painter.clip_rect(), - painter.ctx().pixels_per_point(), - )); - } + painter.add(gpu_bridge::new_renderer_callback( + ctx.render_ctx, + view_builder, + painter.clip_rect(), + ui.visuals().extreme_bg_color.into(), + )); painter.extend(show_projections_from_3d_space( ctx, diff --git a/crates/re_space_view_spatial/src/ui_3d.rs b/crates/re_space_view_spatial/src/ui_3d.rs index e18d1fb1b80b..736f2151cb81 100644 --- a/crates/re_space_view_spatial/src/ui_3d.rs +++ b/crates/re_space_view_spatial/src/ui_3d.rs @@ -606,19 +606,11 @@ pub fn view_3d( view_builder.queue_draw(re_renderer::renderer::GenericSkyboxDrawData::new( ctx.render_ctx, )); - let command_buffer = match view_builder.draw(ctx.render_ctx, re_renderer::Rgba::TRANSPARENT) { - Ok(command_buffer) => command_buffer, - Err(err) => { - re_log::error_once!("Failed to fill view builder: {err}"); - return Ok(()); // TODO(andreas): Passing the error through would be better - we could show an error on the view instead then. - } - }; - ui.painter().add(gpu_bridge::renderer_paint_callback( + ui.painter().add(gpu_bridge::new_renderer_callback( ctx.render_ctx, - command_buffer, view_builder, rect, - ui.ctx().pixels_per_point(), + re_renderer::Rgba::TRANSPARENT, )); // Add egui driven labels on top of re_renderer content. 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 8e3f3e555ebc..3d28c1a95572 100644 --- a/crates/re_space_view_tensor/src/tensor_dimension_mapper.rs +++ b/crates/re_space_view_tensor/src/tensor_dimension_mapper.rs @@ -159,12 +159,7 @@ fn drop_target_ui( ui.painter().set( where_to_put_background, - egui::epaint::RectShape { - rounding: style.rounding, - fill, - stroke, - rect, - }, + egui::epaint::RectShape::new(rect, style.rounding, fill, stroke), ); egui::InnerResponse::new(ret, response) diff --git a/crates/re_space_view_time_series/src/space_view_class.rs b/crates/re_space_view_time_series/src/space_view_class.rs index 6c396b338d5b..cacaf15926c1 100644 --- a/crates/re_space_view_time_series/src/space_view_class.rs +++ b/crates/re_space_view_time_series/src/space_view_class.rs @@ -136,7 +136,7 @@ impl SpaceViewClass for TimeSeriesSpaceView { position: egui::plot::Corner::RightBottom, ..Default::default() }) - .x_axis_formatter(move |time, _| format_time(time_type, time as i64 + time_offset)) + .x_axis_formatter(move |time, _, _| format_time(time_type, time as i64 + time_offset)) .label_formatter(move |name, value| { let name = if name.is_empty() { "y" } else { name }; let is_integer = value.y.round() == value.y; diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index f5478b045713..7a0b4c1b0cdf 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -576,7 +576,7 @@ impl App { &mut render_state.renderer.write() }; if let Some(render_ctx) = egui_renderer - .paint_callback_resources + .callback_resources .get_mut::() { render_ctx.begin_frame(); @@ -898,7 +898,7 @@ impl eframe::App for App { &mut render_state.renderer.read() }; let render_ctx = egui_renderer - .paint_callback_resources + .callback_resources .get::() .unwrap(); diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index ac75747c1b84..79ae7fac854d 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -150,7 +150,7 @@ pub fn customize_eframe(cc: &eframe::CreationContext<'_>) -> re_ui::ReUi { if let Some(render_state) = &cc.wgpu_render_state { use re_renderer::{config::RenderContextConfig, RenderContext}; - let paint_callback_resources = &mut render_state.renderer.write().paint_callback_resources; + let paint_callback_resources = &mut render_state.renderer.write().callback_resources; paint_callback_resources.insert(RenderContext::new( &render_state.adapter, diff --git a/crates/re_viewer/src/ui/memory_panel.rs b/crates/re_viewer/src/ui/memory_panel.rs index ae71bec3ad85..27385d69ad8c 100644 --- a/crates/re_viewer/src/ui/memory_panel.rs +++ b/crates/re_viewer/src/ui/memory_panel.rs @@ -382,8 +382,8 @@ impl MemoryPanel { egui::plot::Plot::new("mem_history_plot") .min_size(egui::Vec2::splat(200.0)) .label_formatter(|name, value| format!("{name}: {}", format_bytes(value.y))) - .x_axis_formatter(|time, _| format!("{time} s")) - .y_axis_formatter(|bytes, _| format_bytes(bytes)) + .x_axis_formatter(|time, _, _| format!("{time} s")) + .y_axis_formatter(|bytes, _, _| format_bytes(bytes)) .show_x(false) .legend(egui::plot::Legend::default().position(egui::plot::Corner::LeftTop)) .include_y(0.0) diff --git a/crates/re_viewer_context/src/gpu_bridge/mod.rs b/crates/re_viewer_context/src/gpu_bridge/mod.rs index f1b2211c44c8..d43437f1b45d 100644 --- a/crates/re_viewer_context/src/gpu_bridge/mod.rs +++ b/crates/re_viewer_context/src/gpu_bridge/mod.rs @@ -1,14 +1,15 @@ //! Bridge to `re_renderer` +mod re_renderer_callback; mod tensor_to_gpu; + +pub use re_renderer_callback::new_renderer_callback; pub use tensor_to_gpu::{depth_tensor_to_gpu, tensor_to_gpu}; use crate::TensorStats; // ---------------------------------------------------------------------------- -use egui::mutex::Mutex; - use re_renderer::{ renderer::{ColormappedTexture, RectangleOptions}, resource_managers::{ @@ -111,62 +112,6 @@ pub fn get_or_create_texture<'a>( ) } -/// Render a `re_render` view using the given clip rectangle. -pub fn renderer_paint_callback( - render_ctx: &mut re_renderer::RenderContext, - command_buffer: wgpu::CommandBuffer, - view_builder: re_renderer::ViewBuilder, - clip_rect: egui::Rect, - pixels_from_point: f32, -) -> egui::PaintCallback { - re_tracing::profile_function!(); - - slotmap::new_key_type! { pub struct ViewBuilderHandle; } - - type ViewBuilderMap = slotmap::SlotMap; - - // egui paint callback are copyable / not a FnOnce (this in turn is because egui primitives can be callbacks and are copyable) - let command_buffer = std::sync::Arc::new(Mutex::new(Some(command_buffer))); - - let composition_view_builder_map = render_ctx - .active_frame - .per_frame_data_helper - .entry::() - .or_insert_with(Default::default); - let view_builder_handle = composition_view_builder_map.insert(view_builder); - - let screen_position = (clip_rect.min.to_vec2() * pixels_from_point).round(); - let screen_position = glam::vec2(screen_position.x, screen_position.y); - - egui::PaintCallback { - rect: clip_rect, - callback: std::sync::Arc::new( - egui_wgpu::CallbackFn::new() - .prepare( - move |_device, _queue, _encoder, _paint_callback_resources| { - let mut command_buffer = command_buffer.lock(); - vec![command_buffer - .take() - .expect("egui_wgpu prepare callback called more than once")] - }, - ) - .paint(move |_info, render_pass, paint_callback_resources| { - re_tracing::profile_scope!("paint"); - // TODO(andreas): This should work as well but doesn't work in the 3d view. - // Looks like a bug in egui, but unclear what's going on. - //let clip_rect = info.clip_rect_in_pixels(); - - let ctx = paint_callback_resources.get::().unwrap(); - ctx.active_frame - .per_frame_data_helper - .get::() - .unwrap()[view_builder_handle] - .composite(ctx, render_pass, screen_position); - }), - ), - } -} - /// Render the given image, respecting the clip rectangle of the given painter. pub fn render_image( render_ctx: &mut re_renderer::RenderContext, @@ -244,14 +189,11 @@ pub fn render_image( &[textured_rectangle], )?); - let command_buffer = view_builder.draw(render_ctx, re_renderer::Rgba::TRANSPARENT)?; - - painter.add(renderer_paint_callback( + painter.add(new_renderer_callback( render_ctx, - command_buffer, view_builder, clip_rect, - painter.ctx().pixels_per_point(), + re_renderer::Rgba::TRANSPARENT, )); Ok(()) diff --git a/crates/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs b/crates/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs new file mode 100644 index 000000000000..72384c06118d --- /dev/null +++ b/crates/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs @@ -0,0 +1,114 @@ +slotmap::new_key_type! { pub struct ViewBuilderHandle; } + +type ViewBuilderMap = slotmap::SlotMap>; + +pub fn new_renderer_callback( + render_ctx: &mut re_renderer::RenderContext, + view_builder: re_renderer::ViewBuilder, + clip_rect: egui::Rect, + clear_color: re_renderer::Rgba, +) -> egui::PaintCallback { + let composition_view_builder_map = render_ctx + .active_frame + .per_frame_data_helper + .entry::() + .or_insert_with(Default::default); + let view_builder_handle = composition_view_builder_map.insert(Some(view_builder)); + + egui_wgpu::Callback::new_paint_callback( + clip_rect, + ReRendererCallback { + view_builder: view_builder_handle, + clear_color, + }, + ) +} + +struct ReRendererCallback { + // It would be nice to put the ViewBuilder in here directly, but this + // struct is required to be Send/Sync and wgpu resources aren't on wasm. + // Technically, we ignore this restriction by using the `fragile-send-sync-non-atomic-wasm` wgpu feature flag. + // + // However, in addition, we need to make sure that the ViewBuilder outlives the render pass that is used to draw egui. + // (This restriction is likely to be address by Arcanization https://github.com/gfx-rs/wgpu/pull/3626). + view_builder: ViewBuilderHandle, + clear_color: re_renderer::Rgba, +} + +impl egui_wgpu::CallbackTrait for ReRendererCallback { + fn prepare( + &self, + _device: &wgpu::Device, + _queue: &wgpu::Queue, + _egui_encoder: &mut wgpu::CommandEncoder, + paint_callback_resources: &mut egui_wgpu::CallbackResources, + ) -> Vec { + let Some(ctx) = paint_callback_resources.get_mut::() else { + re_log::error_once!("Failed to execute egui prepare callback. No render context available."); + return Vec::new(); + }; + + // Takes the view_builder out of the slotmap, so we don't have a mutable reference to ctx in use. + let Some(mut view_builder) = ctx.active_frame + .per_frame_data_helper + .get_mut::() + .and_then(|view_builder_map| { + view_builder_map + .get_mut(self.view_builder) + .and_then(|slot| slot.take()) + }) else { + re_log::error_once!( + "Failed to execute egui prepare callback. View builder with handle {:?} not found.", self.view_builder + ); + return Vec::new(); + }; + + match view_builder.draw(ctx, self.clear_color) { + Ok(command_buffer) => { + // If drawing worked, put the view_builder back in so we can use it during paint. + ctx.active_frame + .per_frame_data_helper + .get_mut::() + .and_then(|view_builder_map| { + view_builder_map + .get_mut(self.view_builder) + .and_then(|slot| slot.replace(view_builder)) + }); + vec![command_buffer] + } + + Err(err) => { + re_log::error_once!("Failed to fill view builder: {err}"); + // TODO(andreas): It would be nice to paint an error message instead. + Vec::new() + } + } + } + + fn paint<'a>( + &'a self, + info: egui::PaintCallbackInfo, + render_pass: &mut wgpu::RenderPass<'a>, + paint_callback_resources: &'a egui_wgpu::CallbackResources, + ) { + let Some(ctx) = paint_callback_resources.get::() else { + re_log::error_once!("Failed to execute egui draw callback. No render context available."); + return; + }; + + let Some(Some(view_builder)) = ctx + .active_frame + .per_frame_data_helper + .get::().and_then(|view_builder_map| view_builder_map.get(self.view_builder)) else { + re_log::error_once!( + "Failed to execute egui draw callback. View builder with handle {:?} not found.", self.view_builder + ); + return; + }; + + let screen_position = (info.clip_rect.min.to_vec2() * info.pixels_per_point).round(); + let screen_position = glam::vec2(screen_position.x, screen_position.y); + + view_builder.composite(ctx, render_pass, screen_position); + } +} diff --git a/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs b/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs index 9d2f6be69212..938f1fec6efd 100644 --- a/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs +++ b/crates/re_viewer_context/src/gpu_bridge/tensor_to_gpu.rs @@ -117,7 +117,7 @@ fn color_tensor_to_gpu( super::tensor_data_range_heuristic(tensor_stats, tensor.data.dtype())? }; - let color_mapper = if re_renderer::texture_info::num_texture_components(texture_format) == 1 { + let color_mapper = if texture_format.components() == 1 { // Single-channel images = luminance = grayscale Some(ColorMapper::Function(re_renderer::Colormap::Grayscale)) } else { diff --git a/crates/re_viewport/src/space_view_entity_picker.rs b/crates/re_viewport/src/space_view_entity_picker.rs index ad7f3f6b2a95..f6a32de65a75 100644 --- a/crates/re_viewport/src/space_view_entity_picker.rs +++ b/crates/re_viewport/src/space_view_entity_picker.rs @@ -33,7 +33,7 @@ impl SpaceViewEntityPicker { ); painter.add(egui::Shape::rect_filled( ui.ctx().screen_rect(), - egui::Rounding::none(), + egui::Rounding::ZERO, egui::Color32::from_black_alpha(128), )); diff --git a/crates/re_viewport/src/viewport.rs b/crates/re_viewport/src/viewport.rs index b234e28045e3..54f0ff920fd9 100644 --- a/crates/re_viewport/src/viewport.rs +++ b/crates/re_viewport/src/viewport.rs @@ -304,7 +304,7 @@ impl<'a, 'b> egui_tiles::Behavior for TabViewer<'a, 'b> { let frame = egui::Frame { inner_margin: egui::Margin::same(0.), outer_margin: egui::Margin::same(0.), - rounding: egui::Rounding::none(), + rounding: egui::Rounding::ZERO, shadow: Default::default(), fill: egui::Color32::TRANSPARENT, stroke: egui::Stroke::NONE, diff --git a/deny.toml b/deny.toml index 4ee8079e376a..1b4061146b1f 100644 --- a/deny.toml +++ b/deny.toml @@ -44,14 +44,15 @@ deny = [ ] skip = [ - { name = "ahash" }, # Popular crate + fast release schedule = lots of crates still using old versions - { name = "base64" }, # Too popular - { name = "libloading" }, # wgpu pulls in two different versions. It is a small crate though. - { name = "memoffset" }, # Small crate - { name = "nix" }, # difficult to avoid :( - { name = "prettyplease" }, # Old version being used by prost - { name = "time" }, # Too popular - { name = "windows" }, # wgpu and rfd are sometimes on different versions + { name = "ahash" }, # Popular crate + fast release schedule = lots of crates still using old versions + { name = "base64" }, # Too popular + { name = "foreign-types" }, # used for cocoa bindings. wgpu uses newer than winit. + { name = "foreign-types-shared" }, # as above. + { name = "memoffset" }, # Small crate + { name = "nix" }, # difficult to avoid :( + { name = "prettyplease" }, # Old version being used by prost + { name = "time" }, # Too popular + { name = "windows" }, # wgpu and rfd are sometimes on different versions ] skip-tree = [ { name = "cargo-run-wasm" }, # Dev-tool