Skip to content

Commit c860a2c

Browse files
authored
Rename and unsafe start_capture -> start_graphics_debugger_capture (gfx-rs#7470)
* Improve `start_capture` docs * Docs
1 parent eea54c2 commit c860a2c

16 files changed

Lines changed: 146 additions & 44 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@ pub enum PollError {
120120
By @cwfitzgerald in [#6942](https://github.com/gfx-rs/wgpu/pull/6942).
121121
By @cwfitzgerald in [#7030](https://github.com/gfx-rs/wgpu/pull/7030).
122122
123+
#### `wgpu::Device::start_capture` renamed, documented, and made unsafe
124+
125+
```diff
126+
- device.start_capture();
127+
+ unsafe { device.start_graphics_debugger_capture() }
128+
// Your code here
129+
- device.stop_capture();
130+
+ unsafe { device.stop_graphics_debugger_capture() }
131+
```
132+
133+
There is now documentation to describe how this maps to the various debuggers' apis.
134+
135+
By @cwfitzgerald in [#7470](https://github.com/gfx-rs/wgpu/pull/7470)
136+
123137
#### Naga
124138

125139
##### Ensure loops generated by SPIR-V and HLSL Naga backends are bounded

deno_webgpu/device.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,17 @@ impl GPUDevice {
610610

611611
#[fast]
612612
fn start_capture(&self) {
613-
self.instance.device_start_capture(self.id);
613+
unsafe {
614+
self.instance
615+
.device_start_graphics_debugger_capture(self.id)
616+
};
614617
}
615618
#[fast]
616619
fn stop_capture(&self) {
617620
self.instance
618621
.device_poll(self.id, wgpu_types::PollType::wait())
619622
.unwrap();
620-
self.instance.device_stop_capture(self.id);
623+
unsafe { self.instance.device_stop_graphics_debugger_capture(self.id) };
621624
}
622625
}
623626

examples/standalone/custom_backend/src/custom.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ impl DeviceInterface for CustomDevice {
236236
unimplemented!()
237237
}
238238

239-
fn start_capture(&self) {
239+
unsafe fn start_graphics_debugger_capture(&self) {
240240
unimplemented!()
241241
}
242242

243-
fn stop_capture(&self) {
243+
unsafe fn stop_graphics_debugger_capture(&self) {
244244
unimplemented!()
245245
}
246246

player/src/bin/play.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ fn main() {
9999
log::info!("Executing actions");
100100
#[cfg(not(feature = "winit"))]
101101
{
102-
global.device_start_capture(device);
102+
unsafe { global.device_start_graphics_debugger_capture(device) };
103103

104104
while let Some(action) = actions.pop() {
105105
global.process(device, queue, action, &dir, &mut command_buffer_id_manager);
106106
}
107107

108-
global.device_stop_capture(device);
108+
unsafe { global.device_stop_graphics_debugger_capture(device) };
109109
global.device_poll(device, wgt::PollType::wait()).unwrap();
110110
}
111111
#[cfg(feature = "winit")]

wgpu-core/src/device/global.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,26 +2025,36 @@ impl Global {
20252025
Ok(all_queue_empty)
20262026
}
20272027

2028-
pub fn device_start_capture(&self, device_id: DeviceId) {
2029-
api_log!("Device::start_capture");
2028+
/// # Safety
2029+
///
2030+
/// - See [wgpu::Device::start_graphics_debugger_capture][api] for details the safety.
2031+
///
2032+
/// [api]: ../../wgpu/struct.Device.html#method.start_graphics_debugger_capture
2033+
pub unsafe fn device_start_graphics_debugger_capture(&self, device_id: DeviceId) {
2034+
api_log!("Device::start_graphics_debugger_capture");
20302035

20312036
let device = self.hub.devices.get(device_id);
20322037

20332038
if !device.is_valid() {
20342039
return;
20352040
}
2036-
unsafe { device.raw().start_capture() };
2041+
unsafe { device.raw().start_graphics_debugger_capture() };
20372042
}
20382043

2039-
pub fn device_stop_capture(&self, device_id: DeviceId) {
2040-
api_log!("Device::stop_capture");
2044+
/// # Safety
2045+
///
2046+
/// - See [wgpu::Device::stop_graphics_debugger_capture][api] for details the safety.
2047+
///
2048+
/// [api]: ../../wgpu/struct.Device.html#method.stop_graphics_debugger_capture
2049+
pub unsafe fn device_stop_graphics_debugger_capture(&self, device_id: DeviceId) {
2050+
api_log!("Device::stop_graphics_debugger_capture");
20412051

20422052
let device = self.hub.devices.get(device_id);
20432053

20442054
if !device.is_valid() {
20452055
return;
20462056
}
2047-
unsafe { device.raw().stop_capture() };
2057+
unsafe { device.raw().stop_graphics_debugger_capture() };
20482058
}
20492059

20502060
pub fn pipeline_cache_get_data(&self, id: id::PipelineCacheId) -> Option<Vec<u8>> {

wgpu-hal/src/dx12/device.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ impl crate::Device for super::Device {
21122112
}
21132113
}
21142114

2115-
unsafe fn start_capture(&self) -> bool {
2115+
unsafe fn start_graphics_debugger_capture(&self) -> bool {
21162116
#[cfg(feature = "renderdoc")]
21172117
{
21182118
unsafe {
@@ -2124,7 +2124,7 @@ impl crate::Device for super::Device {
21242124
false
21252125
}
21262126

2127-
unsafe fn stop_capture(&self) {
2127+
unsafe fn stop_graphics_debugger_capture(&self) {
21282128
#[cfg(feature = "renderdoc")]
21292129
unsafe {
21302130
self.render_doc

wgpu-hal/src/dynamic/device.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ pub trait DynDevice: DynResource {
146146
timeout_ms: u32,
147147
) -> Result<bool, DeviceError>;
148148

149-
unsafe fn start_capture(&self) -> bool;
150-
unsafe fn stop_capture(&self);
149+
unsafe fn start_graphics_debugger_capture(&self) -> bool;
150+
unsafe fn stop_graphics_debugger_capture(&self);
151151

152152
unsafe fn pipeline_cache_get_data(&self, cache: &dyn DynPipelineCache) -> Option<Vec<u8>>;
153153

@@ -504,12 +504,12 @@ impl<D: Device + DynResource> DynDevice for D {
504504
unsafe { D::wait(self, fence, value, timeout_ms) }
505505
}
506506

507-
unsafe fn start_capture(&self) -> bool {
508-
unsafe { D::start_capture(self) }
507+
unsafe fn start_graphics_debugger_capture(&self) -> bool {
508+
unsafe { D::start_graphics_debugger_capture(self) }
509509
}
510510

511-
unsafe fn stop_capture(&self) {
512-
unsafe { D::stop_capture(self) }
511+
unsafe fn stop_graphics_debugger_capture(&self) {
512+
unsafe { D::stop_graphics_debugger_capture(self) }
513513
}
514514

515515
unsafe fn pipeline_cache_get_data(&self, cache: &dyn DynPipelineCache) -> Option<Vec<u8>> {

wgpu-hal/src/gles/device.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ impl crate::Device for super::Device {
15721572
fence.wait(gl, wait_value, timeout_ns)
15731573
}
15741574

1575-
unsafe fn start_capture(&self) -> bool {
1575+
unsafe fn start_graphics_debugger_capture(&self) -> bool {
15761576
#[cfg(all(native, feature = "renderdoc"))]
15771577
return unsafe {
15781578
self.render_doc
@@ -1581,7 +1581,7 @@ impl crate::Device for super::Device {
15811581
#[allow(unreachable_code)]
15821582
false
15831583
}
1584-
unsafe fn stop_capture(&self) {
1584+
unsafe fn stop_graphics_debugger_capture(&self) {
15851585
#[cfg(all(native, feature = "renderdoc"))]
15861586
unsafe {
15871587
self.render_doc

wgpu-hal/src/lib.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,23 @@ pub trait Device: WasmNotSendSync {
971971
timeout_ms: u32,
972972
) -> Result<bool, DeviceError>;
973973

974-
unsafe fn start_capture(&self) -> bool;
975-
unsafe fn stop_capture(&self);
974+
/// Start a graphics debugger capture.
975+
///
976+
/// # Safety
977+
///
978+
/// See [`wgpu::Device::start_graphics_debugger_capture`][api] for more details.
979+
///
980+
/// [api]: ../wgpu/struct.Device.html#method.start_graphics_debugger_capture
981+
unsafe fn start_graphics_debugger_capture(&self) -> bool;
982+
983+
/// Stop a graphics debugger capture.
984+
///
985+
/// # Safety
986+
///
987+
/// See [`wgpu::Device::stop_graphics_debugger_capture`][api] for more details.
988+
///
989+
/// [api]: ../wgpu/struct.Device.html#method.stop_graphics_debugger_capture
990+
unsafe fn stop_graphics_debugger_capture(&self);
976991

977992
#[allow(unused_variables)]
978993
unsafe fn pipeline_cache_get_data(

wgpu-hal/src/metal/device.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ impl crate::Device for super::Device {
14911491
}
14921492
}
14931493

1494-
unsafe fn start_capture(&self) -> bool {
1494+
unsafe fn start_graphics_debugger_capture(&self) -> bool {
14951495
if !self.shared.private_caps.supports_capture_manager {
14961496
return false;
14971497
}
@@ -1503,7 +1503,8 @@ impl crate::Device for super::Device {
15031503
default_capture_scope.begin_scope();
15041504
true
15051505
}
1506-
unsafe fn stop_capture(&self) {
1506+
1507+
unsafe fn stop_graphics_debugger_capture(&self) {
15071508
let shared_capture_manager = metal::CaptureManager::shared();
15081509
if let Some(default_capture_scope) = shared_capture_manager.default_capture_scope() {
15091510
default_capture_scope.end_scope();

0 commit comments

Comments
 (0)