Skip to content

Commit

Permalink
extensions/khr: Add VK_KHR_maintenance5
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Aug 14, 2023
1 parent 95ff15f commit 61a6a15
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_AMD_shader_info` device extension (#773)
- Added `VK_AMDX_shader_enqueue` device extension (#776)
- Added `VK_EXT_host_image_copy` device extension (#779)
- Added `VK_KHR_maintenance5` device extension (#780)

### Changed

Expand Down
6 changes: 5 additions & 1 deletion ash/src/extensions/ext/host_image_copy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(doc)]
use super::ImageCompressionControl;
use super::{super::khr::Maintenance5, ImageCompressionControl};
use crate::prelude::*;
use crate::vk;
use crate::{Device, Instance};
Expand Down Expand Up @@ -65,9 +65,13 @@ impl HostImageCopy {

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageSubresourceLayout2EXT.html>
///
/// Also available as [`Maintenance5::get_image_subresource_layout2()`]
/// when [`VK_KHR_maintenance5`] is enabled.
///
/// Also available as [`ImageCompressionControl::get_image_subresource_layout2()`]
/// when [`VK_EXT_image_compression_control`] is enabled.
///
/// [`VK_KHR_maintenance5`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance5.html
/// [`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(
Expand Down
6 changes: 5 additions & 1 deletion ash/src/extensions/ext/image_compression_control.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(doc)]
use super::HostImageCopy;
use super::{super::khr::Maintenance5, HostImageCopy};
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
Expand All @@ -23,9 +23,13 @@ impl ImageCompressionControl {

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageSubresourceLayout2EXT.html>
///
/// Also available as [`Maintenance5::get_image_subresource_layout2()`]
/// when [`VK_KHR_maintenance5`] is enabled.
///
/// Also available as [`HostImageCopy::get_image_subresource_layout2()`]
/// when [`VK_EXT_host_image_copy`] is enabled.
///
/// [`VK_KHR_maintenance5`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance5.html
/// [`VK_EXT_host_image_copy`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_host_image_copy.html
#[inline]
pub unsafe fn get_image_subresource_layout2(
Expand Down
1 change: 1 addition & 0 deletions ash/src/extensions/khr/maintenance1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance1.html>
#[derive(Clone)]
pub struct Maintenance1 {
handle: vk::Device,
Expand Down
1 change: 1 addition & 0 deletions ash/src/extensions/khr/maintenance3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance3.html>
#[derive(Clone)]
pub struct Maintenance3 {
handle: vk::Device,
Expand Down
1 change: 1 addition & 0 deletions ash/src/extensions/khr/maintenance4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance4.html>
#[derive(Clone)]
pub struct Maintenance4 {
handle: vk::Device,
Expand Down
93 changes: 93 additions & 0 deletions ash/src/extensions/khr/maintenance5.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#[cfg(doc)]
use super::super::ext::{HostImageCopy, ImageCompressionControl};
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_KHR_maintenance5.html>
#[derive(Clone)]
pub struct Maintenance5 {
handle: vk::Device,
fp: vk::KhrMaintenance5Fn,
}

impl Maintenance5 {
pub fn new(instance: &Instance, device: &Device) -> Self {
let handle = device.handle();
let fp = vk::KhrMaintenance5Fn::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/vkCmdBindIndexBuffer2KHR.html>
#[inline]
pub unsafe fn cmd_bind_index_buffer2(
&self,
command_buffer: vk::CommandBuffer,
buffer: vk::Buffer,
offset: vk::DeviceSize,
size: vk::DeviceSize,
index_type: vk::IndexType,
) {
(self.fp.cmd_bind_index_buffer2_khr)(command_buffer, buffer, offset, size, index_type)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetRenderingAreaGranularityKHR.html>
#[inline]
pub unsafe fn get_rendering_area_granularity(
&self,
rendering_area_info: &vk::RenderingAreaInfoKHR,
) -> vk::Extent2D {
let mut granularity = mem::zeroed();
(self.fp.get_rendering_area_granularity_khr)(
self.handle,
rendering_area_info,
&mut granularity,
);
granularity
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageSubresourceLayoutKHR.html>
#[inline]
pub unsafe fn get_device_image_subresource_layout(
&self,
info: &vk::DeviceImageSubresourceInfoKHR,
layout: &mut vk::SubresourceLayout2KHR,
) {
(self.fp.get_device_image_subresource_layout_khr)(self.handle, info, layout)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageSubresourceLayout2KHR.html>
///
/// Also available as [`HostImageCopy::get_image_subresource_layout2()`]
/// when [`VK_EXT_host_image_copy`] is enabled.
///
/// Also available as [`ImageCompressionControl::get_image_subresource_layout2()`]
/// when [`VK_EXT_image_compression_control`] is enabled.
///
/// [`VK_EXT_host_image_copy`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_host_image_copy.html
/// [`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::ImageSubresource2KHR,
layout: &mut vk::SubresourceLayout2KHR,
) {
(self.fp.get_image_subresource_layout2_khr)(self.handle, image, subresource, layout)
}

pub const NAME: &'static CStr = vk::KhrMaintenance5Fn::NAME;

#[inline]
pub fn fp(&self) -> &vk::KhrMaintenance5Fn {
&self.fp
}

#[inline]
pub fn device(&self) -> vk::Device {
self.handle
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub use self::get_surface_capabilities2::GetSurfaceCapabilities2;
pub use self::maintenance1::Maintenance1;
pub use self::maintenance3::Maintenance3;
pub use self::maintenance4::Maintenance4;
pub use self::maintenance5::Maintenance5;
pub use self::performance_query::PerformanceQuery;
pub use self::pipeline_executable_properties::PipelineExecutableProperties;
pub use self::present_wait::PresentWait;
Expand Down Expand Up @@ -61,6 +62,7 @@ mod get_surface_capabilities2;
mod maintenance1;
mod maintenance3;
mod maintenance4;
mod maintenance5;
mod performance_query;
mod pipeline_executable_properties;
mod present_wait;
Expand Down

0 comments on commit 61a6a15

Please sign in to comment.