extensions/khr: Add VK_KHR_performance_query (#726)
This commit is contained in:
parent
f98cab47dd
commit
74f68f26a2
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
|
||||
- Update Vulkan-Headers to 1.3.244 (#697)
|
||||
- Added `VK_KHR_performance_query` device extension (#726)
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ pub use self::get_surface_capabilities2::GetSurfaceCapabilities2;
|
|||
pub use self::maintenance1::Maintenance1;
|
||||
pub use self::maintenance3::Maintenance3;
|
||||
pub use self::maintenance4::Maintenance4;
|
||||
pub use self::performance_query::PerformanceQuery;
|
||||
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
|
||||
pub use self::present_wait::PresentWait;
|
||||
pub use self::push_descriptor::PushDescriptor;
|
||||
|
@ -60,6 +61,7 @@ mod get_surface_capabilities2;
|
|||
mod maintenance1;
|
||||
mod maintenance3;
|
||||
mod maintenance4;
|
||||
mod performance_query;
|
||||
mod pipeline_executable_properties;
|
||||
mod present_wait;
|
||||
mod push_descriptor;
|
||||
|
|
118
ash/src/extensions/khr/performance_query.rs
Normal file
118
ash/src/extensions/khr/performance_query.rs
Normal file
|
@ -0,0 +1,118 @@
|
|||
use crate::prelude::*;
|
||||
use crate::vk;
|
||||
use crate::{Entry, Instance};
|
||||
use std::ffi::CStr;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_performance_query.html>
|
||||
#[derive(Clone)]
|
||||
pub struct PerformanceQuery {
|
||||
handle: vk::Instance,
|
||||
fp: vk::KhrPerformanceQueryFn,
|
||||
}
|
||||
|
||||
impl PerformanceQuery {
|
||||
pub fn new(entry: &Entry, instance: &Instance) -> Self {
|
||||
let handle = instance.handle();
|
||||
let fp = vk::KhrPerformanceQueryFn::load(|name| unsafe {
|
||||
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
|
||||
});
|
||||
Self { handle, fp }
|
||||
}
|
||||
|
||||
/// Retrieve the number of elements to pass to [`enumerate_physical_device_queue_family_performance_query_counters()`][Self::enumerate_physical_device_queue_family_performance_query_counters()]
|
||||
#[inline]
|
||||
pub unsafe fn enumerate_physical_device_queue_family_performance_query_counters_len(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
queue_family_index: u32,
|
||||
) -> VkResult<usize> {
|
||||
let mut count = 0;
|
||||
(self
|
||||
.fp
|
||||
.enumerate_physical_device_queue_family_performance_query_counters_khr)(
|
||||
physical_device,
|
||||
queue_family_index,
|
||||
&mut count,
|
||||
ptr::null_mut(),
|
||||
ptr::null_mut(),
|
||||
)
|
||||
.result_with_success(count as usize)
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR.html>
|
||||
///
|
||||
/// Call [`enumerate_physical_device_queue_family_performance_query_counters_len()`][Self::enumerate_physical_device_queue_family_performance_query_counters_len()] to query the number of elements to pass to `out_counters` and `out_counter_descriptions`.
|
||||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
|
||||
#[inline]
|
||||
pub unsafe fn enumerate_physical_device_queue_family_performance_query_counters(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
queue_family_index: u32,
|
||||
out_counters: &mut [vk::PerformanceCounterKHR],
|
||||
out_counter_descriptions: &mut [vk::PerformanceCounterDescriptionKHR],
|
||||
) -> VkResult<()> {
|
||||
assert_eq!(out_counters.len(), out_counter_descriptions.len());
|
||||
let mut count = out_counters.len() as u32;
|
||||
(self
|
||||
.fp
|
||||
.enumerate_physical_device_queue_family_performance_query_counters_khr)(
|
||||
physical_device,
|
||||
queue_family_index,
|
||||
&mut count,
|
||||
out_counters.as_mut_ptr(),
|
||||
out_counter_descriptions.as_mut_ptr(),
|
||||
)
|
||||
.result()?;
|
||||
assert_eq!(count as usize, out_counters.len());
|
||||
assert_eq!(count as usize, out_counter_descriptions.len());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn get_physical_device_queue_family_performance_query_passes(
|
||||
&self,
|
||||
physical_device: vk::PhysicalDevice,
|
||||
performance_query_create_info: &vk::QueryPoolPerformanceCreateInfoKHR,
|
||||
) -> u32 {
|
||||
let mut num_passes = 0;
|
||||
(self
|
||||
.fp
|
||||
.get_physical_device_queue_family_performance_query_passes_khr)(
|
||||
physical_device,
|
||||
performance_query_create_info,
|
||||
&mut num_passes,
|
||||
);
|
||||
num_passes
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkAcquireProfilingLockKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn acquire_profiling_lock(
|
||||
&self,
|
||||
device: vk::Device,
|
||||
info: &vk::AcquireProfilingLockInfoKHR,
|
||||
) -> VkResult<()> {
|
||||
(self.fp.acquire_profiling_lock_khr)(device, info).result()
|
||||
}
|
||||
|
||||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkReleaseProfilingLockKHR.html>
|
||||
#[inline]
|
||||
pub unsafe fn release_profiling_lock(&self, device: vk::Device) {
|
||||
(self.fp.release_profiling_lock_khr)(device)
|
||||
}
|
||||
|
||||
pub const NAME: &'static CStr = vk::KhrPerformanceQueryFn::NAME;
|
||||
|
||||
#[inline]
|
||||
pub fn fp(&self) -> &vk::KhrPerformanceQueryFn {
|
||||
&self.fp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn instance(&self) -> vk::Instance {
|
||||
self.handle
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue