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    pub unsafe fn get_pipeline_executable_internal_representations(
24        &self,
25        executable_info: &vk::PipelineExecutableInfoKHR,
26    ) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> {
27        read_into_defaulted_vector(|count, data| {
28            (self.fp.get_pipeline_executable_internal_representations_khr)(
29                self.handle,
30                executable_info,
31                count,
32                data,
33            )
34        })
35    }
36
37    /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html>
38    pub unsafe fn get_pipeline_executable_properties(
39        &self,
40        pipeline_info: &vk::PipelineInfoKHR,
41    ) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> {
42        read_into_defaulted_vector(|count, data| {
43            (self.fp.get_pipeline_executable_properties_khr)(
44                self.handle,
45                pipeline_info,
46                count,
47                data,
48            )
49        })
50    }
51
52    /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html>
53    pub unsafe fn get_pipeline_executable_statistics(
54        &self,
55        executable_info: &vk::PipelineExecutableInfoKHR,
56    ) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> {
57        read_into_defaulted_vector(|count, data| {
58            (self.fp.get_pipeline_executable_statistics_khr)(
59                self.handle,
60                executable_info,
61                count,
62                data,
63            )
64        })
65    }
66
67    pub const fn name() -> &'static CStr {
68        vk::KhrPipelineExecutablePropertiesFn::name()
69    }
70
71    pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {
72        &self.fp
73    }
74
75    pub fn device(&self) -> vk::Device {
76        self.handle
77    }
78}