From a940f18abde3df3639e83373318c395f4fa16d7c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 25 Sep 2024 11:34:30 +0200 Subject: [PATCH 1/5] Update egui with fix for tooltip shrinkage * Fixes https://github.com/rerun-io/rerun/issues/6801 (I hope/believe) --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9792faf0c836..b8e54ff8bb0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1777,7 +1777,7 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecolor" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "bytemuck", "emath", @@ -1787,7 +1787,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "ahash", "bytemuck", @@ -1824,7 +1824,7 @@ dependencies = [ [[package]] name = "egui" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "accesskit", "ahash", @@ -1841,7 +1841,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "ahash", "bytemuck", @@ -1860,7 +1860,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "accesskit_winit", "ahash", @@ -1900,7 +1900,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "ahash", "egui", @@ -1916,7 +1916,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "ahash", "bytemuck", @@ -1989,7 +1989,7 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "emath" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "bytemuck", "serde", @@ -2090,7 +2090,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" dependencies = [ "ab_glyph", "ahash", @@ -2109,7 +2109,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=e0f0b7f47f4094967530214aec060b9f1ce5954e#e0f0b7f47f4094967530214aec060b9f1ce5954e" +source = "git+https://github.com/emilk/egui.git?rev=f97f85089df5e936999d5b7280e2e93e2958fac8#f97f85089df5e936999d5b7280e2e93e2958fac8" [[package]] name = "equivalent" diff --git a/Cargo.toml b/Cargo.toml index 124946079547..f6e3293d99d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -514,12 +514,12 @@ missing_errors_doc = "allow" # 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 = "e0f0b7f47f4094967530214aec060b9f1ce5954e" } # egui master 2024-09-19 -eframe = { git = "https://github.com/emilk/egui.git", rev = "e0f0b7f47f4094967530214aec060b9f1ce5954e" } # egui master 2024-09-19 -egui = { git = "https://github.com/emilk/egui.git", rev = "e0f0b7f47f4094967530214aec060b9f1ce5954e" } # egui master 2024-09-19 -egui_extras = { git = "https://github.com/emilk/egui.git", rev = "e0f0b7f47f4094967530214aec060b9f1ce5954e" } # egui master 2024-09-19 -egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "e0f0b7f47f4094967530214aec060b9f1ce5954e" } # egui master 2024-09-19 -emath = { git = "https://github.com/emilk/egui.git", rev = "e0f0b7f47f4094967530214aec060b9f1ce5954e" } # egui master 2024-09-19 +ecolor = { git = "https://github.com/emilk/egui.git", rev = "f97f85089df5e936999d5b7280e2e93e2958fac8" } # egui master 2024-09-25 +eframe = { git = "https://github.com/emilk/egui.git", rev = "f97f85089df5e936999d5b7280e2e93e2958fac8" } # egui master 2024-09-25 +egui = { git = "https://github.com/emilk/egui.git", rev = "f97f85089df5e936999d5b7280e2e93e2958fac8" } # egui master 2024-09-25 +egui_extras = { git = "https://github.com/emilk/egui.git", rev = "f97f85089df5e936999d5b7280e2e93e2958fac8" } # egui master 2024-09-25 +egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "f97f85089df5e936999d5b7280e2e93e2958fac8" } # egui master 2024-09-25 +emath = { git = "https://github.com/emilk/egui.git", rev = "f97f85089df5e936999d5b7280e2e93e2958fac8" } # egui master 2024-09-25 # Useful while developing: # ecolor = { path = "../../egui/crates/ecolor" } From 6055fb1212d982e41f83f369adcbb79d31743196 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 25 Sep 2024 11:41:29 +0200 Subject: [PATCH 2/5] Update egui_table too --- Cargo.lock | 2 +- crates/viewer/re_space_view_dataframe/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8e54ff8bb0d..c484ef104ef1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1945,7 +1945,7 @@ dependencies = [ [[package]] name = "egui_table" version = "0.28.1" -source = "git+https://github.com/rerun-io/egui_table.git?rev=c76473b244f03a7c67fbbbff9def6fc86c1ca4ea#c76473b244f03a7c67fbbbff9def6fc86c1ca4ea" +source = "git+https://github.com/rerun-io/egui_table.git?rev=15be049a4eac3b9f87aa758505ebe46fd76dcef6#15be049a4eac3b9f87aa758505ebe46fd76dcef6" dependencies = [ "egui", "serde", diff --git a/crates/viewer/re_space_view_dataframe/Cargo.toml b/crates/viewer/re_space_view_dataframe/Cargo.toml index 11a80b39a69b..3613e9f3d3f7 100644 --- a/crates/viewer/re_space_view_dataframe/Cargo.toml +++ b/crates/viewer/re_space_view_dataframe/Cargo.toml @@ -37,7 +37,7 @@ re_viewport_blueprint.workspace = true anyhow.workspace = true egui_extras.workspace = true -egui_table = { git = "https://github.com/rerun-io/egui_table.git", rev = "c76473b244f03a7c67fbbbff9def6fc86c1ca4ea" } # main as of 2024-09-13 +egui_table = { git = "https://github.com/rerun-io/egui_table.git", rev = "15be049a4eac3b9f87aa758505ebe46fd76dcef6" } # main as of 2024-09-25 egui.workspace = true itertools.workspace = true thiserror.workspace = true From acf1e7fa3f84aeff9d86e15902b13ad056c45502 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 25 Sep 2024 12:03:38 +0200 Subject: [PATCH 3/5] Fixup lifted lifetime constraints, remove `StaticResourcePoolMemMoveAccessor` and associated trait as a consequence --- crates/viewer/re_renderer/src/context.rs | 18 +---- .../re_renderer/src/queueable_draw_data.rs | 6 +- .../re_renderer/src/renderer/compositor.rs | 8 +-- .../re_renderer/src/renderer/debug_overlay.rs | 8 +-- .../re_renderer/src/renderer/depth_cloud.rs | 8 +-- .../src/renderer/generic_skybox.rs | 8 +-- .../viewer/re_renderer/src/renderer/lines.rs | 8 +-- .../re_renderer/src/renderer/mesh_renderer.rs | 8 +-- crates/viewer/re_renderer/src/renderer/mod.rs | 8 +-- .../re_renderer/src/renderer/point_cloud.rs | 8 +-- .../re_renderer/src/renderer/rectangles.rs | 8 +-- .../re_renderer/src/renderer/test_triangle.rs | 6 +- crates/viewer/re_renderer/src/view_builder.rs | 18 ++--- .../src/wgpu_resources/bind_group_pool.rs | 1 - .../re_renderer/src/wgpu_resources/mod.rs | 2 +- .../wgpu_resources/pipeline_layout_pool.rs | 4 +- .../wgpu_resources/render_pipeline_pool.rs | 26 +------- .../wgpu_resources/static_resource_pool.rs | 65 +------------------ .../viewer/re_renderer_examples/framework.rs | 11 +--- .../src/space_view_class.rs | 1 + crates/viewer/re_viewer/src/app.rs | 2 +- .../src/gpu_bridge/re_renderer_callback.rs | 45 ++----------- 22 files changed, 66 insertions(+), 211 deletions(-) diff --git a/crates/viewer/re_renderer/src/context.rs b/crates/viewer/re_renderer/src/context.rs index 4bf9c8fc7db7..a191d6010653 100644 --- a/crates/viewer/re_renderer/src/context.rs +++ b/crates/viewer/re_renderer/src/context.rs @@ -13,7 +13,7 @@ use crate::{ global_bindings::GlobalBindings, renderer::Renderer, resource_managers::{MeshManager, TextureManager2D}, - wgpu_resources::{GpuRenderPipelinePoolMoveAccessor, WgpuResourcePools}, + wgpu_resources::WgpuResourcePools, FileServer, RecommendedFileResolver, }; @@ -224,7 +224,6 @@ impl RenderContext { let active_frame = ActiveFrameContext { before_view_builder_encoder: Mutex::new(FrameGlobalCommandEncoder::new(&device)), - pinned_render_pipelines: None, frame_index: STARTUP_FRAME_IDX, top_level_error_scope, }; @@ -341,13 +340,6 @@ This means, either a call to RenderContext::before_submit was omitted, or the pr // Map all read staging buffers. self.gpu_readback_belt.get_mut().after_queue_submit(); - // Give back moved render pipelines to the pool if any were moved out. - if let Some(moved_render_pipelines) = self.active_frame.pinned_render_pipelines.take() { - self.gpu_resources - .render_pipelines - .return_resources(moved_render_pipelines); - } - // Close previous' frame error scope. 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(); @@ -373,7 +365,6 @@ This means, either a call to RenderContext::before_submit was omitted, or the pr // New active frame! self.active_frame = ActiveFrameContext { before_view_builder_encoder: Mutex::new(FrameGlobalCommandEncoder::new(&self.device)), - pinned_render_pipelines: None, frame_index: self.active_frame.frame_index.wrapping_add(1), top_level_error_scope: Some(WgpuErrorScope::start(&self.device)), }; @@ -524,13 +515,6 @@ pub struct ActiveFrameContext { /// (i.e. typically in [`crate::renderer::DrawData`] creation!) pub before_view_builder_encoder: Mutex, - /// Render pipelines that were moved out of the resource pool. - /// - /// Will be moved back to the resource pool at the start of the frame. - /// This is needed for accessing the render pipelines without keeping a reference - /// to the resource pool lock during the lifetime of a render pass. - pub pinned_render_pipelines: Option, - /// Index of this frame. Is incremented for every render frame. /// /// Keep in mind that all operations on WebGPU are asynchronous: diff --git a/crates/viewer/re_renderer/src/queueable_draw_data.rs b/crates/viewer/re_renderer/src/queueable_draw_data.rs index 443da54ff436..4e28d266a390 100644 --- a/crates/viewer/re_renderer/src/queueable_draw_data.rs +++ b/crates/viewer/re_renderer/src/queueable_draw_data.rs @@ -19,10 +19,10 @@ pub enum QueueableDrawDataError { type DrawFn = dyn for<'a, 'b> Fn( &Renderers, - &'b GpuRenderPipelinePoolAccessor<'b>, + &GpuRenderPipelinePoolAccessor<'a>, DrawPhase, - &'a mut wgpu::RenderPass<'b>, - &'b dyn std::any::Any, + &mut wgpu::RenderPass<'b>, + &dyn std::any::Any, ) -> Result<(), QueueableDrawDataError> + Sync + Send; diff --git a/crates/viewer/re_renderer/src/renderer/compositor.rs b/crates/viewer/re_renderer/src/renderer/compositor.rs index c14a74fe108e..d6c3c91ce064 100644 --- a/crates/viewer/re_renderer/src/renderer/compositor.rs +++ b/crates/viewer/re_renderer/src/renderer/compositor.rs @@ -186,12 +186,12 @@ impl Renderer for Compositor { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a CompositorDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &CompositorDrawData, ) -> Result<(), DrawError> { let pipeline_handle = match phase { DrawPhase::Compositing => self.render_pipeline_regular, diff --git a/crates/viewer/re_renderer/src/renderer/debug_overlay.rs b/crates/viewer/re_renderer/src/renderer/debug_overlay.rs index 96e56b8ec9aa..9fc93d454494 100644 --- a/crates/viewer/re_renderer/src/renderer/debug_overlay.rs +++ b/crates/viewer/re_renderer/src/renderer/debug_overlay.rs @@ -223,12 +223,12 @@ impl Renderer for DebugOverlayRenderer { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, _phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a DebugOverlayDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &DebugOverlayDrawData, ) -> Result<(), DrawError> { let pipeline = render_pipelines.get(self.render_pipeline)?; diff --git a/crates/viewer/re_renderer/src/renderer/depth_cloud.rs b/crates/viewer/re_renderer/src/renderer/depth_cloud.rs index d60665ca3bc7..78c7566183ec 100644 --- a/crates/viewer/re_renderer/src/renderer/depth_cloud.rs +++ b/crates/viewer/re_renderer/src/renderer/depth_cloud.rs @@ -473,12 +473,12 @@ impl Renderer for DepthCloudRenderer { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError> { re_tracing::profile_function!(); if draw_data.instances.is_empty() { diff --git a/crates/viewer/re_renderer/src/renderer/generic_skybox.rs b/crates/viewer/re_renderer/src/renderer/generic_skybox.rs index 6be9c9934adc..5fdcbe2e1c7b 100644 --- a/crates/viewer/re_renderer/src/renderer/generic_skybox.rs +++ b/crates/viewer/re_renderer/src/renderer/generic_skybox.rs @@ -146,12 +146,12 @@ impl Renderer for GenericSkybox { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, _phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError> { re_tracing::profile_function!(); diff --git a/crates/viewer/re_renderer/src/renderer/lines.rs b/crates/viewer/re_renderer/src/renderer/lines.rs index d2c04fe45b22..b23424135bb7 100644 --- a/crates/viewer/re_renderer/src/renderer/lines.rs +++ b/crates/viewer/re_renderer/src/renderer/lines.rs @@ -744,12 +744,12 @@ impl Renderer for LineRenderer { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError> { let (pipeline_handle, bind_group_all_lines) = match phase { DrawPhase::OutlineMask => ( diff --git a/crates/viewer/re_renderer/src/renderer/mesh_renderer.rs b/crates/viewer/re_renderer/src/renderer/mesh_renderer.rs index 97085418aa00..2e97ec5e5238 100644 --- a/crates/viewer/re_renderer/src/renderer/mesh_renderer.rs +++ b/crates/viewer/re_renderer/src/renderer/mesh_renderer.rs @@ -395,12 +395,12 @@ impl Renderer for MeshRenderer { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError> { re_tracing::profile_function!(); diff --git a/crates/viewer/re_renderer/src/renderer/mod.rs b/crates/viewer/re_renderer/src/renderer/mod.rs index ccca81217c8a..24f770821c9f 100644 --- a/crates/viewer/re_renderer/src/renderer/mod.rs +++ b/crates/viewer/re_renderer/src/renderer/mod.rs @@ -69,12 +69,12 @@ pub trait Renderer { // TODO(andreas): Some Renderers need to create their own passes, need something like this for that. /// Called once per phase given by [`Renderer::participated_phases`]. - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError>; /// Combination of flags indicating in which phases [`Renderer::draw`] should be called. diff --git a/crates/viewer/re_renderer/src/renderer/point_cloud.rs b/crates/viewer/re_renderer/src/renderer/point_cloud.rs index e81287caa97d..fc7bb9d6d9cc 100644 --- a/crates/viewer/re_renderer/src/renderer/point_cloud.rs +++ b/crates/viewer/re_renderer/src/renderer/point_cloud.rs @@ -571,12 +571,12 @@ impl Renderer for PointCloudRenderer { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError> { let (pipeline_handle, bind_group_all_points) = match phase { DrawPhase::OutlineMask => ( diff --git a/crates/viewer/re_renderer/src/renderer/rectangles.rs b/crates/viewer/re_renderer/src/renderer/rectangles.rs index 3f9a60e46189..c0b4a8d022d1 100644 --- a/crates/viewer/re_renderer/src/renderer/rectangles.rs +++ b/crates/viewer/re_renderer/src/renderer/rectangles.rs @@ -653,12 +653,12 @@ impl Renderer for RectangleRenderer { } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, - draw_data: &'a Self::RendererDrawData, + pass: &mut wgpu::RenderPass<'_>, + draw_data: &Self::RendererDrawData, ) -> Result<(), DrawError> { re_tracing::profile_function!(); if draw_data.instances.is_empty() { diff --git a/crates/viewer/re_renderer/src/renderer/test_triangle.rs b/crates/viewer/re_renderer/src/renderer/test_triangle.rs index 6275c89779a0..2f3b4a9182c7 100644 --- a/crates/viewer/re_renderer/src/renderer/test_triangle.rs +++ b/crates/viewer/re_renderer/src/renderer/test_triangle.rs @@ -69,11 +69,11 @@ impl Renderer for TestTriangle { Self { render_pipeline } } - fn draw<'a>( + fn draw( &self, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, _phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, + pass: &mut wgpu::RenderPass<'_>, _draw_data: &TestTriangleDrawData, ) -> Result<(), DrawError> { let pipeline = render_pipelines.get(self.render_pipeline)?; diff --git a/crates/viewer/re_renderer/src/view_builder.rs b/crates/viewer/re_renderer/src/view_builder.rs index e59732b22c0d..5a1645e45367 100644 --- a/crates/viewer/re_renderer/src/view_builder.rs +++ b/crates/viewer/re_renderer/src/view_builder.rs @@ -481,12 +481,12 @@ impl ViewBuilder { self.setup.resolution_in_pixel } - fn draw_phase<'a>( - &'a self, + fn draw_phase( + &self, renderers: &Renderers, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, + render_pipelines: &GpuRenderPipelinePoolAccessor<'_>, phase: DrawPhase, - pass: &mut wgpu::RenderPass<'a>, + pass: &mut wgpu::RenderPass<'_>, ) { re_tracing::profile_function!(); @@ -764,18 +764,14 @@ impl ViewBuilder { /// /// The bound surface(s) on the `RenderPass` are expected to be the same format as specified on `Context` creation. /// `screen_position` specifies where on the output pass the view is placed. - pub fn composite<'a>( - &'a self, - ctx: &RenderContext, - render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>, - pass: &mut wgpu::RenderPass<'a>, - ) { + pub fn composite(&self, ctx: &RenderContext, pass: &mut wgpu::RenderPass<'_>) { re_tracing::profile_function!(); pass.set_bind_group(0, &self.setup.bind_group_0, &[]); + self.draw_phase( &ctx.read_lock_renderers(), - render_pipelines, + &ctx.gpu_resources.render_pipelines.resources(), DrawPhase::Compositing, pass, ); diff --git a/crates/viewer/re_renderer/src/wgpu_resources/bind_group_pool.rs b/crates/viewer/re_renderer/src/wgpu_resources/bind_group_pool.rs index 266fcd0cf1d6..39be695e14bc 100644 --- a/crates/viewer/re_renderer/src/wgpu_resources/bind_group_pool.rs +++ b/crates/viewer/re_renderer/src/wgpu_resources/bind_group_pool.rs @@ -9,7 +9,6 @@ use super::{ buffer_pool::{GpuBuffer, GpuBufferHandle, GpuBufferPool}, dynamic_resource_pool::{DynamicResource, DynamicResourcePool, DynamicResourcesDesc}, sampler_pool::{GpuSamplerHandle, GpuSamplerPool}, - static_resource_pool::StaticResourcePoolAccessor as _, texture_pool::{GpuTexture, GpuTextureHandle, GpuTexturePool}, WgpuResourcePools, }; diff --git a/crates/viewer/re_renderer/src/wgpu_resources/mod.rs b/crates/viewer/re_renderer/src/wgpu_resources/mod.rs index 42cb22b27edb..e2355f6d1fc0 100644 --- a/crates/viewer/re_renderer/src/wgpu_resources/mod.rs +++ b/crates/viewer/re_renderer/src/wgpu_resources/mod.rs @@ -24,7 +24,7 @@ pub use pipeline_layout_pool::{GpuPipelineLayoutPool, PipelineLayoutDesc}; mod render_pipeline_pool; pub use render_pipeline_pool::{ GpuRenderPipelineHandle, GpuRenderPipelinePool, GpuRenderPipelinePoolAccessor, - GpuRenderPipelinePoolMoveAccessor, RenderPipelineDesc, VertexBufferLayout, + RenderPipelineDesc, VertexBufferLayout, }; mod sampler_pool; diff --git a/crates/viewer/re_renderer/src/wgpu_resources/pipeline_layout_pool.rs b/crates/viewer/re_renderer/src/wgpu_resources/pipeline_layout_pool.rs index a4363716e397..2faaf8d5542d 100644 --- a/crates/viewer/re_renderer/src/wgpu_resources/pipeline_layout_pool.rs +++ b/crates/viewer/re_renderer/src/wgpu_resources/pipeline_layout_pool.rs @@ -2,9 +2,7 @@ use crate::{debug_label::DebugLabel, RenderContext}; use super::{ bind_group_layout_pool::GpuBindGroupLayoutHandle, - static_resource_pool::{ - StaticResourcePool, StaticResourcePoolAccessor as _, StaticResourcePoolReadLockAccessor, - }, + static_resource_pool::{StaticResourcePool, StaticResourcePoolReadLockAccessor}, }; slotmap::new_key_type! { pub struct GpuPipelineLayoutHandle; } diff --git a/crates/viewer/re_renderer/src/wgpu_resources/render_pipeline_pool.rs b/crates/viewer/re_renderer/src/wgpu_resources/render_pipeline_pool.rs index 7477af838354..aba5852989ac 100644 --- a/crates/viewer/re_renderer/src/wgpu_resources/render_pipeline_pool.rs +++ b/crates/viewer/re_renderer/src/wgpu_resources/render_pipeline_pool.rs @@ -6,10 +6,7 @@ use super::{ pipeline_layout_pool::{GpuPipelineLayoutHandle, GpuPipelineLayoutPool}, resource::PoolError, shader_module_pool::{GpuShaderModuleHandle, GpuShaderModulePool}, - static_resource_pool::{ - StaticResourcePool, StaticResourcePoolAccessor, StaticResourcePoolMemMoveAccessor, - StaticResourcePoolReadLockAccessor, - }, + static_resource_pool::{StaticResourcePool, StaticResourcePoolReadLockAccessor}, }; slotmap::new_key_type! { pub struct GpuRenderPipelineHandle; } @@ -171,10 +168,7 @@ impl RenderPipelineDesc { } pub type GpuRenderPipelinePoolAccessor<'a> = - dyn StaticResourcePoolAccessor + 'a; - -pub type GpuRenderPipelinePoolMoveAccessor = - StaticResourcePoolMemMoveAccessor; + StaticResourcePoolReadLockAccessor<'a, GpuRenderPipelineHandle, wgpu::RenderPipeline>; #[derive(Default)] pub struct GpuRenderPipelinePool { @@ -256,22 +250,6 @@ impl GpuRenderPipelinePool { self.pool.resources() } - /// Takes out all resources from the pool. - /// - /// This is useful when the existing resources need to be accessed without - /// taking a lock on the pool. - /// Resource can be put with `return_resources`. - pub fn take_resources(&mut self) -> GpuRenderPipelinePoolMoveAccessor { - self.pool.take_resources() - } - - /// Counterpart to `take_resources`. - /// - /// Logs an error if resources were added to the pool since `take_resources` was called. - pub fn return_resources(&mut self, resources: GpuRenderPipelinePoolMoveAccessor) { - self.pool.return_resources(resources); - } - pub fn num_resources(&self) -> usize { self.pool.num_resources() } diff --git a/crates/viewer/re_renderer/src/wgpu_resources/static_resource_pool.rs b/crates/viewer/re_renderer/src/wgpu_resources/static_resource_pool.rs index 989bdab2a8bd..e5df9c9b0d53 100644 --- a/crates/viewer/re_renderer/src/wgpu_resources/static_resource_pool.rs +++ b/crates/viewer/re_renderer/src/wgpu_resources/static_resource_pool.rs @@ -92,31 +92,6 @@ where } } - /// Takes out all resources from the pool. - /// - /// This is useful when the existing resources need to be accessed without - /// taking a lock on the pool. - pub fn take_resources(&mut self) -> StaticResourcePoolMemMoveAccessor { - StaticResourcePoolMemMoveAccessor { - resources: std::mem::take(self.resources.get_mut()), - current_frame_index: self.current_frame_index, - } - } - - /// Counter part to `take_resources`. - /// - /// Logs an error if resources were added to the pool since `take_resources` was called. - pub fn return_resources(&mut self, resources: StaticResourcePoolMemMoveAccessor) { - let resources_added_meanwhile = - std::mem::replace(self.resources.get_mut(), resources.resources); - if !resources_added_meanwhile.is_empty() { - re_log::error!( - "{} resources were discarded because they were added to the resource pool while the resources were taken out.", - resources_added_meanwhile.len() - ); - } - } - pub fn num_resources(&self) -> usize { self.resources.read().len() } @@ -132,21 +107,14 @@ fn to_pool_error(get_result: Option, handle: impl Key) -> Result { - fn get(&self, handle: Handle) -> Result<&Res, PoolError>; -} - /// Accessor to the resource pool by taking a read lock. pub struct StaticResourcePoolReadLockAccessor<'a, Handle: Key, Res> { resources: RwLockReadGuard<'a, SlotMap>>, current_frame_index: u64, } -impl<'a, Handle: Key, Res> StaticResourcePoolAccessor - for StaticResourcePoolReadLockAccessor<'a, Handle, Res> -{ - fn get(&self, handle: Handle) -> Result<&Res, PoolError> { +impl<'a, Handle: Key, Res> StaticResourcePoolReadLockAccessor<'a, Handle, Res> { + pub fn get(&self, handle: Handle) -> Result<&Res, PoolError> { to_pool_error( self.resources.get(handle).map(|resource| { resource.statistics.last_frame_used.store( @@ -158,9 +126,7 @@ impl<'a, Handle: Key, Res> StaticResourcePoolAccessor handle, ) } -} -impl<'a, Handle: Key, Res> StaticResourcePoolReadLockAccessor<'a, Handle, Res> { pub fn get_statistics(&self, handle: Handle) -> Result<&ResourceStatistics, PoolError> { to_pool_error( self.resources @@ -171,29 +137,6 @@ impl<'a, Handle: Key, Res> StaticResourcePoolReadLockAccessor<'a, Handle, Res> { } } -/// Accessor to the resource pool by moving out the resources. -pub struct StaticResourcePoolMemMoveAccessor { - resources: SlotMap>, - current_frame_index: u64, -} - -impl StaticResourcePoolAccessor - for StaticResourcePoolMemMoveAccessor -{ - fn get(&self, handle: Handle) -> Result<&Res, PoolError> { - to_pool_error( - self.resources.get(handle).map(|resource| { - resource.statistics.last_frame_used.store( - self.current_frame_index, - std::sync::atomic::Ordering::Relaxed, - ); - &resource.resource - }), - handle, - ) - } -} - #[cfg(test)] mod tests { use std::cell::Cell; @@ -201,9 +144,7 @@ mod tests { use slotmap::Key; use super::StaticResourcePool; - use crate::wgpu_resources::{ - resource::PoolError, static_resource_pool::StaticResourcePoolAccessor as _, - }; + use crate::wgpu_resources::resource::PoolError; slotmap::new_key_type! { pub struct ConcreteHandle; } diff --git a/crates/viewer/re_renderer_examples/framework.rs b/crates/viewer/re_renderer_examples/framework.rs index f34fb77e2755..98f16fe3e4c1 100644 --- a/crates/viewer/re_renderer_examples/framework.rs +++ b/crates/viewer/re_renderer_examples/framework.rs @@ -255,9 +255,6 @@ impl Application { }); { - // Lock render pipelines for the lifetime of the composite pass. - let render_pipelines = self.re_ctx.gpu_resources.render_pipelines.resources(); - let mut composite_pass = composite_cmd_encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, @@ -283,11 +280,9 @@ impl Application { 0.0, 1.0, ); - draw_result.view_builder.composite( - &self.re_ctx, - &render_pipelines, - &mut composite_pass, - ); + draw_result + .view_builder + .composite(&self.re_ctx, &mut composite_pass); } }; diff --git a/crates/viewer/re_space_view_tensor/src/space_view_class.rs b/crates/viewer/re_space_view_tensor/src/space_view_class.rs index 8df682914cfd..3afc47498bf3 100644 --- a/crates/viewer/re_space_view_tensor/src/space_view_class.rs +++ b/crates/viewer/re_space_view_tensor/src/space_view_class.rs @@ -374,6 +374,7 @@ impl TensorSpaceView { }, minification: egui::TextureFilter::Linear, // TODO(andreas): allow for mipmapping based filter wrap_mode: egui::TextureWrapMode::ClampToEdge, + mipmap_mode: None, }; gpu_bridge::render_image( diff --git a/crates/viewer/re_viewer/src/app.rs b/crates/viewer/re_viewer/src/app.rs index 0b0afd2d2308..e270663963ec 100644 --- a/crates/viewer/re_viewer/src/app.rs +++ b/crates/viewer/re_viewer/src/app.rs @@ -910,7 +910,7 @@ impl App { .on_hover_text("Request a second layout pass. Just for testing.") .clicked() { - ui.ctx().request_discard(); + ui.ctx().request_discard("testing"); } egui::CollapsingHeader::new("egui settings") diff --git a/crates/viewer/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs b/crates/viewer/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs index 1cba5d61191f..66babf71f9ef 100644 --- a/crates/viewer/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs +++ b/crates/viewer/re_viewer_context/src/gpu_bridge/re_renderer_callback.rs @@ -48,39 +48,11 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback { } } - fn finish_prepare( + fn paint( &self, - _device: &wgpu::Device, - _queue: &wgpu::Queue, - _egui_encoder: &mut wgpu::CommandEncoder, - callback_resources: &mut egui_wgpu::CallbackResources, - ) -> Vec { - let Some(ctx) = callback_resources.get_mut::() else { - re_log::error_once!( - "Failed to execute egui prepare callback. No render context available." - ); - return Vec::new(); - }; - - // We don't own the render pass that renders the egui ui. - // But we *still* need to somehow ensure that all resources used in callbacks drawing to it, - // are longer lived than the pass itself. - // This is a bit of a conundrum since we can't store a lock guard in the callback resources. - // So instead, we work around this by moving the render pipelines out of their lock! - // TODO(gfx-rs/wgpu#1453): Future wgpu versions will lift this restriction and will allow us to remove this workaround. - if ctx.active_frame.pinned_render_pipelines.is_none() { - let render_pipelines = ctx.gpu_resources.render_pipelines.take_resources(); - ctx.active_frame.pinned_render_pipelines = Some(render_pipelines); - } - - Vec::new() - } - - fn paint<'a>( - &'a self, _info: egui::PaintCallbackInfo, - render_pass: &mut wgpu::RenderPass<'a>, - paint_callback_resources: &'a egui_wgpu::CallbackResources, + render_pass: &mut wgpu::RenderPass<'static>, + paint_callback_resources: &egui_wgpu::CallbackResources, ) { let Some(ctx) = paint_callback_resources.get::() else { // TODO(#4433): Shouldn't show up like this. @@ -89,15 +61,6 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback { ); return; }; - let Some(render_pipelines) = ctx.active_frame.pinned_render_pipelines.as_ref() else { - // TODO(#4433): Shouldn't show up like this. - re_log::error_once!( - "Failed to execute egui draw callback. Render pipelines weren't transferred out of the pool first." - ); - return; - }; - - self.view_builder - .composite(ctx, render_pipelines, render_pass); + self.view_builder.composite(ctx, render_pass); } } From b176b0538186b68184c4680b88ada6206490a645 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 25 Sep 2024 12:12:14 +0200 Subject: [PATCH 4/5] adding pixels_per_point display to debug menu --- crates/viewer/re_viewer/src/ui/rerun_menu.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/viewer/re_viewer/src/ui/rerun_menu.rs b/crates/viewer/re_viewer/src/ui/rerun_menu.rs index 7bc7d9dd9d0b..9650b42bc0bc 100644 --- a/crates/viewer/re_viewer/src/ui/rerun_menu.rs +++ b/crates/viewer/re_viewer/src/ui/rerun_menu.rs @@ -91,6 +91,10 @@ impl App { debug_menu_options_ui(ui, &mut self.state.app_options, &self.command_sender); ui.label("egui debug options:"); + ui.weak(format!( + "pixels_per_point: {:?}", + ui.ctx().pixels_per_point() + )); egui_debug_options_ui(ui); }); From e073f61c1e30a4706f379e3304703604e295ad71 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Wed, 25 Sep 2024 16:09:30 +0200 Subject: [PATCH 5/5] improve lifetime names --- crates/viewer/re_renderer/src/queueable_draw_data.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/viewer/re_renderer/src/queueable_draw_data.rs b/crates/viewer/re_renderer/src/queueable_draw_data.rs index 4e28d266a390..795068fc7011 100644 --- a/crates/viewer/re_renderer/src/queueable_draw_data.rs +++ b/crates/viewer/re_renderer/src/queueable_draw_data.rs @@ -17,11 +17,11 @@ pub enum QueueableDrawDataError { UnexpectedDrawDataType(&'static str), } -type DrawFn = dyn for<'a, 'b> Fn( +type DrawFn = dyn for<'pipelines, 'encoder> Fn( &Renderers, - &GpuRenderPipelinePoolAccessor<'a>, + &GpuRenderPipelinePoolAccessor<'pipelines>, DrawPhase, - &mut wgpu::RenderPass<'b>, + &mut wgpu::RenderPass<'encoder>, &dyn std::any::Any, ) -> Result<(), QueueableDrawDataError> + Sync