@@ -35,9 +35,10 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
35
35
Loading ,
36
36
Ready {
37
37
window : Arc < winit:: window:: Window > ,
38
+ queue : wgpu:: Queue ,
39
+ device : wgpu:: Device ,
38
40
surface : wgpu:: Surface < ' static > ,
39
41
format : wgpu:: TextureFormat ,
40
- device : wgpu:: Device ,
41
42
renderer : Renderer ,
42
43
scene : Scene ,
43
44
state : program:: State < Controls > ,
@@ -143,10 +144,18 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
143
144
144
145
// Initialize iced
145
146
let mut debug = Debug :: new ( ) ;
146
- let engine =
147
- Engine :: new ( & adapter, device. clone ( ) , queue, format, None ) ;
148
- let mut renderer =
149
- Renderer :: new ( engine, Font :: default ( ) , Pixels :: from ( 16 ) ) ;
147
+
148
+ let mut renderer = {
149
+ let engine = Engine :: new (
150
+ & adapter,
151
+ device. clone ( ) ,
152
+ queue. clone ( ) ,
153
+ format,
154
+ None ,
155
+ ) ;
156
+
157
+ Renderer :: new ( engine, Font :: default ( ) , Pixels :: from ( 16 ) )
158
+ } ;
150
159
151
160
let state = program:: State :: new (
152
161
controls,
@@ -160,10 +169,11 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
160
169
161
170
* self = Self :: Ready {
162
171
window,
163
- surface,
164
- format,
165
172
device,
173
+ queue,
166
174
renderer,
175
+ surface,
176
+ format,
167
177
scene,
168
178
state,
169
179
cursor_position : None ,
@@ -185,6 +195,7 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
185
195
let Self :: Ready {
186
196
window,
187
197
device,
198
+ queue,
188
199
surface,
189
200
format,
190
201
renderer,
@@ -230,18 +241,18 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
230
241
231
242
match surface. get_current_texture ( ) {
232
243
Ok ( frame) => {
233
- let mut encoder = device. create_command_encoder (
234
- & wgpu:: CommandEncoderDescriptor { label : None } ,
235
- ) ;
236
-
237
244
let program = state. program ( ) ;
238
245
239
246
let view = frame. texture . create_view (
240
247
& wgpu:: TextureViewDescriptor :: default ( ) ,
241
248
) ;
242
249
250
+ let mut encoder = device. create_command_encoder (
251
+ & wgpu:: CommandEncoderDescriptor { label : None } ,
252
+ ) ;
253
+
243
254
{
244
- // We clear the frame
255
+ // Clear the frame
245
256
let mut render_pass = Scene :: clear (
246
257
& view,
247
258
& mut encoder,
@@ -252,7 +263,10 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
252
263
scene. draw ( & mut render_pass) ;
253
264
}
254
265
255
- // And then iced on top
266
+ // Submit the scene
267
+ queue. submit ( [ encoder. finish ( ) ] ) ;
268
+
269
+ // Draw iced on top
256
270
renderer. present (
257
271
None ,
258
272
frame. texture . format ( ) ,
@@ -261,7 +275,7 @@ pub fn main() -> Result<(), winit::error::EventLoopError> {
261
275
& debug. overlay ( ) ,
262
276
) ;
263
277
264
- // Then we submit the work
278
+ // Present the frame
265
279
frame. present ( ) ;
266
280
267
281
// Update the mouse cursor
0 commit comments