1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_descriptor_buffer.html>

use crate::prelude::*;
use crate::vk;
use core::mem;

impl crate::ext::descriptor_buffer::Device {
    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorSetLayoutSizeEXT.html>
    #[inline]
    pub unsafe fn get_descriptor_set_layout_size(
        &self,
        layout: vk::DescriptorSetLayout,
    ) -> vk::DeviceSize {
        let mut count = mem::MaybeUninit::uninit();
        (self.fp.get_descriptor_set_layout_size_ext)(self.handle, layout, count.as_mut_ptr());
        count.assume_init()
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorSetLayoutBindingOffsetEXT.html>
    #[inline]
    pub unsafe fn get_descriptor_set_layout_binding_offset(
        &self,
        layout: vk::DescriptorSetLayout,
        binding: u32,
    ) -> vk::DeviceSize {
        let mut offset = mem::MaybeUninit::uninit();
        (self.fp.get_descriptor_set_layout_binding_offset_ext)(
            self.handle,
            layout,
            binding,
            offset.as_mut_ptr(),
        );
        offset.assume_init()
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorEXT.html>
    #[inline]
    pub unsafe fn get_descriptor(
        &self,
        descriptor_info: &vk::DescriptorGetInfoEXT<'_>,
        descriptor: &mut [u8],
    ) {
        (self.fp.get_descriptor_ext)(
            self.handle,
            descriptor_info,
            descriptor.len(),
            descriptor.as_mut_ptr().cast(),
        )
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBindDescriptorBuffersEXT.html>
    #[inline]
    pub unsafe fn cmd_bind_descriptor_buffers(
        &self,
        command_buffer: vk::CommandBuffer,
        binding_info: &[vk::DescriptorBufferBindingInfoEXT<'_>],
    ) {
        (self.fp.cmd_bind_descriptor_buffers_ext)(
            command_buffer,
            binding_info.len() as u32,
            binding_info.as_ptr(),
        )
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdSetDescriptorBufferOffsetsEXT.html>
    #[inline]
    pub unsafe fn cmd_set_descriptor_buffer_offsets(
        &self,
        command_buffer: vk::CommandBuffer,
        pipeline_bind_point: vk::PipelineBindPoint,
        layout: vk::PipelineLayout,
        first_set: u32,
        buffer_indices: &[u32],
        offsets: &[vk::DeviceSize],
    ) {
        assert_eq!(buffer_indices.len(), offsets.len());
        (self.fp.cmd_set_descriptor_buffer_offsets_ext)(
            command_buffer,
            pipeline_bind_point,
            layout,
            first_set,
            buffer_indices.len() as u32,
            buffer_indices.as_ptr(),
            offsets.as_ptr(),
        )
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBindDescriptorBufferEmbeddedSamplersEXT.html>
    #[inline]
    pub unsafe fn cmd_bind_descriptor_buffer_embedded_samplers(
        &self,
        command_buffer: vk::CommandBuffer,
        pipeline_bind_point: vk::PipelineBindPoint,
        layout: vk::PipelineLayout,
        set: u32,
    ) {
        (self.fp.cmd_bind_descriptor_buffer_embedded_samplers_ext)(
            command_buffer,
            pipeline_bind_point,
            layout,
            set,
        )
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetBufferOpaqueCaptureDescriptorDataEXT.html>
    #[inline]
    pub unsafe fn get_buffer_opaque_capture_descriptor_data(
        &self,
        info: &vk::BufferCaptureDescriptorDataInfoEXT<'_>,
        data: &mut [u8],
    ) -> VkResult<()> {
        (self.fp.get_buffer_opaque_capture_descriptor_data_ext)(
            self.handle,
            info,
            data.as_mut_ptr().cast(),
        )
        .result()
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageOpaqueCaptureDescriptorDataEXT.html>
    #[inline]
    pub unsafe fn get_image_opaque_capture_descriptor_data(
        &self,
        info: &vk::ImageCaptureDescriptorDataInfoEXT<'_>,
        data: &mut [u8],
    ) -> VkResult<()> {
        (self.fp.get_image_opaque_capture_descriptor_data_ext)(
            self.handle,
            info,
            data.as_mut_ptr().cast(),
        )
        .result()
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetImageViewOpaqueCaptureDescriptorDataEXT.html>
    #[inline]
    pub unsafe fn get_image_view_opaque_capture_descriptor_data(
        &self,
        info: &vk::ImageViewCaptureDescriptorDataInfoEXT<'_>,
        data: &mut [u8],
    ) -> VkResult<()> {
        (self.fp.get_image_view_opaque_capture_descriptor_data_ext)(
            self.handle,
            info,
            data.as_mut_ptr().cast(),
        )
        .result()
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetSamplerOpaqueCaptureDescriptorDataEXT.html>
    #[inline]
    pub unsafe fn get_sampler_opaque_capture_descriptor_data(
        &self,
        info: &vk::SamplerCaptureDescriptorDataInfoEXT<'_>,
        data: &mut [u8],
    ) -> VkResult<()> {
        (self.fp.get_sampler_opaque_capture_descriptor_data_ext)(
            self.handle,
            info,
            data.as_mut_ptr().cast(),
        )
        .result()
    }

    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT.html>
    #[inline]
    pub unsafe fn get_acceleration_structure_opaque_capture_descriptor_data(
        &self,
        info: &vk::AccelerationStructureCaptureDescriptorDataInfoEXT<'_>,
        data: &mut [u8],
    ) -> VkResult<()> {
        (self
            .fp
            .get_acceleration_structure_opaque_capture_descriptor_data_ext)(
            self.handle,
            info,
            data.as_mut_ptr().cast(),
        )
        .result()
    }
}