From cd27dae8abdecc5ff751e1e201ade79bc6b8e23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 3 Apr 2025 20:36:30 +0200 Subject: [PATCH] Fix submission in `integration` example --- examples/integration/src/main.rs | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 6c6cb120..025971a4 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -35,9 +35,10 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { Loading, Ready { window: Arc, + queue: wgpu::Queue, + device: wgpu::Device, surface: wgpu::Surface<'static>, format: wgpu::TextureFormat, - device: wgpu::Device, renderer: Renderer, scene: Scene, state: program::State, @@ -143,10 +144,18 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { // Initialize iced let mut debug = Debug::new(); - let engine = - Engine::new(&adapter, device.clone(), queue, format, None); - let mut renderer = - Renderer::new(engine, Font::default(), Pixels::from(16)); + + let mut renderer = { + let engine = Engine::new( + &adapter, + device.clone(), + queue.clone(), + format, + None, + ); + + Renderer::new(engine, Font::default(), Pixels::from(16)) + }; let state = program::State::new( controls, @@ -160,10 +169,11 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { *self = Self::Ready { window, + device, + queue, + renderer, surface, format, - device, - renderer, scene, state, cursor_position: None, @@ -185,6 +195,7 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { let Self::Ready { window, device, + queue, surface, format, renderer, @@ -230,18 +241,18 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { match surface.get_current_texture() { Ok(frame) => { - let mut encoder = device.create_command_encoder( - &wgpu::CommandEncoderDescriptor { label: None }, - ); - let program = state.program(); let view = frame.texture.create_view( &wgpu::TextureViewDescriptor::default(), ); + let mut encoder = device.create_command_encoder( + &wgpu::CommandEncoderDescriptor { label: None }, + ); + { - // We clear the frame + // Clear the frame let mut render_pass = Scene::clear( &view, &mut encoder, @@ -252,7 +263,10 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { scene.draw(&mut render_pass); } - // And then iced on top + // Submit the scene + queue.submit([encoder.finish()]); + + // Draw iced on top renderer.present( None, frame.texture.format(), @@ -261,7 +275,7 @@ pub fn main() -> Result<(), winit::error::EventLoopError> { &debug.overlay(), ); - // Then we submit the work + // Present the frame frame.present(); // Update the mouse cursor