Skip to content

Commit 2d7c52c

Browse files
committed
fix unnecessary bind group recreation during viewport panning
1 parent dfba7f9 commit 2d7c52c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

  • desktop/src/render
  • node-graph/libraries/wgpu-executor/src

desktop/src/render/state.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,20 @@ impl RenderState {
236236
return;
237237
};
238238
let size = glam::UVec2::new(viewport_texture.width(), viewport_texture.height());
239+
240+
// Track whether the overlay texture is newly created or resized, since only then does the bind group need updating
241+
let old_texture_size = self.overlays_texture.as_ref().map(|t| t.size());
242+
239243
let result = futures::executor::block_on(self.executor.render_vello_scene_to_target_texture(&scene, size, &Default::default(), None, &mut self.overlays_texture));
240244
if let Err(e) = result {
241245
tracing::error!("Error rendering overlays: {:?}", e);
242246
return;
243247
}
244-
self.update_bindgroup();
248+
249+
let new_texture_size = self.overlays_texture.as_ref().map(|t| t.size());
250+
if old_texture_size != new_texture_size {
251+
self.update_bindgroup();
252+
}
245253
}
246254

247255
pub(crate) fn render(&mut self, window: &Window) -> Result<(), RenderError> {

node-graph/libraries/wgpu-executor/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ impl TargetTexture {
9898
&self.view
9999
}
100100

101+
/// Returns the size of the texture.
102+
pub fn size(&self) -> UVec2 {
103+
self.size
104+
}
105+
101106
/// Returns a reference to the underlying texture.
102107
pub fn texture(&self) -> &wgpu::Texture {
103108
&self.texture

0 commit comments

Comments
 (0)