diff --git a/Changelog.md b/Changelog.md index 5ac17ab37..2735b5ae2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Changed + +- `VK_NV_device_diagnostic_checkpoints`: Allow passing `pNext`-initialized structs to `get_queue_checkpoint_data` (#588) + ## [0.36.0] - 2022-02-21 ### Changed diff --git a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs index 61bd964f8..6afb70d98 100644 --- a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs +++ b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs @@ -4,6 +4,7 @@ use std::ffi::CStr; use std::mem; use std::os::raw::c_void; +/// #[derive(Clone)] pub struct DeviceDiagnosticCheckpoints { fp: vk::NvDeviceDiagnosticCheckpointsFn, @@ -27,22 +28,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 + } + /// - pub unsafe fn get_queue_checkpoint_data(&self, queue: vk::Queue) -> Vec { - 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 = - 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 {