Skip to content

Commit 69cf5ec

Browse files
committed
extensions/khr: Add VK_KHR_pipeline_binary extension
1 parent 0b5b1a4 commit 69cf5ec

File tree

4 files changed

+99
-2
lines changed

4 files changed

+99
-2
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Added `VK_KHR_get_display_properties2` instance extension (#932)
1414
- Added `VK_EXT_metal_objects` device extension (#942)
1515
- Added `VK_AMD_anti_lag` device extension (#943)
16+
- Added `VK_KHR_pipeline_binary` device extension (#944)
1617

1718
## [0.38.0] - 2024-04-01
1819

ash/src/extensions/khr/mod.rs

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

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)