Skip to content

Commit

Permalink
extensions/khr: Add VK_KHR_cooperative_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Jul 31, 2023
1 parent f558761 commit dc57d23
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 @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_ANDROID_external_memory_android_hardware_buffer` device extension (#769)
- Added `VK_AMD_buffer_marker` device extension (#772)
- Added `VK_AMD_shader_info` device extension (#773)
- 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 @@ -40,6 +41,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 dc57d23

Please sign in to comment.