1 /* This file is generated by venus-protocol. See vn_protocol_driver.h. */
2
3 /*
4 * Copyright 2020 Google LLC
5 * SPDX-License-Identifier: MIT
6 */
7
8 #ifndef VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_H
9 #define VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_H
10
11 #include "vn_instance.h"
12 #include "vn_protocol_driver_structs.h"
13
14 /*
15 * These structs/unions/commands are not included
16 *
17 * vkUpdateDescriptorSetWithTemplate
18 */
19
20 /* struct VkDescriptorSetVariableDescriptorCountAllocateInfo chain */
21
22 static inline size_t
vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext(const void * val)23 vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext(const void *val)
24 {
25 /* no known/supported struct */
26 return vn_sizeof_simple_pointer(NULL);
27 }
28
29 static inline size_t
vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(const VkDescriptorSetVariableDescriptorCountAllocateInfo * val)30 vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(const VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
31 {
32 size_t size = 0;
33 /* skip val->{sType,pNext} */
34 size += vn_sizeof_uint32_t(&val->descriptorSetCount);
35 if (val->pDescriptorCounts) {
36 size += vn_sizeof_array_size(val->descriptorSetCount);
37 size += vn_sizeof_uint32_t_array(val->pDescriptorCounts, val->descriptorSetCount);
38 } else {
39 size += vn_sizeof_array_size(0);
40 }
41 return size;
42 }
43
44 static inline size_t
vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo(const VkDescriptorSetVariableDescriptorCountAllocateInfo * val)45 vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo(const VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
46 {
47 size_t size = 0;
48
49 size += vn_sizeof_VkStructureType(&val->sType);
50 size += vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext(val->pNext);
51 size += vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(val);
52
53 return size;
54 }
55
56 static inline void
vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext(struct vn_cs_encoder * enc,const void * val)57 vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
58 {
59 /* no known/supported struct */
60 vn_encode_simple_pointer(enc, NULL);
61 }
62
63 static inline void
vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(struct vn_cs_encoder * enc,const VkDescriptorSetVariableDescriptorCountAllocateInfo * val)64 vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(struct vn_cs_encoder *enc, const VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
65 {
66 /* skip val->{sType,pNext} */
67 vn_encode_uint32_t(enc, &val->descriptorSetCount);
68 if (val->pDescriptorCounts) {
69 vn_encode_array_size(enc, val->descriptorSetCount);
70 vn_encode_uint32_t_array(enc, val->pDescriptorCounts, val->descriptorSetCount);
71 } else {
72 vn_encode_array_size(enc, 0);
73 }
74 }
75
76 static inline void
vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo(struct vn_cs_encoder * enc,const VkDescriptorSetVariableDescriptorCountAllocateInfo * val)77 vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo(struct vn_cs_encoder *enc, const VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
78 {
79 assert(val->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO);
80 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO });
81 vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext(enc, val->pNext);
82 vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(enc, val);
83 }
84
85 /* struct VkDescriptorSetAllocateInfo chain */
86
87 static inline size_t
vn_sizeof_VkDescriptorSetAllocateInfo_pnext(const void * val)88 vn_sizeof_VkDescriptorSetAllocateInfo_pnext(const void *val)
89 {
90 const VkBaseInStructure *pnext = val;
91 size_t size = 0;
92
93 while (pnext) {
94 switch ((int32_t)pnext->sType) {
95 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO:
96 size += vn_sizeof_simple_pointer(pnext);
97 size += vn_sizeof_VkStructureType(&pnext->sType);
98 size += vn_sizeof_VkDescriptorSetAllocateInfo_pnext(pnext->pNext);
99 size += vn_sizeof_VkDescriptorSetVariableDescriptorCountAllocateInfo_self((const VkDescriptorSetVariableDescriptorCountAllocateInfo *)pnext);
100 return size;
101 default:
102 /* ignore unknown/unsupported struct */
103 break;
104 }
105 pnext = pnext->pNext;
106 }
107
108 return vn_sizeof_simple_pointer(NULL);
109 }
110
111 static inline size_t
vn_sizeof_VkDescriptorSetAllocateInfo_self(const VkDescriptorSetAllocateInfo * val)112 vn_sizeof_VkDescriptorSetAllocateInfo_self(const VkDescriptorSetAllocateInfo *val)
113 {
114 size_t size = 0;
115 /* skip val->{sType,pNext} */
116 size += vn_sizeof_VkDescriptorPool(&val->descriptorPool);
117 size += vn_sizeof_uint32_t(&val->descriptorSetCount);
118 if (val->pSetLayouts) {
119 size += vn_sizeof_array_size(val->descriptorSetCount);
120 for (uint32_t i = 0; i < val->descriptorSetCount; i++)
121 size += vn_sizeof_VkDescriptorSetLayout(&val->pSetLayouts[i]);
122 } else {
123 size += vn_sizeof_array_size(0);
124 }
125 return size;
126 }
127
128 static inline size_t
vn_sizeof_VkDescriptorSetAllocateInfo(const VkDescriptorSetAllocateInfo * val)129 vn_sizeof_VkDescriptorSetAllocateInfo(const VkDescriptorSetAllocateInfo *val)
130 {
131 size_t size = 0;
132
133 size += vn_sizeof_VkStructureType(&val->sType);
134 size += vn_sizeof_VkDescriptorSetAllocateInfo_pnext(val->pNext);
135 size += vn_sizeof_VkDescriptorSetAllocateInfo_self(val);
136
137 return size;
138 }
139
140 static inline void
vn_encode_VkDescriptorSetAllocateInfo_pnext(struct vn_cs_encoder * enc,const void * val)141 vn_encode_VkDescriptorSetAllocateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
142 {
143 const VkBaseInStructure *pnext = val;
144
145 while (pnext) {
146 switch ((int32_t)pnext->sType) {
147 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO:
148 vn_encode_simple_pointer(enc, pnext);
149 vn_encode_VkStructureType(enc, &pnext->sType);
150 vn_encode_VkDescriptorSetAllocateInfo_pnext(enc, pnext->pNext);
151 vn_encode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self(enc, (const VkDescriptorSetVariableDescriptorCountAllocateInfo *)pnext);
152 return;
153 default:
154 /* ignore unknown/unsupported struct */
155 break;
156 }
157 pnext = pnext->pNext;
158 }
159
160 vn_encode_simple_pointer(enc, NULL);
161 }
162
163 static inline void
vn_encode_VkDescriptorSetAllocateInfo_self(struct vn_cs_encoder * enc,const VkDescriptorSetAllocateInfo * val)164 vn_encode_VkDescriptorSetAllocateInfo_self(struct vn_cs_encoder *enc, const VkDescriptorSetAllocateInfo *val)
165 {
166 /* skip val->{sType,pNext} */
167 vn_encode_VkDescriptorPool(enc, &val->descriptorPool);
168 vn_encode_uint32_t(enc, &val->descriptorSetCount);
169 if (val->pSetLayouts) {
170 vn_encode_array_size(enc, val->descriptorSetCount);
171 for (uint32_t i = 0; i < val->descriptorSetCount; i++)
172 vn_encode_VkDescriptorSetLayout(enc, &val->pSetLayouts[i]);
173 } else {
174 vn_encode_array_size(enc, 0);
175 }
176 }
177
178 static inline void
vn_encode_VkDescriptorSetAllocateInfo(struct vn_cs_encoder * enc,const VkDescriptorSetAllocateInfo * val)179 vn_encode_VkDescriptorSetAllocateInfo(struct vn_cs_encoder *enc, const VkDescriptorSetAllocateInfo *val)
180 {
181 assert(val->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO);
182 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO });
183 vn_encode_VkDescriptorSetAllocateInfo_pnext(enc, val->pNext);
184 vn_encode_VkDescriptorSetAllocateInfo_self(enc, val);
185 }
186
187 /* struct VkDescriptorImageInfo */
188
189 static inline size_t
vn_sizeof_VkDescriptorImageInfo(const VkDescriptorImageInfo * val)190 vn_sizeof_VkDescriptorImageInfo(const VkDescriptorImageInfo *val)
191 {
192 size_t size = 0;
193 size += vn_sizeof_VkSampler(&val->sampler);
194 size += vn_sizeof_VkImageView(&val->imageView);
195 size += vn_sizeof_VkImageLayout(&val->imageLayout);
196 return size;
197 }
198
199 static inline void
vn_encode_VkDescriptorImageInfo(struct vn_cs_encoder * enc,const VkDescriptorImageInfo * val)200 vn_encode_VkDescriptorImageInfo(struct vn_cs_encoder *enc, const VkDescriptorImageInfo *val)
201 {
202 vn_encode_VkSampler(enc, &val->sampler);
203 vn_encode_VkImageView(enc, &val->imageView);
204 vn_encode_VkImageLayout(enc, &val->imageLayout);
205 }
206
207 /* struct VkDescriptorBufferInfo */
208
209 static inline size_t
vn_sizeof_VkDescriptorBufferInfo(const VkDescriptorBufferInfo * val)210 vn_sizeof_VkDescriptorBufferInfo(const VkDescriptorBufferInfo *val)
211 {
212 size_t size = 0;
213 size += vn_sizeof_VkBuffer(&val->buffer);
214 size += vn_sizeof_VkDeviceSize(&val->offset);
215 size += vn_sizeof_VkDeviceSize(&val->range);
216 return size;
217 }
218
219 static inline void
vn_encode_VkDescriptorBufferInfo(struct vn_cs_encoder * enc,const VkDescriptorBufferInfo * val)220 vn_encode_VkDescriptorBufferInfo(struct vn_cs_encoder *enc, const VkDescriptorBufferInfo *val)
221 {
222 vn_encode_VkBuffer(enc, &val->buffer);
223 vn_encode_VkDeviceSize(enc, &val->offset);
224 vn_encode_VkDeviceSize(enc, &val->range);
225 }
226
227 /* struct VkWriteDescriptorSet chain */
228
229 static inline size_t
vn_sizeof_VkWriteDescriptorSet_pnext(const void * val)230 vn_sizeof_VkWriteDescriptorSet_pnext(const void *val)
231 {
232 /* no known/supported struct */
233 return vn_sizeof_simple_pointer(NULL);
234 }
235
236 static inline size_t
vn_sizeof_VkWriteDescriptorSet_self(const VkWriteDescriptorSet * val)237 vn_sizeof_VkWriteDescriptorSet_self(const VkWriteDescriptorSet *val)
238 {
239 size_t size = 0;
240 /* skip val->{sType,pNext} */
241 size += vn_sizeof_VkDescriptorSet(&val->dstSet);
242 size += vn_sizeof_uint32_t(&val->dstBinding);
243 size += vn_sizeof_uint32_t(&val->dstArrayElement);
244 size += vn_sizeof_uint32_t(&val->descriptorCount);
245 size += vn_sizeof_VkDescriptorType(&val->descriptorType);
246 if (val->pImageInfo) {
247 size += vn_sizeof_array_size(val->descriptorCount);
248 for (uint32_t i = 0; i < val->descriptorCount; i++)
249 size += vn_sizeof_VkDescriptorImageInfo(&val->pImageInfo[i]);
250 } else {
251 size += vn_sizeof_array_size(0);
252 }
253 if (val->pBufferInfo) {
254 size += vn_sizeof_array_size(val->descriptorCount);
255 for (uint32_t i = 0; i < val->descriptorCount; i++)
256 size += vn_sizeof_VkDescriptorBufferInfo(&val->pBufferInfo[i]);
257 } else {
258 size += vn_sizeof_array_size(0);
259 }
260 if (val->pTexelBufferView) {
261 size += vn_sizeof_array_size(val->descriptorCount);
262 for (uint32_t i = 0; i < val->descriptorCount; i++)
263 size += vn_sizeof_VkBufferView(&val->pTexelBufferView[i]);
264 } else {
265 size += vn_sizeof_array_size(0);
266 }
267 return size;
268 }
269
270 static inline size_t
vn_sizeof_VkWriteDescriptorSet(const VkWriteDescriptorSet * val)271 vn_sizeof_VkWriteDescriptorSet(const VkWriteDescriptorSet *val)
272 {
273 size_t size = 0;
274
275 size += vn_sizeof_VkStructureType(&val->sType);
276 size += vn_sizeof_VkWriteDescriptorSet_pnext(val->pNext);
277 size += vn_sizeof_VkWriteDescriptorSet_self(val);
278
279 return size;
280 }
281
282 static inline void
vn_encode_VkWriteDescriptorSet_pnext(struct vn_cs_encoder * enc,const void * val)283 vn_encode_VkWriteDescriptorSet_pnext(struct vn_cs_encoder *enc, const void *val)
284 {
285 /* no known/supported struct */
286 vn_encode_simple_pointer(enc, NULL);
287 }
288
289 static inline void
vn_encode_VkWriteDescriptorSet_self(struct vn_cs_encoder * enc,const VkWriteDescriptorSet * val)290 vn_encode_VkWriteDescriptorSet_self(struct vn_cs_encoder *enc, const VkWriteDescriptorSet *val)
291 {
292 /* skip val->{sType,pNext} */
293 vn_encode_VkDescriptorSet(enc, &val->dstSet);
294 vn_encode_uint32_t(enc, &val->dstBinding);
295 vn_encode_uint32_t(enc, &val->dstArrayElement);
296 vn_encode_uint32_t(enc, &val->descriptorCount);
297 vn_encode_VkDescriptorType(enc, &val->descriptorType);
298 if (val->pImageInfo) {
299 vn_encode_array_size(enc, val->descriptorCount);
300 for (uint32_t i = 0; i < val->descriptorCount; i++)
301 vn_encode_VkDescriptorImageInfo(enc, &val->pImageInfo[i]);
302 } else {
303 vn_encode_array_size(enc, 0);
304 }
305 if (val->pBufferInfo) {
306 vn_encode_array_size(enc, val->descriptorCount);
307 for (uint32_t i = 0; i < val->descriptorCount; i++)
308 vn_encode_VkDescriptorBufferInfo(enc, &val->pBufferInfo[i]);
309 } else {
310 vn_encode_array_size(enc, 0);
311 }
312 if (val->pTexelBufferView) {
313 vn_encode_array_size(enc, val->descriptorCount);
314 for (uint32_t i = 0; i < val->descriptorCount; i++)
315 vn_encode_VkBufferView(enc, &val->pTexelBufferView[i]);
316 } else {
317 vn_encode_array_size(enc, 0);
318 }
319 }
320
321 static inline void
vn_encode_VkWriteDescriptorSet(struct vn_cs_encoder * enc,const VkWriteDescriptorSet * val)322 vn_encode_VkWriteDescriptorSet(struct vn_cs_encoder *enc, const VkWriteDescriptorSet *val)
323 {
324 assert(val->sType == VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET);
325 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET });
326 vn_encode_VkWriteDescriptorSet_pnext(enc, val->pNext);
327 vn_encode_VkWriteDescriptorSet_self(enc, val);
328 }
329
330 /* struct VkCopyDescriptorSet chain */
331
332 static inline size_t
vn_sizeof_VkCopyDescriptorSet_pnext(const void * val)333 vn_sizeof_VkCopyDescriptorSet_pnext(const void *val)
334 {
335 /* no known/supported struct */
336 return vn_sizeof_simple_pointer(NULL);
337 }
338
339 static inline size_t
vn_sizeof_VkCopyDescriptorSet_self(const VkCopyDescriptorSet * val)340 vn_sizeof_VkCopyDescriptorSet_self(const VkCopyDescriptorSet *val)
341 {
342 size_t size = 0;
343 /* skip val->{sType,pNext} */
344 size += vn_sizeof_VkDescriptorSet(&val->srcSet);
345 size += vn_sizeof_uint32_t(&val->srcBinding);
346 size += vn_sizeof_uint32_t(&val->srcArrayElement);
347 size += vn_sizeof_VkDescriptorSet(&val->dstSet);
348 size += vn_sizeof_uint32_t(&val->dstBinding);
349 size += vn_sizeof_uint32_t(&val->dstArrayElement);
350 size += vn_sizeof_uint32_t(&val->descriptorCount);
351 return size;
352 }
353
354 static inline size_t
vn_sizeof_VkCopyDescriptorSet(const VkCopyDescriptorSet * val)355 vn_sizeof_VkCopyDescriptorSet(const VkCopyDescriptorSet *val)
356 {
357 size_t size = 0;
358
359 size += vn_sizeof_VkStructureType(&val->sType);
360 size += vn_sizeof_VkCopyDescriptorSet_pnext(val->pNext);
361 size += vn_sizeof_VkCopyDescriptorSet_self(val);
362
363 return size;
364 }
365
366 static inline void
vn_encode_VkCopyDescriptorSet_pnext(struct vn_cs_encoder * enc,const void * val)367 vn_encode_VkCopyDescriptorSet_pnext(struct vn_cs_encoder *enc, const void *val)
368 {
369 /* no known/supported struct */
370 vn_encode_simple_pointer(enc, NULL);
371 }
372
373 static inline void
vn_encode_VkCopyDescriptorSet_self(struct vn_cs_encoder * enc,const VkCopyDescriptorSet * val)374 vn_encode_VkCopyDescriptorSet_self(struct vn_cs_encoder *enc, const VkCopyDescriptorSet *val)
375 {
376 /* skip val->{sType,pNext} */
377 vn_encode_VkDescriptorSet(enc, &val->srcSet);
378 vn_encode_uint32_t(enc, &val->srcBinding);
379 vn_encode_uint32_t(enc, &val->srcArrayElement);
380 vn_encode_VkDescriptorSet(enc, &val->dstSet);
381 vn_encode_uint32_t(enc, &val->dstBinding);
382 vn_encode_uint32_t(enc, &val->dstArrayElement);
383 vn_encode_uint32_t(enc, &val->descriptorCount);
384 }
385
386 static inline void
vn_encode_VkCopyDescriptorSet(struct vn_cs_encoder * enc,const VkCopyDescriptorSet * val)387 vn_encode_VkCopyDescriptorSet(struct vn_cs_encoder *enc, const VkCopyDescriptorSet *val)
388 {
389 assert(val->sType == VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET);
390 vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET });
391 vn_encode_VkCopyDescriptorSet_pnext(enc, val->pNext);
392 vn_encode_VkCopyDescriptorSet_self(enc, val);
393 }
394
vn_sizeof_vkAllocateDescriptorSets(VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)395 static inline size_t vn_sizeof_vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
396 {
397 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkAllocateDescriptorSets_EXT;
398 const VkFlags cmd_flags = 0;
399 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
400
401 cmd_size += vn_sizeof_VkDevice(&device);
402 cmd_size += vn_sizeof_simple_pointer(pAllocateInfo);
403 if (pAllocateInfo)
404 cmd_size += vn_sizeof_VkDescriptorSetAllocateInfo(pAllocateInfo);
405 if (pDescriptorSets) {
406 cmd_size += vn_sizeof_array_size((pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0));
407 for (uint32_t i = 0; i < (pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0); i++)
408 cmd_size += vn_sizeof_VkDescriptorSet(&pDescriptorSets[i]);
409 } else {
410 cmd_size += vn_sizeof_array_size(0);
411 }
412
413 return cmd_size;
414 }
415
vn_encode_vkAllocateDescriptorSets(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)416 static inline void vn_encode_vkAllocateDescriptorSets(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
417 {
418 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkAllocateDescriptorSets_EXT;
419
420 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
421 vn_encode_VkFlags(enc, &cmd_flags);
422
423 vn_encode_VkDevice(enc, &device);
424 if (vn_encode_simple_pointer(enc, pAllocateInfo))
425 vn_encode_VkDescriptorSetAllocateInfo(enc, pAllocateInfo);
426 if (pDescriptorSets) {
427 vn_encode_array_size(enc, (pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0));
428 for (uint32_t i = 0; i < (pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0); i++)
429 vn_encode_VkDescriptorSet(enc, &pDescriptorSets[i]);
430 } else {
431 vn_encode_array_size(enc, 0);
432 }
433 }
434
vn_sizeof_vkAllocateDescriptorSets_reply(VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)435 static inline size_t vn_sizeof_vkAllocateDescriptorSets_reply(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
436 {
437 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkAllocateDescriptorSets_EXT;
438 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
439
440 VkResult ret;
441 cmd_size += vn_sizeof_VkResult(&ret);
442 /* skip device */
443 /* skip pAllocateInfo */
444 if (pDescriptorSets) {
445 cmd_size += vn_sizeof_array_size((pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0));
446 for (uint32_t i = 0; i < (pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0); i++)
447 cmd_size += vn_sizeof_VkDescriptorSet(&pDescriptorSets[i]);
448 } else {
449 cmd_size += vn_sizeof_array_size(0);
450 }
451
452 return cmd_size;
453 }
454
vn_decode_vkAllocateDescriptorSets_reply(struct vn_cs_decoder * dec,VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)455 static inline VkResult vn_decode_vkAllocateDescriptorSets_reply(struct vn_cs_decoder *dec, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
456 {
457 VkCommandTypeEXT command_type;
458 vn_decode_VkCommandTypeEXT(dec, &command_type);
459 assert(command_type == VK_COMMAND_TYPE_vkAllocateDescriptorSets_EXT);
460
461 VkResult ret;
462 vn_decode_VkResult(dec, &ret);
463 /* skip device */
464 /* skip pAllocateInfo */
465 if (vn_peek_array_size(dec)) {
466 const uint32_t iter_count = vn_decode_array_size(dec, (pAllocateInfo ? pAllocateInfo->descriptorSetCount : 0));
467 for (uint32_t i = 0; i < iter_count; i++)
468 vn_decode_VkDescriptorSet(dec, &pDescriptorSets[i]);
469 } else {
470 vn_decode_array_size_unchecked(dec);
471 pDescriptorSets = NULL;
472 }
473
474 return ret;
475 }
476
vn_sizeof_vkFreeDescriptorSets(VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)477 static inline size_t vn_sizeof_vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
478 {
479 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkFreeDescriptorSets_EXT;
480 const VkFlags cmd_flags = 0;
481 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
482
483 cmd_size += vn_sizeof_VkDevice(&device);
484 cmd_size += vn_sizeof_VkDescriptorPool(&descriptorPool);
485 cmd_size += vn_sizeof_uint32_t(&descriptorSetCount);
486 if (pDescriptorSets) {
487 cmd_size += vn_sizeof_array_size(descriptorSetCount);
488 for (uint32_t i = 0; i < descriptorSetCount; i++)
489 cmd_size += vn_sizeof_VkDescriptorSet(&pDescriptorSets[i]);
490 } else {
491 cmd_size += vn_sizeof_array_size(0);
492 }
493
494 return cmd_size;
495 }
496
vn_encode_vkFreeDescriptorSets(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)497 static inline void vn_encode_vkFreeDescriptorSets(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
498 {
499 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkFreeDescriptorSets_EXT;
500
501 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
502 vn_encode_VkFlags(enc, &cmd_flags);
503
504 vn_encode_VkDevice(enc, &device);
505 vn_encode_VkDescriptorPool(enc, &descriptorPool);
506 vn_encode_uint32_t(enc, &descriptorSetCount);
507 if (pDescriptorSets) {
508 vn_encode_array_size(enc, descriptorSetCount);
509 for (uint32_t i = 0; i < descriptorSetCount; i++)
510 vn_encode_VkDescriptorSet(enc, &pDescriptorSets[i]);
511 } else {
512 vn_encode_array_size(enc, 0);
513 }
514 }
515
vn_sizeof_vkFreeDescriptorSets_reply(VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)516 static inline size_t vn_sizeof_vkFreeDescriptorSets_reply(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
517 {
518 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkFreeDescriptorSets_EXT;
519 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
520
521 VkResult ret;
522 cmd_size += vn_sizeof_VkResult(&ret);
523 /* skip device */
524 /* skip descriptorPool */
525 /* skip descriptorSetCount */
526 /* skip pDescriptorSets */
527
528 return cmd_size;
529 }
530
vn_decode_vkFreeDescriptorSets_reply(struct vn_cs_decoder * dec,VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)531 static inline VkResult vn_decode_vkFreeDescriptorSets_reply(struct vn_cs_decoder *dec, VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
532 {
533 VkCommandTypeEXT command_type;
534 vn_decode_VkCommandTypeEXT(dec, &command_type);
535 assert(command_type == VK_COMMAND_TYPE_vkFreeDescriptorSets_EXT);
536
537 VkResult ret;
538 vn_decode_VkResult(dec, &ret);
539 /* skip device */
540 /* skip descriptorPool */
541 /* skip descriptorSetCount */
542 /* skip pDescriptorSets */
543
544 return ret;
545 }
546
vn_sizeof_vkUpdateDescriptorSets(VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)547 static inline size_t vn_sizeof_vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
548 {
549 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkUpdateDescriptorSets_EXT;
550 const VkFlags cmd_flags = 0;
551 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
552
553 cmd_size += vn_sizeof_VkDevice(&device);
554 cmd_size += vn_sizeof_uint32_t(&descriptorWriteCount);
555 if (pDescriptorWrites) {
556 cmd_size += vn_sizeof_array_size(descriptorWriteCount);
557 for (uint32_t i = 0; i < descriptorWriteCount; i++)
558 cmd_size += vn_sizeof_VkWriteDescriptorSet(&pDescriptorWrites[i]);
559 } else {
560 cmd_size += vn_sizeof_array_size(0);
561 }
562 cmd_size += vn_sizeof_uint32_t(&descriptorCopyCount);
563 if (pDescriptorCopies) {
564 cmd_size += vn_sizeof_array_size(descriptorCopyCount);
565 for (uint32_t i = 0; i < descriptorCopyCount; i++)
566 cmd_size += vn_sizeof_VkCopyDescriptorSet(&pDescriptorCopies[i]);
567 } else {
568 cmd_size += vn_sizeof_array_size(0);
569 }
570
571 return cmd_size;
572 }
573
vn_encode_vkUpdateDescriptorSets(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)574 static inline void vn_encode_vkUpdateDescriptorSets(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
575 {
576 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkUpdateDescriptorSets_EXT;
577
578 vn_encode_VkCommandTypeEXT(enc, &cmd_type);
579 vn_encode_VkFlags(enc, &cmd_flags);
580
581 vn_encode_VkDevice(enc, &device);
582 vn_encode_uint32_t(enc, &descriptorWriteCount);
583 if (pDescriptorWrites) {
584 vn_encode_array_size(enc, descriptorWriteCount);
585 for (uint32_t i = 0; i < descriptorWriteCount; i++)
586 vn_encode_VkWriteDescriptorSet(enc, &pDescriptorWrites[i]);
587 } else {
588 vn_encode_array_size(enc, 0);
589 }
590 vn_encode_uint32_t(enc, &descriptorCopyCount);
591 if (pDescriptorCopies) {
592 vn_encode_array_size(enc, descriptorCopyCount);
593 for (uint32_t i = 0; i < descriptorCopyCount; i++)
594 vn_encode_VkCopyDescriptorSet(enc, &pDescriptorCopies[i]);
595 } else {
596 vn_encode_array_size(enc, 0);
597 }
598 }
599
vn_sizeof_vkUpdateDescriptorSets_reply(VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)600 static inline size_t vn_sizeof_vkUpdateDescriptorSets_reply(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
601 {
602 const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkUpdateDescriptorSets_EXT;
603 size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
604
605 /* skip device */
606 /* skip descriptorWriteCount */
607 /* skip pDescriptorWrites */
608 /* skip descriptorCopyCount */
609 /* skip pDescriptorCopies */
610
611 return cmd_size;
612 }
613
vn_decode_vkUpdateDescriptorSets_reply(struct vn_cs_decoder * dec,VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)614 static inline void vn_decode_vkUpdateDescriptorSets_reply(struct vn_cs_decoder *dec, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
615 {
616 VkCommandTypeEXT command_type;
617 vn_decode_VkCommandTypeEXT(dec, &command_type);
618 assert(command_type == VK_COMMAND_TYPE_vkUpdateDescriptorSets_EXT);
619
620 /* skip device */
621 /* skip descriptorWriteCount */
622 /* skip pDescriptorWrites */
623 /* skip descriptorCopyCount */
624 /* skip pDescriptorCopies */
625 }
626
vn_submit_vkAllocateDescriptorSets(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets,struct vn_instance_submit_command * submit)627 static inline void vn_submit_vkAllocateDescriptorSets(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets, struct vn_instance_submit_command *submit)
628 {
629 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
630 void *cmd_data = local_cmd_data;
631 size_t cmd_size = vn_sizeof_vkAllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
632 if (cmd_size > sizeof(local_cmd_data)) {
633 cmd_data = malloc(cmd_size);
634 if (!cmd_data)
635 cmd_size = 0;
636 }
637 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkAllocateDescriptorSets_reply(device, pAllocateInfo, pDescriptorSets) : 0;
638
639 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
640 if (cmd_size) {
641 vn_encode_vkAllocateDescriptorSets(enc, cmd_flags, device, pAllocateInfo, pDescriptorSets);
642 vn_instance_submit_command(vn_instance, submit);
643 if (cmd_data != local_cmd_data)
644 free(cmd_data);
645 }
646 }
647
vn_submit_vkFreeDescriptorSets(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets,struct vn_instance_submit_command * submit)648 static inline void vn_submit_vkFreeDescriptorSets(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets, struct vn_instance_submit_command *submit)
649 {
650 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
651 void *cmd_data = local_cmd_data;
652 size_t cmd_size = vn_sizeof_vkFreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets);
653 if (cmd_size > sizeof(local_cmd_data)) {
654 cmd_data = malloc(cmd_size);
655 if (!cmd_data)
656 cmd_size = 0;
657 }
658 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkFreeDescriptorSets_reply(device, descriptorPool, descriptorSetCount, pDescriptorSets) : 0;
659
660 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
661 if (cmd_size) {
662 vn_encode_vkFreeDescriptorSets(enc, cmd_flags, device, descriptorPool, descriptorSetCount, pDescriptorSets);
663 vn_instance_submit_command(vn_instance, submit);
664 if (cmd_data != local_cmd_data)
665 free(cmd_data);
666 }
667 }
668
vn_submit_vkUpdateDescriptorSets(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies,struct vn_instance_submit_command * submit)669 static inline void vn_submit_vkUpdateDescriptorSets(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies, struct vn_instance_submit_command *submit)
670 {
671 uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
672 void *cmd_data = local_cmd_data;
673 size_t cmd_size = vn_sizeof_vkUpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
674 if (cmd_size > sizeof(local_cmd_data)) {
675 cmd_data = malloc(cmd_size);
676 if (!cmd_data)
677 cmd_size = 0;
678 }
679 const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkUpdateDescriptorSets_reply(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies) : 0;
680
681 struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
682 if (cmd_size) {
683 vn_encode_vkUpdateDescriptorSets(enc, cmd_flags, device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
684 vn_instance_submit_command(vn_instance, submit);
685 if (cmd_data != local_cmd_data)
686 free(cmd_data);
687 }
688 }
689
vn_call_vkAllocateDescriptorSets(struct vn_instance * vn_instance,VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)690 static inline VkResult vn_call_vkAllocateDescriptorSets(struct vn_instance *vn_instance, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
691 {
692 VN_TRACE_FUNC();
693
694 struct vn_instance_submit_command submit;
695 vn_submit_vkAllocateDescriptorSets(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pAllocateInfo, pDescriptorSets, &submit);
696 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
697 if (dec) {
698 const VkResult ret = vn_decode_vkAllocateDescriptorSets_reply(dec, device, pAllocateInfo, pDescriptorSets);
699 vn_instance_free_command_reply(vn_instance, &submit);
700 return ret;
701 } else {
702 return VK_ERROR_OUT_OF_HOST_MEMORY;
703 }
704 }
705
vn_async_vkAllocateDescriptorSets(struct vn_instance * vn_instance,VkDevice device,const VkDescriptorSetAllocateInfo * pAllocateInfo,VkDescriptorSet * pDescriptorSets)706 static inline void vn_async_vkAllocateDescriptorSets(struct vn_instance *vn_instance, VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
707 {
708 struct vn_instance_submit_command submit;
709 vn_submit_vkAllocateDescriptorSets(vn_instance, 0, device, pAllocateInfo, pDescriptorSets, &submit);
710 }
711
vn_call_vkFreeDescriptorSets(struct vn_instance * vn_instance,VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)712 static inline VkResult vn_call_vkFreeDescriptorSets(struct vn_instance *vn_instance, VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
713 {
714 VN_TRACE_FUNC();
715
716 struct vn_instance_submit_command submit;
717 vn_submit_vkFreeDescriptorSets(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, descriptorPool, descriptorSetCount, pDescriptorSets, &submit);
718 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
719 if (dec) {
720 const VkResult ret = vn_decode_vkFreeDescriptorSets_reply(dec, device, descriptorPool, descriptorSetCount, pDescriptorSets);
721 vn_instance_free_command_reply(vn_instance, &submit);
722 return ret;
723 } else {
724 return VK_ERROR_OUT_OF_HOST_MEMORY;
725 }
726 }
727
vn_async_vkFreeDescriptorSets(struct vn_instance * vn_instance,VkDevice device,VkDescriptorPool descriptorPool,uint32_t descriptorSetCount,const VkDescriptorSet * pDescriptorSets)728 static inline void vn_async_vkFreeDescriptorSets(struct vn_instance *vn_instance, VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
729 {
730 struct vn_instance_submit_command submit;
731 vn_submit_vkFreeDescriptorSets(vn_instance, 0, device, descriptorPool, descriptorSetCount, pDescriptorSets, &submit);
732 }
733
vn_call_vkUpdateDescriptorSets(struct vn_instance * vn_instance,VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)734 static inline void vn_call_vkUpdateDescriptorSets(struct vn_instance *vn_instance, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
735 {
736 VN_TRACE_FUNC();
737
738 struct vn_instance_submit_command submit;
739 vn_submit_vkUpdateDescriptorSets(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies, &submit);
740 struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
741 if (dec) {
742 vn_decode_vkUpdateDescriptorSets_reply(dec, device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
743 vn_instance_free_command_reply(vn_instance, &submit);
744 }
745 }
746
vn_async_vkUpdateDescriptorSets(struct vn_instance * vn_instance,VkDevice device,uint32_t descriptorWriteCount,const VkWriteDescriptorSet * pDescriptorWrites,uint32_t descriptorCopyCount,const VkCopyDescriptorSet * pDescriptorCopies)747 static inline void vn_async_vkUpdateDescriptorSets(struct vn_instance *vn_instance, VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
748 {
749 struct vn_instance_submit_command submit;
750 vn_submit_vkUpdateDescriptorSets(vn_instance, 0, device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies, &submit);
751 }
752
753 #endif /* VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_H */
754