mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
Clean up device poll API
This commit is contained in:
1 parent
07ce023cf1
commit
1be2ce6190
5 files changed
+23
-15
No files matched your search
@@ -125,9 +125,7 @@ fn main() {
|
||||
}
|
||||
|
||||
unsafe { global.device_stop_graphics_debugger_capture(device) };
|
||||
let (user_closures, result) = device.poll(wgt::PollType::wait_indefinitely());
|
||||
user_closures.fire();
|
||||
result.unwrap();
|
||||
device.poll(wgt::PollType::wait_indefinitely()).unwrap();
|
||||
}
|
||||
#[cfg(feature = "winit")]
|
||||
{
|
||||
@@ -212,10 +210,7 @@ fn main() {
|
||||
},
|
||||
Event::LoopExiting => {
|
||||
log::info!("Closing");
|
||||
let (user_closures, result) =
|
||||
device.poll(wgt::PollType::wait_indefinitely());
|
||||
user_closures.fire();
|
||||
result.unwrap();
|
||||
device.poll(wgt::PollType::wait_indefinitely()).unwrap();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -116,12 +116,11 @@ impl Test<'_> {
|
||||
}
|
||||
|
||||
println!("\t\t\tWaiting...");
|
||||
let (user_closures, result) = device.poll(wgt::PollType::Wait {
|
||||
device.poll(wgt::PollType::Wait {
|
||||
submission_index: None,
|
||||
timeout: Some(std::time::Duration::from_secs(1)), // Tests really shouldn't need longer than that!
|
||||
});
|
||||
user_closures.fire();
|
||||
result.unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
for expect in self.expectations {
|
||||
println!("\t\t\tChecking {}", expect.name);
|
||||
|
||||
@@ -1792,7 +1792,7 @@ impl Global {
|
||||
|
||||
let device = self.hub.devices.get(device_id);
|
||||
|
||||
let (closures, result) = device.poll(poll_type);
|
||||
let (closures, result) = device.poll_and_return_closures(poll_type);
|
||||
|
||||
closures.fire();
|
||||
|
||||
@@ -1825,7 +1825,7 @@ impl Global {
|
||||
wgt::PollType::Poll
|
||||
};
|
||||
|
||||
let (closures, result) = device.poll(poll_type);
|
||||
let (closures, result) = device.poll_and_return_closures(poll_type);
|
||||
|
||||
let is_queue_empty = matches!(result, Ok(wgt::PollStatus::QueueEmpty));
|
||||
|
||||
|
||||
@@ -174,8 +174,7 @@ impl UserClosures {
|
||||
.extend(other.device_lost_invocations);
|
||||
}
|
||||
|
||||
/// Not a public API. For use by `player` only.
|
||||
pub fn fire(self) {
|
||||
fn fire(self) {
|
||||
// Note: this logic is specifically moved out of `handle_mapping()` in order to
|
||||
// have nothing locked by the time we execute users callback code.
|
||||
|
||||
|
||||
@@ -715,6 +715,21 @@ impl Device {
|
||||
pub fn poll(
|
||||
&self,
|
||||
poll_type: wgt::PollType<crate::SubmissionIndex>,
|
||||
) -> Result<wgt::PollStatus, WaitIdleError> {
|
||||
let (user_closures, result) = self.poll_and_return_closures(poll_type);
|
||||
user_closures.fire();
|
||||
result
|
||||
}
|
||||
|
||||
/// Poll the device, returning any `UserClosures` that need to be executed.
|
||||
///
|
||||
/// The caller must invoke the `UserClosures` even if this function returns
|
||||
/// an error. This is an internal helper, used by `Device::poll` and
|
||||
/// `Global::poll_all_devices`, so that `poll_all_devices` can invoke
|
||||
/// closures once after all devices have been polled.
|
||||
pub(crate) fn poll_and_return_closures(
|
||||
&self,
|
||||
poll_type: wgt::PollType<crate::SubmissionIndex>,
|
||||
) -> (UserClosures, Result<wgt::PollStatus, WaitIdleError>) {
|
||||
let snatch_guard = self.snatchable_lock.read();
|
||||
let fence = self.fence.read();
|
||||
|
||||
Reference in new issue
Block a user