-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions/ext: Add VK_EXT_host_image_copy device extension
- Loading branch information
Showing
4 changed files
with
103 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
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,93 @@ | ||
#[cfg(doc)] | ||
use super::ImageCompressionControl; | ||
use crate::prelude::*; | ||
use crate::vk; | ||
use crate::{Device, Instance}; | ||
use std::ffi::CStr; | ||
use std::mem; | ||
|
||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_host_image_copy.html> | ||
#[derive(Clone)] | ||
pub struct HostImageCopy { | ||
handle: vk::Device, | ||
fp: vk::ExtHostImageCopyFn, | ||
} | ||
|
||
impl HostImageCopy { | ||
pub fn new(instance: &Instance, device: &Device) -> Self { | ||
let handle = device.handle(); | ||
let fp = vk::ExtHostImageCopyFn::load(|name| unsafe { | ||
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) | ||
}); | ||
Self { handle, fp } | ||
} | ||
|
||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyMemoryToImageEXT.html> | ||
#[inline] | ||
pub unsafe fn copy_memory_to_image( | ||
&self, | ||
copy_memory_to_image_info: &vk::CopyMemoryToImageInfoEXT, | ||
) -> VkResult<()> { | ||
(self.fp.copy_memory_to_image_ext)(self.handle, copy_memory_to_image_info).result() | ||
} | ||
|
||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyImageToMemoryEXT.html> | ||
#[inline] | ||
pub unsafe fn copy_image_to_memory( | ||
&self, | ||
copy_image_to_memory_info: &vk::CopyImageToMemoryInfoEXT, | ||
) -> VkResult<()> { | ||
(self.fp.copy_image_to_memory_ext)(self.handle, copy_image_to_memory_info).result() | ||
} | ||
|
||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyImageToImageEXT.html> | ||
#[inline] | ||
pub unsafe fn copy_image_to_image( | ||
&self, | ||
copy_image_to_image_info: &vk::CopyImageToImageInfoEXT, | ||
) -> VkResult<()> { | ||
(self.fp.copy_image_to_image_ext)(self.handle, copy_image_to_image_info).result() | ||
} | ||
|
||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkTransitionImageLayoutEXT.html> | ||
#[inline] | ||
pub unsafe fn transition_image_layout( | ||
&self, | ||
transitions: &[vk::HostImageLayoutTransitionInfoEXT], | ||
) -> VkResult<()> { | ||
(self.fp.transition_image_layout_ext)( | ||
self.handle, | ||
transitions.len() as u32, | ||
transitions.as_ptr(), | ||
) | ||
.result() | ||
} | ||
|
||
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageSubresourceLayout2EXT.html> | ||
/// | ||
/// Also available as [`ImageCompressionControl::get_image_subresource_layout2()`] | ||
/// when [`VK_EXT_image_compression_control`] is enabled. | ||
/// | ||
/// [`VK_EXT_image_compression_control`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_image_compression_control.html | ||
#[inline] | ||
pub unsafe fn get_image_subresource_layout2( | ||
&self, | ||
image: vk::Image, | ||
subresource: &vk::ImageSubresource2EXT, | ||
layout: &mut vk::SubresourceLayout2EXT, | ||
) { | ||
(self.fp.get_image_subresource_layout2_ext)(self.handle, image, subresource, layout) | ||
} | ||
|
||
pub const NAME: &'static CStr = vk::ExtHostImageCopyFn::NAME; | ||
|
||
#[inline] | ||
pub fn fp(&self) -> &vk::ExtHostImageCopyFn { | ||
&self.fp | ||
} | ||
|
||
#[inline] | ||
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
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