Skip to content

Commit 72e71a7

Browse files
committed
Add helper wrappers for Vulkan core 1.4 Device functions
1 parent fd4eb11 commit 72e71a7

File tree

8 files changed

+294
-1
lines changed

8 files changed

+294
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Added `push()` method to all root structs to insert a single extension-struct in the pointer chain. (#909)
1313
- Update Vulkan-Headers to 1.3.296 (#910)
14+
- Added helper wrappers for Vulkan core 1.4 `Device` functions (#1000)
1415
- Added `VK_KHR_get_display_properties2` instance extension (#932)
1516
- Added `VK_EXT_metal_objects` device extension (#942)
1617
- Added `VK_AMD_anti_lag` device extension (#943)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A very lightweight wrapper around Vulkan
1919
- [x] No validation, everything is **unsafe**
2020
- [x] Lifetime-safety on structs created with the builder pattern
2121
- [x] Generated from `vk.xml`
22-
- [x] Support for Vulkan `1.1`, `1.2`, `1.3`
22+
- [x] Support for Vulkan `1.1`, `1.2`, `1.3`, `1.4`
2323
- [x] `no_std` support
2424

2525
## ⚠️ Semver compatibility warning

ash/src/device.rs

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct Device {
1818
pub(crate) device_fn_1_1: crate::DeviceFnV1_1,
1919
pub(crate) device_fn_1_2: crate::DeviceFnV1_2,
2020
pub(crate) device_fn_1_3: crate::DeviceFnV1_3,
21+
pub(crate) device_fn_1_4: crate::DeviceFnV1_4,
2122
}
2223

2324
impl Device {
@@ -38,6 +39,7 @@ impl Device {
3839
crate::DeviceFnV1_1::load(&mut load_fn),
3940
crate::DeviceFnV1_2::load(&mut load_fn),
4041
crate::DeviceFnV1_3::load(&mut load_fn),
42+
crate::DeviceFnV1_4::load(&mut load_fn),
4143
)
4244
}
4345

@@ -48,6 +50,7 @@ impl Device {
4850
device_fn_1_1: crate::DeviceFnV1_1,
4951
device_fn_1_2: crate::DeviceFnV1_2,
5052
device_fn_1_3: crate::DeviceFnV1_3,
53+
device_fn_1_4: crate::DeviceFnV1_4,
5154
) -> Self {
5255
Self {
5356
handle,
@@ -56,6 +59,7 @@ impl Device {
5659
device_fn_1_1,
5760
device_fn_1_2,
5861
device_fn_1_3,
62+
device_fn_1_4,
5963
}
6064
}
6165

@@ -65,6 +69,274 @@ impl Device {
6569
}
6670
}
6771

72+
/// Vulkan core 1.4
73+
impl Device {
74+
#[inline]
75+
pub fn fp_v1_4(&self) -> &crate::DeviceFnV1_4 {
76+
&self.device_fn_1_4
77+
}
78+
79+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineStipple.html>
80+
#[inline]
81+
#[doc(alias = "vkCmdSetLineStipple")]
82+
pub unsafe fn cmd_set_line_stipple(
83+
&self,
84+
command_buffer: vk::CommandBuffer,
85+
line_stipple_factor: u32,
86+
line_stipple_pattern: u16,
87+
) {
88+
(self.device_fn_1_4.cmd_set_line_stipple)(
89+
command_buffer,
90+
line_stipple_factor,
91+
line_stipple_pattern,
92+
)
93+
}
94+
95+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkMapMemory2.html>
96+
#[inline]
97+
#[doc(alias = "vkMapMemory2")]
98+
pub unsafe fn map_memory2(
99+
&self,
100+
memory_map_info: &vk::MemoryMapInfo<'_>,
101+
) -> VkResult<*mut ffi::c_void> {
102+
let mut data = mem::MaybeUninit::uninit();
103+
(self.device_fn_1_4.map_memory2)(self.handle, memory_map_info, data.as_mut_ptr())
104+
.assume_init_on_success(data)
105+
}
106+
107+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkUnmapMemory2.html>
108+
#[inline]
109+
#[doc(alias = "vkUnmapMemory2")]
110+
pub unsafe fn unmap_memory2(
111+
&self,
112+
memory_unmap_info: &vk::MemoryUnmapInfo<'_>,
113+
) -> VkResult<()> {
114+
(self.device_fn_1_4.unmap_memory2)(self.handle, memory_unmap_info).result()
115+
}
116+
117+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBindIndexBuffer2.html>
118+
#[inline]
119+
#[doc(alias = "vkCmdBindIndexBuffer2")]
120+
pub unsafe fn cmd_bind_index_buffer2(
121+
&self,
122+
command_buffer: vk::CommandBuffer,
123+
buffer: vk::Buffer,
124+
offset: vk::DeviceSize,
125+
size: vk::DeviceSize,
126+
index_type: vk::IndexType,
127+
) {
128+
(self.device_fn_1_4.cmd_bind_index_buffer2)(
129+
command_buffer,
130+
buffer,
131+
offset,
132+
size,
133+
index_type,
134+
)
135+
}
136+
137+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetRenderingAreaGranularity.html>
138+
#[inline]
139+
#[doc(alias = "vkGetRenderingAreaGranularity")]
140+
pub unsafe fn get_rendering_area_granularity(
141+
&self,
142+
rendering_area_info: &vk::RenderingAreaInfo<'_>,
143+
) -> vk::Extent2D {
144+
let mut granularity = mem::MaybeUninit::uninit();
145+
(self.device_fn_1_4.get_rendering_area_granularity)(
146+
self.handle,
147+
rendering_area_info,
148+
granularity.as_mut_ptr(),
149+
);
150+
granularity.assume_init()
151+
}
152+
153+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageSubresourceLayout.html>
154+
#[inline]
155+
#[doc(alias = "vkGetDeviceImageSubresourceLayout")]
156+
pub unsafe fn get_device_image_subresource_layout(
157+
&self,
158+
info: &vk::DeviceImageSubresourceInfo<'_>,
159+
layout: &mut vk::SubresourceLayout2<'_>,
160+
) {
161+
(self.device_fn_1_4.get_device_image_subresource_layout)(self.handle, info, layout)
162+
}
163+
164+
// XXX: Replicate comments from VK_EXT_host_image_copy, VK_EXT_image_compression_control
165+
// and VK_KHR_maintenance5 about alternative ways to fetch and use a suffixed vesion of this
166+
// function? And retroactively update those docs?
167+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageSubresourceLayout2.html>
168+
#[inline]
169+
#[doc(alias = "vkGetImageSubresourceLayout2")]
170+
pub unsafe fn get_image_subresource_layout2(
171+
&self,
172+
image: vk::Image,
173+
subresource: &vk::ImageSubresource2<'_>,
174+
layout: &mut vk::SubresourceLayout2<'_>,
175+
) {
176+
(self.device_fn_1_4.get_image_subresource_layout2)(self.handle, image, subresource, layout)
177+
}
178+
179+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSet.html>
180+
#[inline]
181+
#[doc(alias = "vkCmdPushDescriptorSet")]
182+
pub unsafe fn cmd_push_descriptor_set(
183+
&self,
184+
command_buffer: vk::CommandBuffer,
185+
pipeline_bind_point: vk::PipelineBindPoint,
186+
layout: vk::PipelineLayout,
187+
set: u32,
188+
descriptor_writes: &[vk::WriteDescriptorSet<'_>],
189+
) {
190+
(self.device_fn_1_4.cmd_push_descriptor_set)(
191+
command_buffer,
192+
pipeline_bind_point,
193+
layout,
194+
set,
195+
descriptor_writes.len() as u32,
196+
descriptor_writes.as_ptr(),
197+
)
198+
}
199+
200+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSetWithTemplate.html>
201+
#[inline]
202+
#[doc(alias = "vkCmdPushDescriptorSetWithTemplate")]
203+
pub unsafe fn cmd_push_descriptor_set_with_template(
204+
&self,
205+
command_buffer: vk::CommandBuffer,
206+
descriptor_update_template: vk::DescriptorUpdateTemplate,
207+
layout: vk::PipelineLayout,
208+
set: u32,
209+
p_data: *const ffi::c_void,
210+
) {
211+
(self.device_fn_1_4.cmd_push_descriptor_set_with_template)(
212+
command_buffer,
213+
descriptor_update_template,
214+
layout,
215+
set,
216+
p_data,
217+
)
218+
}
219+
220+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetRenderingAttachmentLocations.html>
221+
#[inline]
222+
#[doc(alias = "vkCmdSetRenderingAttachmentLocations")]
223+
pub unsafe fn cmd_set_rendering_attachment_locations(
224+
&self,
225+
command_buffer: vk::CommandBuffer,
226+
location_info: &vk::RenderingAttachmentLocationInfo<'_>,
227+
) {
228+
(self.device_fn_1_4.cmd_set_rendering_attachment_locations)(command_buffer, location_info)
229+
}
230+
231+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetRenderingInputAttachmentIndices.html>
232+
#[inline]
233+
#[doc(alias = "vkCmdSetRenderingInputAttachmentIndices")]
234+
pub unsafe fn cmd_set_rendering_input_attachment_indices(
235+
&self,
236+
command_buffer: vk::CommandBuffer,
237+
input_attachment_index_info: &vk::RenderingInputAttachmentIndexInfo<'_>,
238+
) {
239+
(self
240+
.device_fn_1_4
241+
.cmd_set_rendering_input_attachment_indices)(
242+
command_buffer,
243+
input_attachment_index_info,
244+
)
245+
}
246+
247+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBindDescriptorSets2.html>
248+
#[inline]
249+
#[doc(alias = "vkCmdBindDescriptorSets2")]
250+
pub unsafe fn cmd_bind_descriptor_sets2(
251+
&self,
252+
command_buffer: vk::CommandBuffer,
253+
bind_descriptor_sets_info: &vk::BindDescriptorSetsInfo<'_>,
254+
) {
255+
(self.device_fn_1_4.cmd_bind_descriptor_sets2)(command_buffer, bind_descriptor_sets_info)
256+
}
257+
258+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdPushConstants2.html>
259+
#[inline]
260+
#[doc(alias = "vkCmdPushConstants2")]
261+
pub unsafe fn cmd_push_constants2(
262+
&self,
263+
command_buffer: vk::CommandBuffer,
264+
push_constants_info: &vk::PushConstantsInfo<'_>,
265+
) {
266+
(self.device_fn_1_4.cmd_push_constants2)(command_buffer, push_constants_info)
267+
}
268+
269+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSet2.html>
270+
#[inline]
271+
#[doc(alias = "vkCmdPushDescriptorSet2")]
272+
pub unsafe fn cmd_push_descriptor_set2(
273+
&self,
274+
command_buffer: vk::CommandBuffer,
275+
push_descriptor_set_info: &vk::PushDescriptorSetInfo<'_>,
276+
) {
277+
(self.device_fn_1_4.cmd_push_descriptor_set2)(command_buffer, push_descriptor_set_info)
278+
}
279+
280+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSetWithTemplate2.html>
281+
#[inline]
282+
#[doc(alias = "vkCmdPushDescriptorSetWithTemplate2")]
283+
pub unsafe fn cmd_push_descriptor_set_with_template2(
284+
&self,
285+
command_buffer: vk::CommandBuffer,
286+
push_descriptor_set_with_template_info: &vk::PushDescriptorSetWithTemplateInfo<'_>,
287+
) {
288+
(self.device_fn_1_4.cmd_push_descriptor_set_with_template2)(
289+
command_buffer,
290+
push_descriptor_set_with_template_info,
291+
)
292+
}
293+
294+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyMemoryToImage.html>
295+
#[inline]
296+
#[doc(alias = "vkCopyMemoryToImage")]
297+
pub unsafe fn copy_memory_to_image(
298+
&self,
299+
copy_memory_to_image_info: &vk::CopyMemoryToImageInfo<'_>,
300+
) -> VkResult<()> {
301+
(self.device_fn_1_4.copy_memory_to_image)(self.handle, copy_memory_to_image_info).result()
302+
}
303+
304+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyImageToMemory.html>
305+
#[inline]
306+
#[doc(alias = "vkCopyImageToMemory")]
307+
pub unsafe fn copy_image_to_memory(
308+
&self,
309+
copy_image_to_memory_info: &vk::CopyImageToMemoryInfo<'_>,
310+
) -> VkResult<()> {
311+
(self.device_fn_1_4.copy_image_to_memory)(self.handle, copy_image_to_memory_info).result()
312+
}
313+
314+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyImageToImage.html>
315+
#[inline]
316+
#[doc(alias = "vkCopyImageToImage")]
317+
pub unsafe fn copy_image_to_image(
318+
&self,
319+
copy_image_to_image_info: &vk::CopyImageToImageInfo<'_>,
320+
) -> VkResult<()> {
321+
(self.device_fn_1_4.copy_image_to_image)(self.handle, copy_image_to_image_info).result()
322+
}
323+
324+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkTransitionImageLayout.html>
325+
#[inline]
326+
#[doc(alias = "vkTransitionImageLayout")]
327+
pub unsafe fn transition_image_layout(
328+
&self,
329+
transitions: &[vk::HostImageLayoutTransitionInfo<'_>],
330+
) -> VkResult<()> {
331+
(self.device_fn_1_4.transition_image_layout)(
332+
self.handle,
333+
transitions.len() as u32,
334+
transitions.as_ptr(),
335+
)
336+
.result()
337+
}
338+
}
339+
68340
/// Vulkan core 1.3
69341
impl Device {
70342
#[inline]

ash/src/extensions/ext/host_image_copy.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{ext, khr};
88
impl crate::ext::host_image_copy::Device {
99
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyMemoryToImageEXT.html>
1010
#[inline]
11+
#[doc(alias = "vkCopyMemoryToImageEXT")]
1112
pub unsafe fn copy_memory_to_image(
1213
&self,
1314
copy_memory_to_image_info: &vk::CopyMemoryToImageInfoEXT<'_>,
@@ -17,6 +18,7 @@ impl crate::ext::host_image_copy::Device {
1718

1819
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyImageToMemoryEXT.html>
1920
#[inline]
21+
#[doc(alias = "vkCopyImageToMemoryEXT")]
2022
pub unsafe fn copy_image_to_memory(
2123
&self,
2224
copy_image_to_memory_info: &vk::CopyImageToMemoryInfoEXT<'_>,
@@ -26,6 +28,7 @@ impl crate::ext::host_image_copy::Device {
2628

2729
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCopyImageToImageEXT.html>
2830
#[inline]
31+
#[doc(alias = "vkCopyImageToImageEXT")]
2932
pub unsafe fn copy_image_to_image(
3033
&self,
3134
copy_image_to_image_info: &vk::CopyImageToImageInfoEXT<'_>,
@@ -35,6 +38,7 @@ impl crate::ext::host_image_copy::Device {
3538

3639
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkTransitionImageLayoutEXT.html>
3740
#[inline]
41+
#[doc(alias = "vkTransitionImageLayoutEXT")]
3842
pub unsafe fn transition_image_layout(
3943
&self,
4044
transitions: &[vk::HostImageLayoutTransitionInfoEXT<'_>],

ash/src/extensions/khr/dynamic_rendering_local_read.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::vk;
55
impl crate::khr::dynamic_rendering_local_read::Device {
66
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetRenderingAttachmentLocationsKHR.html>
77
#[inline]
8+
#[doc(alias = "vkCmdSetRenderingAttachmentLocations")]
89
pub unsafe fn cmd_set_rendering_attachment_locations(
910
&self,
1011
command_buffer: vk::CommandBuffer,
@@ -15,6 +16,7 @@ impl crate::khr::dynamic_rendering_local_read::Device {
1516

1617
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetRenderingInputAttachmentIndicesKHR.html>
1718
#[inline]
19+
#[doc(alias = "vkCmdSetRenderingInputAttachmentIndices")]
1820
pub unsafe fn cmd_set_rendering_input_attachment_indices(
1921
&self,
2022
command_buffer: vk::CommandBuffer,

0 commit comments

Comments
 (0)