Skip to content

Commit e46d73b

Browse files
committed
extensions/khr: Add VK_KHR_pipeline_binary extension
1 parent 020ef0c commit e46d73b

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Added `VK_EXT_metal_objects` device extension (#942)
13+
- Added `VK_KHR_pipeline_binary` device extension (#944)
1314

1415
## [0.38.0] - 2024-04-01
1516

ash/src/extensions/khr/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub mod maintenance4;
2929
pub mod maintenance5;
3030
pub mod maintenance6;
3131
pub mod performance_query;
32+
pub mod pipeline_binary;
3233
pub mod pipeline_executable_properties;
3334
pub mod present_wait;
3435
pub mod push_descriptor;
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_pipeline_binary.html>
2+
3+
use crate::prelude::*;
4+
use crate::vk;
5+
use crate::RawPtr as _;
6+
use core::ffi::c_void;
7+
use core::mem::MaybeUninit;
8+
9+
impl crate::khr::pipeline_binary::Device {
10+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreatePipelineBinariesKHR.html>
11+
#[inline]
12+
#[doc(alias = "vkCreatePipelineBinariesKHR")]
13+
pub unsafe fn create_pipeline_binaries(
14+
&self,
15+
create_info: &vk::PipelineBinaryCreateInfoKHR<'_>,
16+
allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
17+
binaries: &mut vk::PipelineBinaryHandlesInfoKHR<'_>,
18+
) -> VkResult<()> {
19+
(self.fp.create_pipeline_binaries_khr)(
20+
self.handle,
21+
create_info,
22+
allocation_callbacks.as_raw_ptr(),
23+
binaries,
24+
)
25+
.result()
26+
}
27+
28+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyPipelineBinaryKHR.html>
29+
#[inline]
30+
#[doc(alias = "vkDestroyPipelineBinaryKHR")]
31+
pub unsafe fn destroy_pipeline_binary(
32+
&self,
33+
pipeline_binary: vk::PipelineBinaryKHR,
34+
allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
35+
) {
36+
(self.fp.destroy_pipeline_binary_khr)(
37+
self.handle,
38+
pipeline_binary,
39+
allocation_callbacks.as_raw_ptr(),
40+
)
41+
}
42+
43+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPipelineKeyKHR.html>
44+
#[inline]
45+
#[doc(alias = "vkGetPipelineKeyKHR")]
46+
pub unsafe fn get_pipeline_key(
47+
&self,
48+
pipeline_create_info: Option<&vk::PipelineCreateInfoKHR<'_>>,
49+
) -> VkResult<vk::PipelineBinaryKeyKHR<'_>> {
50+
let mut pipeline_key = MaybeUninit::uninit();
51+
(self.fp.get_pipeline_key_khr)(
52+
self.handle,
53+
pipeline_create_info.as_raw_ptr(),
54+
pipeline_key.as_mut_ptr(),
55+
)
56+
.assume_init_on_success(pipeline_key)
57+
}
58+
59+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPipelineBinaryDataKHR.html>
60+
#[inline]
61+
#[doc(alias = "vkGetPipelineBinaryDataKHR")]
62+
pub unsafe fn get_pipeline_binary_data(
63+
&self,
64+
info: &vk::PipelineBinaryDataInfoKHR<'_>,
65+
pipeline_binary_key: &mut vk::PipelineBinaryKeyKHR<'_>,
66+
) -> VkResult<Vec<u8>> {
67+
// TODO: This returns NOT_ENOUGH_SPACE_KHR, not INCOMPLETE (because nothing is written, instead of returning an impartial result)
68+
read_into_uninitialized_vector(|count, data| {
69+
(self.fp.get_pipeline_binary_data_khr)(
70+
self.handle,
71+
info,
72+
pipeline_binary_key,
73+
count,
74+
data as *mut c_void,
75+
)
76+
})
77+
}
78+
79+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkReleaseCapturedPipelineDataKHR.html>
80+
#[inline]
81+
#[doc(alias = "vkReleaseCapturedPipelineDataKHR")]
82+
pub unsafe fn release_captured_pipeline_data(
83+
&self,
84+
info: &vk::ReleaseCapturedPipelineDataInfoKHR<'_>,
85+
allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
86+
) -> VkResult<()> {
87+
(self.fp.release_captured_pipeline_data_khr)(
88+
self.handle,
89+
info,
90+
allocation_callbacks.as_raw_ptr(),
91+
)
92+
.result()
93+
}
94+
}

ash/src/prelude.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl vk::Result {
4343
///
4444
/// [`vkEnumerateInstanceExtensionProperties`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkEnumerateInstanceExtensionProperties.html
4545
pub(crate) unsafe fn read_into_uninitialized_vector<N: Copy + Default + TryInto<usize>, T>(
46-
f: impl Fn(&mut N, *mut T) -> vk::Result,
46+
mut f: impl FnMut(&mut N, *mut T) -> vk::Result,
4747
) -> VkResult<Vec<T>>
4848
where
4949
<N as TryInto<usize>>::Error: core::fmt::Debug,
@@ -81,7 +81,7 @@ pub(crate) unsafe fn read_into_defaulted_vector<
8181
N: Copy + Default + TryInto<usize>,
8282
T: Default + Clone,
8383
>(
84-
f: impl Fn(&mut N, *mut T) -> vk::Result,
84+
mut f: impl FnMut(&mut N, *mut T) -> vk::Result,
8585
) -> VkResult<Vec<T>>
8686
where
8787
<N as TryInto<usize>>::Error: core::fmt::Debug,

0 commit comments

Comments
 (0)