@@ -22,7 +22,7 @@ use crate::{
2222 resource_log, track, FastHashMap , SubmissionIndex ,
2323} ;
2424
25- use hal:: { CommandEncoder as _, Device as _, Queue as _} ;
25+ use hal:: { CommandEncoder as _, Device as _, Queue as _, RawSet as _ } ;
2626use parking_lot:: Mutex ;
2727
2828use std:: {
@@ -1133,6 +1133,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
11331133 . fetch_add ( 1 , Ordering :: Relaxed )
11341134 + 1 ;
11351135 let mut active_executions = Vec :: new ( ) ;
1136+
1137+ // SAFETY: We're constructing this during the submission phase,
1138+ // where all resources it uses are guaranteed to outlive this
1139+ // short-lived set.
1140+ let mut submit_surface_textures = A :: SubmitSurfaceTextureSet :: new ( ) ;
1141+
11361142 let mut used_surface_textures = track:: TextureUsageScope :: new ( ) ;
11371143
11381144 let snatch_guard = device. snatchable_lock . read ( ) ;
@@ -1237,8 +1243,19 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
12371243 return Err ( QueueSubmitError :: DestroyedTexture ( id) ) ;
12381244 }
12391245 Some ( TextureInner :: Native { .. } ) => false ,
1240- Some ( TextureInner :: Surface { ref has_work, .. } ) => {
1246+ Some ( TextureInner :: Surface {
1247+ ref has_work,
1248+ ref raw,
1249+ ..
1250+ } ) => {
12411251 has_work. store ( true , Ordering :: Relaxed ) ;
1252+
1253+ if let Some ( raw) = raw {
1254+ unsafe {
1255+ submit_surface_textures. insert ( raw) ;
1256+ }
1257+ }
1258+
12421259 true
12431260 }
12441261 } ;
@@ -1429,8 +1446,19 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
14291446 return Err ( QueueSubmitError :: DestroyedTexture ( id) ) ;
14301447 }
14311448 Some ( TextureInner :: Native { .. } ) => { }
1432- Some ( TextureInner :: Surface { ref has_work, .. } ) => {
1449+ Some ( TextureInner :: Surface {
1450+ ref has_work,
1451+ ref raw,
1452+ ..
1453+ } ) => {
14331454 has_work. store ( true , Ordering :: Relaxed ) ;
1455+
1456+ if let Some ( raw) = raw {
1457+ unsafe {
1458+ submit_surface_textures. insert ( raw) ;
1459+ }
1460+ }
1461+
14341462 unsafe {
14351463 used_surface_textures
14361464 . merge_single ( texture, None , hal:: TextureUses :: PRESENT )
@@ -1469,12 +1497,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
14691497 . flat_map ( |pool_execution| pool_execution. cmd_buffers . iter ( ) ) ,
14701498 )
14711499 . collect :: < Vec < _ > > ( ) ;
1500+
14721501 unsafe {
14731502 queue
14741503 . raw
14751504 . as_ref ( )
14761505 . unwrap ( )
1477- . submit ( & refs, Some ( ( fence, submit_index) ) )
1506+ . submit ( & refs, & submit_surface_textures , Some ( ( fence, submit_index) ) )
14781507 . map_err ( DeviceError :: from) ?;
14791508 }
14801509
0 commit comments