• 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_FENCE_H
9 #define VN_PROTOCOL_RENDERER_FENCE_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 VkExportFenceCreateInfo chain */
18 
19 static inline void *
vn_decode_VkExportFenceCreateInfo_pnext_temp(struct vn_cs_decoder * dec)20 vn_decode_VkExportFenceCreateInfo_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_VkExportFenceCreateInfo_self_temp(struct vn_cs_decoder * dec,VkExportFenceCreateInfo * val)29 vn_decode_VkExportFenceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkExportFenceCreateInfo *val)
30 {
31     /* skip val->{sType,pNext} */
32     vn_decode_VkFlags(dec, &val->handleTypes);
33 }
34 
35 static inline void
vn_decode_VkExportFenceCreateInfo_temp(struct vn_cs_decoder * dec,VkExportFenceCreateInfo * val)36 vn_decode_VkExportFenceCreateInfo_temp(struct vn_cs_decoder *dec, VkExportFenceCreateInfo *val)
37 {
38     VkStructureType stype;
39     vn_decode_VkStructureType(dec, &stype);
40     if (stype != VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO)
41         vn_cs_decoder_set_fatal(dec);
42 
43     val->sType = stype;
44     val->pNext = vn_decode_VkExportFenceCreateInfo_pnext_temp(dec);
45     vn_decode_VkExportFenceCreateInfo_self_temp(dec, val);
46 }
47 
48 static inline void
vn_replace_VkExportFenceCreateInfo_handle_self(VkExportFenceCreateInfo * val)49 vn_replace_VkExportFenceCreateInfo_handle_self(VkExportFenceCreateInfo *val)
50 {
51     /* skip val->sType */
52     /* skip val->pNext */
53     /* skip val->handleTypes */
54 }
55 
56 static inline void
vn_replace_VkExportFenceCreateInfo_handle(VkExportFenceCreateInfo * val)57 vn_replace_VkExportFenceCreateInfo_handle(VkExportFenceCreateInfo *val)
58 {
59     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
60 
61     do {
62         switch ((int32_t)pnext->sType) {
63         case VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO:
64             vn_replace_VkExportFenceCreateInfo_handle_self((VkExportFenceCreateInfo *)pnext);
65             break;
66         default:
67             /* ignore unknown/unsupported struct */
68             break;
69         }
70         pnext = pnext->pNext;
71     } while (pnext);
72 }
73 
74 /* struct VkFenceCreateInfo chain */
75 
76 static inline void *
vn_decode_VkFenceCreateInfo_pnext_temp(struct vn_cs_decoder * dec)77 vn_decode_VkFenceCreateInfo_pnext_temp(struct vn_cs_decoder *dec)
78 {
79     VkBaseOutStructure *pnext;
80     VkStructureType stype;
81 
82     if (!vn_decode_simple_pointer(dec))
83         return NULL;
84 
85     vn_decode_VkStructureType(dec, &stype);
86     switch ((int32_t)stype) {
87     case VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO:
88         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkExportFenceCreateInfo));
89         if (pnext) {
90             pnext->sType = stype;
91             pnext->pNext = vn_decode_VkFenceCreateInfo_pnext_temp(dec);
92             vn_decode_VkExportFenceCreateInfo_self_temp(dec, (VkExportFenceCreateInfo *)pnext);
93         }
94         break;
95     default:
96         /* unexpected struct */
97         pnext = NULL;
98         vn_cs_decoder_set_fatal(dec);
99         break;
100     }
101 
102     return pnext;
103 }
104 
105 static inline void
vn_decode_VkFenceCreateInfo_self_temp(struct vn_cs_decoder * dec,VkFenceCreateInfo * val)106 vn_decode_VkFenceCreateInfo_self_temp(struct vn_cs_decoder *dec, VkFenceCreateInfo *val)
107 {
108     /* skip val->{sType,pNext} */
109     vn_decode_VkFlags(dec, &val->flags);
110 }
111 
112 static inline void
vn_decode_VkFenceCreateInfo_temp(struct vn_cs_decoder * dec,VkFenceCreateInfo * val)113 vn_decode_VkFenceCreateInfo_temp(struct vn_cs_decoder *dec, VkFenceCreateInfo *val)
114 {
115     VkStructureType stype;
116     vn_decode_VkStructureType(dec, &stype);
117     if (stype != VK_STRUCTURE_TYPE_FENCE_CREATE_INFO)
118         vn_cs_decoder_set_fatal(dec);
119 
120     val->sType = stype;
121     val->pNext = vn_decode_VkFenceCreateInfo_pnext_temp(dec);
122     vn_decode_VkFenceCreateInfo_self_temp(dec, val);
123 }
124 
125 static inline void
vn_replace_VkFenceCreateInfo_handle_self(VkFenceCreateInfo * val)126 vn_replace_VkFenceCreateInfo_handle_self(VkFenceCreateInfo *val)
127 {
128     /* skip val->sType */
129     /* skip val->pNext */
130     /* skip val->flags */
131 }
132 
133 static inline void
vn_replace_VkFenceCreateInfo_handle(VkFenceCreateInfo * val)134 vn_replace_VkFenceCreateInfo_handle(VkFenceCreateInfo *val)
135 {
136     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
137 
138     do {
139         switch ((int32_t)pnext->sType) {
140         case VK_STRUCTURE_TYPE_FENCE_CREATE_INFO:
141             vn_replace_VkFenceCreateInfo_handle_self((VkFenceCreateInfo *)pnext);
142             break;
143         case VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO:
144             vn_replace_VkExportFenceCreateInfo_handle_self((VkExportFenceCreateInfo *)pnext);
145             break;
146         default:
147             /* ignore unknown/unsupported struct */
148             break;
149         }
150         pnext = pnext->pNext;
151     } while (pnext);
152 }
153 
vn_decode_vkCreateFence_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkCreateFence * args)154 static inline void vn_decode_vkCreateFence_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkCreateFence *args)
155 {
156     vn_decode_VkDevice_lookup(dec, &args->device);
157     if (vn_decode_simple_pointer(dec)) {
158         args->pCreateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfo));
159         if (!args->pCreateInfo) return;
160         vn_decode_VkFenceCreateInfo_temp(dec, (VkFenceCreateInfo *)args->pCreateInfo);
161     } else {
162         args->pCreateInfo = NULL;
163         vn_cs_decoder_set_fatal(dec);
164     }
165     if (vn_decode_simple_pointer(dec)) {
166         vn_cs_decoder_set_fatal(dec);
167     } else {
168         args->pAllocator = NULL;
169     }
170     if (vn_decode_simple_pointer(dec)) {
171         args->pFence = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFence));
172         if (!args->pFence) return;
173         vn_decode_VkFence(dec, args->pFence);
174     } else {
175         args->pFence = NULL;
176         vn_cs_decoder_set_fatal(dec);
177     }
178 }
179 
vn_replace_vkCreateFence_args_handle(struct vn_command_vkCreateFence * args)180 static inline void vn_replace_vkCreateFence_args_handle(struct vn_command_vkCreateFence *args)
181 {
182     vn_replace_VkDevice_handle(&args->device);
183     if (args->pCreateInfo)
184         vn_replace_VkFenceCreateInfo_handle((VkFenceCreateInfo *)args->pCreateInfo);
185     /* skip args->pAllocator */
186     /* skip args->pFence */
187 }
188 
vn_encode_vkCreateFence_reply(struct vn_cs_encoder * enc,const struct vn_command_vkCreateFence * args)189 static inline void vn_encode_vkCreateFence_reply(struct vn_cs_encoder *enc, const struct vn_command_vkCreateFence *args)
190 {
191     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkCreateFence_EXT});
192 
193     vn_encode_VkResult(enc, &args->ret);
194     /* skip args->device */
195     /* skip args->pCreateInfo */
196     /* skip args->pAllocator */
197     if (vn_encode_simple_pointer(enc, args->pFence))
198         vn_encode_VkFence(enc, args->pFence);
199 }
200 
vn_decode_vkDestroyFence_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkDestroyFence * args)201 static inline void vn_decode_vkDestroyFence_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkDestroyFence *args)
202 {
203     vn_decode_VkDevice_lookup(dec, &args->device);
204     vn_decode_VkFence_lookup(dec, &args->fence);
205     if (vn_decode_simple_pointer(dec)) {
206         vn_cs_decoder_set_fatal(dec);
207     } else {
208         args->pAllocator = NULL;
209     }
210 }
211 
vn_replace_vkDestroyFence_args_handle(struct vn_command_vkDestroyFence * args)212 static inline void vn_replace_vkDestroyFence_args_handle(struct vn_command_vkDestroyFence *args)
213 {
214     vn_replace_VkDevice_handle(&args->device);
215     vn_replace_VkFence_handle(&args->fence);
216     /* skip args->pAllocator */
217 }
218 
vn_encode_vkDestroyFence_reply(struct vn_cs_encoder * enc,const struct vn_command_vkDestroyFence * args)219 static inline void vn_encode_vkDestroyFence_reply(struct vn_cs_encoder *enc, const struct vn_command_vkDestroyFence *args)
220 {
221     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkDestroyFence_EXT});
222 
223     /* skip args->device */
224     /* skip args->fence */
225     /* skip args->pAllocator */
226 }
227 
vn_decode_vkResetFences_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkResetFences * args)228 static inline void vn_decode_vkResetFences_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkResetFences *args)
229 {
230     vn_decode_VkDevice_lookup(dec, &args->device);
231     vn_decode_uint32_t(dec, &args->fenceCount);
232     if (vn_peek_array_size(dec)) {
233         const uint32_t iter_count = vn_decode_array_size(dec, args->fenceCount);
234         args->pFences = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFences) * iter_count);
235         if (!args->pFences) return;
236         for (uint32_t i = 0; i < iter_count; i++)
237             vn_decode_VkFence_lookup(dec, &((VkFence *)args->pFences)[i]);
238     } else {
239         vn_decode_array_size(dec, args->fenceCount);
240         args->pFences = NULL;
241     }
242 }
243 
vn_replace_vkResetFences_args_handle(struct vn_command_vkResetFences * args)244 static inline void vn_replace_vkResetFences_args_handle(struct vn_command_vkResetFences *args)
245 {
246     vn_replace_VkDevice_handle(&args->device);
247     /* skip args->fenceCount */
248     if (args->pFences) {
249        for (uint32_t i = 0; i < args->fenceCount; i++)
250             vn_replace_VkFence_handle(&((VkFence *)args->pFences)[i]);
251     }
252 }
253 
vn_encode_vkResetFences_reply(struct vn_cs_encoder * enc,const struct vn_command_vkResetFences * args)254 static inline void vn_encode_vkResetFences_reply(struct vn_cs_encoder *enc, const struct vn_command_vkResetFences *args)
255 {
256     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkResetFences_EXT});
257 
258     vn_encode_VkResult(enc, &args->ret);
259     /* skip args->device */
260     /* skip args->fenceCount */
261     /* skip args->pFences */
262 }
263 
vn_decode_vkGetFenceStatus_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkGetFenceStatus * args)264 static inline void vn_decode_vkGetFenceStatus_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkGetFenceStatus *args)
265 {
266     vn_decode_VkDevice_lookup(dec, &args->device);
267     vn_decode_VkFence_lookup(dec, &args->fence);
268 }
269 
vn_replace_vkGetFenceStatus_args_handle(struct vn_command_vkGetFenceStatus * args)270 static inline void vn_replace_vkGetFenceStatus_args_handle(struct vn_command_vkGetFenceStatus *args)
271 {
272     vn_replace_VkDevice_handle(&args->device);
273     vn_replace_VkFence_handle(&args->fence);
274 }
275 
vn_encode_vkGetFenceStatus_reply(struct vn_cs_encoder * enc,const struct vn_command_vkGetFenceStatus * args)276 static inline void vn_encode_vkGetFenceStatus_reply(struct vn_cs_encoder *enc, const struct vn_command_vkGetFenceStatus *args)
277 {
278     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkGetFenceStatus_EXT});
279 
280     vn_encode_VkResult(enc, &args->ret);
281     /* skip args->device */
282     /* skip args->fence */
283 }
284 
vn_decode_vkWaitForFences_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkWaitForFences * args)285 static inline void vn_decode_vkWaitForFences_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkWaitForFences *args)
286 {
287     vn_decode_VkDevice_lookup(dec, &args->device);
288     vn_decode_uint32_t(dec, &args->fenceCount);
289     if (vn_peek_array_size(dec)) {
290         const uint32_t iter_count = vn_decode_array_size(dec, args->fenceCount);
291         args->pFences = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pFences) * iter_count);
292         if (!args->pFences) return;
293         for (uint32_t i = 0; i < iter_count; i++)
294             vn_decode_VkFence_lookup(dec, &((VkFence *)args->pFences)[i]);
295     } else {
296         vn_decode_array_size(dec, args->fenceCount);
297         args->pFences = NULL;
298     }
299     vn_decode_VkBool32(dec, &args->waitAll);
300     vn_decode_uint64_t(dec, &args->timeout);
301 }
302 
vn_replace_vkWaitForFences_args_handle(struct vn_command_vkWaitForFences * args)303 static inline void vn_replace_vkWaitForFences_args_handle(struct vn_command_vkWaitForFences *args)
304 {
305     vn_replace_VkDevice_handle(&args->device);
306     /* skip args->fenceCount */
307     if (args->pFences) {
308        for (uint32_t i = 0; i < args->fenceCount; i++)
309             vn_replace_VkFence_handle(&((VkFence *)args->pFences)[i]);
310     }
311     /* skip args->waitAll */
312     /* skip args->timeout */
313 }
314 
vn_encode_vkWaitForFences_reply(struct vn_cs_encoder * enc,const struct vn_command_vkWaitForFences * args)315 static inline void vn_encode_vkWaitForFences_reply(struct vn_cs_encoder *enc, const struct vn_command_vkWaitForFences *args)
316 {
317     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkWaitForFences_EXT});
318 
319     vn_encode_VkResult(enc, &args->ret);
320     /* skip args->device */
321     /* skip args->fenceCount */
322     /* skip args->pFences */
323     /* skip args->waitAll */
324     /* skip args->timeout */
325 }
326 
vn_dispatch_vkCreateFence(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)327 static inline void vn_dispatch_vkCreateFence(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
328 {
329     struct vn_command_vkCreateFence args;
330 
331     if (!ctx->dispatch_vkCreateFence) {
332         vn_cs_decoder_set_fatal(ctx->decoder);
333         return;
334     }
335 
336     vn_decode_vkCreateFence_args_temp(ctx->decoder, &args);
337     if (!args.device) {
338         vn_cs_decoder_set_fatal(ctx->decoder);
339         return;
340     }
341 
342     if (!vn_cs_decoder_get_fatal(ctx->decoder))
343         ctx->dispatch_vkCreateFence(ctx, &args);
344 
345 #ifdef DEBUG
346     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
347         vn_dispatch_debug_log(ctx, "vkCreateFence returned %d", args.ret);
348 #endif
349 
350     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
351        vn_encode_vkCreateFence_reply(ctx->encoder, &args);
352 
353     vn_cs_decoder_reset_temp_pool(ctx->decoder);
354 }
355 
vn_dispatch_vkDestroyFence(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)356 static inline void vn_dispatch_vkDestroyFence(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
357 {
358     struct vn_command_vkDestroyFence args;
359 
360     if (!ctx->dispatch_vkDestroyFence) {
361         vn_cs_decoder_set_fatal(ctx->decoder);
362         return;
363     }
364 
365     vn_decode_vkDestroyFence_args_temp(ctx->decoder, &args);
366     if (!args.device) {
367         vn_cs_decoder_set_fatal(ctx->decoder);
368         return;
369     }
370 
371     if (!vn_cs_decoder_get_fatal(ctx->decoder))
372         ctx->dispatch_vkDestroyFence(ctx, &args);
373 
374 
375     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
376        vn_encode_vkDestroyFence_reply(ctx->encoder, &args);
377 
378     vn_cs_decoder_reset_temp_pool(ctx->decoder);
379 }
380 
vn_dispatch_vkResetFences(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)381 static inline void vn_dispatch_vkResetFences(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
382 {
383     struct vn_command_vkResetFences args;
384 
385     if (!ctx->dispatch_vkResetFences) {
386         vn_cs_decoder_set_fatal(ctx->decoder);
387         return;
388     }
389 
390     vn_decode_vkResetFences_args_temp(ctx->decoder, &args);
391     if (!args.device) {
392         vn_cs_decoder_set_fatal(ctx->decoder);
393         return;
394     }
395 
396     if (!vn_cs_decoder_get_fatal(ctx->decoder))
397         ctx->dispatch_vkResetFences(ctx, &args);
398 
399 #ifdef DEBUG
400     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
401         vn_dispatch_debug_log(ctx, "vkResetFences returned %d", args.ret);
402 #endif
403 
404     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
405        vn_encode_vkResetFences_reply(ctx->encoder, &args);
406 
407     vn_cs_decoder_reset_temp_pool(ctx->decoder);
408 }
409 
vn_dispatch_vkGetFenceStatus(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)410 static inline void vn_dispatch_vkGetFenceStatus(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
411 {
412     struct vn_command_vkGetFenceStatus args;
413 
414     if (!ctx->dispatch_vkGetFenceStatus) {
415         vn_cs_decoder_set_fatal(ctx->decoder);
416         return;
417     }
418 
419     vn_decode_vkGetFenceStatus_args_temp(ctx->decoder, &args);
420     if (!args.device) {
421         vn_cs_decoder_set_fatal(ctx->decoder);
422         return;
423     }
424 
425     if (!vn_cs_decoder_get_fatal(ctx->decoder))
426         ctx->dispatch_vkGetFenceStatus(ctx, &args);
427 
428 #ifdef DEBUG
429     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
430         vn_dispatch_debug_log(ctx, "vkGetFenceStatus returned %d", args.ret);
431 #endif
432 
433     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
434        vn_encode_vkGetFenceStatus_reply(ctx->encoder, &args);
435 
436     vn_cs_decoder_reset_temp_pool(ctx->decoder);
437 }
438 
vn_dispatch_vkWaitForFences(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)439 static inline void vn_dispatch_vkWaitForFences(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
440 {
441     struct vn_command_vkWaitForFences args;
442 
443     if (!ctx->dispatch_vkWaitForFences) {
444         vn_cs_decoder_set_fatal(ctx->decoder);
445         return;
446     }
447 
448     vn_decode_vkWaitForFences_args_temp(ctx->decoder, &args);
449     if (!args.device) {
450         vn_cs_decoder_set_fatal(ctx->decoder);
451         return;
452     }
453 
454     if (!vn_cs_decoder_get_fatal(ctx->decoder))
455         ctx->dispatch_vkWaitForFences(ctx, &args);
456 
457 #ifdef DEBUG
458     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
459         vn_dispatch_debug_log(ctx, "vkWaitForFences returned %d", args.ret);
460 #endif
461 
462     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
463        vn_encode_vkWaitForFences_reply(ctx->encoder, &args);
464 
465     vn_cs_decoder_reset_temp_pool(ctx->decoder);
466 }
467 
468 #pragma GCC diagnostic pop
469 
470 #endif /* VN_PROTOCOL_RENDERER_FENCE_H */
471