xref: /aosp_15_r20/external/virglrenderer/src/venus/venus-protocol/vn_protocol_renderer_sampler.h (revision bbecb9d118dfdb95f99bd754f8fa9be01f189df3)
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_SAMPLER_H
9 #define VN_PROTOCOL_RENDERER_SAMPLER_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 VkSamplerReductionModeCreateInfo chain */
18 
19 static inline void *
vn_decode_VkSamplerReductionModeCreateInfo_pnext_temp(struct vn_cs_decoder * dec)20 vn_decode_VkSamplerReductionModeCreateInfo_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_VkSamplerReductionModeCreateInfo_self_temp(struct vn_cs_decoder * dec,VkSamplerReductionModeCreateInfo * val)29 vn_decode_VkSamplerReductionModeCreateInfo_self_temp(struct vn_cs_decoder *dec, VkSamplerReductionModeCreateInfo *val)
30 {
31     /* skip val->{sType,pNext} */
32     vn_decode_VkSamplerReductionMode(dec, &val->reductionMode);
33 }
34 
35 static inline void
vn_decode_VkSamplerReductionModeCreateInfo_temp(struct vn_cs_decoder * dec,VkSamplerReductionModeCreateInfo * val)36 vn_decode_VkSamplerReductionModeCreateInfo_temp(struct vn_cs_decoder *dec, VkSamplerReductionModeCreateInfo *val)
37 {
38     VkStructureType stype;
39     vn_decode_VkStructureType(dec, &stype);
40     if (stype != VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO)
41         vn_cs_decoder_set_fatal(dec);
42 
43     val->sType = stype;
44     val->pNext = vn_decode_VkSamplerReductionModeCreateInfo_pnext_temp(dec);
45     vn_decode_VkSamplerReductionModeCreateInfo_self_temp(dec, val);
46 }
47 
48 static inline void
vn_replace_VkSamplerReductionModeCreateInfo_handle_self(VkSamplerReductionModeCreateInfo * val)49 vn_replace_VkSamplerReductionModeCreateInfo_handle_self(VkSamplerReductionModeCreateInfo *val)
50 {
51     /* skip val->sType */
52     /* skip val->pNext */
53     /* skip val->reductionMode */
54 }
55 
56 static inline void
vn_replace_VkSamplerReductionModeCreateInfo_handle(VkSamplerReductionModeCreateInfo * val)57 vn_replace_VkSamplerReductionModeCreateInfo_handle(VkSamplerReductionModeCreateInfo *val)
58 {
59     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
60 
61     do {
62         switch ((int32_t)pnext->sType) {
63         case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
64             vn_replace_VkSamplerReductionModeCreateInfo_handle_self((VkSamplerReductionModeCreateInfo *)pnext);
65             break;
66         default:
67             /* ignore unknown/unsupported struct */
68             break;
69         }
70         pnext = pnext->pNext;
71     } while (pnext);
72 }
73 
74 /* struct VkSamplerCustomBorderColorCreateInfoEXT chain */
75 
76 static inline void *
vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_pnext_temp(struct vn_cs_decoder * dec)77 vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_pnext_temp(struct vn_cs_decoder *dec)
78 {
79     /* no known/supported struct */
80     if (vn_decode_simple_pointer(dec))
81         vn_cs_decoder_set_fatal(dec);
82     return NULL;
83 }
84 
85 static inline void
vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_self_temp(struct vn_cs_decoder * dec,VkSamplerCustomBorderColorCreateInfoEXT * val)86 vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_self_temp(struct vn_cs_decoder *dec, VkSamplerCustomBorderColorCreateInfoEXT *val)
87 {
88     /* skip val->{sType,pNext} */
89     vn_decode_VkClearColorValue_temp(dec, &val->customBorderColor);
90     vn_decode_VkFormat(dec, &val->format);
91 }
92 
93 static inline void
vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_temp(struct vn_cs_decoder * dec,VkSamplerCustomBorderColorCreateInfoEXT * val)94 vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_temp(struct vn_cs_decoder *dec, VkSamplerCustomBorderColorCreateInfoEXT *val)
95 {
96     VkStructureType stype;
97     vn_decode_VkStructureType(dec, &stype);
98     if (stype != VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT)
99         vn_cs_decoder_set_fatal(dec);
100 
101     val->sType = stype;
102     val->pNext = vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_pnext_temp(dec);
103     vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_self_temp(dec, val);
104 }
105 
106 static inline void
vn_replace_VkSamplerCustomBorderColorCreateInfoEXT_handle_self(VkSamplerCustomBorderColorCreateInfoEXT * val)107 vn_replace_VkSamplerCustomBorderColorCreateInfoEXT_handle_self(VkSamplerCustomBorderColorCreateInfoEXT *val)
108 {
109     /* skip val->sType */
110     /* skip val->pNext */
111     /* skip val->customBorderColor */
112     /* skip val->format */
113 }
114 
115 static inline void
vn_replace_VkSamplerCustomBorderColorCreateInfoEXT_handle(VkSamplerCustomBorderColorCreateInfoEXT * val)116 vn_replace_VkSamplerCustomBorderColorCreateInfoEXT_handle(VkSamplerCustomBorderColorCreateInfoEXT *val)
117 {
118     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
119 
120     do {
121         switch ((int32_t)pnext->sType) {
122         case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
123             vn_replace_VkSamplerCustomBorderColorCreateInfoEXT_handle_self((VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
124             break;
125         default:
126             /* ignore unknown/unsupported struct */
127             break;
128         }
129         pnext = pnext->pNext;
130     } while (pnext);
131 }
132 
133 /* struct VkSamplerCreateInfo chain */
134 
135 static inline void *
vn_decode_VkSamplerCreateInfo_pnext_temp(struct vn_cs_decoder * dec)136 vn_decode_VkSamplerCreateInfo_pnext_temp(struct vn_cs_decoder *dec)
137 {
138     VkBaseOutStructure *pnext;
139     VkStructureType stype;
140 
141     if (!vn_decode_simple_pointer(dec))
142         return NULL;
143 
144     vn_decode_VkStructureType(dec, &stype);
145     switch ((int32_t)stype) {
146     case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
147         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkSamplerYcbcrConversionInfo));
148         if (pnext) {
149             pnext->sType = stype;
150             pnext->pNext = vn_decode_VkSamplerCreateInfo_pnext_temp(dec);
151             vn_decode_VkSamplerYcbcrConversionInfo_self_temp(dec, (VkSamplerYcbcrConversionInfo *)pnext);
152         }
153         break;
154     case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
155         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkSamplerReductionModeCreateInfo));
156         if (pnext) {
157             pnext->sType = stype;
158             pnext->pNext = vn_decode_VkSamplerCreateInfo_pnext_temp(dec);
159             vn_decode_VkSamplerReductionModeCreateInfo_self_temp(dec, (VkSamplerReductionModeCreateInfo *)pnext);
160         }
161         break;
162     case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
163         pnext = vn_cs_decoder_alloc_temp(dec, sizeof(VkSamplerCustomBorderColorCreateInfoEXT));
164         if (pnext) {
165             pnext->sType = stype;
166             pnext->pNext = vn_decode_VkSamplerCreateInfo_pnext_temp(dec);
167             vn_decode_VkSamplerCustomBorderColorCreateInfoEXT_self_temp(dec, (VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
168         }
169         break;
170     default:
171         /* unexpected struct */
172         pnext = NULL;
173         vn_cs_decoder_set_fatal(dec);
174         break;
175     }
176 
177     return pnext;
178 }
179 
180 static inline void
vn_decode_VkSamplerCreateInfo_self_temp(struct vn_cs_decoder * dec,VkSamplerCreateInfo * val)181 vn_decode_VkSamplerCreateInfo_self_temp(struct vn_cs_decoder *dec, VkSamplerCreateInfo *val)
182 {
183     /* skip val->{sType,pNext} */
184     vn_decode_VkFlags(dec, &val->flags);
185     vn_decode_VkFilter(dec, &val->magFilter);
186     vn_decode_VkFilter(dec, &val->minFilter);
187     vn_decode_VkSamplerMipmapMode(dec, &val->mipmapMode);
188     vn_decode_VkSamplerAddressMode(dec, &val->addressModeU);
189     vn_decode_VkSamplerAddressMode(dec, &val->addressModeV);
190     vn_decode_VkSamplerAddressMode(dec, &val->addressModeW);
191     vn_decode_float(dec, &val->mipLodBias);
192     vn_decode_VkBool32(dec, &val->anisotropyEnable);
193     vn_decode_float(dec, &val->maxAnisotropy);
194     vn_decode_VkBool32(dec, &val->compareEnable);
195     vn_decode_VkCompareOp(dec, &val->compareOp);
196     vn_decode_float(dec, &val->minLod);
197     vn_decode_float(dec, &val->maxLod);
198     vn_decode_VkBorderColor(dec, &val->borderColor);
199     vn_decode_VkBool32(dec, &val->unnormalizedCoordinates);
200 }
201 
202 static inline void
vn_decode_VkSamplerCreateInfo_temp(struct vn_cs_decoder * dec,VkSamplerCreateInfo * val)203 vn_decode_VkSamplerCreateInfo_temp(struct vn_cs_decoder *dec, VkSamplerCreateInfo *val)
204 {
205     VkStructureType stype;
206     vn_decode_VkStructureType(dec, &stype);
207     if (stype != VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO)
208         vn_cs_decoder_set_fatal(dec);
209 
210     val->sType = stype;
211     val->pNext = vn_decode_VkSamplerCreateInfo_pnext_temp(dec);
212     vn_decode_VkSamplerCreateInfo_self_temp(dec, val);
213 }
214 
215 static inline void
vn_replace_VkSamplerCreateInfo_handle_self(VkSamplerCreateInfo * val)216 vn_replace_VkSamplerCreateInfo_handle_self(VkSamplerCreateInfo *val)
217 {
218     /* skip val->sType */
219     /* skip val->pNext */
220     /* skip val->flags */
221     /* skip val->magFilter */
222     /* skip val->minFilter */
223     /* skip val->mipmapMode */
224     /* skip val->addressModeU */
225     /* skip val->addressModeV */
226     /* skip val->addressModeW */
227     /* skip val->mipLodBias */
228     /* skip val->anisotropyEnable */
229     /* skip val->maxAnisotropy */
230     /* skip val->compareEnable */
231     /* skip val->compareOp */
232     /* skip val->minLod */
233     /* skip val->maxLod */
234     /* skip val->borderColor */
235     /* skip val->unnormalizedCoordinates */
236 }
237 
238 static inline void
vn_replace_VkSamplerCreateInfo_handle(VkSamplerCreateInfo * val)239 vn_replace_VkSamplerCreateInfo_handle(VkSamplerCreateInfo *val)
240 {
241     struct VkBaseOutStructure *pnext = (struct VkBaseOutStructure *)val;
242 
243     do {
244         switch ((int32_t)pnext->sType) {
245         case VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO:
246             vn_replace_VkSamplerCreateInfo_handle_self((VkSamplerCreateInfo *)pnext);
247             break;
248         case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
249             vn_replace_VkSamplerYcbcrConversionInfo_handle_self((VkSamplerYcbcrConversionInfo *)pnext);
250             break;
251         case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
252             vn_replace_VkSamplerReductionModeCreateInfo_handle_self((VkSamplerReductionModeCreateInfo *)pnext);
253             break;
254         case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
255             vn_replace_VkSamplerCustomBorderColorCreateInfoEXT_handle_self((VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
256             break;
257         default:
258             /* ignore unknown/unsupported struct */
259             break;
260         }
261         pnext = pnext->pNext;
262     } while (pnext);
263 }
264 
vn_decode_vkCreateSampler_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkCreateSampler * args)265 static inline void vn_decode_vkCreateSampler_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkCreateSampler *args)
266 {
267     vn_decode_VkDevice_lookup(dec, &args->device);
268     if (vn_decode_simple_pointer(dec)) {
269         args->pCreateInfo = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pCreateInfo));
270         if (!args->pCreateInfo) return;
271         vn_decode_VkSamplerCreateInfo_temp(dec, (VkSamplerCreateInfo *)args->pCreateInfo);
272     } else {
273         args->pCreateInfo = NULL;
274         vn_cs_decoder_set_fatal(dec);
275     }
276     if (vn_decode_simple_pointer(dec)) {
277         vn_cs_decoder_set_fatal(dec);
278     } else {
279         args->pAllocator = NULL;
280     }
281     if (vn_decode_simple_pointer(dec)) {
282         args->pSampler = vn_cs_decoder_alloc_temp(dec, sizeof(*args->pSampler));
283         if (!args->pSampler) return;
284         vn_decode_VkSampler(dec, args->pSampler);
285     } else {
286         args->pSampler = NULL;
287         vn_cs_decoder_set_fatal(dec);
288     }
289 }
290 
vn_replace_vkCreateSampler_args_handle(struct vn_command_vkCreateSampler * args)291 static inline void vn_replace_vkCreateSampler_args_handle(struct vn_command_vkCreateSampler *args)
292 {
293     vn_replace_VkDevice_handle(&args->device);
294     if (args->pCreateInfo)
295         vn_replace_VkSamplerCreateInfo_handle((VkSamplerCreateInfo *)args->pCreateInfo);
296     /* skip args->pAllocator */
297     /* skip args->pSampler */
298 }
299 
vn_encode_vkCreateSampler_reply(struct vn_cs_encoder * enc,const struct vn_command_vkCreateSampler * args)300 static inline void vn_encode_vkCreateSampler_reply(struct vn_cs_encoder *enc, const struct vn_command_vkCreateSampler *args)
301 {
302     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkCreateSampler_EXT});
303 
304     vn_encode_VkResult(enc, &args->ret);
305     /* skip args->device */
306     /* skip args->pCreateInfo */
307     /* skip args->pAllocator */
308     if (vn_encode_simple_pointer(enc, args->pSampler))
309         vn_encode_VkSampler(enc, args->pSampler);
310 }
311 
vn_decode_vkDestroySampler_args_temp(struct vn_cs_decoder * dec,struct vn_command_vkDestroySampler * args)312 static inline void vn_decode_vkDestroySampler_args_temp(struct vn_cs_decoder *dec, struct vn_command_vkDestroySampler *args)
313 {
314     vn_decode_VkDevice_lookup(dec, &args->device);
315     vn_decode_VkSampler_lookup(dec, &args->sampler);
316     if (vn_decode_simple_pointer(dec)) {
317         vn_cs_decoder_set_fatal(dec);
318     } else {
319         args->pAllocator = NULL;
320     }
321 }
322 
vn_replace_vkDestroySampler_args_handle(struct vn_command_vkDestroySampler * args)323 static inline void vn_replace_vkDestroySampler_args_handle(struct vn_command_vkDestroySampler *args)
324 {
325     vn_replace_VkDevice_handle(&args->device);
326     vn_replace_VkSampler_handle(&args->sampler);
327     /* skip args->pAllocator */
328 }
329 
vn_encode_vkDestroySampler_reply(struct vn_cs_encoder * enc,const struct vn_command_vkDestroySampler * args)330 static inline void vn_encode_vkDestroySampler_reply(struct vn_cs_encoder *enc, const struct vn_command_vkDestroySampler *args)
331 {
332     vn_encode_VkCommandTypeEXT(enc, &(VkCommandTypeEXT){VK_COMMAND_TYPE_vkDestroySampler_EXT});
333 
334     /* skip args->device */
335     /* skip args->sampler */
336     /* skip args->pAllocator */
337 }
338 
vn_dispatch_vkCreateSampler(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)339 static inline void vn_dispatch_vkCreateSampler(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
340 {
341     struct vn_command_vkCreateSampler args;
342 
343     if (!ctx->dispatch_vkCreateSampler) {
344         vn_cs_decoder_set_fatal(ctx->decoder);
345         return;
346     }
347 
348     vn_decode_vkCreateSampler_args_temp(ctx->decoder, &args);
349     if (!args.device) {
350         vn_cs_decoder_set_fatal(ctx->decoder);
351         return;
352     }
353 
354     if (!vn_cs_decoder_get_fatal(ctx->decoder))
355         ctx->dispatch_vkCreateSampler(ctx, &args);
356 
357 #ifdef DEBUG
358     if (!vn_cs_decoder_get_fatal(ctx->decoder) && vn_dispatch_should_log_result(args.ret))
359         vn_dispatch_debug_log(ctx, "vkCreateSampler returned %d", args.ret);
360 #endif
361 
362     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
363        vn_encode_vkCreateSampler_reply(ctx->encoder, &args);
364 
365     vn_cs_decoder_reset_temp_pool(ctx->decoder);
366 }
367 
vn_dispatch_vkDestroySampler(struct vn_dispatch_context * ctx,VkCommandFlagsEXT flags)368 static inline void vn_dispatch_vkDestroySampler(struct vn_dispatch_context *ctx, VkCommandFlagsEXT flags)
369 {
370     struct vn_command_vkDestroySampler args;
371 
372     if (!ctx->dispatch_vkDestroySampler) {
373         vn_cs_decoder_set_fatal(ctx->decoder);
374         return;
375     }
376 
377     vn_decode_vkDestroySampler_args_temp(ctx->decoder, &args);
378     if (!args.device) {
379         vn_cs_decoder_set_fatal(ctx->decoder);
380         return;
381     }
382 
383     if (!vn_cs_decoder_get_fatal(ctx->decoder))
384         ctx->dispatch_vkDestroySampler(ctx, &args);
385 
386 
387     if (!vn_cs_decoder_get_fatal(ctx->decoder) && (flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT))
388        vn_encode_vkDestroySampler_reply(ctx->encoder, &args);
389 
390     vn_cs_decoder_reset_temp_pool(ctx->decoder);
391 }
392 
393 #pragma GCC diagnostic pop
394 
395 #endif /* VN_PROTOCOL_RENDERER_SAMPLER_H */
396