Skip to content

Commit

Permalink
device_diagnostic_checkpoints: Allow passing pNext-initialized structs
Browse files Browse the repository at this point in the history
To match all other functions which accept an array of to-be-initialized
structs with a `pNext` pointer that is possibly initialized by the
caller.
  • Loading branch information
MarijnS95 committed Feb 23, 2022
1 parent 8d7abfb commit b04d8b5
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions ash/src/extensions/nv/device_diagnostic_checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,27 @@ impl DeviceDiagnosticCheckpoints {
.cmd_set_checkpoint_nv(command_buffer, p_checkpoint_marker);
}

/// Retrieve the number of elements to pass to [`get_queue_checkpoint_data()`][Self::get_queue_checkpoint_data()]
pub unsafe fn get_queue_checkpoint_data_len(&self, queue: vk::Queue) -> usize {
let mut count = 0;
self.fp
.get_queue_checkpoint_data_nv(queue, &mut count, std::ptr::null_mut());
count as usize
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetQueueCheckpointDataNV.html>
pub unsafe fn get_queue_checkpoint_data(&self, queue: vk::Queue) -> Vec<vk::CheckpointDataNV> {
let mut checkpoint_data_count: u32 = 0;
self.fp.get_queue_checkpoint_data_nv(
queue,
&mut checkpoint_data_count,
std::ptr::null_mut(),
);
let mut checkpoint_data: Vec<vk::CheckpointDataNV> =
vec![vk::CheckpointDataNV::default(); checkpoint_data_count as _];
self.fp.get_queue_checkpoint_data_nv(
queue,
&mut checkpoint_data_count,
checkpoint_data.as_mut_ptr(),
);
checkpoint_data
///
/// Call [`get_queue_checkpoint_data_len()`][Self::get_queue_checkpoint_data_len()] to query the number of elements to pass to `out`.
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
pub unsafe fn get_queue_checkpoint_data(
&self,
queue: vk::Queue,
out: &mut [vk::CheckpointDataNV],
) {
let mut count = out.len() as u32;
self.fp
.get_queue_checkpoint_data_nv(queue, &mut count, out.as_mut_ptr());
assert_eq!(count as usize, out.len());
}

pub fn name() -> &'static CStr {
Expand Down

0 comments on commit b04d8b5

Please sign in to comment.