ash/extensions/nv/
device_diagnostic_checkpoints.rs1use crate::vk;
2use crate::{Device, Instance};
3use std::ffi::CStr;
4use std::mem;
5use std::os::raw::c_void;
6
7#[derive(Clone)]
9pub struct DeviceDiagnosticCheckpoints {
10 fp: vk::NvDeviceDiagnosticCheckpointsFn,
11}
12
13impl DeviceDiagnosticCheckpoints {
14 pub fn new(instance: &Instance, device: &Device) -> Self {
15 let fp = vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe {
16 mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
17 });
18 Self { fp }
19 }
20
21 pub unsafe fn cmd_set_checkpoint(
23 &self,
24 command_buffer: vk::CommandBuffer,
25 p_checkpoint_marker: *const c_void,
26 ) {
27 (self.fp.cmd_set_checkpoint_nv)(command_buffer, p_checkpoint_marker);
28 }
29
30 pub unsafe fn get_queue_checkpoint_data_len(&self, queue: vk::Queue) -> usize {
32 let mut count = 0;
33 (self.fp.get_queue_checkpoint_data_nv)(queue, &mut count, std::ptr::null_mut());
34 count as usize
35 }
36
37 pub unsafe fn get_queue_checkpoint_data(
42 &self,
43 queue: vk::Queue,
44 out: &mut [vk::CheckpointDataNV],
45 ) {
46 let mut count = out.len() as u32;
47 (self.fp.get_queue_checkpoint_data_nv)(queue, &mut count, out.as_mut_ptr());
48 assert_eq!(count as usize, out.len());
49 }
50
51 pub const fn name() -> &'static CStr {
52 vk::NvDeviceDiagnosticCheckpointsFn::name()
53 }
54
55 pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn {
56 &self.fp
57 }
58}