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_LAYOUT_H
9 #define VN_PROTOCOL_RENDERER_PIPELINE_LAYOUT_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 VkPushConstantRange */
18
19 static inline void
vn_decode_VkPushConstantRange_temp(struct vn_cs_decoder * dec,VkPushConstantRange * val)20 vn_decode_VkPushConstantRange_temp(struct vn_cs_decoder *dec, VkPushConstantRange *val)
21 {
22 vn_decode_VkFlags(dec, &val->stageFlags);
23 vn_decode_uint32_t(dec, &val->offset);
24 vn_decode_uint32_t(dec, &val->size);
25 }
26
27 static inline void
vn_replace_VkPushConstantRange_handle(VkPushConstantRange * val)28 vn_replace_VkPushConstantRange_handle(VkPushConstantRange *val)
29 {
30 /* skip val->stageFlags */
31 /* skip val->offset */
32 /* skip val->size */
33 }
34
35 /* struct VkPipelineLayoutCreateInfo chain */
36
37 static inline void *
vn_decode_VkPipelineLayoutCreateInfo_pnext_temp(struct vn_cs_decoder * dec)38 vn_decode_VkPipelineLayoutCreateInfo_pnext_temp(struct vn_cs_decoder *dec)
39 {
40 /* no known/supported struct */
41 if (vn_decode_simple_pointer(dec))
42 vn_cs_decoder_set_fatal(dec);
43 return NULL;
44 }
45
46 static inline void
vn_decode_VkPipelineLayoutCreateInfo_self_temp(struct vn_cs_decoder * dec,VkPipelineLayoutCreateInfo * val)47 vn_decode_VkPipelineLayoutCreateInfo_self_temp(struct vn_cs_decoder *dec, VkPipelineLayoutCreateInfo *val)
48 {
49 /* skip val->{sType,pNext} */
50 vn_decode_VkFlags(dec, &val->flags);
51 vn_decode_uint32_t(dec, &val->setLayoutCount);
52 if (vn_peek_array_size(dec)) {
53 const uint32_t iter_count = vn_decode_array_size(dec, val->setLayoutCount);
54 val->pSetLayouts = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pSetLayouts) * iter_count);
55 if (!val->pSetLayouts) return;
56 for (uint32_t i = 0; i < iter_count; i++)
57 vn_decode_VkDescriptorSetLayout_lookup(dec, &((VkDescriptorSetLayout *)val->pSetLayouts)[i]);
58 } else {
59 vn_decode_array_size(dec, val->setLayoutCount);
60 val->pSetLayouts = NULL;
61 }
62 vn_decode_uint32_t(dec, &val->pushConstantRangeCount);
63 if (vn_peek_array_size(dec)) {
64 const uint32_t iter_count = vn_decode_array_size(dec, val->pushConstantRangeCount);
65 val->pPushConstantRanges = vn_cs_decoder_alloc_temp(dec, sizeof(*val->pPushConstantRanges) * iter_count);
66 if (!val->pPushConstantRanges) return;
67 for (uint32_t i = 0; i < iter_count; i++)
68 vn_decode_VkPushConstantRange_temp(dec, &((VkPushConstantRange *)val->pPushConstantRanges)[i]);
69 } else {
70 vn_decode_array_size(dec, val->pushConstantRangeCount);
71 val->pPushConstantRanges = NULL;
72 }
73 }
74
75 static inline void
vn_decode_VkPipelineLayoutCreateInfo_temp(struct vn_cs_decoder * dec,VkPipelineLayoutCreateInfo * val)76 vn_decode_VkPipelineLayoutCreateInfo_temp(struct vn_cs_decoder *dec, VkPipelineLayoutCreateInfo *val)
77 {
78 VkStructureType stype;
79 vn_decode_VkStructureType(dec, &stype);
80 if (stype != VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO)
81 vn_cs_decoder_set_fatal(dec);
82
83 val->sType = stype;
84 val->pNext = vn_decode_VkPipelineLayoutCreateInfo_pnext_temp(dec);
85 vn_decode_VkPipelineLayoutCreateInfo_self_temp(dec, val);
86 }
87
88 static inline void
vn_replace_VkPipelineLayoutCreateInfo_handle_self(VkPipelineLayoutCreateInfo * val)89 vn_replace_VkPipelineLayoutCreateInfo_handle_self(VkPipelineLayoutCreateInfo *val)
90 {
91 /* skip val->sType */
92 /* skip val->pNext */
93 /* skip val->flags */
94 /* skip val->setLayoutCount */
95 if (val->pSetLayouts) {
96 for (uint32_t i = 0; i < val->setLayoutCount; i++)
97 vn_replace_VkDescriptorSetLayout_handle(&((VkDescriptorSetLayout *)val->pSetLayouts)[i]);
98 }
99 /* skip val->pushConstantRangeCount */
100 if (val->pPushConstantRanges) {
101 for (uint32_t i = 0; i < val->pushConstantRangeCount; i++)
102 vn_replace_VkPushConstantRange_handle(&((VkPushConstantRange *)val->pPushConstantRanges)[i]);
103 }
104 }
105
106 static inline void
vn_replace_VkPipelineLayoutCreateInfo_handle(VkPipelineLayoutCreateInfo * val)107 vn_replace_VkPipelineLayoutCreateInfo_handle(VkPipelineLayoutCreateInfo *val)
108 {
109 struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
110
111 do {
112 switch ((int32_t)pnext->sType) {
113 case VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO:
114 vn_replace_VkPipelineLayoutCreateInfo_handle_self((VkPipelineLayoutCreateInfo *)pnext);
115 break;
116 default:
117 /* ignore unknown/unsupported struct */
118 break;
119 }
120 pnext = pnext->pNext;
121 } while (pnext);
122 }
123
vn_decode_vkCreatePipelineLayout_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkCreatePipelineLayout * args)124 static inline void vn_decode_vkCreatePipelineLayout_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkCreatePipelineLayout *args)
125 {
126 vn_decode_VkDevice_lookup(dec, &args->device);
127 if (vn_decode_simple_pointer(dec)) {
128 args->pCreateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfo));
129 if (!args->pCreateInfo) return;
130 vn_decode_VkPipelineLayoutCreateInfo_temp(dec, (VkPipelineLayoutCreateInfo *)args->pCreateInfo);
131 } else {
132 args->pCreateInfo = NULL;
133 vn_cs_decoder_set_fatal(dec);
134 }
135 if (vn_decode_simple_pointer(dec)) {
136 vn_cs_decoder_set_fatal(dec);
137 } else {
138 args->pAllocator = NULL;
139 }
140 if (vn_decode_simple_pointer(dec)) {
141 args->pPipelineLayout = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pPipelineLayout));
142 if (!args->pPipelineLayout) return;
143 vn_decode_VkPipelineLayout(dec, args->pPipelineLayout);
144 } else {
145 args->pPipelineLayout = NULL;
146 vn_cs_decoder_set_fatal(dec);
147 }
148 }
149
vn_replace_vkCreatePipelineLayout_args_handle(struct vn_command_vkCreatePipelineLayout * args)150 static inline void vn_replace_vkCreatePipelineLayout_args_handle(struct vn_command_vkCreatePipelineLayout *args)
151 {
152 vn_replace_VkDevice_handle(&args->device);
153 if (args->pCreateInfo)
154 vn_replace_VkPipelineLayoutCreateInfo_handle((VkPipelineLayoutCreateInfo *)args->pCreateInfo);
155 /* skip args->pAllocator */
156 /* skip args->pPipelineLayout */
157 }
158
vn_encode_vkCreatePipelineLayout_reply(struct vn_cs_encoder * enc,const struct vn_command_vkCreatePipelineLayout * args)159 static inline void vn_encode_vkCreatePipelineLayout_reply(struct vn_cs_encoder *enc, const struct vn_command_vkCreatePipelineLayout *args)
160 {
161 vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkCreatePipelineLayout_EXT});
162
163 vn_encode_VkResult(enc, &args->ret);
164 /* skip args->device */
165 /* skip args->pCreateInfo */
166 /* skip args->pAllocator */
167 if (vn_encode_simple_pointer(enc, args->pPipelineLayout))
168 vn_encode_VkPipelineLayout(enc, args->pPipelineLayout);
169 }
170
vn_decode_vkDestroyPipelineLayout_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkDestroyPipelineLayout * args)171 static inline void vn_decode_vkDestroyPipelineLayout_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkDestroyPipelineLayout *args)
172 {
173 vn_decode_VkDevice_lookup(dec, &args->device);
174 vn_decode_VkPipelineLayout_lookup(dec, &args->pipelineLayout);
175 if (vn_decode_simple_pointer(dec)) {
176 vn_cs_decoder_set_fatal(dec);
177 } else {
178 args->pAllocator = NULL;
179 }
180 }
181
vn_replace_vkDestroyPipelineLayout_args_handle(struct vn_command_vkDestroyPipelineLayout * args)182 static inline void vn_replace_vkDestroyPipelineLayout_args_handle(struct vn_command_vkDestroyPipelineLayout *args)
183 {
184 vn_replace_VkDevice_handle(&args->device);
185 vn_replace_VkPipelineLayout_handle(&args->pipelineLayout);
186 /* skip args->pAllocator */
187 }
188
vn_encode_vkDestroyPipelineLayout_reply(struct vn_cs_encoder * enc,const struct vn_command_vkDestroyPipelineLayout * args)189 static inline void vn_encode_vkDestroyPipelineLayout_reply(struct vn_cs_encoder *enc, const struct vn_command_vkDestroyPipelineLayout *args)
190 {
191 vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkDestroyPipelineLayout_EXT});
192
193 /* skip args->device */
194 /* skip args->pipelineLayout */
195 /* skip args->pAllocator */
196 }
197
vn_dispatch_vkCreatePipelineLayout(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)198 static inline void vn_dispatch_vkCreatePipelineLayout(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
199 {
200 struct vn_command_vkCreatePipelineLayout args;
201
202 if (!ctx->dispatch_vkCreatePipelineLayout) {
203 vn_cs_decoder_set_fatal(ctx->decoder);
204 return;
205 }
206
207 vn_decode_vkCreatePipelineLayout_args_temp(ctx->decoder, &args);
208 if (!args.device) {
209 vn_cs_decoder_set_fatal(ctx->decoder);
210 return;
211 }
212
213 if (!vn_cs_decoder_get_fatal(ctx->decoder))
214 ctx->dispatch_vkCreatePipelineLayout(ctx, &args);
215
216 #ifdef DEBUG
217 if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
218 vn_dispatch_debug_log(ctx, "vkCreatePipelineLayout returned %d", args.ret);
219 #endif
220
221 if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
222 vn_encode_vkCreatePipelineLayout_reply(ctx->encoder, &args);
223
224 vn_cs_decoder_reset_temp_pool(ctx->decoder);
225 }
226
vn_dispatch_vkDestroyPipelineLayout(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)227 static inline void vn_dispatch_vkDestroyPipelineLayout(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
228 {
229 struct vn_command_vkDestroyPipelineLayout args;
230
231 if (!ctx->dispatch_vkDestroyPipelineLayout) {
232 vn_cs_decoder_set_fatal(ctx->decoder);
233 return;
234 }
235
236 vn_decode_vkDestroyPipelineLayout_args_temp(ctx->decoder, &args);
237 if (!args.device) {
238 vn_cs_decoder_set_fatal(ctx->decoder);
239 return;
240 }
241
242 if (!vn_cs_decoder_get_fatal(ctx->decoder))
243 ctx->dispatch_vkDestroyPipelineLayout(ctx, &args);
244
245
246 if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
247 vn_encode_vkDestroyPipelineLayout_reply(ctx->encoder, &args);
248
249 vn_cs_decoder_reset_temp_pool(ctx->decoder);
250 }
251
252 #pragma GCC diagnostic pop
253
254 #endif /* VN_PROTOCOL_RENDERER_PIPELINE_LAYOUT_H */
255