• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* This file is generated by venus-protocol.  See vn_protocol_renderer.h. */
2 
3 /*
4  * Copyright 2020 Google LLC
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef VN_PROTOCOL_RENDERER_DESCRIPTOR_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 VkDescriptorPoolCreateInfo chain */
34 
35 static inline void *
vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(struct vn_cs_decoder * dec)36 vn_decode_VkDescriptorPoolCreateInfo_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_VkDescriptorPoolCreateInfo_self_temp(struct vn_cs_decoder * dec,VkDescriptorPoolCreateInfo * val)45 vn_decode_VkDescriptorPoolCreateInfo_self_temp(struct vn_cs_decoder *dec, VkDescriptorPoolCreateInfo *val)
46 {
47     /* skip val->{sType,pNext} */
48     vn_decode_VkFlags(dec, &val->flags);
49     vn_decode_uint32_t(dec, &val->maxSets);
50     vn_decode_uint32_t(dec, &val->poolSizeCount);
51     if (vn_peek_array_size(dec)) {
52         const uint32_t iter_count = vn_decode_array_size(dec, val->poolSizeCount);
53         val->pPoolSizes = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPoolSizes) * iter_count);
54         if (!val->pPoolSizes) return;
55         for (uint32_t i = 0; i < iter_count; i++)
56             vn_decode_VkDescriptorPoolSize_temp(dec, &((VkDescriptorPoolSize *)val->pPoolSizes)[i]);
57     } else {
58         vn_decode_array_size(dec, val->poolSizeCount);
59         val->pPoolSizes = NULL;
60     }
61 }
62 
63 static inline void
vn_decode_VkDescriptorPoolCreateInfo_temp(struct vn_cs_decoder * dec,VkDescriptorPoolCreateInfo * val)64 vn_decode_VkDescriptorPoolCreateInfo_temp(struct vn_cs_decoder *dec, VkDescriptorPoolCreateInfo *val)
65 {
66     VkStructureType stype;
67     vn_decode_VkStructureType(dec, &stype);
68     if (stype != VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO)
69         vn_cs_decoder_set_fatal(dec);
70 
71     val->sType = stype;
72     val->pNext = vn_decode_VkDescriptorPoolCreateInfo_pnext_temp(dec);
73     vn_decode_VkDescriptorPoolCreateInfo_self_temp(dec, val);
74 }
75 
76 static inline void
vn_replace_VkDescriptorPoolCreateInfo_handle_self(VkDescriptorPoolCreateInfo * val)77 vn_replace_VkDescriptorPoolCreateInfo_handle_self(VkDescriptorPoolCreateInfo *val)
78 {
79     /* skip val->sType */
80     /* skip val->pNext */
81     /* skip val->flags */
82     /* skip val->maxSets */
83     /* skip val->poolSizeCount */
84     if (val->pPoolSizes) {
85        for (uint32_t i = 0; i < val->poolSizeCount; i++)
86             vn_replace_VkDescriptorPoolSize_handle(&((VkDescriptorPoolSize *)val->pPoolSizes)[i]);
87     }
88 }
89 
90 static inline void
vn_replace_VkDescriptorPoolCreateInfo_handle(VkDescriptorPoolCreateInfo * val)91 vn_replace_VkDescriptorPoolCreateInfo_handle(VkDescriptorPoolCreateInfo *val)
92 {
93     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
94 
95     do {
96         switch ((int32_t)pnext->sType) {
97         case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO:
98             vn_replace_VkDescriptorPoolCreateInfo_handle_self((VkDescriptorPoolCreateInfo *)pnext);
99             break;
100         default:
101             /* ignore unknown/unsupported struct */
102             break;
103         }
104         pnext = pnext->pNext;
105     } while (pnext);
106 }
107 
vn_decode_vkCreateDescriptorPool_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkCreateDescriptorPool * args)108 static inline void vn_decode_vkCreateDescriptorPool_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkCreateDescriptorPool *args)
109 {
110     vn_decode_VkDevice_lookup(dec, &args->device);
111     if (vn_decode_simple_pointer(dec)) {
112         args->pCreateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfo));
113         if (!args->pCreateInfo) return;
114         vn_decode_VkDescriptorPoolCreateInfo_temp(dec, (VkDescriptorPoolCreateInfo *)args->pCreateInfo);
115     } else {
116         args->pCreateInfo = NULL;
117         vn_cs_decoder_set_fatal(dec);
118     }
119     if (vn_decode_simple_pointer(dec)) {
120         vn_cs_decoder_set_fatal(dec);
121     } else {
122         args->pAllocator = NULL;
123     }
124     if (vn_decode_simple_pointer(dec)) {
125         args->pDescriptorPool = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDescriptorPool));
126         if (!args->pDescriptorPool) return;
127         vn_decode_VkDescriptorPool(dec, args->pDescriptorPool);
128     } else {
129         args->pDescriptorPool = NULL;
130         vn_cs_decoder_set_fatal(dec);
131     }
132 }
133 
vn_replace_vkCreateDescriptorPool_args_handle(struct vn_command_vkCreateDescriptorPool * args)134 static inline void vn_replace_vkCreateDescriptorPool_args_handle(struct vn_command_vkCreateDescriptorPool *args)
135 {
136     vn_replace_VkDevice_handle(&args->device);
137     if (args->pCreateInfo)
138         vn_replace_VkDescriptorPoolCreateInfo_handle((VkDescriptorPoolCreateInfo *)args->pCreateInfo);
139     /* skip args->pAllocator */
140     /* skip args->pDescriptorPool */
141 }
142 
vn_encode_vkCreateDescriptorPool_reply(struct vn_cs_encoder * enc,const struct vn_command_vkCreateDescriptorPool * args)143 static inline void vn_encode_vkCreateDescriptorPool_reply(struct vn_cs_encoder *enc, const struct vn_command_vkCreateDescriptorPool *args)
144 {
145     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkCreateDescriptorPool_EXT});
146 
147     vn_encode_VkResult(enc, &args->ret);
148     /* skip args->device */
149     /* skip args->pCreateInfo */
150     /* skip args->pAllocator */
151     if (vn_encode_simple_pointer(enc, args->pDescriptorPool))
152         vn_encode_VkDescriptorPool(enc, args->pDescriptorPool);
153 }
154 
vn_decode_vkDestroyDescriptorPool_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkDestroyDescriptorPool * args)155 static inline void vn_decode_vkDestroyDescriptorPool_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkDestroyDescriptorPool *args)
156 {
157     vn_decode_VkDevice_lookup(dec, &args->device);
158     vn_decode_VkDescriptorPool_lookup(dec, &args->descriptorPool);
159     if (vn_decode_simple_pointer(dec)) {
160         vn_cs_decoder_set_fatal(dec);
161     } else {
162         args->pAllocator = NULL;
163     }
164 }
165 
vn_replace_vkDestroyDescriptorPool_args_handle(struct vn_command_vkDestroyDescriptorPool * args)166 static inline void vn_replace_vkDestroyDescriptorPool_args_handle(struct vn_command_vkDestroyDescriptorPool *args)
167 {
168     vn_replace_VkDevice_handle(&args->device);
169     vn_replace_VkDescriptorPool_handle(&args->descriptorPool);
170     /* skip args->pAllocator */
171 }
172 
vn_encode_vkDestroyDescriptorPool_reply(struct vn_cs_encoder * enc,const struct vn_command_vkDestroyDescriptorPool * args)173 static inline void vn_encode_vkDestroyDescriptorPool_reply(struct vn_cs_encoder *enc, const struct vn_command_vkDestroyDescriptorPool *args)
174 {
175     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkDestroyDescriptorPool_EXT});
176 
177     /* skip args->device */
178     /* skip args->descriptorPool */
179     /* skip args->pAllocator */
180 }
181 
vn_decode_vkResetDescriptorPool_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkResetDescriptorPool * args)182 static inline void vn_decode_vkResetDescriptorPool_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkResetDescriptorPool *args)
183 {
184     vn_decode_VkDevice_lookup(dec, &args->device);
185     vn_decode_VkDescriptorPool_lookup(dec, &args->descriptorPool);
186     vn_decode_VkFlags(dec, &args->flags);
187 }
188 
vn_replace_vkResetDescriptorPool_args_handle(struct vn_command_vkResetDescriptorPool * args)189 static inline void vn_replace_vkResetDescriptorPool_args_handle(struct vn_command_vkResetDescriptorPool *args)
190 {
191     vn_replace_VkDevice_handle(&args->device);
192     vn_replace_VkDescriptorPool_handle(&args->descriptorPool);
193     /* skip args->flags */
194 }
195 
vn_encode_vkResetDescriptorPool_reply(struct vn_cs_encoder * enc,const struct vn_command_vkResetDescriptorPool * args)196 static inline void vn_encode_vkResetDescriptorPool_reply(struct vn_cs_encoder *enc, const struct vn_command_vkResetDescriptorPool *args)
197 {
198     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkResetDescriptorPool_EXT});
199 
200     vn_encode_VkResult(enc, &args->ret);
201     /* skip args->device */
202     /* skip args->descriptorPool */
203     /* skip args->flags */
204 }
205 
vn_dispatch_vkCreateDescriptorPool(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)206 static inline void vn_dispatch_vkCreateDescriptorPool(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
207 {
208     struct vn_command_vkCreateDescriptorPool args;
209 
210     if (!ctx->dispatch_vkCreateDescriptorPool) {
211         vn_cs_decoder_set_fatal(ctx->decoder);
212         return;
213     }
214 
215     vn_decode_vkCreateDescriptorPool_args_temp(ctx->decoder, &args);
216     if (!args.device) {
217         vn_cs_decoder_set_fatal(ctx->decoder);
218         return;
219     }
220 
221     if (!vn_cs_decoder_get_fatal(ctx->decoder))
222         ctx->dispatch_vkCreateDescriptorPool(ctx, &args);
223 
224 #ifdef DEBUG
225     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
226         vn_dispatch_debug_log(ctx, "vkCreateDescriptorPool returned %d", args.ret);
227 #endif
228 
229     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
230        vn_encode_vkCreateDescriptorPool_reply(ctx->encoder, &args);
231 
232     vn_cs_decoder_reset_temp_pool(ctx->decoder);
233 }
234 
vn_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)235 static inline void vn_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
236 {
237     struct vn_command_vkDestroyDescriptorPool args;
238 
239     if (!ctx->dispatch_vkDestroyDescriptorPool) {
240         vn_cs_decoder_set_fatal(ctx->decoder);
241         return;
242     }
243 
244     vn_decode_vkDestroyDescriptorPool_args_temp(ctx->decoder, &args);
245     if (!args.device) {
246         vn_cs_decoder_set_fatal(ctx->decoder);
247         return;
248     }
249 
250     if (!vn_cs_decoder_get_fatal(ctx->decoder))
251         ctx->dispatch_vkDestroyDescriptorPool(ctx, &args);
252 
253 
254     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
255        vn_encode_vkDestroyDescriptorPool_reply(ctx->encoder, &args);
256 
257     vn_cs_decoder_reset_temp_pool(ctx->decoder);
258 }
259 
vn_dispatch_vkResetDescriptorPool(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)260 static inline void vn_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
261 {
262     struct vn_command_vkResetDescriptorPool args;
263 
264     if (!ctx->dispatch_vkResetDescriptorPool) {
265         vn_cs_decoder_set_fatal(ctx->decoder);
266         return;
267     }
268 
269     vn_decode_vkResetDescriptorPool_args_temp(ctx->decoder, &args);
270     if (!args.device) {
271         vn_cs_decoder_set_fatal(ctx->decoder);
272         return;
273     }
274 
275     if (!vn_cs_decoder_get_fatal(ctx->decoder))
276         ctx->dispatch_vkResetDescriptorPool(ctx, &args);
277 
278 #ifdef DEBUG
279     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
280         vn_dispatch_debug_log(ctx, "vkResetDescriptorPool returned %d", args.ret);
281 #endif
282 
283     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
284        vn_encode_vkResetDescriptorPool_reply(ctx->encoder, &args);
285 
286     vn_cs_decoder_reset_temp_pool(ctx->decoder);
287 }
288 
289 #pragma GCC diagnostic pop
290 
291 #endif /* VN_PROTOCOL_RENDERER_DESCRIPTOR_POOL_H */
292