ash/extensions/khr/
pipeline_executable_properties.rs

1use crate::prelude::*;
2use crate::vk;
3use crate::{Device, Instance};
4use std::ffi::CStr;
5use std::mem;
6
7#[derive(Clone)]
8pub struct PipelineExecutableProperties {
9    handle: vk::Device,
10    fp: vk::KhrPipelineExecutablePropertiesFn,
11}
12
13impl PipelineExecutableProperties {
14    pub fn new(instance: &Instance, device: &Device) -> Self {
15        let handle = device.handle();
16        let fp = vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe {
17            mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
18        });
19        Self { handle, fp }
20    }
21
22    /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableInternalRepresentationsKHR.html>
23    #[inline]
24    pub unsafe fn get_pipeline_executable_internal_representations(
25        &self,
26        executable_info: &vk::PipelineExecutableInfoKHR,
27    ) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> {
28        read_into_defaulted_vector(|count, data| {
29            (self.fp.get_pipeline_executable_internal_representations_khr)(
30                self.handle,
31                executable_info,
32                count,
33                data,
34            )
35        })
36    }
37
38    /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html>
39    #[inline]
40    pub unsafe fn get_pipeline_executable_properties(
41        &self,
42        pipeline_info: &vk::PipelineInfoKHR,
43    ) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> {
44        read_into_defaulted_vector(|count, data| {
45            (self.fp.get_pipeline_executable_properties_khr)(
46                self.handle,
47                pipeline_info,
48                count,
49                data,
50            )
51        })
52    }
53
54    /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html>
55    #[inline]
56    pub unsafe fn get_pipeline_executable_statistics(
57        &self,
58        executable_info: &vk::PipelineExecutableInfoKHR,
59    ) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> {
60        read_into_defaulted_vector(|count, data| {
61            (self.fp.get_pipeline_executable_statistics_khr)(
62                self.handle,
63                executable_info,
64                count,
65                data,
66            )
67        })
68    }
69
70    #[inline]
71    pub const fn name() -> &'static CStr {
72        vk::KhrPipelineExecutablePropertiesFn::name()
73    }
74
75    #[inline]
76    pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {
77        &self.fp
78    }
79
80    #[inline]
81    pub fn device(&self) -> vk::Device {
82        self.handle
83    }
84}