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_PIPELINE_CACHE_H
9 #define VN_PROTOCOL_RENDERER_PIPELINE_CACHE_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 VkPipelineCacheCreateInfo chain */
18 
19 static inline void *
vn_decode_VkPipelineCacheCreateInfo_pnext_temp(struct vn_cs_decoder * dec)20 vn_decode_VkPipelineCacheCreateInfo_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_VkPipelineCacheCreateInfo_self_temp(struct vn_cs_decoder * dec,VkPipelineCacheCreateInfo * val)29 vn_decode_VkPipelineCacheCreateInfo_self_temp(struct vn_cs_decoder *dec, VkPipelineCacheCreateInfo *val)
30 {
31     /* skip val->{sType,pNext} */
32     vn_decode_VkFlags(dec, &val->flags);
33     vn_decode_size_t(dec, &val->initialDataSize);
34     if (vn_peek_array_size(dec)) {
35         const size_t array_size = vn_decode_array_size(dec, val->initialDataSize);
36         val->pInitialData = vn_cs_decoder_alloc_temp(dec, array_size);
37         if (!val->pInitialData) return;
38         vn_decode_blob_array(dec, (void *)val->pInitialData, array_size);
39     } else {
40         vn_decode_array_size(dec, val->initialDataSize);
41         val->pInitialData = NULL;
42     }
43 }
44 
45 static inline void
vn_decode_VkPipelineCacheCreateInfo_temp(struct vn_cs_decoder * dec,VkPipelineCacheCreateInfo * val)46 vn_decode_VkPipelineCacheCreateInfo_temp(struct vn_cs_decoder *dec, VkPipelineCacheCreateInfo *val)
47 {
48     VkStructureType stype;
49     vn_decode_VkStructureType(dec, &stype);
50     if (stype != VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO)
51         vn_cs_decoder_set_fatal(dec);
52 
53     val->sType = stype;
54     val->pNext = vn_decode_VkPipelineCacheCreateInfo_pnext_temp(dec);
55     vn_decode_VkPipelineCacheCreateInfo_self_temp(dec, val);
56 }
57 
58 static inline void
vn_replace_VkPipelineCacheCreateInfo_handle_self(VkPipelineCacheCreateInfo * val)59 vn_replace_VkPipelineCacheCreateInfo_handle_self(VkPipelineCacheCreateInfo *val)
60 {
61     /* skip val->sType */
62     /* skip val->pNext */
63     /* skip val->flags */
64     /* skip val->initialDataSize */
65     /* skip val->pInitialData */
66 }
67 
68 static inline void
vn_replace_VkPipelineCacheCreateInfo_handle(VkPipelineCacheCreateInfo * val)69 vn_replace_VkPipelineCacheCreateInfo_handle(VkPipelineCacheCreateInfo *val)
70 {
71     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
72 
73     do {
74         switch ((int32_t)pnext->sType) {
75         case VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO:
76             vn_replace_VkPipelineCacheCreateInfo_handle_self((VkPipelineCacheCreateInfo *)pnext);
77             break;
78         default:
79             /* ignore unknown/unsupported struct */
80             break;
81         }
82         pnext = pnext->pNext;
83     } while (pnext);
84 }
85 
vn_decode_vkCreatePipelineCache_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkCreatePipelineCache * args)86 static inline void vn_decode_vkCreatePipelineCache_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkCreatePipelineCache *args)
87 {
88     vn_decode_VkDevice_lookup(dec, &args->device);
89     if (vn_decode_simple_pointer(dec)) {
90         args->pCreateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfo));
91         if (!args->pCreateInfo) return;
92         vn_decode_VkPipelineCacheCreateInfo_temp(dec, (VkPipelineCacheCreateInfo *)args->pCreateInfo);
93     } else {
94         args->pCreateInfo = NULL;
95         vn_cs_decoder_set_fatal(dec);
96     }
97     if (vn_decode_simple_pointer(dec)) {
98         vn_cs_decoder_set_fatal(dec);
99     } else {
100         args->pAllocator = NULL;
101     }
102     if (vn_decode_simple_pointer(dec)) {
103         args->pPipelineCache = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPipelineCache));
104         if (!args->pPipelineCache) return;
105         vn_decode_VkPipelineCache(dec, args->pPipelineCache);
106     } else {
107         args->pPipelineCache = NULL;
108         vn_cs_decoder_set_fatal(dec);
109     }
110 }
111 
vn_replace_vkCreatePipelineCache_args_handle(struct vn_command_vkCreatePipelineCache * args)112 static inline void vn_replace_vkCreatePipelineCache_args_handle(struct vn_command_vkCreatePipelineCache *args)
113 {
114     vn_replace_VkDevice_handle(&args->device);
115     if (args->pCreateInfo)
116         vn_replace_VkPipelineCacheCreateInfo_handle((VkPipelineCacheCreateInfo *)args->pCreateInfo);
117     /* skip args->pAllocator */
118     /* skip args->pPipelineCache */
119 }
120 
vn_encode_vkCreatePipelineCache_reply(struct vn_cs_encoder * enc,const struct vn_command_vkCreatePipelineCache * args)121 static inline void vn_encode_vkCreatePipelineCache_reply(struct vn_cs_encoder *enc, const struct vn_command_vkCreatePipelineCache *args)
122 {
123     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkCreatePipelineCache_EXT});
124 
125     vn_encode_VkResult(enc, &args->ret);
126     /* skip args->device */
127     /* skip args->pCreateInfo */
128     /* skip args->pAllocator */
129     if (vn_encode_simple_pointer(enc, args->pPipelineCache))
130         vn_encode_VkPipelineCache(enc, args->pPipelineCache);
131 }
132 
vn_decode_vkDestroyPipelineCache_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkDestroyPipelineCache * args)133 static inline void vn_decode_vkDestroyPipelineCache_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkDestroyPipelineCache *args)
134 {
135     vn_decode_VkDevice_lookup(dec, &args->device);
136     vn_decode_VkPipelineCache_lookup(dec, &args->pipelineCache);
137     if (vn_decode_simple_pointer(dec)) {
138         vn_cs_decoder_set_fatal(dec);
139     } else {
140         args->pAllocator = NULL;
141     }
142 }
143 
vn_replace_vkDestroyPipelineCache_args_handle(struct vn_command_vkDestroyPipelineCache * args)144 static inline void vn_replace_vkDestroyPipelineCache_args_handle(struct vn_command_vkDestroyPipelineCache *args)
145 {
146     vn_replace_VkDevice_handle(&args->device);
147     vn_replace_VkPipelineCache_handle(&args->pipelineCache);
148     /* skip args->pAllocator */
149 }
150 
vn_encode_vkDestroyPipelineCache_reply(struct vn_cs_encoder * enc,const struct vn_command_vkDestroyPipelineCache * args)151 static inline void vn_encode_vkDestroyPipelineCache_reply(struct vn_cs_encoder *enc, const struct vn_command_vkDestroyPipelineCache *args)
152 {
153     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkDestroyPipelineCache_EXT});
154 
155     /* skip args->device */
156     /* skip args->pipelineCache */
157     /* skip args->pAllocator */
158 }
159 
vn_decode_vkGetPipelineCacheData_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkGetPipelineCacheData * args)160 static inline void vn_decode_vkGetPipelineCacheData_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkGetPipelineCacheData *args)
161 {
162     vn_decode_VkDevice_lookup(dec, &args->device);
163     vn_decode_VkPipelineCache_lookup(dec, &args->pipelineCache);
164     if (vn_decode_simple_pointer(dec)) {
165         args->pDataSize = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pDataSize));
166         if (!args->pDataSize) return;
167         vn_decode_size_t(dec, args->pDataSize);
168     } else {
169         args->pDataSize = NULL;
170         vn_cs_decoder_set_fatal(dec);
171     }
172     if (vn_peek_array_size(dec)) {
173         const size_t array_size = vn_decode_array_size(dec, (args->pDataSize ? *args->pDataSize : 0));
174         args->pData = vn_cs_decoder_alloc_temp(dec, array_size);
175         if (!args->pData) return;
176     } else {
177         vn_decode_array_size_unchecked(dec);
178         args->pData = NULL;
179     }
180 }
181 
vn_replace_vkGetPipelineCacheData_args_handle(struct vn_command_vkGetPipelineCacheData * args)182 static inline void vn_replace_vkGetPipelineCacheData_args_handle(struct vn_command_vkGetPipelineCacheData *args)
183 {
184     vn_replace_VkDevice_handle(&args->device);
185     vn_replace_VkPipelineCache_handle(&args->pipelineCache);
186     /* skip args->pDataSize */
187     /* skip args->pData */
188 }
189 
vn_encode_vkGetPipelineCacheData_reply(struct vn_cs_encoder * enc,const struct vn_command_vkGetPipelineCacheData * args)190 static inline void vn_encode_vkGetPipelineCacheData_reply(struct vn_cs_encoder *enc, const struct vn_command_vkGetPipelineCacheData *args)
191 {
192     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkGetPipelineCacheData_EXT});
193 
194     vn_encode_VkResult(enc, &args->ret);
195     /* skip args->device */
196     /* skip args->pipelineCache */
197     if (vn_encode_simple_pointer(enc, args->pDataSize))
198         vn_encode_size_t(enc, args->pDataSize);
199     if (args->pData) {
200         vn_encode_array_size(enc, (args->pDataSize ? *args->pDataSize : 0));
201         vn_encode_blob_array(enc, args->pData, (args->pDataSize ? *args->pDataSize : 0));
202     } else {
203         vn_encode_array_size(enc, 0);
204     }
205 }
206 
vn_decode_vkMergePipelineCaches_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkMergePipelineCaches * args)207 static inline void vn_decode_vkMergePipelineCaches_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkMergePipelineCaches *args)
208 {
209     vn_decode_VkDevice_lookup(dec, &args->device);
210     vn_decode_VkPipelineCache_lookup(dec, &args->dstCache);
211     vn_decode_uint32_t(dec, &args->srcCacheCount);
212     if (vn_peek_array_size(dec)) {
213         const uint32_t iter_count = vn_decode_array_size(dec, args->srcCacheCount);
214         args->pSrcCaches = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSrcCaches) * iter_count);
215         if (!args->pSrcCaches) return;
216         for (uint32_t i = 0; i < iter_count; i++)
217             vn_decode_VkPipelineCache_lookup(dec, &((VkPipelineCache *)args->pSrcCaches)[i]);
218     } else {
219         vn_decode_array_size(dec, args->srcCacheCount);
220         args->pSrcCaches = NULL;
221     }
222 }
223 
vn_replace_vkMergePipelineCaches_args_handle(struct vn_command_vkMergePipelineCaches * args)224 static inline void vn_replace_vkMergePipelineCaches_args_handle(struct vn_command_vkMergePipelineCaches *args)
225 {
226     vn_replace_VkDevice_handle(&args->device);
227     vn_replace_VkPipelineCache_handle(&args->dstCache);
228     /* skip args->srcCacheCount */
229     if (args->pSrcCaches) {
230        for (uint32_t i = 0; i < args->srcCacheCount; i++)
231             vn_replace_VkPipelineCache_handle(&((VkPipelineCache *)args->pSrcCaches)[i]);
232     }
233 }
234 
vn_encode_vkMergePipelineCaches_reply(struct vn_cs_encoder * enc,const struct vn_command_vkMergePipelineCaches * args)235 static inline void vn_encode_vkMergePipelineCaches_reply(struct vn_cs_encoder *enc, const struct vn_command_vkMergePipelineCaches *args)
236 {
237     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkMergePipelineCaches_EXT});
238 
239     vn_encode_VkResult(enc, &args->ret);
240     /* skip args->device */
241     /* skip args->dstCache */
242     /* skip args->srcCacheCount */
243     /* skip args->pSrcCaches */
244 }
245 
vn_dispatch_vkCreatePipelineCache(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)246 static inline void vn_dispatch_vkCreatePipelineCache(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
247 {
248     struct vn_command_vkCreatePipelineCache args;
249 
250     if (!ctx->dispatch_vkCreatePipelineCache) {
251         vn_cs_decoder_set_fatal(ctx->decoder);
252         return;
253     }
254 
255     vn_decode_vkCreatePipelineCache_args_temp(ctx->decoder, &args);
256     if (!args.device) {
257         vn_cs_decoder_set_fatal(ctx->decoder);
258         return;
259     }
260 
261     if (!vn_cs_decoder_get_fatal(ctx->decoder))
262         ctx->dispatch_vkCreatePipelineCache(ctx, &args);
263 
264 #ifdef DEBUG
265     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
266         vn_dispatch_debug_log(ctx, "vkCreatePipelineCache returned %d", args.ret);
267 #endif
268 
269     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
270        vn_encode_vkCreatePipelineCache_reply(ctx->encoder, &args);
271 
272     vn_cs_decoder_reset_temp_pool(ctx->decoder);
273 }
274 
vn_dispatch_vkDestroyPipelineCache(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)275 static inline void vn_dispatch_vkDestroyPipelineCache(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
276 {
277     struct vn_command_vkDestroyPipelineCache args;
278 
279     if (!ctx->dispatch_vkDestroyPipelineCache) {
280         vn_cs_decoder_set_fatal(ctx->decoder);
281         return;
282     }
283 
284     vn_decode_vkDestroyPipelineCache_args_temp(ctx->decoder, &args);
285     if (!args.device) {
286         vn_cs_decoder_set_fatal(ctx->decoder);
287         return;
288     }
289 
290     if (!vn_cs_decoder_get_fatal(ctx->decoder))
291         ctx->dispatch_vkDestroyPipelineCache(ctx, &args);
292 
293 
294     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
295        vn_encode_vkDestroyPipelineCache_reply(ctx->encoder, &args);
296 
297     vn_cs_decoder_reset_temp_pool(ctx->decoder);
298 }
299 
vn_dispatch_vkGetPipelineCacheData(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)300 static inline void vn_dispatch_vkGetPipelineCacheData(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
301 {
302     struct vn_command_vkGetPipelineCacheData args;
303 
304     if (!ctx->dispatch_vkGetPipelineCacheData) {
305         vn_cs_decoder_set_fatal(ctx->decoder);
306         return;
307     }
308 
309     vn_decode_vkGetPipelineCacheData_args_temp(ctx->decoder, &args);
310     if (!args.device) {
311         vn_cs_decoder_set_fatal(ctx->decoder);
312         return;
313     }
314 
315     if (!vn_cs_decoder_get_fatal(ctx->decoder))
316         ctx->dispatch_vkGetPipelineCacheData(ctx, &args);
317 
318 #ifdef DEBUG
319     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
320         vn_dispatch_debug_log(ctx, "vkGetPipelineCacheData returned %d", args.ret);
321 #endif
322 
323     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
324        vn_encode_vkGetPipelineCacheData_reply(ctx->encoder, &args);
325 
326     vn_cs_decoder_reset_temp_pool(ctx->decoder);
327 }
328 
vn_dispatch_vkMergePipelineCaches(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)329 static inline void vn_dispatch_vkMergePipelineCaches(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
330 {
331     struct vn_command_vkMergePipelineCaches args;
332 
333     if (!ctx->dispatch_vkMergePipelineCaches) {
334         vn_cs_decoder_set_fatal(ctx->decoder);
335         return;
336     }
337 
338     vn_decode_vkMergePipelineCaches_args_temp(ctx->decoder, &args);
339     if (!args.device) {
340         vn_cs_decoder_set_fatal(ctx->decoder);
341         return;
342     }
343 
344     if (!vn_cs_decoder_get_fatal(ctx->decoder))
345         ctx->dispatch_vkMergePipelineCaches(ctx, &args);
346 
347 #ifdef DEBUG
348     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
349         vn_dispatch_debug_log(ctx, "vkMergePipelineCaches returned %d", args.ret);
350 #endif
351 
352     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
353        vn_encode_vkMergePipelineCaches_reply(ctx->encoder, &args);
354 
355     vn_cs_decoder_reset_temp_pool(ctx->decoder);
356 }
357 
358 #pragma GCC diagnostic pop
359 
360 #endif /* VN_PROTOCOL_RENDERER_PIPELINE_CACHE_H */
361