-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
use crate::vk; | ||
use crate::{Device, Instance}; | ||
use std::ffi::CStr; | ||
use std::mem; | ||
|
||
#[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( | ||
&self, | ||
create_info: &vk::DeviceBufferMemoryRequirementsKHR, | ||
out: &mut vk::MemoryRequirements2, | ||
) { | ||
self.fns | ||
.get_device_buffer_memory_requirements_khr(self.handle, create_info, out) | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceImageMemoryRequirementsKHR.html>"] | ||
pub unsafe fn get_device_image_memory_requirements( | ||
&self, | ||
create_info: &vk::DeviceImageMemoryRequirementsKHR, | ||
out: &mut vk::MemoryRequirements2, | ||
) { | ||
self.fns | ||
.get_device_image_memory_requirements_khr(self.handle, create_info, out) | ||
} | ||
|
||
/// Retrieve the number of elements to pass to [`Self::get_device_image_sparse_memory_requirements()`] | ||
pub unsafe fn get_device_image_sparse_memory_requirements_len( | ||
&self, | ||
create_info: &vk::DeviceImageMemoryRequirementsKHR, | ||
) -> usize { | ||
let mut count = 0; | ||
self.fns.get_device_image_sparse_memory_requirements_khr( | ||
self.handle, | ||
create_info, | ||
&mut count, | ||
std::ptr::null_mut(), | ||
); | ||
count as usize | ||
} | ||
|
||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDeviceImageSparseMemoryRequirementsKHR.html>"] | ||
/// | ||
/// Call [`Self::get_device_image_sparse_memory_requirements_len()`] to query the number of elements to pass to `sparse_memory_requirements`. | ||
/// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. | ||
pub unsafe fn get_device_image_sparse_memory_requirements( | ||
&self, | ||
create_info: &vk::DeviceImageMemoryRequirementsKHR, | ||
out: &mut [vk::SparseImageMemoryRequirements2], | ||
) { | ||
let mut count = out.len() as u32; | ||
self.fns.get_device_image_sparse_memory_requirements_khr( | ||
self.handle, | ||
create_info, | ||
&mut count, | ||
out.as_mut_ptr(), | ||
); | ||
assert_eq!(count, out.len() as u32); | ||
} | ||
|
||
pub fn name() -> &'static CStr { | ||
vk::KhrMaintenance4Fn::name() | ||
} | ||
|
||
pub fn fp(&self) -> &vk::KhrMaintenance4Fn { | ||
&self.fns | ||
} | ||
|
||
pub fn device(&self) -> vk::Device { | ||
self.handle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters