755: Add Instance::poll_all r=kvark a=lachlansneff

`Instance::poll_all` polls all devices. This will be useful for integrating into the winit event loop from a third-party crate.


Co-authored-by: Lachlan Sneff <lachlan.sneff@gmail.com>
This commit is contained in:
bors[bot]andLachlan Sneff authored and GitHub committed 2021-02-11 15:52:26 +00:00
commit 229dbb3491
3 files changed
+20

No files matched your search

+8
View File
@@ -688,6 +688,14 @@ impl crate::Context for Context {
ready(id.ok())
}
fn instance_poll_all_devices(&self, force_wait: bool) {
let global = &self.0;
match global.poll_all_devices(force_wait) {
Ok(()) => (),
Err(err) => self.handle_error_fatal(err, "Device::poll"),
}
}
fn adapter_request_device(
&self,
adapter: &Self::AdapterId,
+4
View File
@@ -945,6 +945,10 @@ impl crate::Context for Context {
)
}
fn instance_poll_all_devices(&self, _force_wait: bool) {
// Devices are automatically polled.
}
fn adapter_request_device(
&self,
adapter: &Self::AdapterId,
+8
View File
@@ -197,6 +197,7 @@ trait Context: Debug + Send + Sized + Sync {
desc: &DeviceDescriptor,
trace_dir: Option<&std::path::Path>,
) -> Self::RequestDeviceFuture;
fn instance_poll_all_devices(&self, force_wait: bool);
fn adapter_get_swap_chain_preferred_format(
&self,
adapter: &Self::AdapterId,
@@ -1390,6 +1391,13 @@ impl Instance {
) -> Surface {
self.context.create_surface_from_core_animation_layer(layer)
}
/// Polls all devices.
/// If `force_wait` is true and this is not running on the web,
/// then this function will block until all in-flight buffers have been mapped.
pub fn poll_all(&self, force_wait: bool) {
self.context.instance_poll_all_devices(force_wait);
}
}
impl Adapter {