Add VK_NV_device_diagnostics_config device extension (#385)

This commit is contained in:
Philippe Renon 2021-03-06 21:16:17 +01:00 committed by GitHub
parent 057fd76be1
commit c554da6321
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 0 deletions

View file

@ -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<I: InstanceV1_0, D: DeviceV1_0>(
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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdSetCheckpointNV.html>"]
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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-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.device_diagnostic_checkpoints_fn
.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.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
}
}

View file

@ -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;