Skip to content

Commit

Permalink
extensions: Add VK_KHR_maintenance4
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 10, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent c4dd1d6 commit 5dadadd
Showing 2 changed files with 100 additions and 0 deletions.
98 changes: 98 additions & 0 deletions ash/src/extensions/khr/maintenance4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;
use std::ops::DerefMut;

#[derive(Clone)]
pub struct Maintenance4 {
handle: vk::Device,
fns: vk::KhrMaintenance4Fn,
}

impl Maintenance4 {
pub fn new(instance: &Instance, device: &Device) -> Self {
let fns = vk::KhrMaintenance4Fn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr()))
});
Self {
handle: device.handle(),
fns,
}
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceBufferMemoryRequirementsKHR.html>"]
pub unsafe fn get_device_buffer_memory_requirements<'a>(
&self,
create_info: &vk::DeviceBufferMemoryRequirementsKHR,
next: Option<&'a mut impl vk::ExtendsMemoryRequirements2>,
) -> vk::MemoryRequirements2Builder<'a> {
let mut memory_requirements = vk::MemoryRequirements2::builder();
if let Some(next) = next {
memory_requirements = memory_requirements.push_next(next);
}

self.fns.get_device_buffer_memory_requirements_khr(
self.handle,
create_info,
memory_requirements.deref_mut(),
);

memory_requirements
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceImageMemoryRequirementsKHR.html>"]
pub unsafe fn get_device_image_memory_requirements<'a>(
&self,
create_info: &vk::DeviceImageMemoryRequirementsKHR,
next: Option<&'a mut impl vk::ExtendsMemoryRequirements2>,
) -> vk::MemoryRequirements2Builder<'a> {
let mut memory_requirements = vk::MemoryRequirements2::builder();
if let Some(next) = next {
memory_requirements = memory_requirements.push_next(next);
}

self.fns.get_device_image_memory_requirements_khr(
self.handle,
create_info,
memory_requirements.deref_mut(),
);

memory_requirements
}

#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceImageSparseMemoryRequirementsKHR.html>"]
pub unsafe fn get_device_image_sparse_memory_requirements(
&self,
create_info: &vk::DeviceImageMemoryRequirementsKHR,
) -> Vec<vk::SparseImageMemoryRequirements2> {
let mut count = 0;
self.fns.get_device_image_sparse_memory_requirements_khr(
self.handle,
create_info,
&mut count,
std::ptr::null_mut(),
);
let mut data = Vec::with_capacity(count as usize);
self.fns.get_device_image_sparse_memory_requirements_khr(
self.handle,
create_info,
&mut count,
data.as_mut_ptr(),
);
data.set_len(count as usize);
data
}

pub fn name() -> &'static CStr {
vk::KhrMaintenance4Fn::name()
}

pub fn fp(&self) -> &vk::KhrMaintenance4Fn {
&self.fns
}

pub fn device(&self) -> vk::Device {
self.handle
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ pub use self::get_memory_requirements2::GetMemoryRequirements2;
pub use self::get_physical_device_properties2::GetPhysicalDeviceProperties2;
pub use self::maintenance1::Maintenance1;
pub use self::maintenance3::Maintenance3;
pub use self::maintenance4::Maintenance4;
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
pub use self::push_descriptor::PushDescriptor;
pub use self::ray_tracing_pipeline::RayTracingPipeline;
@@ -42,6 +43,7 @@ mod get_memory_requirements2;
mod get_physical_device_properties2;
mod maintenance1;
mod maintenance3;
mod maintenance4;
mod pipeline_executable_properties;
mod push_descriptor;
mod ray_tracing_pipeline;

0 comments on commit 5dadadd

Please sign in to comment.