• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* This file is generated by venus-protocol.  See vn_protocol_renderer.h. */
2 
3 /*
4  * Copyright 2020 Google LLC
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef VN_PROTOCOL_RENDERER_DESCRIPTOR_SET_H
9 #define VN_PROTOCOL_RENDERER_DESCRIPTOR_SET_H
10 
11 #include "vn_protocol_renderer_structs.h"
12 
13 #pragma GCC diagnostic push
14 #pragma GCC diagnostic ignored "-Wpointer-arith"
15 #pragma GCC diagnostic ignored "-Wunused-parameter"
16 
17 /*
18  * These structs/unions/commands are not included
19  *
20  *   vkUpdateDescriptorSetWithTemplate
21  */
22 
23 /* struct VkDescriptorSetVariableDescriptorCountAllocateInfo chain */
24 
25 static inline void *
vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext_temp(struct vn_cs_decoder * dec)26 vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext_temp(struct vn_cs_decoder *dec)
27 {
28     /* no known/supported struct */
29     if (vn_decode_simple_pointer(dec))
30         vn_cs_decoder_set_fatal(dec);
31     return NULL;
32 }
33 
34 static inline void
vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self_temp(struct vn_cs_decoder * dec,VkDescriptorSetVariableDescriptorCountAllocateInfo * val)35 vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self_temp(struct vn_cs_decoder *dec, VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
36 {
37     /* skip val->{sType,pNext} */
38     vn_decode_uint32_t(dec, &val->descriptorSetCount);
39     if (vn_peek_array_size(dec)) {
40         const size_t array_size = vn_decode_array_size(dec, val->descriptorSetCount);
41         val->pDescriptorCounts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pDescriptorCounts) * array_size);
42         if (!val->pDescriptorCounts) return;
43         vn_decode_uint32_t_array(dec, (uint32_t *)val->pDescriptorCounts, array_size);
44     } else {
45         vn_decode_array_size(dec, val->descriptorSetCount);
46         val->pDescriptorCounts = NULL;
47     }
48 }
49 
50 static inline void
vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_temp(struct vn_cs_decoder * dec,VkDescriptorSetVariableDescriptorCountAllocateInfo * val)51 vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_temp(struct vn_cs_decoder *dec, VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
52 {
53     VkStructureType stype;
54     vn_decode_VkStructureType(dec, &stype);
55     if (stype != VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO)
56         vn_cs_decoder_set_fatal(dec);
57 
58     val->sType = stype;
59     val->pNext = vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_pnext_temp(dec);
60     vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self_temp(dec, val);
61 }
62 
63 static inline void
vn_replace_VkDescriptorSetVariableDescriptorCountAllocateInfo_handle_self(VkDescriptorSetVariableDescriptorCountAllocateInfo * val)64 vn_replace_VkDescriptorSetVariableDescriptorCountAllocateInfo_handle_self(VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
65 {
66     /* skip val->sType */
67     /* skip val->pNext */
68     /* skip val->descriptorSetCount */
69     /* skip val->pDescriptorCounts */
70 }
71 
72 static inline void
vn_replace_VkDescriptorSetVariableDescriptorCountAllocateInfo_handle(VkDescriptorSetVariableDescriptorCountAllocateInfo * val)73 vn_replace_VkDescriptorSetVariableDescriptorCountAllocateInfo_handle(VkDescriptorSetVariableDescriptorCountAllocateInfo *val)
74 {
75     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
76 
77     do {
78         switch ((int32_t)pnext->sType) {
79         case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO:
80             vn_replace_VkDescriptorSetVariableDescriptorCountAllocateInfo_handle_self((VkDescriptorSetVariableDescriptorCountAllocateInfo *)pnext);
81             break;
82         default:
83             /* ignore unknown/unsupported struct */
84             break;
85         }
86         pnext = pnext->pNext;
87     } while (pnext);
88 }
89 
90 /* struct VkDescriptorSetAllocateInfo chain */
91 
92 static inline void *
vn_decode_VkDescriptorSetAllocateInfo_pnext_temp(struct vn_cs_decoder * dec)93 vn_decode_VkDescriptorSetAllocateInfo_pnext_temp(struct vn_cs_decoder *dec)
94 {
95     VkBaseOutStructure *pnext;
96     VkStructureType stype;
97 
98     if (!vn_decode_simple_pointer(dec))
99         return NULL;
100 
101     vn_decode_VkStructureType(dec, &stype);
102     switch ((int32_t)stype) {
103     case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO:
104         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkDescriptorSetVariableDescriptorCountAllocateInfo));
105         if (pnext) {
106             pnext->sType = stype;
107             pnext->pNext = vn_decode_VkDescriptorSetAllocateInfo_pnext_temp(dec);
108             vn_decode_VkDescriptorSetVariableDescriptorCountAllocateInfo_self_temp(dec, (VkDescriptorSetVariableDescriptorCountAllocateInfo *)pnext);
109         }
110         break;
111     default:
112         /* unexpected struct */
113         pnext = NULL;
114         vn_cs_decoder_set_fatal(dec);
115         break;
116     }
117 
118     return pnext;
119 }
120 
121 static inline void
vn_decode_VkDescriptorSetAllocateInfo_self_temp(struct vn_cs_decoder * dec,VkDescriptorSetAllocateInfo * val)122 vn_decode_VkDescriptorSetAllocateInfo_self_temp(struct vn_cs_decoder *dec, VkDescriptorSetAllocateInfo *val)
123 {
124     /* skip val->{sType,pNext} */
125     vn_decode_VkDescriptorPool_lookup(dec, &val->descriptorPool);
126     vn_decode_uint32_t(dec, &val->descriptorSetCount);
127     if (vn_peek_array_size(dec)) {
128         const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorSetCount);
129         val->pSetLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSetLayouts) * iter_count);
130         if (!val->pSetLayouts) return;
131         for (uint32_t i = 0; i < iter_count; i++)
132             vn_decode_VkDescriptorSetLayout_lookup(dec, &((VkDescriptorSetLayout *)val->pSetLayouts)[i]);
133     } else {
134         vn_decode_array_size(dec, val->descriptorSetCount);
135         val->pSetLayouts = NULL;
136     }
137 }
138 
139 static inline void
vn_decode_VkDescriptorSetAllocateInfo_temp(struct vn_cs_decoder * dec,VkDescriptorSetAllocateInfo * val)140 vn_decode_VkDescriptorSetAllocateInfo_temp(struct vn_cs_decoder *dec, VkDescriptorSetAllocateInfo *val)
141 {
142     VkStructureType stype;
143     vn_decode_VkStructureType(dec, &stype);
144     if (stype != VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO)
145         vn_cs_decoder_set_fatal(dec);
146 
147     val->sType = stype;
148     val->pNext = vn_decode_VkDescriptorSetAllocateInfo_pnext_temp(dec);
149     vn_decode_VkDescriptorSetAllocateInfo_self_temp(dec, val);
150 }
151 
152 static inline void
vn_replace_VkDescriptorSetAllocateInfo_handle_self(VkDescriptorSetAllocateInfo * val)153 vn_replace_VkDescriptorSetAllocateInfo_handle_self(VkDescriptorSetAllocateInfo *val)
154 {
155     /* skip val->sType */
156     /* skip val->pNext */
157     vn_replace_VkDescriptorPool_handle(&val->descriptorPool);
158     /* skip val->descriptorSetCount */
159     if (val->pSetLayouts) {
160        for (uint32_t i = 0; i < val->descriptorSetCount; i++)
161             vn_replace_VkDescriptorSetLayout_handle(&((VkDescriptorSetLayout *)val->pSetLayouts)[i]);
162     }
163 }
164 
165 static inline void
vn_replace_VkDescriptorSetAllocateInfo_handle(VkDescriptorSetAllocateInfo * val)166 vn_replace_VkDescriptorSetAllocateInfo_handle(VkDescriptorSetAllocateInfo *val)
167 {
168     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
169 
170     do {
171         switch ((int32_t)pnext->sType) {
172         case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO:
173             vn_replace_VkDescriptorSetAllocateInfo_handle_self((VkDescriptorSetAllocateInfo *)pnext);
174             break;
175         case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO:
176             vn_replace_VkDescriptorSetVariableDescriptorCountAllocateInfo_handle_self((VkDescriptorSetVariableDescriptorCountAllocateInfo *)pnext);
177             break;
178         default:
179             /* ignore unknown/unsupported struct */
180             break;
181         }
182         pnext = pnext->pNext;
183     } while (pnext);
184 }
185 
186 /* struct VkDescriptorImageInfo */
187 
188 static inline void
vn_decode_VkDescriptorImageInfo_temp(struct vn_cs_decoder * dec,VkDescriptorImageInfo * val)189 vn_decode_VkDescriptorImageInfo_temp(struct vn_cs_decoder *dec, VkDescriptorImageInfo *val)
190 {
191     vn_decode_VkSampler_lookup(dec, &val->sampler);
192     vn_decode_VkImageView_lookup(dec, &val->imageView);
193     vn_decode_VkImageLayout(dec, &val->imageLayout);
194 }
195 
196 static inline void
vn_replace_VkDescriptorImageInfo_handle(VkDescriptorImageInfo * val)197 vn_replace_VkDescriptorImageInfo_handle(VkDescriptorImageInfo *val)
198 {
199     vn_replace_VkSampler_handle(&val->sampler);
200     vn_replace_VkImageView_handle(&val->imageView);
201     /* skip val->imageLayout */
202 }
203 
204 /* struct VkDescriptorBufferInfo */
205 
206 static inline void
vn_decode_VkDescriptorBufferInfo_temp(struct vn_cs_decoder * dec,VkDescriptorBufferInfo * val)207 vn_decode_VkDescriptorBufferInfo_temp(struct vn_cs_decoder *dec, VkDescriptorBufferInfo *val)
208 {
209     vn_decode_VkBuffer_lookup(dec, &val->buffer);
210     vn_decode_VkDeviceSize(dec, &val->offset);
211     vn_decode_VkDeviceSize(dec, &val->range);
212 }
213 
214 static inline void
vn_replace_VkDescriptorBufferInfo_handle(VkDescriptorBufferInfo * val)215 vn_replace_VkDescriptorBufferInfo_handle(VkDescriptorBufferInfo *val)
216 {
217     vn_replace_VkBuffer_handle(&val->buffer);
218     /* skip val->offset */
219     /* skip val->range */
220 }
221 
222 /* struct VkWriteDescriptorSet chain */
223 
224 static inline void *
vn_decode_VkWriteDescriptorSet_pnext_temp(struct vn_cs_decoder * dec)225 vn_decode_VkWriteDescriptorSet_pnext_temp(struct vn_cs_decoder *dec)
226 {
227     /* no known/supported struct */
228     if (vn_decode_simple_pointer(dec))
229         vn_cs_decoder_set_fatal(dec);
230     return NULL;
231 }
232 
233 static inline void
vn_decode_VkWriteDescriptorSet_self_temp(struct vn_cs_decoder * dec,VkWriteDescriptorSet * val)234 vn_decode_VkWriteDescriptorSet_self_temp(struct vn_cs_decoder *dec, VkWriteDescriptorSet *val)
235 {
236     /* skip val->{sType,pNext} */
237     vn_decode_VkDescriptorSet_lookup(dec, &val->dstSet);
238     vn_decode_uint32_t(dec, &val->dstBinding);
239     vn_decode_uint32_t(dec, &val->dstArrayElement);
240     vn_decode_uint32_t(dec, &val->descriptorCount);
241     vn_decode_VkDescriptorType(dec, &val->descriptorType);
242     if (vn_peek_array_size(dec)) {
243         const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount);
244         val->pImageInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageInfo) * iter_count);
245         if (!val->pImageInfo) return;
246         for (uint32_t i = 0; i < iter_count; i++)
247             vn_decode_VkDescriptorImageInfo_temp(dec, &((VkDescriptorImageInfo *)val->pImageInfo)[i]);
248     } else {
249         vn_decode_array_size_unchecked(dec);
250         val->pImageInfo = NULL;
251     }
252     if (vn_peek_array_size(dec)) {
253         const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount);
254         val->pBufferInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBufferInfo) * iter_count);
255         if (!val->pBufferInfo) return;
256         for (uint32_t i = 0; i < iter_count; i++)
257             vn_decode_VkDescriptorBufferInfo_temp(dec, &((VkDescriptorBufferInfo *)val->pBufferInfo)[i]);
258     } else {
259         vn_decode_array_size_unchecked(dec);
260         val->pBufferInfo = NULL;
261     }
262     if (vn_peek_array_size(dec)) {
263         const uint32_t iter_count = vn_decode_array_size(dec, val->descriptorCount);
264         val->pTexelBufferView = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pTexelBufferView) * iter_count);
265         if (!val->pTexelBufferView) return;
266         for (uint32_t i = 0; i < iter_count; i++)
267             vn_decode_VkBufferView_lookup(dec, &((VkBufferView *)val->pTexelBufferView)[i]);
268     } else {
269         vn_decode_array_size_unchecked(dec);
270         val->pTexelBufferView = NULL;
271     }
272 }
273 
274 static inline void
vn_decode_VkWriteDescriptorSet_temp(struct vn_cs_decoder * dec,VkWriteDescriptorSet * val)275 vn_decode_VkWriteDescriptorSet_temp(struct vn_cs_decoder *dec, VkWriteDescriptorSet *val)
276 {
277     VkStructureType stype;
278     vn_decode_VkStructureType(dec, &stype);
279     if (stype != VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET)
280         vn_cs_decoder_set_fatal(dec);
281 
282     val->sType = stype;
283     val->pNext = vn_decode_VkWriteDescriptorSet_pnext_temp(dec);
284     vn_decode_VkWriteDescriptorSet_self_temp(dec, val);
285 }
286 
287 static inline void
vn_replace_VkWriteDescriptorSet_handle_self(VkWriteDescriptorSet * val)288 vn_replace_VkWriteDescriptorSet_handle_self(VkWriteDescriptorSet *val)
289 {
290     /* skip val->sType */
291     /* skip val->pNext */
292     vn_replace_VkDescriptorSet_handle(&val->dstSet);
293     /* skip val->dstBinding */
294     /* skip val->dstArrayElement */
295     /* skip val->descriptorCount */
296     /* skip val->descriptorType */
297     if (val->pImageInfo) {
298        for (uint32_t i = 0; i < val->descriptorCount; i++)
299             vn_replace_VkDescriptorImageInfo_handle(&((VkDescriptorImageInfo *)val->pImageInfo)[i]);
300     }
301     if (val->pBufferInfo) {
302        for (uint32_t i = 0; i < val->descriptorCount; i++)
303             vn_replace_VkDescriptorBufferInfo_handle(&((VkDescriptorBufferInfo *)val->pBufferInfo)[i]);
304     }
305     if (val->pTexelBufferView) {
306        for (uint32_t i = 0; i < val->descriptorCount; i++)
307             vn_replace_VkBufferView_handle(&((VkBufferView *)val->pTexelBufferView)[i]);
308     }
309 }
310 
311 static inline void
vn_replace_VkWriteDescriptorSet_handle(VkWriteDescriptorSet * val)312 vn_replace_VkWriteDescriptorSet_handle(VkWriteDescriptorSet *val)
313 {
314     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
315 
316     do {
317         switch ((int32_t)pnext->sType) {
318         case VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET:
319             vn_replace_VkWriteDescriptorSet_handle_self((VkWriteDescriptorSet *)pnext);
320             break;
321         default:
322             /* ignore unknown/unsupported struct */
323             break;
324         }
325         pnext = pnext->pNext;
326     } while (pnext);
327 }
328 
329 /* struct VkCopyDescriptorSet chain */
330 
331 static inline void *
vn_decode_VkCopyDescriptorSet_pnext_temp(struct vn_cs_decoder * dec)332 vn_decode_VkCopyDescriptorSet_pnext_temp(struct vn_cs_decoder *dec)
333 {
334     /* no known/supported struct */
335     if (vn_decode_simple_pointer(dec))
336         vn_cs_decoder_set_fatal(dec);
337     return NULL;
338 }
339 
340 static inline void
vn_decode_VkCopyDescriptorSet_self_temp(struct vn_cs_decoder * dec,VkCopyDescriptorSet * val)341 vn_decode_VkCopyDescriptorSet_self_temp(struct vn_cs_decoder *dec, VkCopyDescriptorSet *val)
342 {
343     /* skip val->{sType,pNext} */
344     vn_decode_VkDescriptorSet_lookup(dec, &val->srcSet);
345     vn_decode_uint32_t(dec, &val->srcBinding);
346     vn_decode_uint32_t(dec, &val->srcArrayElement);
347     vn_decode_VkDescriptorSet_lookup(dec, &val->dstSet);
348     vn_decode_uint32_t(dec, &val->dstBinding);
349     vn_decode_uint32_t(dec, &val->dstArrayElement);
350     vn_decode_uint32_t(dec, &val->descriptorCount);
351 }
352 
353 static inline void
vn_decode_VkCopyDescriptorSet_temp(struct vn_cs_decoder * dec,VkCopyDescriptorSet * val)354 vn_decode_VkCopyDescriptorSet_temp(struct vn_cs_decoder *dec, VkCopyDescriptorSet *val)
355 {
356     VkStructureType stype;
357     vn_decode_VkStructureType(dec, &stype);
358     if (stype != VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET)
359         vn_cs_decoder_set_fatal(dec);
360 
361     val->sType = stype;
362     val->pNext = vn_decode_VkCopyDescriptorSet_pnext_temp(dec);
363     vn_decode_VkCopyDescriptorSet_self_temp(dec, val);
364 }
365 
366 static inline void
vn_replace_VkCopyDescriptorSet_handle_self(VkCopyDescriptorSet * val)367 vn_replace_VkCopyDescriptorSet_handle_self(VkCopyDescriptorSet *val)
368 {
369     /* skip val->sType */
370     /* skip val->pNext */
371     vn_replace_VkDescriptorSet_handle(&val->srcSet);
372     /* skip val->srcBinding */
373     /* skip val->srcArrayElement */
374     vn_replace_VkDescriptorSet_handle(&val->dstSet);
375     /* skip val->dstBinding */
376     /* skip val->dstArrayElement */
377     /* skip val->descriptorCount */
378 }
379 
380 static inline void
vn_replace_VkCopyDescriptorSet_handle(VkCopyDescriptorSet * val)381 vn_replace_VkCopyDescriptorSet_handle(VkCopyDescriptorSet *val)
382 {
383     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
384 
385     do {
386         switch ((int32_t)pnext->sType) {
387         case VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET:
388             vn_replace_VkCopyDescriptorSet_handle_self((VkCopyDescriptorSet *)pnext);
389             break;
390         default:
391             /* ignore unknown/unsupported struct */
392             break;
393         }
394         pnext = pnext->pNext;
395     } while (pnext);
396 }
397 
vn_decode_vkAllocateDescriptorSets_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkAllocateDescriptorSets * args)398 static inline void vn_decode_vkAllocateDescriptorSets_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkAllocateDescriptorSets *args)
399 {
400     vn_decode_VkDevice_lookup(dec, &args->device);
401     if (vn_decode_simple_pointer(dec)) {
402         args->pAllocateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pAllocateInfo));
403         if (!args->pAllocateInfo) return;
404         vn_decode_VkDescriptorSetAllocateInfo_temp(dec, (VkDescriptorSetAllocateInfo *)args->pAllocateInfo);
405     } else {
406         args->pAllocateInfo = NULL;
407         vn_cs_decoder_set_fatal(dec);
408     }
409     if (vn_peek_array_size(dec)) {
410         const uint32_t iter_count = vn_decode_array_size(dec, (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0));
411         args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * iter_count);
412         if (!args->pDescriptorSets) return;
413         for (uint32_t i = 0; i < iter_count; i++)
414             vn_decode_VkDescriptorSet(dec, &args->pDescriptorSets[i]);
415     } else {
416         vn_decode_array_size(dec, (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0));
417         args->pDescriptorSets = NULL;
418     }
419 }
420 
vn_replace_vkAllocateDescriptorSets_args_handle(struct vn_command_vkAllocateDescriptorSets * args)421 static inline void vn_replace_vkAllocateDescriptorSets_args_handle(struct vn_command_vkAllocateDescriptorSets *args)
422 {
423     vn_replace_VkDevice_handle(&args->device);
424     if (args->pAllocateInfo)
425         vn_replace_VkDescriptorSetAllocateInfo_handle((VkDescriptorSetAllocateInfo *)args->pAllocateInfo);
426     /* skip args->pDescriptorSets */
427 }
428 
vn_encode_vkAllocateDescriptorSets_reply(struct vn_cs_encoder * enc,const struct vn_command_vkAllocateDescriptorSets * args)429 static inline void vn_encode_vkAllocateDescriptorSets_reply(struct vn_cs_encoder *enc, const struct vn_command_vkAllocateDescriptorSets *args)
430 {
431     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkAllocateDescriptorSets_EXT});
432 
433     vn_encode_VkResult(enc, &args->ret);
434     /* skip args->device */
435     /* skip args->pAllocateInfo */
436     if (args->pDescriptorSets) {
437         vn_encode_array_size(enc, (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0));
438         for (uint32_t i = 0; i < (args->pAllocateInfo ? args->pAllocateInfo->descriptorSetCount : 0); i++)
439             vn_encode_VkDescriptorSet(enc, &args->pDescriptorSets[i]);
440     } else {
441         vn_encode_array_size(enc, 0);
442     }
443 }
444 
vn_decode_vkFreeDescriptorSets_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkFreeDescriptorSets * args)445 static inline void vn_decode_vkFreeDescriptorSets_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkFreeDescriptorSets *args)
446 {
447     vn_decode_VkDevice_lookup(dec, &args->device);
448     vn_decode_VkDescriptorPool_lookup(dec, &args->descriptorPool);
449     vn_decode_uint32_t(dec, &args->descriptorSetCount);
450     if (vn_peek_array_size(dec)) {
451         const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorSetCount);
452         args->pDescriptorSets = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorSets) * iter_count);
453         if (!args->pDescriptorSets) return;
454         for (uint32_t i = 0; i < iter_count; i++)
455             vn_decode_VkDescriptorSet_lookup(dec, &((VkDescriptorSet *)args->pDescriptorSets)[i]);
456     } else {
457         vn_decode_array_size_unchecked(dec);
458         args->pDescriptorSets = NULL;
459     }
460 }
461 
vn_replace_vkFreeDescriptorSets_args_handle(struct vn_command_vkFreeDescriptorSets * args)462 static inline void vn_replace_vkFreeDescriptorSets_args_handle(struct vn_command_vkFreeDescriptorSets *args)
463 {
464     vn_replace_VkDevice_handle(&args->device);
465     vn_replace_VkDescriptorPool_handle(&args->descriptorPool);
466     /* skip args->descriptorSetCount */
467     if (args->pDescriptorSets) {
468        for (uint32_t i = 0; i < args->descriptorSetCount; i++)
469             vn_replace_VkDescriptorSet_handle(&((VkDescriptorSet *)args->pDescriptorSets)[i]);
470     }
471 }
472 
vn_encode_vkFreeDescriptorSets_reply(struct vn_cs_encoder * enc,const struct vn_command_vkFreeDescriptorSets * args)473 static inline void vn_encode_vkFreeDescriptorSets_reply(struct vn_cs_encoder *enc, const struct vn_command_vkFreeDescriptorSets *args)
474 {
475     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkFreeDescriptorSets_EXT});
476 
477     vn_encode_VkResult(enc, &args->ret);
478     /* skip args->device */
479     /* skip args->descriptorPool */
480     /* skip args->descriptorSetCount */
481     /* skip args->pDescriptorSets */
482 }
483 
vn_decode_vkUpdateDescriptorSets_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkUpdateDescriptorSets * args)484 static inline void vn_decode_vkUpdateDescriptorSets_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkUpdateDescriptorSets *args)
485 {
486     vn_decode_VkDevice_lookup(dec, &args->device);
487     vn_decode_uint32_t(dec, &args->descriptorWriteCount);
488     if (vn_peek_array_size(dec)) {
489         const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorWriteCount);
490         args->pDescriptorWrites = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorWrites) * iter_count);
491         if (!args->pDescriptorWrites) return;
492         for (uint32_t i = 0; i < iter_count; i++)
493             vn_decode_VkWriteDescriptorSet_temp(dec, &((VkWriteDescriptorSet *)args->pDescriptorWrites)[i]);
494     } else {
495         vn_decode_array_size(dec, args->descriptorWriteCount);
496         args->pDescriptorWrites = NULL;
497     }
498     vn_decode_uint32_t(dec, &args->descriptorCopyCount);
499     if (vn_peek_array_size(dec)) {
500         const uint32_t iter_count = vn_decode_array_size(dec, args->descriptorCopyCount);
501         args->pDescriptorCopies = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorCopies) * iter_count);
502         if (!args->pDescriptorCopies) return;
503         for (uint32_t i = 0; i < iter_count; i++)
504             vn_decode_VkCopyDescriptorSet_temp(dec, &((VkCopyDescriptorSet *)args->pDescriptorCopies)[i]);
505     } else {
506         vn_decode_array_size(dec, args->descriptorCopyCount);
507         args->pDescriptorCopies = NULL;
508     }
509 }
510 
vn_replace_vkUpdateDescriptorSets_args_handle(struct vn_command_vkUpdateDescriptorSets * args)511 static inline void vn_replace_vkUpdateDescriptorSets_args_handle(struct vn_command_vkUpdateDescriptorSets *args)
512 {
513     vn_replace_VkDevice_handle(&args->device);
514     /* skip args->descriptorWriteCount */
515     if (args->pDescriptorWrites) {
516        for (uint32_t i = 0; i < args->descriptorWriteCount; i++)
517             vn_replace_VkWriteDescriptorSet_handle(&((VkWriteDescriptorSet *)args->pDescriptorWrites)[i]);
518     }
519     /* skip args->descriptorCopyCount */
520     if (args->pDescriptorCopies) {
521        for (uint32_t i = 0; i < args->descriptorCopyCount; i++)
522             vn_replace_VkCopyDescriptorSet_handle(&((VkCopyDescriptorSet *)args->pDescriptorCopies)[i]);
523     }
524 }
525 
vn_encode_vkUpdateDescriptorSets_reply(struct vn_cs_encoder * enc,const struct vn_command_vkUpdateDescriptorSets * args)526 static inline void vn_encode_vkUpdateDescriptorSets_reply(struct vn_cs_encoder *enc, const struct vn_command_vkUpdateDescriptorSets *args)
527 {
528     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkUpdateDescriptorSets_EXT});
529 
530     /* skip args->device */
531     /* skip args->descriptorWriteCount */
532     /* skip args->pDescriptorWrites */
533     /* skip args->descriptorCopyCount */
534     /* skip args->pDescriptorCopies */
535 }
536 
vn_dispatch_vkAllocateDescriptorSets(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)537 static inline void vn_dispatch_vkAllocateDescriptorSets(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
538 {
539     struct vn_command_vkAllocateDescriptorSets args;
540 
541     if (!ctx->dispatch_vkAllocateDescriptorSets) {
542         vn_cs_decoder_set_fatal(ctx->decoder);
543         return;
544     }
545 
546     vn_decode_vkAllocateDescriptorSets_args_temp(ctx->decoder, &args);
547     if (!args.device) {
548         vn_cs_decoder_set_fatal(ctx->decoder);
549         return;
550     }
551 
552     if (!vn_cs_decoder_get_fatal(ctx->decoder))
553         ctx->dispatch_vkAllocateDescriptorSets(ctx, &args);
554 
555 #ifdef DEBUG
556     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
557         vn_dispatch_debug_log(ctx, "vkAllocateDescriptorSets returned %d", args.ret);
558 #endif
559 
560     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
561        vn_encode_vkAllocateDescriptorSets_reply(ctx->encoder, &args);
562 
563     vn_cs_decoder_reset_temp_pool(ctx->decoder);
564 }
565 
vn_dispatch_vkFreeDescriptorSets(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)566 static inline void vn_dispatch_vkFreeDescriptorSets(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
567 {
568     struct vn_command_vkFreeDescriptorSets args;
569 
570     if (!ctx->dispatch_vkFreeDescriptorSets) {
571         vn_cs_decoder_set_fatal(ctx->decoder);
572         return;
573     }
574 
575     vn_decode_vkFreeDescriptorSets_args_temp(ctx->decoder, &args);
576     if (!args.device) {
577         vn_cs_decoder_set_fatal(ctx->decoder);
578         return;
579     }
580 
581     if (!vn_cs_decoder_get_fatal(ctx->decoder))
582         ctx->dispatch_vkFreeDescriptorSets(ctx, &args);
583 
584 #ifdef DEBUG
585     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
586         vn_dispatch_debug_log(ctx, "vkFreeDescriptorSets returned %d", args.ret);
587 #endif
588 
589     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
590        vn_encode_vkFreeDescriptorSets_reply(ctx->encoder, &args);
591 
592     vn_cs_decoder_reset_temp_pool(ctx->decoder);
593 }
594 
vn_dispatch_vkUpdateDescriptorSets(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)595 static inline void vn_dispatch_vkUpdateDescriptorSets(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
596 {
597     struct vn_command_vkUpdateDescriptorSets args;
598 
599     if (!ctx->dispatch_vkUpdateDescriptorSets) {
600         vn_cs_decoder_set_fatal(ctx->decoder);
601         return;
602     }
603 
604     vn_decode_vkUpdateDescriptorSets_args_temp(ctx->decoder, &args);
605     if (!args.device) {
606         vn_cs_decoder_set_fatal(ctx->decoder);
607         return;
608     }
609 
610     if (!vn_cs_decoder_get_fatal(ctx->decoder))
611         ctx->dispatch_vkUpdateDescriptorSets(ctx, &args);
612 
613 
614     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
615        vn_encode_vkUpdateDescriptorSets_reply(ctx->encoder, &args);
616 
617     vn_cs_decoder_reset_temp_pool(ctx->decoder);
618 }
619 
620 #pragma GCC diagnostic pop
621 
622 #endif /* VN_PROTOCOL_RENDERER_DESCRIPTOR_SET_H */
623