-
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.
Add VK_KHR_get_memory_requirements2 extension (#401)
- Loading branch information
Showing
2 changed files
with
89 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,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 | ||
} | ||
} |
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