Added VK_KHR_pipeline_executable_properties extension support. (#313)

* Added `VK_KHR_pipeline_executable_properties` extension support.

* Unused import removed.

* Cargo-fmt requirements satisfied.

* Specification requirements satisfied.

* Cargo-fmt requirements satisfied.

* Recommended fixes applied.
This commit is contained in:
zedrian 2020-07-20 21:48:53 +02:00 committed by GitHub
parent 9aae30ecc2
commit b6d9a40b0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 131 additions and 0 deletions

View file

@ -3,6 +3,7 @@ pub use self::display::Display;
pub use self::display_swapchain::DisplaySwapchain;
pub use self::draw_indirect_count::DrawIndirectCount;
pub use self::external_memory_fd::ExternalMemoryFd;
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
pub use self::push_descriptor::PushDescriptor;
pub use self::ray_tracing::RayTracing;
pub use self::surface::Surface;
@ -18,6 +19,7 @@ mod display;
mod display_swapchain;
mod draw_indirect_count;
mod external_memory_fd;
mod pipeline_executable_properties;
mod push_descriptor;
mod ray_tracing;
mod surface;

View file

@ -0,0 +1,129 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use std::ffi::CStr;
use std::mem;
use std::ptr;
#[derive(Clone)]
pub struct PipelineExecutableProperties {
handle: vk::Instance,
pipeline_executable_properties_fn: vk::KhrPipelineExecutablePropertiesFn,
}
impl PipelineExecutableProperties {
pub fn new<E: EntryV1_0, I: InstanceV1_0>(
entry: &E,
instance: &I,
) -> PipelineExecutableProperties {
let pipeline_executable_properties_fn =
vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
});
PipelineExecutableProperties {
handle: instance.handle(),
pipeline_executable_properties_fn,
}
}
pub fn name() -> &'static CStr {
vk::KhrPipelineExecutablePropertiesFn::name()
}
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableInternalRepresentationsKHR.html"]
pub unsafe fn get_pipeline_executable_internal_representations(
&self,
device: vk::Device,
executable_info: &vk::PipelineExecutableInfoKHR,
) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> {
let mut count = 0;
self.pipeline_executable_properties_fn
.get_pipeline_executable_internal_representations_khr(
device,
executable_info,
&mut count,
ptr::null_mut(),
);
let mut v: Vec<_> = vec![Default::default(); count as usize];
let err_code = self
.pipeline_executable_properties_fn
.get_pipeline_executable_internal_representations_khr(
device,
executable_info,
&mut count,
v.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html"]
pub unsafe fn get_pipeline_executable_properties(
&self,
device: vk::Device,
pipeline_info: &vk::PipelineInfoKHR,
) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> {
let mut count = 0;
self.pipeline_executable_properties_fn
.get_pipeline_executable_properties_khr(
device,
pipeline_info,
&mut count,
ptr::null_mut(),
);
let mut v: Vec<_> = vec![Default::default(); count as usize];
let err_code = self
.pipeline_executable_properties_fn
.get_pipeline_executable_properties_khr(
device,
pipeline_info,
&mut count,
v.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
#[doc = "https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html"]
pub unsafe fn get_pipeline_executable_statistics(
&self,
device: vk::Device,
executable_info: &vk::PipelineExecutableInfoKHR,
) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> {
let mut count = 0;
self.pipeline_executable_properties_fn
.get_pipeline_executable_statistics_khr(
device,
executable_info,
&mut count,
ptr::null_mut(),
);
let mut v: Vec<_> = vec![Default::default(); count as usize];
let err_code = self
.pipeline_executable_properties_fn
.get_pipeline_executable_statistics_khr(
device,
executable_info,
&mut count,
v.as_mut_ptr(),
);
match err_code {
vk::Result::SUCCESS => Ok(v),
_ => Err(err_code),
}
}
pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn {
&self.pipeline_executable_properties_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}