1 /* This file is generated by venus-protocol.  See vn_protocol_renderer.h. */
2 
3 /*
4  * Copyright 2020 Google LLC
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef VN_PROTOCOL_RENDERER_DESCRIPTOR_POOL_H
9 #define VN_PROTOCOL_RENDERER_DESCRIPTOR_POOL_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 VkDescriptorPoolSize */
18 
19 static inline void
vn_decode_VkDescriptorPoolSize_temp(struct vn_cs_decoder * dec,VkDescriptorPoolSize * val)20 vn_decode_VkDescriptorPoolSize_temp(struct vn_cs_decoder *dec, VkDescriptorPoolSize *val)
21 {
22     vn_decode_VkDescriptorType(dec, &val->type);
23     vn_decode_uint32_t(dec, &val->descriptorCount);
24 }
25 
26 static inline void
vn_replace_VkDescriptorPoolSize_handle(VkDescriptorPoolSize * val)27 vn_replace_VkDescriptorPoolSize_handle(VkDescriptorPoolSize *val)
28 {
29     /* skip val->type */
30     /* skip val->descriptorCount */
31 }
32 
33 /* struct VkDescriptorPoolInlineUniformBlockCreateInfo chain */
34 
35 static inline void *
vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_pnext_temp(struct vn_cs_decoder * dec)36 vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_pnext_temp(struct vn_cs_decoder *dec)
37 {
38     /* no known/supported struct */
39     if (vn_decode_simple_pointer(dec))
40         vn_cs_decoder_set_fatal(dec);
41     return NULL;
42 }
43 
44 static inline void
vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_self_temp(struct vn_cs_decoder * dec,VkDescriptorPoolInlineUniformBlockCreateInfo * val)45 vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDescriptorPoolInlineUniformBlockCreateInfo *val)
46 {
47     /* skip val->{sType,pNext} */
48     vn_decode_uint32_t(dec, &val->maxInlineUniformBlockBindings);
49 }
50 
51 static inline void
vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_temp(struct vn_cs_decoder * dec,VkDescriptorPoolInlineUniformBlockCreateInfo * val)52 vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_temp(struct vn_cs_decoder *dec, VkDescriptorPoolInlineUniformBlockCreateInfo *val)
53 {
54     VkStructureType stype;
55     vn_decode_VkStructureType(dec, &stype);
56     if (stype != VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO)
57         vn_cs_decoder_set_fatal(dec);
58 
59     val->sType = stype;
60     val->pNext = vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_pnext_temp(dec);
61     vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_self_temp(dec, val);
62 }
63 
64 static inline void
vn_replace_VkDescriptorPoolInlineUniformBlockCreateInfo_handle_self(VkDescriptorPoolInlineUniformBlockCreateInfo * val)65 vn_replace_VkDescriptorPoolInlineUniformBlockCreateInfo_handle_self(VkDescriptorPoolInlineUniformBlockCreateInfo *val)
66 {
67     /* skip val->sType */
68     /* skip val->pNext */
69     /* skip val->maxInlineUniformBlockBindings */
70 }
71 
72 static inline void
vn_replace_VkDescriptorPoolInlineUniformBlockCreateInfo_handle(VkDescriptorPoolInlineUniformBlockCreateInfo * val)73 vn_replace_VkDescriptorPoolInlineUniformBlockCreateInfo_handle(VkDescriptorPoolInlineUniformBlockCreateInfo *val)
74 {
75     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
76 
77     do {
78         switch ((int32_t)pnext->sType) {
79         case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO:
80             vn_replace_VkDescriptorPoolInlineUniformBlockCreateInfo_handle_self((VkDescriptorPoolInlineUniformBlockCreateInfo *)pnext);
81             break;
82         default:
83             /* ignore unknown/unsupported struct */
84             break;
85         }
86         pnext = pnext->pNext;
87     } while (pnext);
88 }
89 
90 /* struct VkDescriptorPoolCreateInfo chain */
91 
92 static inline void *
vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(struct vn_cs_decoder * dec)93 vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(struct vn_cs_decoder *dec)
94 {
95     VkBaseOutStructure *pnext;
96     VkStructureType stype;
97 
98     if (!vn_decode_simple_pointer(dec))
99         return NULL;
100 
101     vn_decode_VkStructureType(dec, &stype);
102     switch ((int32_t)stype) {
103     case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO:
104         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkDescriptorPoolInlineUniformBlockCreateInfo));
105         if (pnext) {
106             pnext->sType = stype;
107             pnext->pNext = vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(dec);
108             vn_decode_VkDescriptorPoolInlineUniformBlockCreateInfo_self_temp(dec, (VkDescriptorPoolInlineUniformBlockCreateInfo *)pnext);
109         }
110         break;
111     case VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT:
112         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkMutableDescriptorTypeCreateInfoEXT));
113         if (pnext) {
114             pnext->sType = stype;
115             pnext->pNext = vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(dec);
116             vn_decode_VkMutableDescriptorTypeCreateInfoEXT_self_temp(dec, (VkMutableDescriptorTypeCreateInfoEXT *)pnext);
117         }
118         break;
119     default:
120         /* unexpected struct */
121         pnext = NULL;
122         vn_cs_decoder_set_fatal(dec);
123         break;
124     }
125 
126     return pnext;
127 }
128 
129 static inline void
vn_decode_VkDescriptorPoolCreateInfo_self_temp(struct vn_cs_decoder * dec,VkDescriptorPoolCreateInfo * val)130 vn_decode_VkDescriptorPoolCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDescriptorPoolCreateInfo *val)
131 {
132     /* skip val->{sType,pNext} */
133     vn_decode_VkFlags(dec, &val->flags);
134     vn_decode_uint32_t(dec, &val->maxSets);
135     vn_decode_uint32_t(dec, &val->poolSizeCount);
136     if (vn_peek_array_size(dec)) {
137         const uint32_t iter_count = vn_decode_array_size(dec, val->poolSizeCount);
138         val->pPoolSizes = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPoolSizes) * iter_count);
139         if (!val->pPoolSizes) return;
140         for (uint32_t i = 0; i < iter_count; i++)
141             vn_decode_VkDescriptorPoolSize_temp(dec, &((VkDescriptorPoolSize *)val->pPoolSizes)[i]);
142     } else {
143         vn_decode_array_size(dec, val->poolSizeCount);
144         val->pPoolSizes = NULL;
145     }
146 }
147 
148 static inline void
vn_decode_VkDescriptorPoolCreateInfo_temp(struct vn_cs_decoder * dec,VkDescriptorPoolCreateInfo * val)149 vn_decode_VkDescriptorPoolCreateInfo_temp(struct vn_cs_decoder *dec, VkDescriptorPoolCreateInfo *val)
150 {
151     VkStructureType stype;
152     vn_decode_VkStructureType(dec, &stype);
153     if (stype != VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO)
154         vn_cs_decoder_set_fatal(dec);
155 
156     val->sType = stype;
157     val->pNext = vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(dec);
158     vn_decode_VkDescriptorPoolCreateInfo_self_temp(dec, val);
159 }
160 
161 static inline void
vn_replace_VkDescriptorPoolCreateInfo_handle_self(VkDescriptorPoolCreateInfo * val)162 vn_replace_VkDescriptorPoolCreateInfo_handle_self(VkDescriptorPoolCreateInfo *val)
163 {
164     /* skip val->sType */
165     /* skip val->pNext */
166     /* skip val->flags */
167     /* skip val->maxSets */
168     /* skip val->poolSizeCount */
169     if (val->pPoolSizes) {
170        for (uint32_t i = 0; i < val->poolSizeCount; i++)
171             vn_replace_VkDescriptorPoolSize_handle(&((VkDescriptorPoolSize *)val->pPoolSizes)[i]);
172     }
173 }
174 
175 static inline void
vn_replace_VkDescriptorPoolCreateInfo_handle(VkDescriptorPoolCreateInfo * val)176 vn_replace_VkDescriptorPoolCreateInfo_handle(VkDescriptorPoolCreateInfo *val)
177 {
178     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
179 
180     do {
181         switch ((int32_t)pnext->sType) {
182         case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO:
183             vn_replace_VkDescriptorPoolCreateInfo_handle_self((VkDescriptorPoolCreateInfo *)pnext);
184             break;
185         case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO:
186             vn_replace_VkDescriptorPoolInlineUniformBlockCreateInfo_handle_self((VkDescriptorPoolInlineUniformBlockCreateInfo *)pnext);
187             break;
188         case VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT:
189             vn_replace_VkMutableDescriptorTypeCreateInfoEXT_handle_self((VkMutableDescriptorTypeCreateInfoEXT *)pnext);
190             break;
191         default:
192             /* ignore unknown/unsupported struct */
193             break;
194         }
195         pnext = pnext->pNext;
196     } while (pnext);
197 }
198 
vn_decode_vkCreateDescriptorPool_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkCreateDescriptorPool * args)199 static inline void vn_decode_vkCreateDescriptorPool_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkCreateDescriptorPool *args)
200 {
201     vn_decode_VkDevice_lookup(dec, &args->device);
202     if (vn_decode_simple_pointer(dec)) {
203         args->pCreateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfo));
204         if (!args->pCreateInfo) return;
205         vn_decode_VkDescriptorPoolCreateInfo_temp(dec, (VkDescriptorPoolCreateInfo *)args->pCreateInfo);
206     } else {
207         args->pCreateInfo = NULL;
208         vn_cs_decoder_set_fatal(dec);
209     }
210     if (vn_decode_simple_pointer(dec)) {
211         vn_cs_decoder_set_fatal(dec);
212     } else {
213         args->pAllocator = NULL;
214     }
215     if (vn_decode_simple_pointer(dec)) {
216         args->pDescriptorPool = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorPool));
217         if (!args->pDescriptorPool) return;
218         vn_decode_VkDescriptorPool(dec, args->pDescriptorPool);
219     } else {
220         args->pDescriptorPool = NULL;
221         vn_cs_decoder_set_fatal(dec);
222     }
223 }
224 
vn_replace_vkCreateDescriptorPool_args_handle(struct vn_command_vkCreateDescriptorPool * args)225 static inline void vn_replace_vkCreateDescriptorPool_args_handle(struct vn_command_vkCreateDescriptorPool *args)
226 {
227     vn_replace_VkDevice_handle(&args->device);
228     if (args->pCreateInfo)
229         vn_replace_VkDescriptorPoolCreateInfo_handle((VkDescriptorPoolCreateInfo *)args->pCreateInfo);
230     /* skip args->pAllocator */
231     /* skip args->pDescriptorPool */
232 }
233 
vn_encode_vkCreateDescriptorPool_reply(struct vn_cs_encoder * enc,const struct vn_command_vkCreateDescriptorPool * args)234 static inline void vn_encode_vkCreateDescriptorPool_reply(struct vn_cs_encoder *enc, const struct vn_command_vkCreateDescriptorPool *args)
235 {
236     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkCreateDescriptorPool_EXT});
237 
238     vn_encode_VkResult(enc, &args->ret);
239     /* skip args->device */
240     /* skip args->pCreateInfo */
241     /* skip args->pAllocator */
242     if (vn_encode_simple_pointer(enc, args->pDescriptorPool))
243         vn_encode_VkDescriptorPool(enc, args->pDescriptorPool);
244 }
245 
vn_decode_vkDestroyDescriptorPool_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkDestroyDescriptorPool * args)246 static inline void vn_decode_vkDestroyDescriptorPool_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkDestroyDescriptorPool *args)
247 {
248     vn_decode_VkDevice_lookup(dec, &args->device);
249     vn_decode_VkDescriptorPool_lookup(dec, &args->descriptorPool);
250     if (vn_decode_simple_pointer(dec)) {
251         vn_cs_decoder_set_fatal(dec);
252     } else {
253         args->pAllocator = NULL;
254     }
255 }
256 
vn_replace_vkDestroyDescriptorPool_args_handle(struct vn_command_vkDestroyDescriptorPool * args)257 static inline void vn_replace_vkDestroyDescriptorPool_args_handle(struct vn_command_vkDestroyDescriptorPool *args)
258 {
259     vn_replace_VkDevice_handle(&args->device);
260     vn_replace_VkDescriptorPool_handle(&args->descriptorPool);
261     /* skip args->pAllocator */
262 }
263 
vn_encode_vkDestroyDescriptorPool_reply(struct vn_cs_encoder * enc,const struct vn_command_vkDestroyDescriptorPool * args)264 static inline void vn_encode_vkDestroyDescriptorPool_reply(struct vn_cs_encoder *enc, const struct vn_command_vkDestroyDescriptorPool *args)
265 {
266     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkDestroyDescriptorPool_EXT});
267 
268     /* skip args->device */
269     /* skip args->descriptorPool */
270     /* skip args->pAllocator */
271 }
272 
vn_decode_vkResetDescriptorPool_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkResetDescriptorPool * args)273 static inline void vn_decode_vkResetDescriptorPool_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkResetDescriptorPool *args)
274 {
275     vn_decode_VkDevice_lookup(dec, &args->device);
276     vn_decode_VkDescriptorPool_lookup(dec, &args->descriptorPool);
277     vn_decode_VkFlags(dec, &args->flags);
278 }
279 
vn_replace_vkResetDescriptorPool_args_handle(struct vn_command_vkResetDescriptorPool * args)280 static inline void vn_replace_vkResetDescriptorPool_args_handle(struct vn_command_vkResetDescriptorPool *args)
281 {
282     vn_replace_VkDevice_handle(&args->device);
283     vn_replace_VkDescriptorPool_handle(&args->descriptorPool);
284     /* skip args->flags */
285 }
286 
vn_encode_vkResetDescriptorPool_reply(struct vn_cs_encoder * enc,const struct vn_command_vkResetDescriptorPool * args)287 static inline void vn_encode_vkResetDescriptorPool_reply(struct vn_cs_encoder *enc, const struct vn_command_vkResetDescriptorPool *args)
288 {
289     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkResetDescriptorPool_EXT});
290 
291     vn_encode_VkResult(enc, &args->ret);
292     /* skip args->device */
293     /* skip args->descriptorPool */
294     /* skip args->flags */
295 }
296 
vn_dispatch_vkCreateDescriptorPool(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)297 static inline void vn_dispatch_vkCreateDescriptorPool(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
298 {
299     struct vn_command_vkCreateDescriptorPool args;
300 
301     if (!ctx->dispatch_vkCreateDescriptorPool) {
302         vn_cs_decoder_set_fatal(ctx->decoder);
303         return;
304     }
305 
306     vn_decode_vkCreateDescriptorPool_args_temp(ctx->decoder, &args);
307     if (!args.device) {
308         vn_cs_decoder_set_fatal(ctx->decoder);
309         return;
310     }
311 
312     if (!vn_cs_decoder_get_fatal(ctx->decoder))
313         ctx->dispatch_vkCreateDescriptorPool(ctx, &args);
314 
315 #ifdef DEBUG
316     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
317         vn_dispatch_debug_log(ctx, "vkCreateDescriptorPool returned %d", args.ret);
318 #endif
319 
320     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
321        vn_encode_vkCreateDescriptorPool_reply(ctx->encoder, &args);
322 
323     vn_cs_decoder_reset_temp_pool(ctx->decoder);
324 }
325 
vn_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)326 static inline void vn_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
327 {
328     struct vn_command_vkDestroyDescriptorPool args;
329 
330     if (!ctx->dispatch_vkDestroyDescriptorPool) {
331         vn_cs_decoder_set_fatal(ctx->decoder);
332         return;
333     }
334 
335     vn_decode_vkDestroyDescriptorPool_args_temp(ctx->decoder, &args);
336     if (!args.device) {
337         vn_cs_decoder_set_fatal(ctx->decoder);
338         return;
339     }
340 
341     if (!vn_cs_decoder_get_fatal(ctx->decoder))
342         ctx->dispatch_vkDestroyDescriptorPool(ctx, &args);
343 
344 
345     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
346        vn_encode_vkDestroyDescriptorPool_reply(ctx->encoder, &args);
347 
348     vn_cs_decoder_reset_temp_pool(ctx->decoder);
349 }
350 
vn_dispatch_vkResetDescriptorPool(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)351 static inline void vn_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
352 {
353     struct vn_command_vkResetDescriptorPool args;
354 
355     if (!ctx->dispatch_vkResetDescriptorPool) {
356         vn_cs_decoder_set_fatal(ctx->decoder);
357         return;
358     }
359 
360     vn_decode_vkResetDescriptorPool_args_temp(ctx->decoder, &args);
361     if (!args.device) {
362         vn_cs_decoder_set_fatal(ctx->decoder);
363         return;
364     }
365 
366     if (!vn_cs_decoder_get_fatal(ctx->decoder))
367         ctx->dispatch_vkResetDescriptorPool(ctx, &args);
368 
369 #ifdef DEBUG
370     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
371         vn_dispatch_debug_log(ctx, "vkResetDescriptorPool returned %d", args.ret);
372 #endif
373 
374     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
375        vn_encode_vkResetDescriptorPool_reply(ctx->encoder, &args);
376 
377     vn_cs_decoder_reset_temp_pool(ctx->decoder);
378 }
379 
380 #pragma GCC diagnostic pop
381 
382 #endif /* VN_PROTOCOL_RENDERER_DESCRIPTOR_POOL_H */
383