Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type issues in CaptureDescriptor and CaptureManager, add documentation #258

Merged
merged 2 commits into from
Mar 12, 2023
Merged

Fix type issues in CaptureDescriptor and CaptureManager, add documentation #258

merged 2 commits into from
Mar 12, 2023

Conversation

finnvoor
Copy link
Contributor

@finnvoor finnvoor commented Mar 6, 2023

These issues were causing a panic both when setting a CaptureDescriptor outputURL and when starting a capture using a CaptureDescriptor.


Example usage in a wgpu/winit program

// create capture scope using wgpu device
let capture_scope = unsafe {
    device.as_hal::<api::Metal, _, _>(|device| {
        let raw_device = device.unwrap().raw_device().lock();
        metal::CaptureManager::shared().new_capture_scope_with_device(&raw_device)
    })
};
let capture_scope = metal::CaptureManager::shared()
    .new_capture_scope_with_device(&metal::Device::system_default().unwrap());

// inside event loop
Event::RedrawRequested(_) => {
    capture_scope.begin_scope();
    // render work
    capture_scope.end_scope();
}

// when you want to capture a frame to a trace file
let capture_descriptor = metal::CaptureDescriptor::new();
capture_descriptor.set_capture_scope(&capture_scope);
capture_descriptor.set_output_url(std::path::Path::new(
    "~/.../.../framecapture.gputrace",
));
capture_descriptor.set_destination(metal::MTLCaptureDestination::GpuTraceDocument);
metal::CaptureManager::shared().start_capture(&capture_descriptor);
window.request_redraw();

guide/debugging-in-xcode/README.md Show resolved Hide resolved
@kvark kvark enabled auto-merge (rebase) March 12, 2023 01:57
@kvark kvark merged commit bbb1803 into gfx-rs:master Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants