diff --git a/ash/src/extensions/khr/get_memory_requirements2.rs b/ash/src/extensions/khr/get_memory_requirements2.rs new file mode 100644 index 0000000..09e5bfb --- /dev/null +++ b/ash/src/extensions/khr/get_memory_requirements2.rs @@ -0,0 +1,87 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct GetMemoryRequirements2 { + handle: vk::Device, + get_memory_requirements2_fn: vk::KhrGetMemoryRequirements2Fn, +} + +impl GetMemoryRequirements2 { + pub fn new(instance: &I, device: &D) -> GetMemoryRequirements2 { + let get_memory_requirements2_fn = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + GetMemoryRequirements2 { + handle: device.handle(), + get_memory_requirements2_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrGetMemoryRequirements2Fn::name() + } + + #[doc = ""] + unsafe fn get_buffer_memory_requirements2( + &self, + info: &vk::BufferMemoryRequirementsInfo2KHR, + memory_requirements: &mut vk::MemoryRequirements2KHR, + ) { + self.get_memory_requirements2_fn + .get_buffer_memory_requirements2_khr(self.handle, info, memory_requirements); + } + + #[doc = ""] + unsafe fn get_image_memory_requirements2( + &self, + info: &vk::ImageMemoryRequirementsInfo2KHR, + memory_requirements: &mut vk::MemoryRequirements2KHR, + ) { + self.get_memory_requirements2_fn + .get_image_memory_requirements2_khr(self.handle, info, memory_requirements); + } + + unsafe fn get_image_sparse_memory_requirements2_len( + &self, + info: &vk::ImageSparseMemoryRequirementsInfo2KHR, + ) -> usize { + let mut count = mem::zeroed(); + self.get_memory_requirements2_fn + .get_image_sparse_memory_requirements2_khr( + self.handle, + info, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + #[doc = ""] + unsafe fn get_image_sparse_memory_requirements2( + &self, + info: &vk::ImageSparseMemoryRequirementsInfo2KHR, + sparse_memory_requirements: &mut [vk::SparseImageMemoryRequirements2KHR], + ) { + let mut count = sparse_memory_requirements.len() as u32; + self.get_memory_requirements2_fn + .get_image_sparse_memory_requirements2_khr( + self.handle, + info, + &mut count, + sparse_memory_requirements.as_mut_ptr(), + ); + } + + pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn { + &self.get_memory_requirements2_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index e67da08..e07dd89 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -6,6 +6,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::get_memory_requirements2::GetMemoryRequirements2; pub use self::maintenance1::Maintenance1; pub use self::maintenance3::Maintenance3; pub use self::pipeline_executable_properties::PipelineExecutableProperties; @@ -27,6 +28,7 @@ mod display; mod display_swapchain; mod draw_indirect_count; mod external_memory_fd; +mod get_memory_requirements2; mod maintenance1; mod maintenance3; mod pipeline_executable_properties;