Skip to content

Commit

Permalink
extensions/khr: Add VK_KHR_cooperative_matrix (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Aug 14, 2023
1 parent 3fa908c commit 39dc6d6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_EXT_host_image_copy` device extension (#779)
- Added `VK_KHR_maintenance5` device extension (#780)
- Added `VK_NV_device_generated_commands_compute` device extension (#781)
- Added `VK_KHR_cooperative_matrix` instance extension (#782)

### Changed

Expand Down
45 changes: 45 additions & 0 deletions ash/src/extensions/khr/cooperative_matrix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use crate::prelude::*;
use crate::vk;
use crate::{Entry, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_cooperative_matrix.html>
#[derive(Clone)]
pub struct CooperativeMatrix {
fp: vk::KhrCooperativeMatrixFn,
}

impl CooperativeMatrix {
pub fn new(entry: &Entry, instance: &Instance) -> Self {
let handle = instance.handle();
let fp = vk::KhrCooperativeMatrixFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
});
Self { fp }
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR.html>
#[inline]
pub unsafe fn get_physical_device_cooperative_matrix_properties(
&self,
physical_device: vk::PhysicalDevice,
) -> VkResult<Vec<vk::CooperativeMatrixPropertiesKHR>> {
read_into_defaulted_vector(|count, data| {
(self
.fp
.get_physical_device_cooperative_matrix_properties_khr)(
physical_device,
count,
data,
)
})
}

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

#[inline]
pub fn fp(&self) -> &vk::KhrCooperativeMatrixFn {
&self.fp
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub use self::acceleration_structure::AccelerationStructure;
pub use self::android_surface::AndroidSurface;
pub use self::buffer_device_address::BufferDeviceAddress;
pub use self::cooperative_matrix::CooperativeMatrix;
pub use self::copy_commands2::CopyCommands2;
pub use self::create_render_pass2::CreateRenderPass2;
pub use self::deferred_host_operations::DeferredHostOperations;
Expand Down Expand Up @@ -41,6 +42,7 @@ pub use self::xlib_surface::XlibSurface;
mod acceleration_structure;
mod android_surface;
mod buffer_device_address;
mod cooperative_matrix;
mod copy_commands2;
mod create_render_pass2;
mod deferred_host_operations;
Expand Down

0 comments on commit 39dc6d6

Please sign in to comment.