Add VK_KHR_get_memory_requirements2 extension (#401)

This commit is contained in:
Rua 2021-03-20 14:12:09 +01:00 committed by GitHub
parent bbbcd037a9
commit d8d742348e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 89 additions and 0 deletions

View file

@ -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<I: InstanceV1_0, D: DeviceV1_0>(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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetBufferMemoryRequirements2KHR.html>"]
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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetImageMemoryRequirements2KHR.html>"]
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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetImageSparseMemoryRequirements2KHR.html>"]
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
}
}

View file

@ -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;