Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove log spam when quickly resizing the viewer #5189

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions crates/re_renderer/src/view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,11 @@ impl ViewBuilder {
}
}

/// Resolution in pixels as configured on view builder creation.
pub fn resolution_in_pixel(&self) -> [u32; 2] {
self.setup.resolution_in_pixel
}

fn draw_phase<'a>(
&'a self,
renderers: &Renderers,
Expand Down Expand Up @@ -787,19 +792,9 @@ impl ViewBuilder {
ctx: &RenderContext,
render_pipelines: &'a GpuRenderPipelinePoolAccessor<'a>,
pass: &mut wgpu::RenderPass<'a>,
screen_position: glam::Vec2,
) {
re_tracing::profile_function!();

pass.set_viewport(
screen_position.x,
screen_position.y,
self.setup.resolution_in_pixel[0] as f32,
self.setup.resolution_in_pixel[1] as f32,
0.0,
1.0,
);

pass.set_bind_group(0, &self.setup.bind_group_0, &[]);
self.draw_phase(
&ctx.read_lock_renderers(),
Expand Down
12 changes: 9 additions & 3 deletions crates/re_renderer_examples/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ impl<E: Example + 'static> Application<E> {
&wgpu::DeviceDescriptor {
label: None,
required_features: wgpu::Features::empty(),
required_limits: wgpu::Limits::downlevel_webgl2_defaults()
.using_resolution(adapter.limits()),
required_limits: device_caps.limits(),
},
None,
)
Expand Down Expand Up @@ -295,11 +294,18 @@ impl<E: Example + 'static> Application<E> {
);

for draw_result in &draw_results {
composite_pass.set_viewport(
draw_result.target_location.x,
draw_result.target_location.y,
draw_result.view_builder.resolution_in_pixel()[0] as f32,
draw_result.view_builder.resolution_in_pixel()[1] as f32,
0.0,
1.0,
);
draw_result.view_builder.composite(
&self.re_ctx,
&render_pipelines,
&mut composite_pass,
draw_result.target_location,
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {

fn paint<'a>(
&'a self,
info: egui::PaintCallbackInfo,
_info: egui::PaintCallbackInfo,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the viewport coming from egui was somehow wrong?
Is this a bug in an egui crate?

Copy link
Member Author

@Wumpf Wumpf Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we only passed on the viewport offset from egui, not the viewport size. We then assumed the size was what we had previously on the viewbuilder and set a new viewport accordingly. In rare cases it turned out that this size + the offset from egui caused us to set an invalid viewport (after egui already set a correct one).

... which come to think means that the viewbuilder got an outdated size! This is concerning but I reckon this can easily happen though when new sizes come in asynchronously; to nail this down perfectly we'd need to know when egui queries the size that leads to the final renderpass.
This PR instead just trusts egui with the viewport setting, after all egui also set up the renderpass and knows what a valid viewport is for that renderpass.

render_pass: &mut wgpu::RenderPass<'a>,
paint_callback_resources: &'a egui_wgpu::CallbackResources,
) {
Expand All @@ -97,10 +97,7 @@ impl egui_wgpu::CallbackTrait for ReRendererCallback {
return;
};

let screen_position = (info.viewport.min.to_vec2() * info.pixels_per_point).round();
let screen_position = glam::vec2(screen_position.x, screen_position.y);

self.view_builder
.composite(ctx, render_pipelines, render_pass, screen_position);
.composite(ctx, render_pipelines, render_pass);
}
}
Loading