@@ -2106,19 +2106,32 @@ impl Global {
2106
2106
}
2107
2107
}
2108
2108
2109
- let ( closures, queue_empty) = {
2110
- let fence = device. fence . read ( ) ;
2111
- let fence = fence. as_ref ( ) . unwrap ( ) ;
2112
- device. maintain ( fence, maintain) ?
2113
- } ;
2109
+ let DevicePoll {
2110
+ closures,
2111
+ queue_empty,
2112
+ } = Self :: poll_single_device ( & device, maintain) ?;
2113
+
2114
+ closures. fire ( ) ;
2115
+
2116
+ Ok ( queue_empty)
2117
+ }
2118
+
2119
+ fn poll_single_device < A : HalApi > (
2120
+ device : & crate :: device:: Device < A > ,
2121
+ maintain : wgt:: Maintain < queue:: WrappedSubmissionIndex > ,
2122
+ ) -> Result < DevicePoll , WaitIdleError > {
2123
+ let fence = device. fence . read ( ) ;
2124
+ let fence = fence. as_ref ( ) . unwrap ( ) ;
2125
+ let ( closures, queue_empty) = device. maintain ( fence, maintain) ?;
2114
2126
2115
2127
// Some deferred destroys are scheduled in maintain so run this right after
2116
2128
// to avoid holding on to them until the next device poll.
2117
2129
device. deferred_resource_destruction ( ) ;
2118
2130
2119
- closures. fire ( ) ;
2120
-
2121
- Ok ( queue_empty)
2131
+ Ok ( DevicePoll {
2132
+ closures,
2133
+ queue_empty,
2134
+ } )
2122
2135
}
2123
2136
2124
2137
/// Poll all devices belonging to the backend `A`.
@@ -2145,16 +2158,15 @@ impl Global {
2145
2158
} else {
2146
2159
wgt:: Maintain :: Poll
2147
2160
} ;
2148
- let fence = device. fence . read ( ) ;
2149
- let fence = fence. as_ref ( ) . unwrap ( ) ;
2150
- let ( cbs, queue_empty) = device. maintain ( fence, maintain) ?;
2161
+
2162
+ let DevicePoll {
2163
+ closures : cbs,
2164
+ queue_empty,
2165
+ } = Self :: poll_single_device ( device, maintain) ?;
2166
+
2151
2167
all_queue_empty &= queue_empty;
2152
2168
2153
2169
closures. extend ( cbs) ;
2154
-
2155
- // Some deferred destroys are scheduled in maintain so run this right after
2156
- // to avoid holding on to them until the next device poll.
2157
- device. deferred_resource_destruction ( ) ;
2158
2170
}
2159
2171
}
2160
2172
@@ -2567,3 +2579,8 @@ impl Global {
2567
2579
buffer. unmap ( )
2568
2580
}
2569
2581
}
2582
+
2583
+ struct DevicePoll {
2584
+ closures : UserClosures ,
2585
+ queue_empty : bool ,
2586
+ }
0 commit comments