@@ -172,10 +172,10 @@ impl CommandEncoder {
172
172
/// [l]: CommandEncoder::list
173
173
/// [`transition_buffers`]: hal::CommandEncoder::transition_buffers
174
174
/// [`transition_textures`]: hal::CommandEncoder::transition_textures
175
- fn close_and_swap ( & mut self ) -> Result < ( ) , DeviceError > {
175
+ fn close_and_swap ( & mut self , device : & Device ) -> Result < ( ) , DeviceError > {
176
176
if self . is_open {
177
177
self . is_open = false ;
178
- let new = unsafe { self . raw . end_encoding ( ) ? } ;
178
+ let new = unsafe { self . raw . end_encoding ( ) } . map_err ( |e| device . handle_hal_error ( e ) ) ? ;
179
179
self . list . insert ( self . list . len ( ) - 1 , new) ;
180
180
}
181
181
@@ -192,10 +192,11 @@ impl CommandEncoder {
192
192
/// On return, the underlying hal encoder is closed.
193
193
///
194
194
/// [l]: CommandEncoder::list
195
- fn close ( & mut self ) -> Result < ( ) , DeviceError > {
195
+ fn close ( & mut self , device : & Device ) -> Result < ( ) , DeviceError > {
196
196
if self . is_open {
197
197
self . is_open = false ;
198
- let cmd_buf = unsafe { self . raw . end_encoding ( ) ? } ;
198
+ let cmd_buf =
199
+ unsafe { self . raw . end_encoding ( ) } . map_err ( |e| device. handle_hal_error ( e) ) ?;
199
200
self . list . push ( cmd_buf) ;
200
201
}
201
202
@@ -215,11 +216,15 @@ impl CommandEncoder {
215
216
/// Begin recording a new command buffer, if we haven't already.
216
217
///
217
218
/// The underlying hal encoder is put in the "recording" state.
218
- pub ( crate ) fn open ( & mut self ) -> Result < & mut dyn hal:: DynCommandEncoder , DeviceError > {
219
+ pub ( crate ) fn open (
220
+ & mut self ,
221
+ device : & Device ,
222
+ ) -> Result < & mut dyn hal:: DynCommandEncoder , DeviceError > {
219
223
if !self . is_open {
220
224
self . is_open = true ;
221
225
let hal_label = self . hal_label . as_deref ( ) ;
222
- unsafe { self . raw . begin_encoding ( hal_label) ? } ;
226
+ unsafe { self . raw . begin_encoding ( hal_label) }
227
+ . map_err ( |e| device. handle_hal_error ( e) ) ?;
223
228
}
224
229
225
230
Ok ( self . raw . as_mut ( ) )
@@ -229,9 +234,9 @@ impl CommandEncoder {
229
234
/// its own label.
230
235
///
231
236
/// The underlying hal encoder is put in the "recording" state.
232
- fn open_pass ( & mut self , hal_label : Option < & str > ) -> Result < ( ) , DeviceError > {
237
+ fn open_pass ( & mut self , hal_label : Option < & str > , device : & Device ) -> Result < ( ) , DeviceError > {
233
238
self . is_open = true ;
234
- unsafe { self . raw . begin_encoding ( hal_label) ? } ;
239
+ unsafe { self . raw . begin_encoding ( hal_label) } . map_err ( |e| device . handle_hal_error ( e ) ) ? ;
235
240
236
241
Ok ( ( ) )
237
242
}
@@ -276,8 +281,9 @@ pub struct CommandBufferMutable {
276
281
impl CommandBufferMutable {
277
282
pub ( crate ) fn open_encoder_and_tracker (
278
283
& mut self ,
284
+ device : & Device ,
279
285
) -> Result < ( & mut dyn hal:: DynCommandEncoder , & mut Tracker ) , DeviceError > {
280
- let encoder = self . encoder . open ( ) ?;
286
+ let encoder = self . encoder . open ( device ) ?;
281
287
let tracker = & mut self . trackers ;
282
288
283
289
Ok ( ( encoder, tracker) )
@@ -621,7 +627,7 @@ impl Global {
621
627
let cmd_buf_data = cmd_buf_data. as_mut ( ) . unwrap ( ) ;
622
628
match cmd_buf_data. status {
623
629
CommandEncoderStatus :: Recording => {
624
- if let Err ( e) = cmd_buf_data. encoder . close ( ) {
630
+ if let Err ( e) = cmd_buf_data. encoder . close ( & cmd_buf . device ) {
625
631
Some ( e. into ( ) )
626
632
} else {
627
633
cmd_buf_data. status = CommandEncoderStatus :: Finished ;
@@ -671,7 +677,7 @@ impl Global {
671
677
list. push ( TraceCommand :: PushDebugGroup ( label. to_string ( ) ) ) ;
672
678
}
673
679
674
- let cmd_buf_raw = cmd_buf_data. encoder . open ( ) ?;
680
+ let cmd_buf_raw = cmd_buf_data. encoder . open ( & cmd_buf . device ) ?;
675
681
if !self
676
682
. instance
677
683
. flags
@@ -713,7 +719,7 @@ impl Global {
713
719
. flags
714
720
. contains ( wgt:: InstanceFlags :: DISCARD_HAL_LABELS )
715
721
{
716
- let cmd_buf_raw = cmd_buf_data. encoder . open ( ) ?;
722
+ let cmd_buf_raw = cmd_buf_data. encoder . open ( & cmd_buf . device ) ?;
717
723
unsafe {
718
724
cmd_buf_raw. insert_debug_marker ( label) ;
719
725
}
@@ -744,7 +750,7 @@ impl Global {
744
750
list. push ( TraceCommand :: PopDebugGroup ) ;
745
751
}
746
752
747
- let cmd_buf_raw = cmd_buf_data. encoder . open ( ) ?;
753
+ let cmd_buf_raw = cmd_buf_data. encoder . open ( & cmd_buf . device ) ?;
748
754
if !self
749
755
. instance
750
756
. flags
0 commit comments