• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FENCE_H
9 #define VN_PROTOCOL_DRIVER_FENCE_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  *   vkGetFenceFdKHR
18  */
19 
20 /* struct VkExportFenceCreateInfo chain */
21 
22 static inline size_t
vn_sizeof_VkExportFenceCreateInfo_pnext(const void * val)23 vn_sizeof_VkExportFenceCreateInfo_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_VkExportFenceCreateInfo_self(const VkExportFenceCreateInfo * val)30 vn_sizeof_VkExportFenceCreateInfo_self(const VkExportFenceCreateInfo *val)
31 {
32     size_t size = 0;
33     /* skip val->{sType,pNext} */
34     size += vn_sizeof_VkFlags(&val->handleTypes);
35     return size;
36 }
37 
38 static inline size_t
vn_sizeof_VkExportFenceCreateInfo(const VkExportFenceCreateInfo * val)39 vn_sizeof_VkExportFenceCreateInfo(const VkExportFenceCreateInfo *val)
40 {
41     size_t size = 0;
42 
43     size += vn_sizeof_VkStructureType(&val->sType);
44     size += vn_sizeof_VkExportFenceCreateInfo_pnext(val->pNext);
45     size += vn_sizeof_VkExportFenceCreateInfo_self(val);
46 
47     return size;
48 }
49 
50 static inline void
vn_encode_VkExportFenceCreateInfo_pnext(struct vn_cs_encoder * enc,const void * val)51 vn_encode_VkExportFenceCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
52 {
53     /* no known/supported struct */
54     vn_encode_simple_pointer(enc, NULL);
55 }
56 
57 static inline void
vn_encode_VkExportFenceCreateInfo_self(struct vn_cs_encoder * enc,const VkExportFenceCreateInfo * val)58 vn_encode_VkExportFenceCreateInfo_self(struct vn_cs_encoder *enc, const VkExportFenceCreateInfo *val)
59 {
60     /* skip val->{sType,pNext} */
61     vn_encode_VkFlags(enc, &val->handleTypes);
62 }
63 
64 static inline void
vn_encode_VkExportFenceCreateInfo(struct vn_cs_encoder * enc,const VkExportFenceCreateInfo * val)65 vn_encode_VkExportFenceCreateInfo(struct vn_cs_encoder *enc, const VkExportFenceCreateInfo *val)
66 {
67     assert(val->sType == VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO);
68     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO });
69     vn_encode_VkExportFenceCreateInfo_pnext(enc, val->pNext);
70     vn_encode_VkExportFenceCreateInfo_self(enc, val);
71 }
72 
73 /* struct VkFenceCreateInfo chain */
74 
75 static inline size_t
vn_sizeof_VkFenceCreateInfo_pnext(const void * val)76 vn_sizeof_VkFenceCreateInfo_pnext(const void *val)
77 {
78     const VkBaseInStructure *pnext = val;
79     size_t size = 0;
80 
81     while (pnext) {
82         switch ((int32_t)pnext->sType) {
83         case VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO:
84             size += vn_sizeof_simple_pointer(pnext);
85             size += vn_sizeof_VkStructureType(&pnext->sType);
86             size += vn_sizeof_VkFenceCreateInfo_pnext(pnext->pNext);
87             size += vn_sizeof_VkExportFenceCreateInfo_self((const VkExportFenceCreateInfo *)pnext);
88             return size;
89         default:
90             /* ignore unknown/unsupported struct */
91             break;
92         }
93         pnext = pnext->pNext;
94     }
95 
96     return vn_sizeof_simple_pointer(NULL);
97 }
98 
99 static inline size_t
vn_sizeof_VkFenceCreateInfo_self(const VkFenceCreateInfo * val)100 vn_sizeof_VkFenceCreateInfo_self(const VkFenceCreateInfo *val)
101 {
102     size_t size = 0;
103     /* skip val->{sType,pNext} */
104     size += vn_sizeof_VkFlags(&val->flags);
105     return size;
106 }
107 
108 static inline size_t
vn_sizeof_VkFenceCreateInfo(const VkFenceCreateInfo * val)109 vn_sizeof_VkFenceCreateInfo(const VkFenceCreateInfo *val)
110 {
111     size_t size = 0;
112 
113     size += vn_sizeof_VkStructureType(&val->sType);
114     size += vn_sizeof_VkFenceCreateInfo_pnext(val->pNext);
115     size += vn_sizeof_VkFenceCreateInfo_self(val);
116 
117     return size;
118 }
119 
120 static inline void
vn_encode_VkFenceCreateInfo_pnext(struct vn_cs_encoder * enc,const void * val)121 vn_encode_VkFenceCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
122 {
123     const VkBaseInStructure *pnext = val;
124 
125     while (pnext) {
126         switch ((int32_t)pnext->sType) {
127         case VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO:
128             vn_encode_simple_pointer(enc, pnext);
129             vn_encode_VkStructureType(enc, &pnext->sType);
130             vn_encode_VkFenceCreateInfo_pnext(enc, pnext->pNext);
131             vn_encode_VkExportFenceCreateInfo_self(enc, (const VkExportFenceCreateInfo *)pnext);
132             return;
133         default:
134             /* ignore unknown/unsupported struct */
135             break;
136         }
137         pnext = pnext->pNext;
138     }
139 
140     vn_encode_simple_pointer(enc, NULL);
141 }
142 
143 static inline void
vn_encode_VkFenceCreateInfo_self(struct vn_cs_encoder * enc,const VkFenceCreateInfo * val)144 vn_encode_VkFenceCreateInfo_self(struct vn_cs_encoder *enc, const VkFenceCreateInfo *val)
145 {
146     /* skip val->{sType,pNext} */
147     vn_encode_VkFlags(enc, &val->flags);
148 }
149 
150 static inline void
vn_encode_VkFenceCreateInfo(struct vn_cs_encoder * enc,const VkFenceCreateInfo * val)151 vn_encode_VkFenceCreateInfo(struct vn_cs_encoder *enc, const VkFenceCreateInfo *val)
152 {
153     assert(val->sType == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
154     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO });
155     vn_encode_VkFenceCreateInfo_pnext(enc, val->pNext);
156     vn_encode_VkFenceCreateInfo_self(enc, val);
157 }
158 
vn_sizeof_vkCreateFence(VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)159 static inline size_t vn_sizeof_vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
160 {
161     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateFence_EXT;
162     const VkFlags cmd_flags = 0;
163     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
164 
165     cmd_size += vn_sizeof_VkDevice(&device);
166     cmd_size += vn_sizeof_simple_pointer(pCreateInfo);
167     if (pCreateInfo)
168         cmd_size += vn_sizeof_VkFenceCreateInfo(pCreateInfo);
169     cmd_size += vn_sizeof_simple_pointer(pAllocator);
170     if (pAllocator)
171         assert(false);
172     cmd_size += vn_sizeof_simple_pointer(pFence);
173     if (pFence)
174         cmd_size += vn_sizeof_VkFence(pFence);
175 
176     return cmd_size;
177 }
178 
vn_encode_vkCreateFence(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)179 static inline void vn_encode_vkCreateFence(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
180 {
181     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateFence_EXT;
182 
183     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
184     vn_encode_VkFlags(enc, &cmd_flags);
185 
186     vn_encode_VkDevice(enc, &device);
187     if (vn_encode_simple_pointer(enc, pCreateInfo))
188         vn_encode_VkFenceCreateInfo(enc, pCreateInfo);
189     if (vn_encode_simple_pointer(enc, pAllocator))
190         assert(false);
191     if (vn_encode_simple_pointer(enc, pFence))
192         vn_encode_VkFence(enc, pFence);
193 }
194 
vn_sizeof_vkCreateFence_reply(VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)195 static inline size_t vn_sizeof_vkCreateFence_reply(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
196 {
197     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateFence_EXT;
198     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
199 
200     VkResult ret;
201     cmd_size += vn_sizeof_VkResult(&ret);
202     /* skip device */
203     /* skip pCreateInfo */
204     /* skip pAllocator */
205     cmd_size += vn_sizeof_simple_pointer(pFence);
206     if (pFence)
207         cmd_size += vn_sizeof_VkFence(pFence);
208 
209     return cmd_size;
210 }
211 
vn_decode_vkCreateFence_reply(struct vn_cs_decoder * dec,VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)212 static inline VkResult vn_decode_vkCreateFence_reply(struct vn_cs_decoder *dec, VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
213 {
214     VkCommandTypeEXT command_type;
215     vn_decode_VkCommandTypeEXT(dec, &command_type);
216     assert(command_type == VK_COMMAND_TYPE_vkCreateFence_EXT);
217 
218     VkResult ret;
219     vn_decode_VkResult(dec, &ret);
220     /* skip device */
221     /* skip pCreateInfo */
222     /* skip pAllocator */
223     if (vn_decode_simple_pointer(dec)) {
224         vn_decode_VkFence(dec, pFence);
225     } else {
226         pFence = NULL;
227     }
228 
229     return ret;
230 }
231 
vn_sizeof_vkDestroyFence(VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)232 static inline size_t vn_sizeof_vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
233 {
234     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyFence_EXT;
235     const VkFlags cmd_flags = 0;
236     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
237 
238     cmd_size += vn_sizeof_VkDevice(&device);
239     cmd_size += vn_sizeof_VkFence(&fence);
240     cmd_size += vn_sizeof_simple_pointer(pAllocator);
241     if (pAllocator)
242         assert(false);
243 
244     return cmd_size;
245 }
246 
vn_encode_vkDestroyFence(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)247 static inline void vn_encode_vkDestroyFence(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
248 {
249     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyFence_EXT;
250 
251     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
252     vn_encode_VkFlags(enc, &cmd_flags);
253 
254     vn_encode_VkDevice(enc, &device);
255     vn_encode_VkFence(enc, &fence);
256     if (vn_encode_simple_pointer(enc, pAllocator))
257         assert(false);
258 }
259 
vn_sizeof_vkDestroyFence_reply(VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)260 static inline size_t vn_sizeof_vkDestroyFence_reply(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
261 {
262     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroyFence_EXT;
263     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
264 
265     /* skip device */
266     /* skip fence */
267     /* skip pAllocator */
268 
269     return cmd_size;
270 }
271 
vn_decode_vkDestroyFence_reply(struct vn_cs_decoder * dec,VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)272 static inline void vn_decode_vkDestroyFence_reply(struct vn_cs_decoder *dec, VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
273 {
274     VkCommandTypeEXT command_type;
275     vn_decode_VkCommandTypeEXT(dec, &command_type);
276     assert(command_type == VK_COMMAND_TYPE_vkDestroyFence_EXT);
277 
278     /* skip device */
279     /* skip fence */
280     /* skip pAllocator */
281 }
282 
vn_sizeof_vkResetFences(VkDevice device,uint32_t fenceCount,const VkFence * pFences)283 static inline size_t vn_sizeof_vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences)
284 {
285     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkResetFences_EXT;
286     const VkFlags cmd_flags = 0;
287     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
288 
289     cmd_size += vn_sizeof_VkDevice(&device);
290     cmd_size += vn_sizeof_uint32_t(&fenceCount);
291     if (pFences) {
292         cmd_size += vn_sizeof_array_size(fenceCount);
293         for (uint32_t i = 0; i < fenceCount; i++)
294             cmd_size += vn_sizeof_VkFence(&pFences[i]);
295     } else {
296         cmd_size += vn_sizeof_array_size(0);
297     }
298 
299     return cmd_size;
300 }
301 
vn_encode_vkResetFences(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,uint32_t fenceCount,const VkFence * pFences)302 static inline void vn_encode_vkResetFences(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, uint32_t fenceCount, const VkFence* pFences)
303 {
304     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkResetFences_EXT;
305 
306     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
307     vn_encode_VkFlags(enc, &cmd_flags);
308 
309     vn_encode_VkDevice(enc, &device);
310     vn_encode_uint32_t(enc, &fenceCount);
311     if (pFences) {
312         vn_encode_array_size(enc, fenceCount);
313         for (uint32_t i = 0; i < fenceCount; i++)
314             vn_encode_VkFence(enc, &pFences[i]);
315     } else {
316         vn_encode_array_size(enc, 0);
317     }
318 }
319 
vn_sizeof_vkResetFences_reply(VkDevice device,uint32_t fenceCount,const VkFence * pFences)320 static inline size_t vn_sizeof_vkResetFences_reply(VkDevice device, uint32_t fenceCount, const VkFence* pFences)
321 {
322     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkResetFences_EXT;
323     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
324 
325     VkResult ret;
326     cmd_size += vn_sizeof_VkResult(&ret);
327     /* skip device */
328     /* skip fenceCount */
329     /* skip pFences */
330 
331     return cmd_size;
332 }
333 
vn_decode_vkResetFences_reply(struct vn_cs_decoder * dec,VkDevice device,uint32_t fenceCount,const VkFence * pFences)334 static inline VkResult vn_decode_vkResetFences_reply(struct vn_cs_decoder *dec, VkDevice device, uint32_t fenceCount, const VkFence* pFences)
335 {
336     VkCommandTypeEXT command_type;
337     vn_decode_VkCommandTypeEXT(dec, &command_type);
338     assert(command_type == VK_COMMAND_TYPE_vkResetFences_EXT);
339 
340     VkResult ret;
341     vn_decode_VkResult(dec, &ret);
342     /* skip device */
343     /* skip fenceCount */
344     /* skip pFences */
345 
346     return ret;
347 }
348 
vn_sizeof_vkGetFenceStatus(VkDevice device,VkFence fence)349 static inline size_t vn_sizeof_vkGetFenceStatus(VkDevice device, VkFence fence)
350 {
351     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkGetFenceStatus_EXT;
352     const VkFlags cmd_flags = 0;
353     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
354 
355     cmd_size += vn_sizeof_VkDevice(&device);
356     cmd_size += vn_sizeof_VkFence(&fence);
357 
358     return cmd_size;
359 }
360 
vn_encode_vkGetFenceStatus(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,VkFence fence)361 static inline void vn_encode_vkGetFenceStatus(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkFence fence)
362 {
363     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkGetFenceStatus_EXT;
364 
365     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
366     vn_encode_VkFlags(enc, &cmd_flags);
367 
368     vn_encode_VkDevice(enc, &device);
369     vn_encode_VkFence(enc, &fence);
370 }
371 
vn_sizeof_vkGetFenceStatus_reply(VkDevice device,VkFence fence)372 static inline size_t vn_sizeof_vkGetFenceStatus_reply(VkDevice device, VkFence fence)
373 {
374     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkGetFenceStatus_EXT;
375     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
376 
377     VkResult ret;
378     cmd_size += vn_sizeof_VkResult(&ret);
379     /* skip device */
380     /* skip fence */
381 
382     return cmd_size;
383 }
384 
vn_decode_vkGetFenceStatus_reply(struct vn_cs_decoder * dec,VkDevice device,VkFence fence)385 static inline VkResult vn_decode_vkGetFenceStatus_reply(struct vn_cs_decoder *dec, VkDevice device, VkFence fence)
386 {
387     VkCommandTypeEXT command_type;
388     vn_decode_VkCommandTypeEXT(dec, &command_type);
389     assert(command_type == VK_COMMAND_TYPE_vkGetFenceStatus_EXT);
390 
391     VkResult ret;
392     vn_decode_VkResult(dec, &ret);
393     /* skip device */
394     /* skip fence */
395 
396     return ret;
397 }
398 
vn_sizeof_vkWaitForFences(VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)399 static inline size_t vn_sizeof_vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
400 {
401     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkWaitForFences_EXT;
402     const VkFlags cmd_flags = 0;
403     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
404 
405     cmd_size += vn_sizeof_VkDevice(&device);
406     cmd_size += vn_sizeof_uint32_t(&fenceCount);
407     if (pFences) {
408         cmd_size += vn_sizeof_array_size(fenceCount);
409         for (uint32_t i = 0; i < fenceCount; i++)
410             cmd_size += vn_sizeof_VkFence(&pFences[i]);
411     } else {
412         cmd_size += vn_sizeof_array_size(0);
413     }
414     cmd_size += vn_sizeof_VkBool32(&waitAll);
415     cmd_size += vn_sizeof_uint64_t(&timeout);
416 
417     return cmd_size;
418 }
419 
vn_encode_vkWaitForFences(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)420 static inline void vn_encode_vkWaitForFences(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
421 {
422     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkWaitForFences_EXT;
423 
424     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
425     vn_encode_VkFlags(enc, &cmd_flags);
426 
427     vn_encode_VkDevice(enc, &device);
428     vn_encode_uint32_t(enc, &fenceCount);
429     if (pFences) {
430         vn_encode_array_size(enc, fenceCount);
431         for (uint32_t i = 0; i < fenceCount; i++)
432             vn_encode_VkFence(enc, &pFences[i]);
433     } else {
434         vn_encode_array_size(enc, 0);
435     }
436     vn_encode_VkBool32(enc, &waitAll);
437     vn_encode_uint64_t(enc, &timeout);
438 }
439 
vn_sizeof_vkWaitForFences_reply(VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)440 static inline size_t vn_sizeof_vkWaitForFences_reply(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
441 {
442     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkWaitForFences_EXT;
443     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
444 
445     VkResult ret;
446     cmd_size += vn_sizeof_VkResult(&ret);
447     /* skip device */
448     /* skip fenceCount */
449     /* skip pFences */
450     /* skip waitAll */
451     /* skip timeout */
452 
453     return cmd_size;
454 }
455 
vn_decode_vkWaitForFences_reply(struct vn_cs_decoder * dec,VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)456 static inline VkResult vn_decode_vkWaitForFences_reply(struct vn_cs_decoder *dec, VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
457 {
458     VkCommandTypeEXT command_type;
459     vn_decode_VkCommandTypeEXT(dec, &command_type);
460     assert(command_type == VK_COMMAND_TYPE_vkWaitForFences_EXT);
461 
462     VkResult ret;
463     vn_decode_VkResult(dec, &ret);
464     /* skip device */
465     /* skip fenceCount */
466     /* skip pFences */
467     /* skip waitAll */
468     /* skip timeout */
469 
470     return ret;
471 }
472 
vn_submit_vkCreateFence(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence,struct vn_instance_submit_command * submit)473 static inline void vn_submit_vkCreateFence(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence, struct vn_instance_submit_command *submit)
474 {
475     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
476     void *cmd_data = local_cmd_data;
477     size_t cmd_size = vn_sizeof_vkCreateFence(device, pCreateInfo, pAllocator, pFence);
478     if (cmd_size > sizeof(local_cmd_data)) {
479         cmd_data = malloc(cmd_size);
480         if (!cmd_data)
481             cmd_size = 0;
482     }
483     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateFence_reply(device, pCreateInfo, pAllocator, pFence) : 0;
484 
485     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
486     if (cmd_size) {
487         vn_encode_vkCreateFence(enc, cmd_flags, device, pCreateInfo, pAllocator, pFence);
488         vn_instance_submit_command(vn_instance, submit);
489         if (cmd_data != local_cmd_data)
490             free(cmd_data);
491     }
492 }
493 
vn_submit_vkDestroyFence(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator,struct vn_instance_submit_command * submit)494 static inline void vn_submit_vkDestroyFence(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit)
495 {
496     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
497     void *cmd_data = local_cmd_data;
498     size_t cmd_size = vn_sizeof_vkDestroyFence(device, fence, pAllocator);
499     if (cmd_size > sizeof(local_cmd_data)) {
500         cmd_data = malloc(cmd_size);
501         if (!cmd_data)
502             cmd_size = 0;
503     }
504     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroyFence_reply(device, fence, pAllocator) : 0;
505 
506     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
507     if (cmd_size) {
508         vn_encode_vkDestroyFence(enc, cmd_flags, device, fence, pAllocator);
509         vn_instance_submit_command(vn_instance, submit);
510         if (cmd_data != local_cmd_data)
511             free(cmd_data);
512     }
513 }
514 
vn_submit_vkResetFences(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,uint32_t fenceCount,const VkFence * pFences,struct vn_instance_submit_command * submit)515 static inline void vn_submit_vkResetFences(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, uint32_t fenceCount, const VkFence* pFences, struct vn_instance_submit_command *submit)
516 {
517     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
518     void *cmd_data = local_cmd_data;
519     size_t cmd_size = vn_sizeof_vkResetFences(device, fenceCount, pFences);
520     if (cmd_size > sizeof(local_cmd_data)) {
521         cmd_data = malloc(cmd_size);
522         if (!cmd_data)
523             cmd_size = 0;
524     }
525     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkResetFences_reply(device, fenceCount, pFences) : 0;
526 
527     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
528     if (cmd_size) {
529         vn_encode_vkResetFences(enc, cmd_flags, device, fenceCount, pFences);
530         vn_instance_submit_command(vn_instance, submit);
531         if (cmd_data != local_cmd_data)
532             free(cmd_data);
533     }
534 }
535 
vn_submit_vkGetFenceStatus(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,VkFence fence,struct vn_instance_submit_command * submit)536 static inline void vn_submit_vkGetFenceStatus(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkFence fence, struct vn_instance_submit_command *submit)
537 {
538     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
539     void *cmd_data = local_cmd_data;
540     size_t cmd_size = vn_sizeof_vkGetFenceStatus(device, fence);
541     if (cmd_size > sizeof(local_cmd_data)) {
542         cmd_data = malloc(cmd_size);
543         if (!cmd_data)
544             cmd_size = 0;
545     }
546     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkGetFenceStatus_reply(device, fence) : 0;
547 
548     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
549     if (cmd_size) {
550         vn_encode_vkGetFenceStatus(enc, cmd_flags, device, fence);
551         vn_instance_submit_command(vn_instance, submit);
552         if (cmd_data != local_cmd_data)
553             free(cmd_data);
554     }
555 }
556 
vn_submit_vkWaitForFences(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout,struct vn_instance_submit_command * submit)557 static inline void vn_submit_vkWaitForFences(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout, struct vn_instance_submit_command *submit)
558 {
559     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
560     void *cmd_data = local_cmd_data;
561     size_t cmd_size = vn_sizeof_vkWaitForFences(device, fenceCount, pFences, waitAll, timeout);
562     if (cmd_size > sizeof(local_cmd_data)) {
563         cmd_data = malloc(cmd_size);
564         if (!cmd_data)
565             cmd_size = 0;
566     }
567     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkWaitForFences_reply(device, fenceCount, pFences, waitAll, timeout) : 0;
568 
569     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
570     if (cmd_size) {
571         vn_encode_vkWaitForFences(enc, cmd_flags, device, fenceCount, pFences, waitAll, timeout);
572         vn_instance_submit_command(vn_instance, submit);
573         if (cmd_data != local_cmd_data)
574             free(cmd_data);
575     }
576 }
577 
vn_call_vkCreateFence(struct vn_instance * vn_instance,VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)578 static inline VkResult vn_call_vkCreateFence(struct vn_instance *vn_instance, VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
579 {
580     VN_TRACE_FUNC();
581 
582     struct vn_instance_submit_command submit;
583     vn_submit_vkCreateFence(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pFence, &submit);
584     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
585     if (dec) {
586         const VkResult ret = vn_decode_vkCreateFence_reply(dec, device, pCreateInfo, pAllocator, pFence);
587         vn_instance_free_command_reply(vn_instance, &submit);
588         return ret;
589     } else {
590         return VK_ERROR_OUT_OF_HOST_MEMORY;
591     }
592 }
593 
vn_async_vkCreateFence(struct vn_instance * vn_instance,VkDevice device,const VkFenceCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkFence * pFence)594 static inline void vn_async_vkCreateFence(struct vn_instance *vn_instance, VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
595 {
596     struct vn_instance_submit_command submit;
597     vn_submit_vkCreateFence(vn_instance, 0, device, pCreateInfo, pAllocator, pFence, &submit);
598 }
599 
vn_call_vkDestroyFence(struct vn_instance * vn_instance,VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)600 static inline void vn_call_vkDestroyFence(struct vn_instance *vn_instance, VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
601 {
602     VN_TRACE_FUNC();
603 
604     struct vn_instance_submit_command submit;
605     vn_submit_vkDestroyFence(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, fence, pAllocator, &submit);
606     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
607     if (dec) {
608         vn_decode_vkDestroyFence_reply(dec, device, fence, pAllocator);
609         vn_instance_free_command_reply(vn_instance, &submit);
610     }
611 }
612 
vn_async_vkDestroyFence(struct vn_instance * vn_instance,VkDevice device,VkFence fence,const VkAllocationCallbacks * pAllocator)613 static inline void vn_async_vkDestroyFence(struct vn_instance *vn_instance, VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
614 {
615     struct vn_instance_submit_command submit;
616     vn_submit_vkDestroyFence(vn_instance, 0, device, fence, pAllocator, &submit);
617 }
618 
vn_call_vkResetFences(struct vn_instance * vn_instance,VkDevice device,uint32_t fenceCount,const VkFence * pFences)619 static inline VkResult vn_call_vkResetFences(struct vn_instance *vn_instance, VkDevice device, uint32_t fenceCount, const VkFence* pFences)
620 {
621     VN_TRACE_FUNC();
622 
623     struct vn_instance_submit_command submit;
624     vn_submit_vkResetFences(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, fenceCount, pFences, &submit);
625     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
626     if (dec) {
627         const VkResult ret = vn_decode_vkResetFences_reply(dec, device, fenceCount, pFences);
628         vn_instance_free_command_reply(vn_instance, &submit);
629         return ret;
630     } else {
631         return VK_ERROR_OUT_OF_HOST_MEMORY;
632     }
633 }
634 
vn_async_vkResetFences(struct vn_instance * vn_instance,VkDevice device,uint32_t fenceCount,const VkFence * pFences)635 static inline void vn_async_vkResetFences(struct vn_instance *vn_instance, VkDevice device, uint32_t fenceCount, const VkFence* pFences)
636 {
637     struct vn_instance_submit_command submit;
638     vn_submit_vkResetFences(vn_instance, 0, device, fenceCount, pFences, &submit);
639 }
640 
vn_call_vkGetFenceStatus(struct vn_instance * vn_instance,VkDevice device,VkFence fence)641 static inline VkResult vn_call_vkGetFenceStatus(struct vn_instance *vn_instance, VkDevice device, VkFence fence)
642 {
643     VN_TRACE_FUNC();
644 
645     struct vn_instance_submit_command submit;
646     vn_submit_vkGetFenceStatus(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, fence, &submit);
647     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
648     if (dec) {
649         const VkResult ret = vn_decode_vkGetFenceStatus_reply(dec, device, fence);
650         vn_instance_free_command_reply(vn_instance, &submit);
651         return ret;
652     } else {
653         return VK_ERROR_OUT_OF_HOST_MEMORY;
654     }
655 }
656 
vn_async_vkGetFenceStatus(struct vn_instance * vn_instance,VkDevice device,VkFence fence)657 static inline void vn_async_vkGetFenceStatus(struct vn_instance *vn_instance, VkDevice device, VkFence fence)
658 {
659     struct vn_instance_submit_command submit;
660     vn_submit_vkGetFenceStatus(vn_instance, 0, device, fence, &submit);
661 }
662 
vn_call_vkWaitForFences(struct vn_instance * vn_instance,VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)663 static inline VkResult vn_call_vkWaitForFences(struct vn_instance *vn_instance, VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
664 {
665     VN_TRACE_FUNC();
666 
667     struct vn_instance_submit_command submit;
668     vn_submit_vkWaitForFences(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, fenceCount, pFences, waitAll, timeout, &submit);
669     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
670     if (dec) {
671         const VkResult ret = vn_decode_vkWaitForFences_reply(dec, device, fenceCount, pFences, waitAll, timeout);
672         vn_instance_free_command_reply(vn_instance, &submit);
673         return ret;
674     } else {
675         return VK_ERROR_OUT_OF_HOST_MEMORY;
676     }
677 }
678 
vn_async_vkWaitForFences(struct vn_instance * vn_instance,VkDevice device,uint32_t fenceCount,const VkFence * pFences,VkBool32 waitAll,uint64_t timeout)679 static inline void vn_async_vkWaitForFences(struct vn_instance *vn_instance, VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
680 {
681     struct vn_instance_submit_command submit;
682     vn_submit_vkWaitForFences(vn_instance, 0, device, fenceCount, pFences, waitAll, timeout, &submit);
683 }
684 
685 #endif /* VN_PROTOCOL_DRIVER_FENCE_H */
686