xref: /aosp_15_r20/external/virglrenderer/src/venus/venus-protocol/vn_protocol_renderer_queue.h (revision bbecb9d118dfdb95f99bd754f8fa9be01f189df3)
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_QUEUE_H
9 #define VN_PROTOCOL_RENDERER_QUEUE_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 /* struct VkDeviceGroupSubmitInfo chain */
18 
19 static inline void *
vn_decode_VkDeviceGroupSubmitInfo_pnext_temp(struct vn_cs_decoder * dec)20 vn_decode_VkDeviceGroupSubmitInfo_pnext_temp(struct vn_cs_decoder *dec)
21 {
22     /* no known/supported struct */
23     if (vn_decode_simple_pointer(dec))
24         vn_cs_decoder_set_fatal(dec);
25     return NULL;
26 }
27 
28 static inline void
vn_decode_VkDeviceGroupSubmitInfo_self_temp(struct vn_cs_decoder * dec,VkDeviceGroupSubmitInfo * val)29 vn_decode_VkDeviceGroupSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkDeviceGroupSubmitInfo *val)
30 {
31     /* skip val->{sType,pNext} */
32     vn_decode_uint32_t(dec, &val->waitSemaphoreCount);
33     if (vn_peek_array_size(dec)) {
34         const size_t array_size = vn_decode_array_size(dec, val->waitSemaphoreCount);
35         val->pWaitSemaphoreDeviceIndices = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphoreDeviceIndices) * array_size);
36         if (!val->pWaitSemaphoreDeviceIndices) return;
37         vn_decode_uint32_t_array(dec, (uint32_t *)val->pWaitSemaphoreDeviceIndices, array_size);
38     } else {
39         vn_decode_array_size(dec, val->waitSemaphoreCount);
40         val->pWaitSemaphoreDeviceIndices = NULL;
41     }
42     vn_decode_uint32_t(dec, &val->commandBufferCount);
43     if (vn_peek_array_size(dec)) {
44         const size_t array_size = vn_decode_array_size(dec, val->commandBufferCount);
45         val->pCommandBufferDeviceMasks = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pCommandBufferDeviceMasks) * array_size);
46         if (!val->pCommandBufferDeviceMasks) return;
47         vn_decode_uint32_t_array(dec, (uint32_t *)val->pCommandBufferDeviceMasks, array_size);
48     } else {
49         vn_decode_array_size(dec, val->commandBufferCount);
50         val->pCommandBufferDeviceMasks = NULL;
51     }
52     vn_decode_uint32_t(dec, &val->signalSemaphoreCount);
53     if (vn_peek_array_size(dec)) {
54         const size_t array_size = vn_decode_array_size(dec, val->signalSemaphoreCount);
55         val->pSignalSemaphoreDeviceIndices = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphoreDeviceIndices) * array_size);
56         if (!val->pSignalSemaphoreDeviceIndices) return;
57         vn_decode_uint32_t_array(dec, (uint32_t *)val->pSignalSemaphoreDeviceIndices, array_size);
58     } else {
59         vn_decode_array_size(dec, val->signalSemaphoreCount);
60         val->pSignalSemaphoreDeviceIndices = NULL;
61     }
62 }
63 
64 static inline void
vn_decode_VkDeviceGroupSubmitInfo_temp(struct vn_cs_decoder * dec,VkDeviceGroupSubmitInfo * val)65 vn_decode_VkDeviceGroupSubmitInfo_temp(struct vn_cs_decoder *dec, VkDeviceGroupSubmitInfo *val)
66 {
67     VkStructureType stype;
68     vn_decode_VkStructureType(dec, &stype);
69     if (stype != VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO)
70         vn_cs_decoder_set_fatal(dec);
71 
72     val->sType = stype;
73     val->pNext = vn_decode_VkDeviceGroupSubmitInfo_pnext_temp(dec);
74     vn_decode_VkDeviceGroupSubmitInfo_self_temp(dec, val);
75 }
76 
77 static inline void
vn_replace_VkDeviceGroupSubmitInfo_handle_self(VkDeviceGroupSubmitInfo * val)78 vn_replace_VkDeviceGroupSubmitInfo_handle_self(VkDeviceGroupSubmitInfo *val)
79 {
80     /* skip val->sType */
81     /* skip val->pNext */
82     /* skip val->waitSemaphoreCount */
83     /* skip val->pWaitSemaphoreDeviceIndices */
84     /* skip val->commandBufferCount */
85     /* skip val->pCommandBufferDeviceMasks */
86     /* skip val->signalSemaphoreCount */
87     /* skip val->pSignalSemaphoreDeviceIndices */
88 }
89 
90 static inline void
vn_replace_VkDeviceGroupSubmitInfo_handle(VkDeviceGroupSubmitInfo * val)91 vn_replace_VkDeviceGroupSubmitInfo_handle(VkDeviceGroupSubmitInfo *val)
92 {
93     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
94 
95     do {
96         switch ((int32_t)pnext->sType) {
97         case VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO:
98             vn_replace_VkDeviceGroupSubmitInfo_handle_self((VkDeviceGroupSubmitInfo *)pnext);
99             break;
100         default:
101             /* ignore unknown/unsupported struct */
102             break;
103         }
104         pnext = pnext->pNext;
105     } while (pnext);
106 }
107 
108 /* struct VkProtectedSubmitInfo chain */
109 
110 static inline void *
vn_decode_VkProtectedSubmitInfo_pnext_temp(struct vn_cs_decoder * dec)111 vn_decode_VkProtectedSubmitInfo_pnext_temp(struct vn_cs_decoder *dec)
112 {
113     /* no known/supported struct */
114     if (vn_decode_simple_pointer(dec))
115         vn_cs_decoder_set_fatal(dec);
116     return NULL;
117 }
118 
119 static inline void
vn_decode_VkProtectedSubmitInfo_self_temp(struct vn_cs_decoder * dec,VkProtectedSubmitInfo * val)120 vn_decode_VkProtectedSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkProtectedSubmitInfo *val)
121 {
122     /* skip val->{sType,pNext} */
123     vn_decode_VkBool32(dec, &val->protectedSubmit);
124 }
125 
126 static inline void
vn_decode_VkProtectedSubmitInfo_temp(struct vn_cs_decoder * dec,VkProtectedSubmitInfo * val)127 vn_decode_VkProtectedSubmitInfo_temp(struct vn_cs_decoder *dec, VkProtectedSubmitInfo *val)
128 {
129     VkStructureType stype;
130     vn_decode_VkStructureType(dec, &stype);
131     if (stype != VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO)
132         vn_cs_decoder_set_fatal(dec);
133 
134     val->sType = stype;
135     val->pNext = vn_decode_VkProtectedSubmitInfo_pnext_temp(dec);
136     vn_decode_VkProtectedSubmitInfo_self_temp(dec, val);
137 }
138 
139 static inline void
vn_replace_VkProtectedSubmitInfo_handle_self(VkProtectedSubmitInfo * val)140 vn_replace_VkProtectedSubmitInfo_handle_self(VkProtectedSubmitInfo *val)
141 {
142     /* skip val->sType */
143     /* skip val->pNext */
144     /* skip val->protectedSubmit */
145 }
146 
147 static inline void
vn_replace_VkProtectedSubmitInfo_handle(VkProtectedSubmitInfo * val)148 vn_replace_VkProtectedSubmitInfo_handle(VkProtectedSubmitInfo *val)
149 {
150     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
151 
152     do {
153         switch ((int32_t)pnext->sType) {
154         case VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO:
155             vn_replace_VkProtectedSubmitInfo_handle_self((VkProtectedSubmitInfo *)pnext);
156             break;
157         default:
158             /* ignore unknown/unsupported struct */
159             break;
160         }
161         pnext = pnext->pNext;
162     } while (pnext);
163 }
164 
165 /* struct VkTimelineSemaphoreSubmitInfo chain */
166 
167 static inline void *
vn_decode_VkTimelineSemaphoreSubmitInfo_pnext_temp(struct vn_cs_decoder * dec)168 vn_decode_VkTimelineSemaphoreSubmitInfo_pnext_temp(struct vn_cs_decoder *dec)
169 {
170     /* no known/supported struct */
171     if (vn_decode_simple_pointer(dec))
172         vn_cs_decoder_set_fatal(dec);
173     return NULL;
174 }
175 
176 static inline void
vn_decode_VkTimelineSemaphoreSubmitInfo_self_temp(struct vn_cs_decoder * dec,VkTimelineSemaphoreSubmitInfo * val)177 vn_decode_VkTimelineSemaphoreSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkTimelineSemaphoreSubmitInfo *val)
178 {
179     /* skip val->{sType,pNext} */
180     vn_decode_uint32_t(dec, &val->waitSemaphoreValueCount);
181     if (vn_peek_array_size(dec)) {
182         const size_t array_size = vn_decode_array_size(dec, val->waitSemaphoreValueCount);
183         val->pWaitSemaphoreValues = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphoreValues) * array_size);
184         if (!val->pWaitSemaphoreValues) return;
185         vn_decode_uint64_t_array(dec, (uint64_t *)val->pWaitSemaphoreValues, array_size);
186     } else {
187         vn_decode_array_size_unchecked(dec);
188         val->pWaitSemaphoreValues = NULL;
189     }
190     vn_decode_uint32_t(dec, &val->signalSemaphoreValueCount);
191     if (vn_peek_array_size(dec)) {
192         const size_t array_size = vn_decode_array_size(dec, val->signalSemaphoreValueCount);
193         val->pSignalSemaphoreValues = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphoreValues) * array_size);
194         if (!val->pSignalSemaphoreValues) return;
195         vn_decode_uint64_t_array(dec, (uint64_t *)val->pSignalSemaphoreValues, array_size);
196     } else {
197         vn_decode_array_size_unchecked(dec);
198         val->pSignalSemaphoreValues = NULL;
199     }
200 }
201 
202 static inline void
vn_decode_VkTimelineSemaphoreSubmitInfo_temp(struct vn_cs_decoder * dec,VkTimelineSemaphoreSubmitInfo * val)203 vn_decode_VkTimelineSemaphoreSubmitInfo_temp(struct vn_cs_decoder *dec, VkTimelineSemaphoreSubmitInfo *val)
204 {
205     VkStructureType stype;
206     vn_decode_VkStructureType(dec, &stype);
207     if (stype != VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO)
208         vn_cs_decoder_set_fatal(dec);
209 
210     val->sType = stype;
211     val->pNext = vn_decode_VkTimelineSemaphoreSubmitInfo_pnext_temp(dec);
212     vn_decode_VkTimelineSemaphoreSubmitInfo_self_temp(dec, val);
213 }
214 
215 static inline void
vn_replace_VkTimelineSemaphoreSubmitInfo_handle_self(VkTimelineSemaphoreSubmitInfo * val)216 vn_replace_VkTimelineSemaphoreSubmitInfo_handle_self(VkTimelineSemaphoreSubmitInfo *val)
217 {
218     /* skip val->sType */
219     /* skip val->pNext */
220     /* skip val->waitSemaphoreValueCount */
221     /* skip val->pWaitSemaphoreValues */
222     /* skip val->signalSemaphoreValueCount */
223     /* skip val->pSignalSemaphoreValues */
224 }
225 
226 static inline void
vn_replace_VkTimelineSemaphoreSubmitInfo_handle(VkTimelineSemaphoreSubmitInfo * val)227 vn_replace_VkTimelineSemaphoreSubmitInfo_handle(VkTimelineSemaphoreSubmitInfo *val)
228 {
229     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
230 
231     do {
232         switch ((int32_t)pnext->sType) {
233         case VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO:
234             vn_replace_VkTimelineSemaphoreSubmitInfo_handle_self((VkTimelineSemaphoreSubmitInfo *)pnext);
235             break;
236         default:
237             /* ignore unknown/unsupported struct */
238             break;
239         }
240         pnext = pnext->pNext;
241     } while (pnext);
242 }
243 
244 /* struct VkSubmitInfo chain */
245 
246 static inline void *
vn_decode_VkSubmitInfo_pnext_temp(struct vn_cs_decoder * dec)247 vn_decode_VkSubmitInfo_pnext_temp(struct vn_cs_decoder *dec)
248 {
249     VkBaseOutStructure *pnext;
250     VkStructureType stype;
251 
252     if (!vn_decode_simple_pointer(dec))
253         return NULL;
254 
255     vn_decode_VkStructureType(dec, &stype);
256     switch ((int32_t)stype) {
257     case VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO:
258         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkDeviceGroupSubmitInfo));
259         if (pnext) {
260             pnext->sType = stype;
261             pnext->pNext = vn_decode_VkSubmitInfo_pnext_temp(dec);
262             vn_decode_VkDeviceGroupSubmitInfo_self_temp(dec, (VkDeviceGroupSubmitInfo *)pnext);
263         }
264         break;
265     case VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO:
266         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkProtectedSubmitInfo));
267         if (pnext) {
268             pnext->sType = stype;
269             pnext->pNext = vn_decode_VkSubmitInfo_pnext_temp(dec);
270             vn_decode_VkProtectedSubmitInfo_self_temp(dec, (VkProtectedSubmitInfo *)pnext);
271         }
272         break;
273     case VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO:
274         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkTimelineSemaphoreSubmitInfo));
275         if (pnext) {
276             pnext->sType = stype;
277             pnext->pNext = vn_decode_VkSubmitInfo_pnext_temp(dec);
278             vn_decode_VkTimelineSemaphoreSubmitInfo_self_temp(dec, (VkTimelineSemaphoreSubmitInfo *)pnext);
279         }
280         break;
281     default:
282         /* unexpected struct */
283         pnext = NULL;
284         vn_cs_decoder_set_fatal(dec);
285         break;
286     }
287 
288     return pnext;
289 }
290 
291 static inline void
vn_decode_VkSubmitInfo_self_temp(struct vn_cs_decoder * dec,VkSubmitInfo * val)292 vn_decode_VkSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkSubmitInfo *val)
293 {
294     /* skip val->{sType,pNext} */
295     vn_decode_uint32_t(dec, &val->waitSemaphoreCount);
296     if (vn_peek_array_size(dec)) {
297         const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreCount);
298         val->pWaitSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphores) * iter_count);
299         if (!val->pWaitSemaphores) return;
300         for (uint32_t i = 0; i < iter_count; i++)
301             vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pWaitSemaphores)[i]);
302     } else {
303         vn_decode_array_size(dec, val->waitSemaphoreCount);
304         val->pWaitSemaphores = NULL;
305     }
306     if (vn_peek_array_size(dec)) {
307         const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreCount);
308         val->pWaitDstStageMask = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitDstStageMask) * iter_count);
309         if (!val->pWaitDstStageMask) return;
310         for (uint32_t i = 0; i < iter_count; i++)
311             vn_decode_VkFlags(dec, &((VkPipelineStageFlags *)val->pWaitDstStageMask)[i]);
312     } else {
313         vn_decode_array_size(dec, val->waitSemaphoreCount);
314         val->pWaitDstStageMask = NULL;
315     }
316     vn_decode_uint32_t(dec, &val->commandBufferCount);
317     if (vn_peek_array_size(dec)) {
318         const uint32_t iter_count = vn_decode_array_size(dec, val->commandBufferCount);
319         val->pCommandBuffers = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pCommandBuffers) * iter_count);
320         if (!val->pCommandBuffers) return;
321         for (uint32_t i = 0; i < iter_count; i++)
322             vn_decode_VkCommandBuffer_lookup(dec, &((VkCommandBuffer *)val->pCommandBuffers)[i]);
323     } else {
324         vn_decode_array_size(dec, val->commandBufferCount);
325         val->pCommandBuffers = NULL;
326     }
327     vn_decode_uint32_t(dec, &val->signalSemaphoreCount);
328     if (vn_peek_array_size(dec)) {
329         const uint32_t iter_count = vn_decode_array_size(dec, val->signalSemaphoreCount);
330         val->pSignalSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphores) * iter_count);
331         if (!val->pSignalSemaphores) return;
332         for (uint32_t i = 0; i < iter_count; i++)
333             vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pSignalSemaphores)[i]);
334     } else {
335         vn_decode_array_size(dec, val->signalSemaphoreCount);
336         val->pSignalSemaphores = NULL;
337     }
338 }
339 
340 static inline void
vn_decode_VkSubmitInfo_temp(struct vn_cs_decoder * dec,VkSubmitInfo * val)341 vn_decode_VkSubmitInfo_temp(struct vn_cs_decoder *dec, VkSubmitInfo *val)
342 {
343     VkStructureType stype;
344     vn_decode_VkStructureType(dec, &stype);
345     if (stype != VK_STRUCTURE_TYPE_SUBMIT_INFO)
346         vn_cs_decoder_set_fatal(dec);
347 
348     val->sType = stype;
349     val->pNext = vn_decode_VkSubmitInfo_pnext_temp(dec);
350     vn_decode_VkSubmitInfo_self_temp(dec, val);
351 }
352 
353 static inline void
vn_replace_VkSubmitInfo_handle_self(VkSubmitInfo * val)354 vn_replace_VkSubmitInfo_handle_self(VkSubmitInfo *val)
355 {
356     /* skip val->sType */
357     /* skip val->pNext */
358     /* skip val->waitSemaphoreCount */
359     if (val->pWaitSemaphores) {
360        for (uint32_t i = 0; i < val->waitSemaphoreCount; i++)
361             vn_replace_VkSemaphore_handle(&((VkSemaphore *)val->pWaitSemaphores)[i]);
362     }
363     /* skip val->pWaitDstStageMask */
364     /* skip val->commandBufferCount */
365     if (val->pCommandBuffers) {
366        for (uint32_t i = 0; i < val->commandBufferCount; i++)
367             vn_replace_VkCommandBuffer_handle(&((VkCommandBuffer *)val->pCommandBuffers)[i]);
368     }
369     /* skip val->signalSemaphoreCount */
370     if (val->pSignalSemaphores) {
371        for (uint32_t i = 0; i < val->signalSemaphoreCount; i++)
372             vn_replace_VkSemaphore_handle(&((VkSemaphore *)val->pSignalSemaphores)[i]);
373     }
374 }
375 
376 static inline void
vn_replace_VkSubmitInfo_handle(VkSubmitInfo * val)377 vn_replace_VkSubmitInfo_handle(VkSubmitInfo *val)
378 {
379     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
380 
381     do {
382         switch ((int32_t)pnext->sType) {
383         case VK_STRUCTURE_TYPE_SUBMIT_INFO:
384             vn_replace_VkSubmitInfo_handle_self((VkSubmitInfo *)pnext);
385             break;
386         case VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO:
387             vn_replace_VkDeviceGroupSubmitInfo_handle_self((VkDeviceGroupSubmitInfo *)pnext);
388             break;
389         case VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO:
390             vn_replace_VkProtectedSubmitInfo_handle_self((VkProtectedSubmitInfo *)pnext);
391             break;
392         case VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO:
393             vn_replace_VkTimelineSemaphoreSubmitInfo_handle_self((VkTimelineSemaphoreSubmitInfo *)pnext);
394             break;
395         default:
396             /* ignore unknown/unsupported struct */
397             break;
398         }
399         pnext = pnext->pNext;
400     } while (pnext);
401 }
402 
403 /* struct VkSparseMemoryBind */
404 
405 static inline void
vn_decode_VkSparseMemoryBind_temp(struct vn_cs_decoder * dec,VkSparseMemoryBind * val)406 vn_decode_VkSparseMemoryBind_temp(struct vn_cs_decoder *dec, VkSparseMemoryBind *val)
407 {
408     vn_decode_VkDeviceSize(dec, &val->resourceOffset);
409     vn_decode_VkDeviceSize(dec, &val->size);
410     vn_decode_VkDeviceMemory_lookup(dec, &val->memory);
411     vn_decode_VkDeviceSize(dec, &val->memoryOffset);
412     vn_decode_VkFlags(dec, &val->flags);
413 }
414 
415 static inline void
vn_replace_VkSparseMemoryBind_handle(VkSparseMemoryBind * val)416 vn_replace_VkSparseMemoryBind_handle(VkSparseMemoryBind *val)
417 {
418     /* skip val->resourceOffset */
419     /* skip val->size */
420     vn_replace_VkDeviceMemory_handle(&val->memory);
421     /* skip val->memoryOffset */
422     /* skip val->flags */
423 }
424 
425 /* struct VkSparseBufferMemoryBindInfo */
426 
427 static inline void
vn_decode_VkSparseBufferMemoryBindInfo_temp(struct vn_cs_decoder * dec,VkSparseBufferMemoryBindInfo * val)428 vn_decode_VkSparseBufferMemoryBindInfo_temp(struct vn_cs_decoder *dec, VkSparseBufferMemoryBindInfo *val)
429 {
430     vn_decode_VkBuffer_lookup(dec, &val->buffer);
431     vn_decode_uint32_t(dec, &val->bindCount);
432     if (vn_peek_array_size(dec)) {
433         const uint32_t iter_count = vn_decode_array_size(dec, val->bindCount);
434         val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * iter_count);
435         if (!val->pBinds) return;
436         for (uint32_t i = 0; i < iter_count; i++)
437             vn_decode_VkSparseMemoryBind_temp(dec, &((VkSparseMemoryBind *)val->pBinds)[i]);
438     } else {
439         vn_decode_array_size(dec, val->bindCount);
440         val->pBinds = NULL;
441     }
442 }
443 
444 static inline void
vn_replace_VkSparseBufferMemoryBindInfo_handle(VkSparseBufferMemoryBindInfo * val)445 vn_replace_VkSparseBufferMemoryBindInfo_handle(VkSparseBufferMemoryBindInfo *val)
446 {
447     vn_replace_VkBuffer_handle(&val->buffer);
448     /* skip val->bindCount */
449     if (val->pBinds) {
450        for (uint32_t i = 0; i < val->bindCount; i++)
451             vn_replace_VkSparseMemoryBind_handle(&((VkSparseMemoryBind *)val->pBinds)[i]);
452     }
453 }
454 
455 /* struct VkSparseImageOpaqueMemoryBindInfo */
456 
457 static inline void
vn_decode_VkSparseImageOpaqueMemoryBindInfo_temp(struct vn_cs_decoder * dec,VkSparseImageOpaqueMemoryBindInfo * val)458 vn_decode_VkSparseImageOpaqueMemoryBindInfo_temp(struct vn_cs_decoder *dec, VkSparseImageOpaqueMemoryBindInfo *val)
459 {
460     vn_decode_VkImage_lookup(dec, &val->image);
461     vn_decode_uint32_t(dec, &val->bindCount);
462     if (vn_peek_array_size(dec)) {
463         const uint32_t iter_count = vn_decode_array_size(dec, val->bindCount);
464         val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * iter_count);
465         if (!val->pBinds) return;
466         for (uint32_t i = 0; i < iter_count; i++)
467             vn_decode_VkSparseMemoryBind_temp(dec, &((VkSparseMemoryBind *)val->pBinds)[i]);
468     } else {
469         vn_decode_array_size(dec, val->bindCount);
470         val->pBinds = NULL;
471     }
472 }
473 
474 static inline void
vn_replace_VkSparseImageOpaqueMemoryBindInfo_handle(VkSparseImageOpaqueMemoryBindInfo * val)475 vn_replace_VkSparseImageOpaqueMemoryBindInfo_handle(VkSparseImageOpaqueMemoryBindInfo *val)
476 {
477     vn_replace_VkImage_handle(&val->image);
478     /* skip val->bindCount */
479     if (val->pBinds) {
480        for (uint32_t i = 0; i < val->bindCount; i++)
481             vn_replace_VkSparseMemoryBind_handle(&((VkSparseMemoryBind *)val->pBinds)[i]);
482     }
483 }
484 
485 /* struct VkSparseImageMemoryBind */
486 
487 static inline void
vn_decode_VkSparseImageMemoryBind_temp(struct vn_cs_decoder * dec,VkSparseImageMemoryBind * val)488 vn_decode_VkSparseImageMemoryBind_temp(struct vn_cs_decoder *dec, VkSparseImageMemoryBind *val)
489 {
490     vn_decode_VkImageSubresource_temp(dec, &val->subresource);
491     vn_decode_VkOffset3D_temp(dec, &val->offset);
492     vn_decode_VkExtent3D_temp(dec, &val->extent);
493     vn_decode_VkDeviceMemory_lookup(dec, &val->memory);
494     vn_decode_VkDeviceSize(dec, &val->memoryOffset);
495     vn_decode_VkFlags(dec, &val->flags);
496 }
497 
498 static inline void
vn_replace_VkSparseImageMemoryBind_handle(VkSparseImageMemoryBind * val)499 vn_replace_VkSparseImageMemoryBind_handle(VkSparseImageMemoryBind *val)
500 {
501     vn_replace_VkImageSubresource_handle(&val->subresource);
502     vn_replace_VkOffset3D_handle(&val->offset);
503     vn_replace_VkExtent3D_handle(&val->extent);
504     vn_replace_VkDeviceMemory_handle(&val->memory);
505     /* skip val->memoryOffset */
506     /* skip val->flags */
507 }
508 
509 /* struct VkSparseImageMemoryBindInfo */
510 
511 static inline void
vn_decode_VkSparseImageMemoryBindInfo_temp(struct vn_cs_decoder * dec,VkSparseImageMemoryBindInfo * val)512 vn_decode_VkSparseImageMemoryBindInfo_temp(struct vn_cs_decoder *dec, VkSparseImageMemoryBindInfo *val)
513 {
514     vn_decode_VkImage_lookup(dec, &val->image);
515     vn_decode_uint32_t(dec, &val->bindCount);
516     if (vn_peek_array_size(dec)) {
517         const uint32_t iter_count = vn_decode_array_size(dec, val->bindCount);
518         val->pBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBinds) * iter_count);
519         if (!val->pBinds) return;
520         for (uint32_t i = 0; i < iter_count; i++)
521             vn_decode_VkSparseImageMemoryBind_temp(dec, &((VkSparseImageMemoryBind *)val->pBinds)[i]);
522     } else {
523         vn_decode_array_size(dec, val->bindCount);
524         val->pBinds = NULL;
525     }
526 }
527 
528 static inline void
vn_replace_VkSparseImageMemoryBindInfo_handle(VkSparseImageMemoryBindInfo * val)529 vn_replace_VkSparseImageMemoryBindInfo_handle(VkSparseImageMemoryBindInfo *val)
530 {
531     vn_replace_VkImage_handle(&val->image);
532     /* skip val->bindCount */
533     if (val->pBinds) {
534        for (uint32_t i = 0; i < val->bindCount; i++)
535             vn_replace_VkSparseImageMemoryBind_handle(&((VkSparseImageMemoryBind *)val->pBinds)[i]);
536     }
537 }
538 
539 /* struct VkDeviceGroupBindSparseInfo chain */
540 
541 static inline void *
vn_decode_VkDeviceGroupBindSparseInfo_pnext_temp(struct vn_cs_decoder * dec)542 vn_decode_VkDeviceGroupBindSparseInfo_pnext_temp(struct vn_cs_decoder *dec)
543 {
544     /* no known/supported struct */
545     if (vn_decode_simple_pointer(dec))
546         vn_cs_decoder_set_fatal(dec);
547     return NULL;
548 }
549 
550 static inline void
vn_decode_VkDeviceGroupBindSparseInfo_self_temp(struct vn_cs_decoder * dec,VkDeviceGroupBindSparseInfo * val)551 vn_decode_VkDeviceGroupBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkDeviceGroupBindSparseInfo *val)
552 {
553     /* skip val->{sType,pNext} */
554     vn_decode_uint32_t(dec, &val->resourceDeviceIndex);
555     vn_decode_uint32_t(dec, &val->memoryDeviceIndex);
556 }
557 
558 static inline void
vn_decode_VkDeviceGroupBindSparseInfo_temp(struct vn_cs_decoder * dec,VkDeviceGroupBindSparseInfo * val)559 vn_decode_VkDeviceGroupBindSparseInfo_temp(struct vn_cs_decoder *dec, VkDeviceGroupBindSparseInfo *val)
560 {
561     VkStructureType stype;
562     vn_decode_VkStructureType(dec, &stype);
563     if (stype != VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO)
564         vn_cs_decoder_set_fatal(dec);
565 
566     val->sType = stype;
567     val->pNext = vn_decode_VkDeviceGroupBindSparseInfo_pnext_temp(dec);
568     vn_decode_VkDeviceGroupBindSparseInfo_self_temp(dec, val);
569 }
570 
571 static inline void
vn_replace_VkDeviceGroupBindSparseInfo_handle_self(VkDeviceGroupBindSparseInfo * val)572 vn_replace_VkDeviceGroupBindSparseInfo_handle_self(VkDeviceGroupBindSparseInfo *val)
573 {
574     /* skip val->sType */
575     /* skip val->pNext */
576     /* skip val->resourceDeviceIndex */
577     /* skip val->memoryDeviceIndex */
578 }
579 
580 static inline void
vn_replace_VkDeviceGroupBindSparseInfo_handle(VkDeviceGroupBindSparseInfo * val)581 vn_replace_VkDeviceGroupBindSparseInfo_handle(VkDeviceGroupBindSparseInfo *val)
582 {
583     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
584 
585     do {
586         switch ((int32_t)pnext->sType) {
587         case VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO:
588             vn_replace_VkDeviceGroupBindSparseInfo_handle_self((VkDeviceGroupBindSparseInfo *)pnext);
589             break;
590         default:
591             /* ignore unknown/unsupported struct */
592             break;
593         }
594         pnext = pnext->pNext;
595     } while (pnext);
596 }
597 
598 /* struct VkBindSparseInfo chain */
599 
600 static inline void *
vn_decode_VkBindSparseInfo_pnext_temp(struct vn_cs_decoder * dec)601 vn_decode_VkBindSparseInfo_pnext_temp(struct vn_cs_decoder *dec)
602 {
603     VkBaseOutStructure *pnext;
604     VkStructureType stype;
605 
606     if (!vn_decode_simple_pointer(dec))
607         return NULL;
608 
609     vn_decode_VkStructureType(dec, &stype);
610     switch ((int32_t)stype) {
611     case VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO:
612         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkDeviceGroupBindSparseInfo));
613         if (pnext) {
614             pnext->sType = stype;
615             pnext->pNext = vn_decode_VkBindSparseInfo_pnext_temp(dec);
616             vn_decode_VkDeviceGroupBindSparseInfo_self_temp(dec, (VkDeviceGroupBindSparseInfo *)pnext);
617         }
618         break;
619     case VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO:
620         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkTimelineSemaphoreSubmitInfo));
621         if (pnext) {
622             pnext->sType = stype;
623             pnext->pNext = vn_decode_VkBindSparseInfo_pnext_temp(dec);
624             vn_decode_VkTimelineSemaphoreSubmitInfo_self_temp(dec, (VkTimelineSemaphoreSubmitInfo *)pnext);
625         }
626         break;
627     default:
628         /* unexpected struct */
629         pnext = NULL;
630         vn_cs_decoder_set_fatal(dec);
631         break;
632     }
633 
634     return pnext;
635 }
636 
637 static inline void
vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder * dec,VkBindSparseInfo * val)638 vn_decode_VkBindSparseInfo_self_temp(struct vn_cs_decoder *dec, VkBindSparseInfo *val)
639 {
640     /* skip val->{sType,pNext} */
641     vn_decode_uint32_t(dec, &val->waitSemaphoreCount);
642     if (vn_peek_array_size(dec)) {
643         const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreCount);
644         val->pWaitSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphores) * iter_count);
645         if (!val->pWaitSemaphores) return;
646         for (uint32_t i = 0; i < iter_count; i++)
647             vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pWaitSemaphores)[i]);
648     } else {
649         vn_decode_array_size(dec, val->waitSemaphoreCount);
650         val->pWaitSemaphores = NULL;
651     }
652     vn_decode_uint32_t(dec, &val->bufferBindCount);
653     if (vn_peek_array_size(dec)) {
654         const uint32_t iter_count = vn_decode_array_size(dec, val->bufferBindCount);
655         val->pBufferBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pBufferBinds) * iter_count);
656         if (!val->pBufferBinds) return;
657         for (uint32_t i = 0; i < iter_count; i++)
658             vn_decode_VkSparseBufferMemoryBindInfo_temp(dec, &((VkSparseBufferMemoryBindInfo *)val->pBufferBinds)[i]);
659     } else {
660         vn_decode_array_size(dec, val->bufferBindCount);
661         val->pBufferBinds = NULL;
662     }
663     vn_decode_uint32_t(dec, &val->imageOpaqueBindCount);
664     if (vn_peek_array_size(dec)) {
665         const uint32_t iter_count = vn_decode_array_size(dec, val->imageOpaqueBindCount);
666         val->pImageOpaqueBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageOpaqueBinds) * iter_count);
667         if (!val->pImageOpaqueBinds) return;
668         for (uint32_t i = 0; i < iter_count; i++)
669             vn_decode_VkSparseImageOpaqueMemoryBindInfo_temp(dec, &((VkSparseImageOpaqueMemoryBindInfo *)val->pImageOpaqueBinds)[i]);
670     } else {
671         vn_decode_array_size(dec, val->imageOpaqueBindCount);
672         val->pImageOpaqueBinds = NULL;
673     }
674     vn_decode_uint32_t(dec, &val->imageBindCount);
675     if (vn_peek_array_size(dec)) {
676         const uint32_t iter_count = vn_decode_array_size(dec, val->imageBindCount);
677         val->pImageBinds = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pImageBinds) * iter_count);
678         if (!val->pImageBinds) return;
679         for (uint32_t i = 0; i < iter_count; i++)
680             vn_decode_VkSparseImageMemoryBindInfo_temp(dec, &((VkSparseImageMemoryBindInfo *)val->pImageBinds)[i]);
681     } else {
682         vn_decode_array_size(dec, val->imageBindCount);
683         val->pImageBinds = NULL;
684     }
685     vn_decode_uint32_t(dec, &val->signalSemaphoreCount);
686     if (vn_peek_array_size(dec)) {
687         const uint32_t iter_count = vn_decode_array_size(dec, val->signalSemaphoreCount);
688         val->pSignalSemaphores = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphores) * iter_count);
689         if (!val->pSignalSemaphores) return;
690         for (uint32_t i = 0; i < iter_count; i++)
691             vn_decode_VkSemaphore_lookup(dec, &((VkSemaphore *)val->pSignalSemaphores)[i]);
692     } else {
693         vn_decode_array_size(dec, val->signalSemaphoreCount);
694         val->pSignalSemaphores = NULL;
695     }
696 }
697 
698 static inline void
vn_decode_VkBindSparseInfo_temp(struct vn_cs_decoder * dec,VkBindSparseInfo * val)699 vn_decode_VkBindSparseInfo_temp(struct vn_cs_decoder *dec, VkBindSparseInfo *val)
700 {
701     VkStructureType stype;
702     vn_decode_VkStructureType(dec, &stype);
703     if (stype != VK_STRUCTURE_TYPE_BIND_SPARSE_INFO)
704         vn_cs_decoder_set_fatal(dec);
705 
706     val->sType = stype;
707     val->pNext = vn_decode_VkBindSparseInfo_pnext_temp(dec);
708     vn_decode_VkBindSparseInfo_self_temp(dec, val);
709 }
710 
711 static inline void
vn_replace_VkBindSparseInfo_handle_self(VkBindSparseInfo * val)712 vn_replace_VkBindSparseInfo_handle_self(VkBindSparseInfo *val)
713 {
714     /* skip val->sType */
715     /* skip val->pNext */
716     /* skip val->waitSemaphoreCount */
717     if (val->pWaitSemaphores) {
718        for (uint32_t i = 0; i < val->waitSemaphoreCount; i++)
719             vn_replace_VkSemaphore_handle(&((VkSemaphore *)val->pWaitSemaphores)[i]);
720     }
721     /* skip val->bufferBindCount */
722     if (val->pBufferBinds) {
723        for (uint32_t i = 0; i < val->bufferBindCount; i++)
724             vn_replace_VkSparseBufferMemoryBindInfo_handle(&((VkSparseBufferMemoryBindInfo *)val->pBufferBinds)[i]);
725     }
726     /* skip val->imageOpaqueBindCount */
727     if (val->pImageOpaqueBinds) {
728        for (uint32_t i = 0; i < val->imageOpaqueBindCount; i++)
729             vn_replace_VkSparseImageOpaqueMemoryBindInfo_handle(&((VkSparseImageOpaqueMemoryBindInfo *)val->pImageOpaqueBinds)[i]);
730     }
731     /* skip val->imageBindCount */
732     if (val->pImageBinds) {
733        for (uint32_t i = 0; i < val->imageBindCount; i++)
734             vn_replace_VkSparseImageMemoryBindInfo_handle(&((VkSparseImageMemoryBindInfo *)val->pImageBinds)[i]);
735     }
736     /* skip val->signalSemaphoreCount */
737     if (val->pSignalSemaphores) {
738        for (uint32_t i = 0; i < val->signalSemaphoreCount; i++)
739             vn_replace_VkSemaphore_handle(&((VkSemaphore *)val->pSignalSemaphores)[i]);
740     }
741 }
742 
743 static inline void
vn_replace_VkBindSparseInfo_handle(VkBindSparseInfo * val)744 vn_replace_VkBindSparseInfo_handle(VkBindSparseInfo *val)
745 {
746     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
747 
748     do {
749         switch ((int32_t)pnext->sType) {
750         case VK_STRUCTURE_TYPE_BIND_SPARSE_INFO:
751             vn_replace_VkBindSparseInfo_handle_self((VkBindSparseInfo *)pnext);
752             break;
753         case VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO:
754             vn_replace_VkDeviceGroupBindSparseInfo_handle_self((VkDeviceGroupBindSparseInfo *)pnext);
755             break;
756         case VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO:
757             vn_replace_VkTimelineSemaphoreSubmitInfo_handle_self((VkTimelineSemaphoreSubmitInfo *)pnext);
758             break;
759         default:
760             /* ignore unknown/unsupported struct */
761             break;
762         }
763         pnext = pnext->pNext;
764     } while (pnext);
765 }
766 
767 /* struct VkSemaphoreSubmitInfo chain */
768 
769 static inline void *
vn_decode_VkSemaphoreSubmitInfo_pnext_temp(struct vn_cs_decoder * dec)770 vn_decode_VkSemaphoreSubmitInfo_pnext_temp(struct vn_cs_decoder *dec)
771 {
772     /* no known/supported struct */
773     if (vn_decode_simple_pointer(dec))
774         vn_cs_decoder_set_fatal(dec);
775     return NULL;
776 }
777 
778 static inline void
vn_decode_VkSemaphoreSubmitInfo_self_temp(struct vn_cs_decoder * dec,VkSemaphoreSubmitInfo * val)779 vn_decode_VkSemaphoreSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkSemaphoreSubmitInfo *val)
780 {
781     /* skip val->{sType,pNext} */
782     vn_decode_VkSemaphore_lookup(dec, &val->semaphore);
783     vn_decode_uint64_t(dec, &val->value);
784     vn_decode_VkFlags64(dec, &val->stageMask);
785     vn_decode_uint32_t(dec, &val->deviceIndex);
786 }
787 
788 static inline void
vn_decode_VkSemaphoreSubmitInfo_temp(struct vn_cs_decoder * dec,VkSemaphoreSubmitInfo * val)789 vn_decode_VkSemaphoreSubmitInfo_temp(struct vn_cs_decoder *dec, VkSemaphoreSubmitInfo *val)
790 {
791     VkStructureType stype;
792     vn_decode_VkStructureType(dec, &stype);
793     if (stype != VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO)
794         vn_cs_decoder_set_fatal(dec);
795 
796     val->sType = stype;
797     val->pNext = vn_decode_VkSemaphoreSubmitInfo_pnext_temp(dec);
798     vn_decode_VkSemaphoreSubmitInfo_self_temp(dec, val);
799 }
800 
801 static inline void
vn_replace_VkSemaphoreSubmitInfo_handle_self(VkSemaphoreSubmitInfo * val)802 vn_replace_VkSemaphoreSubmitInfo_handle_self(VkSemaphoreSubmitInfo *val)
803 {
804     /* skip val->sType */
805     /* skip val->pNext */
806     vn_replace_VkSemaphore_handle(&val->semaphore);
807     /* skip val->value */
808     /* skip val->stageMask */
809     /* skip val->deviceIndex */
810 }
811 
812 static inline void
vn_replace_VkSemaphoreSubmitInfo_handle(VkSemaphoreSubmitInfo * val)813 vn_replace_VkSemaphoreSubmitInfo_handle(VkSemaphoreSubmitInfo *val)
814 {
815     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
816 
817     do {
818         switch ((int32_t)pnext->sType) {
819         case VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO:
820             vn_replace_VkSemaphoreSubmitInfo_handle_self((VkSemaphoreSubmitInfo *)pnext);
821             break;
822         default:
823             /* ignore unknown/unsupported struct */
824             break;
825         }
826         pnext = pnext->pNext;
827     } while (pnext);
828 }
829 
830 /* struct VkCommandBufferSubmitInfo chain */
831 
832 static inline void *
vn_decode_VkCommandBufferSubmitInfo_pnext_temp(struct vn_cs_decoder * dec)833 vn_decode_VkCommandBufferSubmitInfo_pnext_temp(struct vn_cs_decoder *dec)
834 {
835     /* no known/supported struct */
836     if (vn_decode_simple_pointer(dec))
837         vn_cs_decoder_set_fatal(dec);
838     return NULL;
839 }
840 
841 static inline void
vn_decode_VkCommandBufferSubmitInfo_self_temp(struct vn_cs_decoder * dec,VkCommandBufferSubmitInfo * val)842 vn_decode_VkCommandBufferSubmitInfo_self_temp(struct vn_cs_decoder *dec, VkCommandBufferSubmitInfo *val)
843 {
844     /* skip val->{sType,pNext} */
845     vn_decode_VkCommandBuffer_lookup(dec, &val->commandBuffer);
846     vn_decode_uint32_t(dec, &val->deviceMask);
847 }
848 
849 static inline void
vn_decode_VkCommandBufferSubmitInfo_temp(struct vn_cs_decoder * dec,VkCommandBufferSubmitInfo * val)850 vn_decode_VkCommandBufferSubmitInfo_temp(struct vn_cs_decoder *dec, VkCommandBufferSubmitInfo *val)
851 {
852     VkStructureType stype;
853     vn_decode_VkStructureType(dec, &stype);
854     if (stype != VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO)
855         vn_cs_decoder_set_fatal(dec);
856 
857     val->sType = stype;
858     val->pNext = vn_decode_VkCommandBufferSubmitInfo_pnext_temp(dec);
859     vn_decode_VkCommandBufferSubmitInfo_self_temp(dec, val);
860 }
861 
862 static inline void
vn_replace_VkCommandBufferSubmitInfo_handle_self(VkCommandBufferSubmitInfo * val)863 vn_replace_VkCommandBufferSubmitInfo_handle_self(VkCommandBufferSubmitInfo *val)
864 {
865     /* skip val->sType */
866     /* skip val->pNext */
867     vn_replace_VkCommandBuffer_handle(&val->commandBuffer);
868     /* skip val->deviceMask */
869 }
870 
871 static inline void
vn_replace_VkCommandBufferSubmitInfo_handle(VkCommandBufferSubmitInfo * val)872 vn_replace_VkCommandBufferSubmitInfo_handle(VkCommandBufferSubmitInfo *val)
873 {
874     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
875 
876     do {
877         switch ((int32_t)pnext->sType) {
878         case VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO:
879             vn_replace_VkCommandBufferSubmitInfo_handle_self((VkCommandBufferSubmitInfo *)pnext);
880             break;
881         default:
882             /* ignore unknown/unsupported struct */
883             break;
884         }
885         pnext = pnext->pNext;
886     } while (pnext);
887 }
888 
889 /* struct VkSubmitInfo2 chain */
890 
891 static inline void *
vn_decode_VkSubmitInfo2_pnext_temp(struct vn_cs_decoder * dec)892 vn_decode_VkSubmitInfo2_pnext_temp(struct vn_cs_decoder *dec)
893 {
894     /* no known/supported struct */
895     if (vn_decode_simple_pointer(dec))
896         vn_cs_decoder_set_fatal(dec);
897     return NULL;
898 }
899 
900 static inline void
vn_decode_VkSubmitInfo2_self_temp(struct vn_cs_decoder * dec,VkSubmitInfo2 * val)901 vn_decode_VkSubmitInfo2_self_temp(struct vn_cs_decoder *dec, VkSubmitInfo2 *val)
902 {
903     /* skip val->{sType,pNext} */
904     vn_decode_VkFlags(dec, &val->flags);
905     vn_decode_uint32_t(dec, &val->waitSemaphoreInfoCount);
906     if (vn_peek_array_size(dec)) {
907         const uint32_t iter_count = vn_decode_array_size(dec, val->waitSemaphoreInfoCount);
908         val->pWaitSemaphoreInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pWaitSemaphoreInfos) * iter_count);
909         if (!val->pWaitSemaphoreInfos) return;
910         for (uint32_t i = 0; i < iter_count; i++)
911             vn_decode_VkSemaphoreSubmitInfo_temp(dec, &((VkSemaphoreSubmitInfo *)val->pWaitSemaphoreInfos)[i]);
912     } else {
913         vn_decode_array_size(dec, val->waitSemaphoreInfoCount);
914         val->pWaitSemaphoreInfos = NULL;
915     }
916     vn_decode_uint32_t(dec, &val->commandBufferInfoCount);
917     if (vn_peek_array_size(dec)) {
918         const uint32_t iter_count = vn_decode_array_size(dec, val->commandBufferInfoCount);
919         val->pCommandBufferInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pCommandBufferInfos) * iter_count);
920         if (!val->pCommandBufferInfos) return;
921         for (uint32_t i = 0; i < iter_count; i++)
922             vn_decode_VkCommandBufferSubmitInfo_temp(dec, &((VkCommandBufferSubmitInfo *)val->pCommandBufferInfos)[i]);
923     } else {
924         vn_decode_array_size(dec, val->commandBufferInfoCount);
925         val->pCommandBufferInfos = NULL;
926     }
927     vn_decode_uint32_t(dec, &val->signalSemaphoreInfoCount);
928     if (vn_peek_array_size(dec)) {
929         const uint32_t iter_count = vn_decode_array_size(dec, val->signalSemaphoreInfoCount);
930         val->pSignalSemaphoreInfos = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSignalSemaphoreInfos) * iter_count);
931         if (!val->pSignalSemaphoreInfos) return;
932         for (uint32_t i = 0; i < iter_count; i++)
933             vn_decode_VkSemaphoreSubmitInfo_temp(dec, &((VkSemaphoreSubmitInfo *)val->pSignalSemaphoreInfos)[i]);
934     } else {
935         vn_decode_array_size(dec, val->signalSemaphoreInfoCount);
936         val->pSignalSemaphoreInfos = NULL;
937     }
938 }
939 
940 static inline void
vn_decode_VkSubmitInfo2_temp(struct vn_cs_decoder * dec,VkSubmitInfo2 * val)941 vn_decode_VkSubmitInfo2_temp(struct vn_cs_decoder *dec, VkSubmitInfo2 *val)
942 {
943     VkStructureType stype;
944     vn_decode_VkStructureType(dec, &stype);
945     if (stype != VK_STRUCTURE_TYPE_SUBMIT_INFO_2)
946         vn_cs_decoder_set_fatal(dec);
947 
948     val->sType = stype;
949     val->pNext = vn_decode_VkSubmitInfo2_pnext_temp(dec);
950     vn_decode_VkSubmitInfo2_self_temp(dec, val);
951 }
952 
953 static inline void
vn_replace_VkSubmitInfo2_handle_self(VkSubmitInfo2 * val)954 vn_replace_VkSubmitInfo2_handle_self(VkSubmitInfo2 *val)
955 {
956     /* skip val->sType */
957     /* skip val->pNext */
958     /* skip val->flags */
959     /* skip val->waitSemaphoreInfoCount */
960     if (val->pWaitSemaphoreInfos) {
961        for (uint32_t i = 0; i < val->waitSemaphoreInfoCount; i++)
962             vn_replace_VkSemaphoreSubmitInfo_handle(&((VkSemaphoreSubmitInfo *)val->pWaitSemaphoreInfos)[i]);
963     }
964     /* skip val->commandBufferInfoCount */
965     if (val->pCommandBufferInfos) {
966        for (uint32_t i = 0; i < val->commandBufferInfoCount; i++)
967             vn_replace_VkCommandBufferSubmitInfo_handle(&((VkCommandBufferSubmitInfo *)val->pCommandBufferInfos)[i]);
968     }
969     /* skip val->signalSemaphoreInfoCount */
970     if (val->pSignalSemaphoreInfos) {
971        for (uint32_t i = 0; i < val->signalSemaphoreInfoCount; i++)
972             vn_replace_VkSemaphoreSubmitInfo_handle(&((VkSemaphoreSubmitInfo *)val->pSignalSemaphoreInfos)[i]);
973     }
974 }
975 
976 static inline void
vn_replace_VkSubmitInfo2_handle(VkSubmitInfo2 * val)977 vn_replace_VkSubmitInfo2_handle(VkSubmitInfo2 *val)
978 {
979     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
980 
981     do {
982         switch ((int32_t)pnext->sType) {
983         case VK_STRUCTURE_TYPE_SUBMIT_INFO_2:
984             vn_replace_VkSubmitInfo2_handle_self((VkSubmitInfo2 *)pnext);
985             break;
986         default:
987             /* ignore unknown/unsupported struct */
988             break;
989         }
990         pnext = pnext->pNext;
991     } while (pnext);
992 }
993 
vn_decode_vkQueueSubmit_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkQueueSubmit * args)994 static inline void vn_decode_vkQueueSubmit_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkQueueSubmit *args)
995 {
996     vn_decode_VkQueue_lookup(dec, &args->queue);
997     vn_decode_uint32_t(dec, &args->submitCount);
998     if (vn_peek_array_size(dec)) {
999         const uint32_t iter_count = vn_decode_array_size(dec, args->submitCount);
1000         args->pSubmits = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSubmits) * iter_count);
1001         if (!args->pSubmits) return;
1002         for (uint32_t i = 0; i < iter_count; i++)
1003             vn_decode_VkSubmitInfo_temp(dec, &((VkSubmitInfo *)args->pSubmits)[i]);
1004     } else {
1005         vn_decode_array_size(dec, args->submitCount);
1006         args->pSubmits = NULL;
1007     }
1008     vn_decode_VkFence_lookup(dec, &args->fence);
1009 }
1010 
vn_replace_vkQueueSubmit_args_handle(struct vn_command_vkQueueSubmit * args)1011 static inline void vn_replace_vkQueueSubmit_args_handle(struct vn_command_vkQueueSubmit *args)
1012 {
1013     vn_replace_VkQueue_handle(&args->queue);
1014     /* skip args->submitCount */
1015     if (args->pSubmits) {
1016        for (uint32_t i = 0; i < args->submitCount; i++)
1017             vn_replace_VkSubmitInfo_handle(&((VkSubmitInfo *)args->pSubmits)[i]);
1018     }
1019     vn_replace_VkFence_handle(&args->fence);
1020 }
1021 
vn_encode_vkQueueSubmit_reply(struct vn_cs_encoder * enc,const struct vn_command_vkQueueSubmit * args)1022 static inline void vn_encode_vkQueueSubmit_reply(struct vn_cs_encoder *enc, const struct vn_command_vkQueueSubmit *args)
1023 {
1024     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkQueueSubmit_EXT});
1025 
1026     vn_encode_VkResult(enc, &args->ret);
1027     /* skip args->queue */
1028     /* skip args->submitCount */
1029     /* skip args->pSubmits */
1030     /* skip args->fence */
1031 }
1032 
vn_decode_vkQueueWaitIdle_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkQueueWaitIdle * args)1033 static inline void vn_decode_vkQueueWaitIdle_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkQueueWaitIdle *args)
1034 {
1035     vn_decode_VkQueue_lookup(dec, &args->queue);
1036 }
1037 
vn_replace_vkQueueWaitIdle_args_handle(struct vn_command_vkQueueWaitIdle * args)1038 static inline void vn_replace_vkQueueWaitIdle_args_handle(struct vn_command_vkQueueWaitIdle *args)
1039 {
1040     vn_replace_VkQueue_handle(&args->queue);
1041 }
1042 
vn_encode_vkQueueWaitIdle_reply(struct vn_cs_encoder * enc,const struct vn_command_vkQueueWaitIdle * args)1043 static inline void vn_encode_vkQueueWaitIdle_reply(struct vn_cs_encoder *enc, const struct vn_command_vkQueueWaitIdle *args)
1044 {
1045     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkQueueWaitIdle_EXT});
1046 
1047     vn_encode_VkResult(enc, &args->ret);
1048     /* skip args->queue */
1049 }
1050 
vn_decode_vkQueueBindSparse_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkQueueBindSparse * args)1051 static inline void vn_decode_vkQueueBindSparse_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkQueueBindSparse *args)
1052 {
1053     vn_decode_VkQueue_lookup(dec, &args->queue);
1054     vn_decode_uint32_t(dec, &args->bindInfoCount);
1055     if (vn_peek_array_size(dec)) {
1056         const uint32_t iter_count = vn_decode_array_size(dec, args->bindInfoCount);
1057         args->pBindInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pBindInfo) * iter_count);
1058         if (!args->pBindInfo) return;
1059         for (uint32_t i = 0; i < iter_count; i++)
1060             vn_decode_VkBindSparseInfo_temp(dec, &((VkBindSparseInfo *)args->pBindInfo)[i]);
1061     } else {
1062         vn_decode_array_size(dec, args->bindInfoCount);
1063         args->pBindInfo = NULL;
1064     }
1065     vn_decode_VkFence_lookup(dec, &args->fence);
1066 }
1067 
vn_replace_vkQueueBindSparse_args_handle(struct vn_command_vkQueueBindSparse * args)1068 static inline void vn_replace_vkQueueBindSparse_args_handle(struct vn_command_vkQueueBindSparse *args)
1069 {
1070     vn_replace_VkQueue_handle(&args->queue);
1071     /* skip args->bindInfoCount */
1072     if (args->pBindInfo) {
1073        for (uint32_t i = 0; i < args->bindInfoCount; i++)
1074             vn_replace_VkBindSparseInfo_handle(&((VkBindSparseInfo *)args->pBindInfo)[i]);
1075     }
1076     vn_replace_VkFence_handle(&args->fence);
1077 }
1078 
vn_encode_vkQueueBindSparse_reply(struct vn_cs_encoder * enc,const struct vn_command_vkQueueBindSparse * args)1079 static inline void vn_encode_vkQueueBindSparse_reply(struct vn_cs_encoder *enc, const struct vn_command_vkQueueBindSparse *args)
1080 {
1081     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkQueueBindSparse_EXT});
1082 
1083     vn_encode_VkResult(enc, &args->ret);
1084     /* skip args->queue */
1085     /* skip args->bindInfoCount */
1086     /* skip args->pBindInfo */
1087     /* skip args->fence */
1088 }
1089 
vn_decode_vkQueueSubmit2_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkQueueSubmit2 * args)1090 static inline void vn_decode_vkQueueSubmit2_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkQueueSubmit2 *args)
1091 {
1092     vn_decode_VkQueue_lookup(dec, &args->queue);
1093     vn_decode_uint32_t(dec, &args->submitCount);
1094     if (vn_peek_array_size(dec)) {
1095         const uint32_t iter_count = vn_decode_array_size(dec, args->submitCount);
1096         args->pSubmits = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSubmits) * iter_count);
1097         if (!args->pSubmits) return;
1098         for (uint32_t i = 0; i < iter_count; i++)
1099             vn_decode_VkSubmitInfo2_temp(dec, &((VkSubmitInfo2 *)args->pSubmits)[i]);
1100     } else {
1101         vn_decode_array_size(dec, args->submitCount);
1102         args->pSubmits = NULL;
1103     }
1104     vn_decode_VkFence_lookup(dec, &args->fence);
1105 }
1106 
vn_replace_vkQueueSubmit2_args_handle(struct vn_command_vkQueueSubmit2 * args)1107 static inline void vn_replace_vkQueueSubmit2_args_handle(struct vn_command_vkQueueSubmit2 *args)
1108 {
1109     vn_replace_VkQueue_handle(&args->queue);
1110     /* skip args->submitCount */
1111     if (args->pSubmits) {
1112        for (uint32_t i = 0; i < args->submitCount; i++)
1113             vn_replace_VkSubmitInfo2_handle(&((VkSubmitInfo2 *)args->pSubmits)[i]);
1114     }
1115     vn_replace_VkFence_handle(&args->fence);
1116 }
1117 
vn_encode_vkQueueSubmit2_reply(struct vn_cs_encoder * enc,const struct vn_command_vkQueueSubmit2 * args)1118 static inline void vn_encode_vkQueueSubmit2_reply(struct vn_cs_encoder *enc, const struct vn_command_vkQueueSubmit2 *args)
1119 {
1120     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkQueueSubmit2_EXT});
1121 
1122     vn_encode_VkResult(enc, &args->ret);
1123     /* skip args->queue */
1124     /* skip args->submitCount */
1125     /* skip args->pSubmits */
1126     /* skip args->fence */
1127 }
1128 
vn_dispatch_vkQueueSubmit(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)1129 static inline void vn_dispatch_vkQueueSubmit(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
1130 {
1131     struct vn_command_vkQueueSubmit args;
1132 
1133     if (!ctx->dispatch_vkQueueSubmit) {
1134         vn_cs_decoder_set_fatal(ctx->decoder);
1135         return;
1136     }
1137 
1138     vn_decode_vkQueueSubmit_args_temp(ctx->decoder, &args);
1139     if (!args.queue) {
1140         vn_cs_decoder_set_fatal(ctx->decoder);
1141         return;
1142     }
1143 
1144     if (!vn_cs_decoder_get_fatal(ctx->decoder))
1145         ctx->dispatch_vkQueueSubmit(ctx, &args);
1146 
1147 #ifdef DEBUG
1148     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
1149         vn_dispatch_debug_log(ctx, "vkQueueSubmit returned %d", args.ret);
1150 #endif
1151 
1152     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
1153        vn_encode_vkQueueSubmit_reply(ctx->encoder, &args);
1154 
1155     vn_cs_decoder_reset_temp_pool(ctx->decoder);
1156 }
1157 
vn_dispatch_vkQueueWaitIdle(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)1158 static inline void vn_dispatch_vkQueueWaitIdle(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
1159 {
1160     struct vn_command_vkQueueWaitIdle args;
1161 
1162     if (!ctx->dispatch_vkQueueWaitIdle) {
1163         vn_cs_decoder_set_fatal(ctx->decoder);
1164         return;
1165     }
1166 
1167     vn_decode_vkQueueWaitIdle_args_temp(ctx->decoder, &args);
1168     if (!args.queue) {
1169         vn_cs_decoder_set_fatal(ctx->decoder);
1170         return;
1171     }
1172 
1173     if (!vn_cs_decoder_get_fatal(ctx->decoder))
1174         ctx->dispatch_vkQueueWaitIdle(ctx, &args);
1175 
1176 #ifdef DEBUG
1177     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
1178         vn_dispatch_debug_log(ctx, "vkQueueWaitIdle returned %d", args.ret);
1179 #endif
1180 
1181     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
1182        vn_encode_vkQueueWaitIdle_reply(ctx->encoder, &args);
1183 
1184     vn_cs_decoder_reset_temp_pool(ctx->decoder);
1185 }
1186 
vn_dispatch_vkQueueBindSparse(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)1187 static inline void vn_dispatch_vkQueueBindSparse(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
1188 {
1189     struct vn_command_vkQueueBindSparse args;
1190 
1191     if (!ctx->dispatch_vkQueueBindSparse) {
1192         vn_cs_decoder_set_fatal(ctx->decoder);
1193         return;
1194     }
1195 
1196     vn_decode_vkQueueBindSparse_args_temp(ctx->decoder, &args);
1197     if (!args.queue) {
1198         vn_cs_decoder_set_fatal(ctx->decoder);
1199         return;
1200     }
1201 
1202     if (!vn_cs_decoder_get_fatal(ctx->decoder))
1203         ctx->dispatch_vkQueueBindSparse(ctx, &args);
1204 
1205 #ifdef DEBUG
1206     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
1207         vn_dispatch_debug_log(ctx, "vkQueueBindSparse returned %d", args.ret);
1208 #endif
1209 
1210     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
1211        vn_encode_vkQueueBindSparse_reply(ctx->encoder, &args);
1212 
1213     vn_cs_decoder_reset_temp_pool(ctx->decoder);
1214 }
1215 
vn_dispatch_vkQueueSubmit2(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)1216 static inline void vn_dispatch_vkQueueSubmit2(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
1217 {
1218     struct vn_command_vkQueueSubmit2 args;
1219 
1220     if (!ctx->dispatch_vkQueueSubmit2) {
1221         vn_cs_decoder_set_fatal(ctx->decoder);
1222         return;
1223     }
1224 
1225     vn_decode_vkQueueSubmit2_args_temp(ctx->decoder, &args);
1226     if (!args.queue) {
1227         vn_cs_decoder_set_fatal(ctx->decoder);
1228         return;
1229     }
1230 
1231     if (!vn_cs_decoder_get_fatal(ctx->decoder))
1232         ctx->dispatch_vkQueueSubmit2(ctx, &args);
1233 
1234 #ifdef DEBUG
1235     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
1236         vn_dispatch_debug_log(ctx, "vkQueueSubmit2 returned %d", args.ret);
1237 #endif
1238 
1239     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
1240        vn_encode_vkQueueSubmit2_reply(ctx->encoder, &args);
1241 
1242     vn_cs_decoder_reset_temp_pool(ctx->decoder);
1243 }
1244 
1245 #pragma GCC diagnostic pop
1246 
1247 #endif /* VN_PROTOCOL_RENDERER_QUEUE_H */
1248