2
2
3
3
use crate :: prelude:: * ;
4
4
use crate :: vk;
5
- use crate :: RawPtr as _ ;
5
+ use crate :: RawPtr ;
6
6
use core:: mem;
7
+ use core:: ptr;
7
8
8
9
impl crate :: khr:: video_queue:: Device {
9
- #[ inline]
10
10
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkBindVideoSessionMemoryKHR.html>
11
+ #[ inline]
12
+ #[ doc( alias = "vkBindVideoSessionMemoryKHR" ) ]
11
13
pub unsafe fn bind_video_session_memory (
12
14
& self ,
13
15
video_session : vk:: VideoSessionKHR ,
@@ -22,72 +24,78 @@ impl crate::khr::video_queue::Device {
22
24
. result ( )
23
25
}
24
26
25
- #[ inline]
26
27
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdBeginVideoCodingKHR.html>
28
+ #[ inline]
29
+ #[ doc( alias = "vkCmdBeginVideoCodingKHR" ) ]
27
30
pub unsafe fn cmd_begin_video_coding (
28
31
& self ,
29
32
command_buffer : vk:: CommandBuffer ,
30
33
begin_info : & vk:: VideoBeginCodingInfoKHR < ' _ > ,
31
34
) {
32
- ( self . fp . cmd_begin_video_coding_khr ) ( command_buffer, begin_info) ;
35
+ ( self . fp . cmd_begin_video_coding_khr ) ( command_buffer, begin_info)
33
36
}
34
37
35
- #[ inline]
36
38
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdControlVideoCodingKHR.html>
39
+ #[ inline]
40
+ #[ doc( alias = "vkCmdControlVideoCodingKHR" ) ]
37
41
pub unsafe fn cmd_control_video_coding (
38
42
& self ,
39
43
command_buffer : vk:: CommandBuffer ,
40
44
coding_control_info : & vk:: VideoCodingControlInfoKHR < ' _ > ,
41
45
) {
42
- ( self . fp . cmd_control_video_coding_khr ) ( command_buffer, coding_control_info) ;
46
+ ( self . fp . cmd_control_video_coding_khr ) ( command_buffer, coding_control_info)
43
47
}
44
48
45
- #[ inline]
46
49
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdEndVideoCodingKHR.html>
50
+ #[ inline]
51
+ #[ doc( alias = "vkCmdEndVideoCodingKHR" ) ]
47
52
pub unsafe fn cmd_end_video_coding (
48
53
& self ,
49
54
command_buffer : vk:: CommandBuffer ,
50
55
end_coding_info : & vk:: VideoEndCodingInfoKHR < ' _ > ,
51
56
) {
52
- ( self . fp . cmd_end_video_coding_khr ) ( command_buffer, end_coding_info) ;
57
+ ( self . fp . cmd_end_video_coding_khr ) ( command_buffer, end_coding_info)
53
58
}
54
59
55
- #[ inline]
56
60
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateVideoSessionKHR.html>
61
+ #[ inline]
62
+ #[ doc( alias = "vkCreateVideoSessionKHR" ) ]
57
63
pub unsafe fn create_video_session (
58
64
& self ,
59
65
create_info : & vk:: VideoSessionCreateInfoKHR < ' _ > ,
60
66
allocation_callbacks : Option < & vk:: AllocationCallbacks < ' _ > > ,
61
67
) -> VkResult < vk:: VideoSessionKHR > {
62
- let mut video_session = mem:: zeroed ( ) ;
68
+ let mut video_session = mem:: MaybeUninit :: uninit ( ) ;
63
69
( self . fp . create_video_session_khr ) (
64
70
self . handle ,
65
71
create_info,
66
72
allocation_callbacks. as_raw_ptr ( ) ,
67
- & mut video_session,
73
+ video_session. as_mut_ptr ( ) ,
68
74
)
69
- . result_with_success ( video_session)
75
+ . assume_init_on_success ( video_session)
70
76
}
71
77
72
- #[ inline]
73
78
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateVideoSessionParametersKHR.html>
79
+ #[ inline]
80
+ #[ doc( alias = "vkCreateVideoSessionParametersKHR" ) ]
74
81
pub unsafe fn create_video_session_parameters (
75
82
& self ,
76
83
create_info : & vk:: VideoSessionParametersCreateInfoKHR < ' _ > ,
77
84
allocation_callbacks : Option < & vk:: AllocationCallbacks < ' _ > > ,
78
85
) -> VkResult < vk:: VideoSessionParametersKHR > {
79
- let mut video_session_parameters = mem:: zeroed ( ) ;
86
+ let mut video_session_parameters = mem:: MaybeUninit :: uninit ( ) ;
80
87
( self . fp . create_video_session_parameters_khr ) (
81
88
self . handle ,
82
89
create_info,
83
90
allocation_callbacks. as_raw_ptr ( ) ,
84
- & mut video_session_parameters,
91
+ video_session_parameters. as_mut_ptr ( ) ,
85
92
)
86
- . result_with_success ( video_session_parameters)
93
+ . assume_init_on_success ( video_session_parameters)
87
94
}
88
95
89
- #[ inline]
90
96
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyVideoSessionKHR.html>
97
+ #[ inline]
98
+ #[ doc( alias = "vkDestroyVideoSessionKHR" ) ]
91
99
pub unsafe fn destroy_video_session (
92
100
& self ,
93
101
video_session : vk:: VideoSessionKHR ,
@@ -97,11 +105,12 @@ impl crate::khr::video_queue::Device {
97
105
self . handle ,
98
106
video_session,
99
107
allocation_callbacks. as_raw_ptr ( ) ,
100
- ) ;
108
+ )
101
109
}
102
110
103
- #[ inline]
104
111
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroyVideoSessionParametersKHR.html>
112
+ #[ inline]
113
+ #[ doc( alias = "vkDestroyVideoSessionParametersKHR" ) ]
105
114
pub unsafe fn destroy_video_session_parameters (
106
115
& self ,
107
116
video_session_parameters : vk:: VideoSessionParametersKHR ,
@@ -111,27 +120,53 @@ impl crate::khr::video_queue::Device {
111
120
self . handle ,
112
121
video_session_parameters,
113
122
allocation_callbacks. as_raw_ptr ( ) ,
114
- ) ;
123
+ )
115
124
}
116
125
126
+ /// Retrieve the number of elements to pass to [`get_video_session_memory_requirements()`][Self::get_video_session_memory_requirements],
117
127
#[ inline]
128
+ pub unsafe fn get_video_session_memory_requirements_len (
129
+ & self ,
130
+ video_session : vk:: VideoSessionKHR ,
131
+ ) -> VkResult < usize > {
132
+ let mut req_count = mem:: MaybeUninit :: uninit ( ) ;
133
+ ( self . fp . get_video_session_memory_requirements_khr ) (
134
+ self . handle ,
135
+ video_session,
136
+ req_count. as_mut_ptr ( ) ,
137
+ ptr:: null_mut ( ) ,
138
+ )
139
+ . assume_init_on_success ( req_count)
140
+ . map ( |c| c as usize )
141
+ }
142
+
118
143
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetVideoSessionMemoryRequirementsKHR.html>
144
+ ///
145
+ /// Call [`get_video_session_memory_requirements_len()`][Self::get_video_session_memory_requirements_len] to query the number of elements to pass to `out.`
146
+ /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
147
+ #[ inline]
148
+ #[ doc( alias = "vkGetVideoSessionMemoryRequirementsKHR" ) ]
119
149
pub unsafe fn get_video_session_memory_requirements (
120
150
& self ,
121
151
video_session : vk:: VideoSessionKHR ,
122
- ) -> VkResult < Vec < vk:: VideoSessionMemoryRequirementsKHR < ' _ > > > {
123
- read_into_defaulted_vector ( |count, data| {
124
- ( self . fp . get_video_session_memory_requirements_khr ) (
125
- self . handle ,
126
- video_session,
127
- count,
128
- data,
129
- )
130
- } )
152
+ out : & mut [ vk:: VideoSessionMemoryRequirementsKHR < ' _ > ] ,
153
+ ) -> VkResult < ( ) > {
154
+ let mut req_count = out. len ( ) as u32 ;
155
+ ( self . fp . get_video_session_memory_requirements_khr ) (
156
+ self . handle ,
157
+ video_session,
158
+ & mut req_count,
159
+ out. as_mut_ptr ( ) ,
160
+ )
161
+ . result ( ) ?;
162
+
163
+ assert_eq ! ( req_count as usize , out. len( ) ) ;
164
+ Ok ( ( ) )
131
165
}
132
166
133
- #[ inline]
134
167
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkUpdateVideoSessionParametersKHR.html>
168
+ #[ inline]
169
+ #[ doc( alias = "vkUpdateVideoSessionParametersKHR" ) ]
135
170
pub unsafe fn update_video_session_parameters (
136
171
& self ,
137
172
video_session_parameters : vk:: VideoSessionParametersKHR ,
@@ -147,8 +182,9 @@ impl crate::khr::video_queue::Device {
147
182
}
148
183
149
184
impl crate :: khr:: video_queue:: Instance {
150
- #[ inline]
151
185
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceVideoCapabilitiesKHR.html>
186
+ #[ inline]
187
+ #[ doc( alias = "vkGetPhysicalDeviceVideoCapabilitiesKHR" ) ]
152
188
pub unsafe fn get_physical_device_video_capabilities (
153
189
& self ,
154
190
physical_device : vk:: PhysicalDevice ,
@@ -163,20 +199,46 @@ impl crate::khr::video_queue::Instance {
163
199
. result ( )
164
200
}
165
201
202
+ /// Retrieve the number of elements to pass to [`get_physical_device_video_format_properties()`][Self::get_physical_device_video_format_properties],
166
203
#[ inline]
204
+ pub unsafe fn get_physical_device_video_format_properties_len (
205
+ & self ,
206
+ physical_device : vk:: PhysicalDevice ,
207
+ video_format_info : & vk:: PhysicalDeviceVideoFormatInfoKHR < ' _ > ,
208
+ ) -> VkResult < usize > {
209
+ let mut format_count = mem:: MaybeUninit :: uninit ( ) ;
210
+ ( self . fp . get_physical_device_video_format_properties_khr ) (
211
+ physical_device,
212
+ video_format_info,
213
+ format_count. as_mut_ptr ( ) ,
214
+ ptr:: null_mut ( ) ,
215
+ )
216
+ . assume_init_on_success ( format_count)
217
+ . map ( |c| c as usize )
218
+ }
219
+
167
220
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceVideoFormatPropertiesKHR.html>
221
+ ///
222
+ /// Call [`get_physical_device_video_format_properties_len()`][Self::get_physical_device_video_format_properties_len] to query the number of elements to pass to `out.`
223
+ /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer.
224
+ #[ inline]
225
+ #[ doc( alias = "vkGetPhysicalDeviceVideoFormatPropertiesKHR" ) ]
168
226
pub unsafe fn get_physical_device_video_format_properties (
169
227
& self ,
170
228
physical_device : vk:: PhysicalDevice ,
171
229
video_format_info : & vk:: PhysicalDeviceVideoFormatInfoKHR < ' _ > ,
172
- ) -> VkResult < Vec < vk:: VideoFormatPropertiesKHR < ' _ > > > {
173
- read_into_defaulted_vector ( |count, data| {
174
- ( self . fp . get_physical_device_video_format_properties_khr ) (
175
- physical_device,
176
- video_format_info,
177
- count,
178
- data,
179
- )
180
- } )
230
+ out : & mut [ vk:: VideoFormatPropertiesKHR < ' _ > ] ,
231
+ ) -> VkResult < ( ) > {
232
+ let mut format_count = out. len ( ) as u32 ;
233
+ ( self . fp . get_physical_device_video_format_properties_khr ) (
234
+ physical_device,
235
+ video_format_info,
236
+ & mut format_count,
237
+ out. as_mut_ptr ( ) ,
238
+ )
239
+ . result ( ) ?;
240
+
241
+ assert_eq ! ( format_count as usize , out. len( ) ) ;
242
+ Ok ( ( ) )
181
243
}
182
244
}
0 commit comments