diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index a37c2718cd..c3caea189d 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -28,20 +28,20 @@ cross = ["wgc/cross"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "45f890c11c6b1251e269afa5bfdd681d409c9202" +rev = "1f9958a88f5bfd79c0f7198dafc26ecdbb07635c" features = ["raw-window-handle"] [target.'cfg(target_arch = "wasm32")'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "45f890c11c6b1251e269afa5bfdd681d409c9202" +rev = "1f9958a88f5bfd79c0f7198dafc26ecdbb07635c" features = ["raw-window-handle"] optional = true [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "45f890c11c6b1251e269afa5bfdd681d409c9202" +rev = "1f9958a88f5bfd79c0f7198dafc26ecdbb07635c" [dependencies] arrayvec = "0.5" diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 6e87583278..df0a335d77 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1883,6 +1883,28 @@ impl crate::Context for Context { } } } + + fn start_capture(&self, device: &Self::DeviceId) { + let global = &self.0; + let res = wgc::gfx_select!(device.id => global.start_capture(device.id)); + match res { + Ok(v) => v, + Err(cause) => { + self.handle_error_fatal(cause, "Device::start_capture"); + } + } + } + + fn stop_capture(&self, device: &Self::DeviceId) { + let global = &self.0; + let res = wgc::gfx_select!(device.id => global.stop_capture(device.id)); + match res { + Ok(v) => v, + Err(cause) => { + self.handle_error_fatal(cause, "Device::stop_capture"); + } + } + } } #[derive(Debug)] diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 45210b8bf1..4862949b8b 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -2021,6 +2021,10 @@ impl crate::Context for Context { fn queue_get_timestamp_period(&self, _queue: &Self::QueueId) -> f32 { 1.0 //TODO } + + fn start_capture(&self, device: &Self::DeviceId) {} + + fn stop_capture(&self, device: &Self::DeviceId) {} } pub(crate) type SwapChainOutputDetail = (); diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 5b366d4c6f..205bdd4fc6 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -179,8 +179,9 @@ trait Context: Debug + Send + Sized + Sync { type SwapChainOutputDetail: Send; type RequestAdapterFuture: Future> + Send; - type RequestDeviceFuture: Future> - + Send; + type RequestDeviceFuture: Future< + Output = Result<(Self::DeviceId, Self::QueueId), RequestDeviceError>, + > + Send; type MapAsyncFuture: Future> + Send; fn init(backends: BackendBit) -> Self; @@ -447,6 +448,10 @@ trait Context: Debug + Send + Sized + Sync { command_buffers: I, ); fn queue_get_timestamp_period(&self, queue: &Self::QueueId) -> f32; + + fn start_capture(&self, device: &Self::DeviceId); + + fn stop_capture(&self, device: &Self::DeviceId); } /// Context for all other wgpu objects. Instance of wgpu. @@ -1650,6 +1655,16 @@ impl Device { pub fn on_uncaptured_error(&self, handler: impl UncapturedErrorHandler) { self.context.device_on_uncaptured_error(&self.id, handler); } + + /// Starts frame capture. + pub fn start_capture(&self) { + Context::start_capture(&*self.context, &self.id) + } + + /// Stops frame capture. + pub fn stop_capture(&self) { + Context::stop_capture(&*self.context, &self.id) + } } impl Drop for Device {