From c554da632120a981e0ac6d41f1a4151cb5ac34a2 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 6 Mar 2021 21:16:17 +0100 Subject: [PATCH] Add VK_NV_device_diagnostics_config device extension (#385) --- .../nv/device_diagnostic_checkpoints.rs | 60 +++++++++++++++++++ ash/src/extensions/nv/mod.rs | 2 + 2 files changed, 62 insertions(+) create mode 100644 ash/src/extensions/nv/device_diagnostic_checkpoints.rs diff --git a/ash/src/extensions/nv/device_diagnostic_checkpoints.rs b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs new file mode 100644 index 0000000..46817ff --- /dev/null +++ b/ash/src/extensions/nv/device_diagnostic_checkpoints.rs @@ -0,0 +1,60 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; +use std::os::raw::c_void; + +#[derive(Clone)] +pub struct DeviceDiagnosticCheckpoints { + device_diagnostic_checkpoints_fn: vk::NvDeviceDiagnosticCheckpointsFn, +} + +impl DeviceDiagnosticCheckpoints { + pub fn new( + instance: &I, + device: &D, + ) -> DeviceDiagnosticCheckpoints { + let device_diagnostic_checkpoints_fn = + vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + DeviceDiagnosticCheckpoints { + device_diagnostic_checkpoints_fn, + } + } + + #[doc = ""] + pub unsafe fn cmd_set_checkpoint( + &self, + command_buffer: vk::CommandBuffer, + p_checkpoint_marker: *const c_void, + ) { + self.device_diagnostic_checkpoints_fn + .cmd_set_checkpoint_nv(command_buffer, p_checkpoint_marker); + } + + #[doc = ""] + pub unsafe fn get_queue_checkpoint_data(&self, queue: vk::Queue) -> Vec { + let mut checkpoint_data_count: u32 = 0; + self.device_diagnostic_checkpoints_fn + .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.device_diagnostic_checkpoints_fn + .get_queue_checkpoint_data_nv( + queue, + &mut checkpoint_data_count, + checkpoint_data.as_mut_ptr(), + ); + checkpoint_data + } + + pub fn name() -> &'static CStr { + vk::NvDeviceDiagnosticCheckpointsFn::name() + } + + pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn { + &self.device_diagnostic_checkpoints_fn + } +} diff --git a/ash/src/extensions/nv/mod.rs b/ash/src/extensions/nv/mod.rs index ffc0c01..47b952f 100644 --- a/ash/src/extensions/nv/mod.rs +++ b/ash/src/extensions/nv/mod.rs @@ -1,5 +1,7 @@ +pub use self::device_diagnostic_checkpoints::DeviceDiagnosticCheckpoints; pub use self::mesh_shader::MeshShader; pub use self::ray_tracing::RayTracing; +mod device_diagnostic_checkpoints; mod mesh_shader; mod ray_tracing;