@@ -1027,11 +1027,13 @@ impl Global {
1027
1027
& self ,
1028
1028
queue_id : QueueId ,
1029
1029
command_buffer_ids : & [ id:: CommandBufferId ] ,
1030
- ) -> Result < SubmissionIndex , QueueSubmitError > {
1030
+ ) -> Result < SubmissionIndex , ( SubmissionIndex , QueueSubmitError ) > {
1031
1031
profiling:: scope!( "Queue::submit" ) ;
1032
1032
api_log ! ( "Queue::submit {queue_id:?}" ) ;
1033
1033
1034
- let ( submit_index, callbacks) = {
1034
+ let submit_index;
1035
+
1036
+ let res = ' error: {
1035
1037
let hub = & self . hub ;
1036
1038
1037
1039
let queue = hub. queues . get ( queue_id) ;
@@ -1042,7 +1044,7 @@ impl Global {
1042
1044
1043
1045
// Fence lock must be acquired after the snatch lock everywhere to avoid deadlocks.
1044
1046
let mut fence = device. fence . write ( ) ;
1045
- let submit_index = device
1047
+ submit_index = device
1046
1048
. active_submission_index
1047
1049
. fetch_add ( 1 , Ordering :: SeqCst )
1048
1050
+ 1 ;
@@ -1119,18 +1121,29 @@ impl Global {
1119
1121
}
1120
1122
1121
1123
// execute resource transitions
1122
- unsafe {
1124
+ if let Err ( e ) = unsafe {
1123
1125
baked. encoder . begin_encoding ( hal_label (
1124
1126
Some ( "(wgpu internal) Transit" ) ,
1125
1127
device. instance_flags ,
1126
1128
) )
1127
1129
}
1128
- . map_err ( |e| device. handle_hal_error ( e) ) ?;
1130
+ . map_err ( |e| device. handle_hal_error ( e) )
1131
+ {
1132
+ break ' error Err ( e. into ( ) ) ;
1133
+ }
1129
1134
1130
1135
//Note: locking the trackers has to be done after the storages
1131
1136
let mut trackers = device. trackers . lock ( ) ;
1132
- baked. initialize_buffer_memory ( & mut trackers, & snatch_guard) ?;
1133
- baked. initialize_texture_memory ( & mut trackers, device, & snatch_guard) ?;
1137
+ if let Err ( e) = baked. initialize_buffer_memory ( & mut trackers, & snatch_guard)
1138
+ {
1139
+ break ' error Err ( e. into ( ) ) ;
1140
+ }
1141
+ if let Err ( e) =
1142
+ baked. initialize_texture_memory ( & mut trackers, device, & snatch_guard)
1143
+ {
1144
+ break ' error Err ( e. into ( ) ) ;
1145
+ }
1146
+
1134
1147
//Note: stateless trackers are not merged:
1135
1148
// device already knows these resources exist.
1136
1149
CommandBuffer :: insert_barriers_from_device_tracker (
@@ -1147,13 +1160,16 @@ impl Global {
1147
1160
// Note: we could technically do it after all of the command buffers,
1148
1161
// but here we have a command encoder by hand, so it's easier to use it.
1149
1162
if !used_surface_textures. is_empty ( ) {
1150
- unsafe {
1163
+ if let Err ( e ) = unsafe {
1151
1164
baked. encoder . begin_encoding ( hal_label (
1152
1165
Some ( "(wgpu internal) Present" ) ,
1153
1166
device. instance_flags ,
1154
1167
) )
1155
1168
}
1156
- . map_err ( |e| device. handle_hal_error ( e) ) ?;
1169
+ . map_err ( |e| device. handle_hal_error ( e) )
1170
+ {
1171
+ break ' error Err ( e. into ( ) ) ;
1172
+ }
1157
1173
let texture_barriers = trackers
1158
1174
. textures
1159
1175
. set_from_usage_scope_and_drain_transitions (
@@ -1180,7 +1196,7 @@ impl Global {
1180
1196
}
1181
1197
1182
1198
if let Some ( first_error) = first_error {
1183
- return Err ( first_error) ;
1199
+ break ' error Err ( first_error) ;
1184
1200
}
1185
1201
}
1186
1202
}
@@ -1190,9 +1206,9 @@ impl Global {
1190
1206
{
1191
1207
used_surface_textures. set_size ( hub. textures . read ( ) . len ( ) ) ;
1192
1208
for texture in pending_writes. dst_textures . values ( ) {
1193
- match texture. try_inner ( & snatch_guard) ? {
1194
- TextureInner :: Native { .. } => { }
1195
- TextureInner :: Surface { .. } => {
1209
+ match texture. try_inner ( & snatch_guard) {
1210
+ Ok ( TextureInner :: Native { .. } ) => { }
1211
+ Ok ( TextureInner :: Surface { .. } ) => {
1196
1212
// Compare the Arcs by pointer as Textures don't implement Eq
1197
1213
submit_surface_textures_owned
1198
1214
. insert ( Arc :: as_ptr ( texture) , texture. clone ( ) ) ;
@@ -1203,6 +1219,7 @@ impl Global {
1203
1219
. unwrap ( )
1204
1220
} ;
1205
1221
}
1222
+ Err ( e) => break ' error Err ( e. into ( ) ) ,
1206
1223
}
1207
1224
}
1208
1225
@@ -1224,10 +1241,12 @@ impl Global {
1224
1241
}
1225
1242
}
1226
1243
1227
- if let Some ( pending_execution) =
1228
- pending_writes. pre_submit ( & device. command_allocator , device, & queue) ?
1229
- {
1230
- active_executions. insert ( 0 , pending_execution) ;
1244
+ match pending_writes. pre_submit ( & device. command_allocator , device, & queue) {
1245
+ Ok ( Some ( pending_execution) ) => {
1246
+ active_executions. insert ( 0 , pending_execution) ;
1247
+ }
1248
+ Ok ( None ) => { }
1249
+ Err ( e) => break ' error Err ( e. into ( ) ) ,
1231
1250
}
1232
1251
1233
1252
let hal_command_buffers = active_executions
@@ -1249,14 +1268,17 @@ impl Global {
1249
1268
submit_surface_textures. push ( raw) ;
1250
1269
}
1251
1270
1252
- unsafe {
1271
+ if let Err ( e ) = unsafe {
1253
1272
queue. raw ( ) . submit (
1254
1273
& hal_command_buffers,
1255
1274
& submit_surface_textures,
1256
1275
( fence. as_mut ( ) , submit_index) ,
1257
1276
)
1258
1277
}
1259
- . map_err ( |e| device. handle_hal_error ( e) ) ?;
1278
+ . map_err ( |e| device. handle_hal_error ( e) )
1279
+ {
1280
+ break ' error Err ( e. into ( ) ) ;
1281
+ }
1260
1282
1261
1283
// Advance the successful submission index.
1262
1284
device
@@ -1280,12 +1302,19 @@ impl Global {
1280
1302
let ( closures, _) =
1281
1303
match device. maintain ( fence_guard, wgt:: Maintain :: Poll , snatch_guard) {
1282
1304
Ok ( closures) => closures,
1283
- Err ( WaitIdleError :: Device ( err) ) => return Err ( QueueSubmitError :: Queue ( err) ) ,
1284
- Err ( WaitIdleError :: StuckGpu ) => return Err ( QueueSubmitError :: StuckGpu ) ,
1305
+ Err ( WaitIdleError :: Device ( err) ) => {
1306
+ break ' error Err ( QueueSubmitError :: Queue ( err) )
1307
+ }
1308
+ Err ( WaitIdleError :: StuckGpu ) => break ' error Err ( QueueSubmitError :: StuckGpu ) ,
1285
1309
Err ( WaitIdleError :: WrongSubmissionIndex ( ..) ) => unreachable ! ( ) ,
1286
1310
} ;
1287
1311
1288
- ( submit_index, closures)
1312
+ Ok ( closures)
1313
+ } ;
1314
+
1315
+ let callbacks = match res {
1316
+ Ok ( ok) => ok,
1317
+ Err ( e) => return Err ( ( submit_index, e) ) ,
1289
1318
} ;
1290
1319
1291
1320
// the closures should execute with nothing locked!
0 commit comments