835: frame capture r=kvark a=adamnemecek



Co-authored-by: adamnemecek <adamnemecek@gmail.com>
This commit is contained in:
bors[bot]
2021-04-01 20:28:21 +00:00
committed by GitHub
4 changed files with 46 additions and 5 deletions

View File

@@ -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"

View File

@@ -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)]

View File

@@ -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 = ();

View File

@@ -179,8 +179,9 @@ trait Context: Debug + Send + Sized + Sync {
type SwapChainOutputDetail: Send;
type RequestAdapterFuture: Future<Output = Option<Self::AdapterId>> + Send;
type RequestDeviceFuture: Future<Output = Result<(Self::DeviceId, Self::QueueId), RequestDeviceError>>
+ Send;
type RequestDeviceFuture: Future<
Output = Result<(Self::DeviceId, Self::QueueId), RequestDeviceError>,
> + Send;
type MapAsyncFuture: Future<Output = Result<(), BufferAsyncError>> + 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 {