• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* This file is generated by venus-protocol.  See vn_protocol_driver.h. */
2 
3 /*
4  * Copyright 2020 Google LLC
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef VN_PROTOCOL_DRIVER_SAMPLER_H
9 #define VN_PROTOCOL_DRIVER_SAMPLER_H
10 
11 #include "vn_instance.h"
12 #include "vn_protocol_driver_structs.h"
13 
14 /* struct VkSamplerReductionModeCreateInfo chain */
15 
16 static inline size_t
vn_sizeof_VkSamplerReductionModeCreateInfo_pnext(const void * val)17 vn_sizeof_VkSamplerReductionModeCreateInfo_pnext(const void *val)
18 {
19     /* no known/supported struct */
20     return vn_sizeof_simple_pointer(NULL);
21 }
22 
23 static inline size_t
vn_sizeof_VkSamplerReductionModeCreateInfo_self(const VkSamplerReductionModeCreateInfo * val)24 vn_sizeof_VkSamplerReductionModeCreateInfo_self(const VkSamplerReductionModeCreateInfo *val)
25 {
26     size_t size = 0;
27     /* skip val->{sType,pNext} */
28     size += vn_sizeof_VkSamplerReductionMode(&val->reductionMode);
29     return size;
30 }
31 
32 static inline size_t
vn_sizeof_VkSamplerReductionModeCreateInfo(const VkSamplerReductionModeCreateInfo * val)33 vn_sizeof_VkSamplerReductionModeCreateInfo(const VkSamplerReductionModeCreateInfo *val)
34 {
35     size_t size = 0;
36 
37     size += vn_sizeof_VkStructureType(&val->sType);
38     size += vn_sizeof_VkSamplerReductionModeCreateInfo_pnext(val->pNext);
39     size += vn_sizeof_VkSamplerReductionModeCreateInfo_self(val);
40 
41     return size;
42 }
43 
44 static inline void
vn_encode_VkSamplerReductionModeCreateInfo_pnext(struct vn_cs_encoder * enc,const void * val)45 vn_encode_VkSamplerReductionModeCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
46 {
47     /* no known/supported struct */
48     vn_encode_simple_pointer(enc, NULL);
49 }
50 
51 static inline void
vn_encode_VkSamplerReductionModeCreateInfo_self(struct vn_cs_encoder * enc,const VkSamplerReductionModeCreateInfo * val)52 vn_encode_VkSamplerReductionModeCreateInfo_self(struct vn_cs_encoder *enc, const VkSamplerReductionModeCreateInfo *val)
53 {
54     /* skip val->{sType,pNext} */
55     vn_encode_VkSamplerReductionMode(enc, &val->reductionMode);
56 }
57 
58 static inline void
vn_encode_VkSamplerReductionModeCreateInfo(struct vn_cs_encoder * enc,const VkSamplerReductionModeCreateInfo * val)59 vn_encode_VkSamplerReductionModeCreateInfo(struct vn_cs_encoder *enc, const VkSamplerReductionModeCreateInfo *val)
60 {
61     assert(val->sType == VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO);
62     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO });
63     vn_encode_VkSamplerReductionModeCreateInfo_pnext(enc, val->pNext);
64     vn_encode_VkSamplerReductionModeCreateInfo_self(enc, val);
65 }
66 
67 /* struct VkSamplerCustomBorderColorCreateInfoEXT chain */
68 
69 static inline size_t
vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_pnext(const void * val)70 vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_pnext(const void *val)
71 {
72     /* no known/supported struct */
73     return vn_sizeof_simple_pointer(NULL);
74 }
75 
76 static inline size_t
vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self(const VkSamplerCustomBorderColorCreateInfoEXT * val)77 vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self(const VkSamplerCustomBorderColorCreateInfoEXT *val)
78 {
79     size_t size = 0;
80     /* skip val->{sType,pNext} */
81     size += vn_sizeof_VkClearColorValue(&val->customBorderColor);
82     size += vn_sizeof_VkFormat(&val->format);
83     return size;
84 }
85 
86 static inline size_t
vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT(const VkSamplerCustomBorderColorCreateInfoEXT * val)87 vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT(const VkSamplerCustomBorderColorCreateInfoEXT *val)
88 {
89     size_t size = 0;
90 
91     size += vn_sizeof_VkStructureType(&val->sType);
92     size += vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_pnext(val->pNext);
93     size += vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self(val);
94 
95     return size;
96 }
97 
98 static inline void
vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_pnext(struct vn_cs_encoder * enc,const void * val)99 vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_pnext(struct vn_cs_encoder *enc, const void *val)
100 {
101     /* no known/supported struct */
102     vn_encode_simple_pointer(enc, NULL);
103 }
104 
105 static inline void
vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(struct vn_cs_encoder * enc,const VkSamplerCustomBorderColorCreateInfoEXT * val)106 vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(struct vn_cs_encoder *enc, const VkSamplerCustomBorderColorCreateInfoEXT *val)
107 {
108     /* skip val->{sType,pNext} */
109     vn_encode_VkClearColorValue(enc, &val->customBorderColor);
110     vn_encode_VkFormat(enc, &val->format);
111 }
112 
113 static inline void
vn_encode_VkSamplerCustomBorderColorCreateInfoEXT(struct vn_cs_encoder * enc,const VkSamplerCustomBorderColorCreateInfoEXT * val)114 vn_encode_VkSamplerCustomBorderColorCreateInfoEXT(struct vn_cs_encoder *enc, const VkSamplerCustomBorderColorCreateInfoEXT *val)
115 {
116     assert(val->sType == VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT);
117     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT });
118     vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_pnext(enc, val->pNext);
119     vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(enc, val);
120 }
121 
122 /* struct VkSamplerCreateInfo chain */
123 
124 static inline size_t
vn_sizeof_VkSamplerCreateInfo_pnext(const void * val)125 vn_sizeof_VkSamplerCreateInfo_pnext(const void *val)
126 {
127     const VkBaseInStructure *pnext = val;
128     size_t size = 0;
129 
130     while (pnext) {
131         switch ((int32_t)pnext->sType) {
132         case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
133             size += vn_sizeof_simple_pointer(pnext);
134             size += vn_sizeof_VkStructureType(&pnext->sType);
135             size += vn_sizeof_VkSamplerCreateInfo_pnext(pnext->pNext);
136             size += vn_sizeof_VkSamplerYcbcrConversionInfo_self((const VkSamplerYcbcrConversionInfo *)pnext);
137             return size;
138         case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
139             size += vn_sizeof_simple_pointer(pnext);
140             size += vn_sizeof_VkStructureType(&pnext->sType);
141             size += vn_sizeof_VkSamplerCreateInfo_pnext(pnext->pNext);
142             size += vn_sizeof_VkSamplerReductionModeCreateInfo_self((const VkSamplerReductionModeCreateInfo *)pnext);
143             return size;
144         case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
145             if (!vn_cs_renderer_protocol_has_extension(288 /* VK_EXT_custom_border_color */))
146                 break;
147             size += vn_sizeof_simple_pointer(pnext);
148             size += vn_sizeof_VkStructureType(&pnext->sType);
149             size += vn_sizeof_VkSamplerCreateInfo_pnext(pnext->pNext);
150             size += vn_sizeof_VkSamplerCustomBorderColorCreateInfoEXT_self((const VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
151             return size;
152         default:
153             /* ignore unknown/unsupported struct */
154             break;
155         }
156         pnext = pnext->pNext;
157     }
158 
159     return vn_sizeof_simple_pointer(NULL);
160 }
161 
162 static inline size_t
vn_sizeof_VkSamplerCreateInfo_self(const VkSamplerCreateInfo * val)163 vn_sizeof_VkSamplerCreateInfo_self(const VkSamplerCreateInfo *val)
164 {
165     size_t size = 0;
166     /* skip val->{sType,pNext} */
167     size += vn_sizeof_VkFlags(&val->flags);
168     size += vn_sizeof_VkFilter(&val->magFilter);
169     size += vn_sizeof_VkFilter(&val->minFilter);
170     size += vn_sizeof_VkSamplerMipmapMode(&val->mipmapMode);
171     size += vn_sizeof_VkSamplerAddressMode(&val->addressModeU);
172     size += vn_sizeof_VkSamplerAddressMode(&val->addressModeV);
173     size += vn_sizeof_VkSamplerAddressMode(&val->addressModeW);
174     size += vn_sizeof_float(&val->mipLodBias);
175     size += vn_sizeof_VkBool32(&val->anisotropyEnable);
176     size += vn_sizeof_float(&val->maxAnisotropy);
177     size += vn_sizeof_VkBool32(&val->compareEnable);
178     size += vn_sizeof_VkCompareOp(&val->compareOp);
179     size += vn_sizeof_float(&val->minLod);
180     size += vn_sizeof_float(&val->maxLod);
181     size += vn_sizeof_VkBorderColor(&val->borderColor);
182     size += vn_sizeof_VkBool32(&val->unnormalizedCoordinates);
183     return size;
184 }
185 
186 static inline size_t
vn_sizeof_VkSamplerCreateInfo(const VkSamplerCreateInfo * val)187 vn_sizeof_VkSamplerCreateInfo(const VkSamplerCreateInfo *val)
188 {
189     size_t size = 0;
190 
191     size += vn_sizeof_VkStructureType(&val->sType);
192     size += vn_sizeof_VkSamplerCreateInfo_pnext(val->pNext);
193     size += vn_sizeof_VkSamplerCreateInfo_self(val);
194 
195     return size;
196 }
197 
198 static inline void
vn_encode_VkSamplerCreateInfo_pnext(struct vn_cs_encoder * enc,const void * val)199 vn_encode_VkSamplerCreateInfo_pnext(struct vn_cs_encoder *enc, const void *val)
200 {
201     const VkBaseInStructure *pnext = val;
202 
203     while (pnext) {
204         switch ((int32_t)pnext->sType) {
205         case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
206             vn_encode_simple_pointer(enc, pnext);
207             vn_encode_VkStructureType(enc, &pnext->sType);
208             vn_encode_VkSamplerCreateInfo_pnext(enc, pnext->pNext);
209             vn_encode_VkSamplerYcbcrConversionInfo_self(enc, (const VkSamplerYcbcrConversionInfo *)pnext);
210             return;
211         case VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO:
212             vn_encode_simple_pointer(enc, pnext);
213             vn_encode_VkStructureType(enc, &pnext->sType);
214             vn_encode_VkSamplerCreateInfo_pnext(enc, pnext->pNext);
215             vn_encode_VkSamplerReductionModeCreateInfo_self(enc, (const VkSamplerReductionModeCreateInfo *)pnext);
216             return;
217         case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
218             if (!vn_cs_renderer_protocol_has_extension(288 /* VK_EXT_custom_border_color */))
219                 break;
220             vn_encode_simple_pointer(enc, pnext);
221             vn_encode_VkStructureType(enc, &pnext->sType);
222             vn_encode_VkSamplerCreateInfo_pnext(enc, pnext->pNext);
223             vn_encode_VkSamplerCustomBorderColorCreateInfoEXT_self(enc, (const VkSamplerCustomBorderColorCreateInfoEXT *)pnext);
224             return;
225         default:
226             /* ignore unknown/unsupported struct */
227             break;
228         }
229         pnext = pnext->pNext;
230     }
231 
232     vn_encode_simple_pointer(enc, NULL);
233 }
234 
235 static inline void
vn_encode_VkSamplerCreateInfo_self(struct vn_cs_encoder * enc,const VkSamplerCreateInfo * val)236 vn_encode_VkSamplerCreateInfo_self(struct vn_cs_encoder *enc, const VkSamplerCreateInfo *val)
237 {
238     /* skip val->{sType,pNext} */
239     vn_encode_VkFlags(enc, &val->flags);
240     vn_encode_VkFilter(enc, &val->magFilter);
241     vn_encode_VkFilter(enc, &val->minFilter);
242     vn_encode_VkSamplerMipmapMode(enc, &val->mipmapMode);
243     vn_encode_VkSamplerAddressMode(enc, &val->addressModeU);
244     vn_encode_VkSamplerAddressMode(enc, &val->addressModeV);
245     vn_encode_VkSamplerAddressMode(enc, &val->addressModeW);
246     vn_encode_float(enc, &val->mipLodBias);
247     vn_encode_VkBool32(enc, &val->anisotropyEnable);
248     vn_encode_float(enc, &val->maxAnisotropy);
249     vn_encode_VkBool32(enc, &val->compareEnable);
250     vn_encode_VkCompareOp(enc, &val->compareOp);
251     vn_encode_float(enc, &val->minLod);
252     vn_encode_float(enc, &val->maxLod);
253     vn_encode_VkBorderColor(enc, &val->borderColor);
254     vn_encode_VkBool32(enc, &val->unnormalizedCoordinates);
255 }
256 
257 static inline void
vn_encode_VkSamplerCreateInfo(struct vn_cs_encoder * enc,const VkSamplerCreateInfo * val)258 vn_encode_VkSamplerCreateInfo(struct vn_cs_encoder *enc, const VkSamplerCreateInfo *val)
259 {
260     assert(val->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
261     vn_encode_VkStructureType(enc, &(VkStructureType){ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO });
262     vn_encode_VkSamplerCreateInfo_pnext(enc, val->pNext);
263     vn_encode_VkSamplerCreateInfo_self(enc, val);
264 }
265 
vn_sizeof_vkCreateSampler(VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)266 static inline size_t vn_sizeof_vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
267 {
268     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSampler_EXT;
269     const VkFlags cmd_flags = 0;
270     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
271 
272     cmd_size += vn_sizeof_VkDevice(&device);
273     cmd_size += vn_sizeof_simple_pointer(pCreateInfo);
274     if (pCreateInfo)
275         cmd_size += vn_sizeof_VkSamplerCreateInfo(pCreateInfo);
276     cmd_size += vn_sizeof_simple_pointer(pAllocator);
277     if (pAllocator)
278         assert(false);
279     cmd_size += vn_sizeof_simple_pointer(pSampler);
280     if (pSampler)
281         cmd_size += vn_sizeof_VkSampler(pSampler);
282 
283     return cmd_size;
284 }
285 
vn_encode_vkCreateSampler(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)286 static inline void vn_encode_vkCreateSampler(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
287 {
288     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSampler_EXT;
289 
290     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
291     vn_encode_VkFlags(enc, &cmd_flags);
292 
293     vn_encode_VkDevice(enc, &device);
294     if (vn_encode_simple_pointer(enc, pCreateInfo))
295         vn_encode_VkSamplerCreateInfo(enc, pCreateInfo);
296     if (vn_encode_simple_pointer(enc, pAllocator))
297         assert(false);
298     if (vn_encode_simple_pointer(enc, pSampler))
299         vn_encode_VkSampler(enc, pSampler);
300 }
301 
vn_sizeof_vkCreateSampler_reply(VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)302 static inline size_t vn_sizeof_vkCreateSampler_reply(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
303 {
304     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkCreateSampler_EXT;
305     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
306 
307     VkResult ret;
308     cmd_size += vn_sizeof_VkResult(&ret);
309     /* skip device */
310     /* skip pCreateInfo */
311     /* skip pAllocator */
312     cmd_size += vn_sizeof_simple_pointer(pSampler);
313     if (pSampler)
314         cmd_size += vn_sizeof_VkSampler(pSampler);
315 
316     return cmd_size;
317 }
318 
vn_decode_vkCreateSampler_reply(struct vn_cs_decoder * dec,VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)319 static inline VkResult vn_decode_vkCreateSampler_reply(struct vn_cs_decoder *dec, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
320 {
321     VkCommandTypeEXT command_type;
322     vn_decode_VkCommandTypeEXT(dec, &command_type);
323     assert(command_type == VK_COMMAND_TYPE_vkCreateSampler_EXT);
324 
325     VkResult ret;
326     vn_decode_VkResult(dec, &ret);
327     /* skip device */
328     /* skip pCreateInfo */
329     /* skip pAllocator */
330     if (vn_decode_simple_pointer(dec)) {
331         vn_decode_VkSampler(dec, pSampler);
332     } else {
333         pSampler = NULL;
334     }
335 
336     return ret;
337 }
338 
vn_sizeof_vkDestroySampler(VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)339 static inline size_t vn_sizeof_vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
340 {
341     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySampler_EXT;
342     const VkFlags cmd_flags = 0;
343     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type) + vn_sizeof_VkFlags(&cmd_flags);
344 
345     cmd_size += vn_sizeof_VkDevice(&device);
346     cmd_size += vn_sizeof_VkSampler(&sampler);
347     cmd_size += vn_sizeof_simple_pointer(pAllocator);
348     if (pAllocator)
349         assert(false);
350 
351     return cmd_size;
352 }
353 
vn_encode_vkDestroySampler(struct vn_cs_encoder * enc,VkCommandFlagsEXT cmd_flags,VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)354 static inline void vn_encode_vkDestroySampler(struct vn_cs_encoder *enc, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
355 {
356     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySampler_EXT;
357 
358     vn_encode_VkCommandTypeEXT(enc, &cmd_type);
359     vn_encode_VkFlags(enc, &cmd_flags);
360 
361     vn_encode_VkDevice(enc, &device);
362     vn_encode_VkSampler(enc, &sampler);
363     if (vn_encode_simple_pointer(enc, pAllocator))
364         assert(false);
365 }
366 
vn_sizeof_vkDestroySampler_reply(VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)367 static inline size_t vn_sizeof_vkDestroySampler_reply(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
368 {
369     const VkCommandTypeEXT cmd_type = VK_COMMAND_TYPE_vkDestroySampler_EXT;
370     size_t cmd_size = vn_sizeof_VkCommandTypeEXT(&cmd_type);
371 
372     /* skip device */
373     /* skip sampler */
374     /* skip pAllocator */
375 
376     return cmd_size;
377 }
378 
vn_decode_vkDestroySampler_reply(struct vn_cs_decoder * dec,VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)379 static inline void vn_decode_vkDestroySampler_reply(struct vn_cs_decoder *dec, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
380 {
381     VkCommandTypeEXT command_type;
382     vn_decode_VkCommandTypeEXT(dec, &command_type);
383     assert(command_type == VK_COMMAND_TYPE_vkDestroySampler_EXT);
384 
385     /* skip device */
386     /* skip sampler */
387     /* skip pAllocator */
388 }
389 
vn_submit_vkCreateSampler(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler,struct vn_instance_submit_command * submit)390 static inline void vn_submit_vkCreateSampler(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler, struct vn_instance_submit_command *submit)
391 {
392     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
393     void *cmd_data = local_cmd_data;
394     size_t cmd_size = vn_sizeof_vkCreateSampler(device, pCreateInfo, pAllocator, pSampler);
395     if (cmd_size > sizeof(local_cmd_data)) {
396         cmd_data = malloc(cmd_size);
397         if (!cmd_data)
398             cmd_size = 0;
399     }
400     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkCreateSampler_reply(device, pCreateInfo, pAllocator, pSampler) : 0;
401 
402     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
403     if (cmd_size) {
404         vn_encode_vkCreateSampler(enc, cmd_flags, device, pCreateInfo, pAllocator, pSampler);
405         vn_instance_submit_command(vn_instance, submit);
406         if (cmd_data != local_cmd_data)
407             free(cmd_data);
408     }
409 }
410 
vn_submit_vkDestroySampler(struct vn_instance * vn_instance,VkCommandFlagsEXT cmd_flags,VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator,struct vn_instance_submit_command * submit)411 static inline void vn_submit_vkDestroySampler(struct vn_instance *vn_instance, VkCommandFlagsEXT cmd_flags, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator, struct vn_instance_submit_command *submit)
412 {
413     uint8_t local_cmd_data[VN_SUBMIT_LOCAL_CMD_SIZE];
414     void *cmd_data = local_cmd_data;
415     size_t cmd_size = vn_sizeof_vkDestroySampler(device, sampler, pAllocator);
416     if (cmd_size > sizeof(local_cmd_data)) {
417         cmd_data = malloc(cmd_size);
418         if (!cmd_data)
419             cmd_size = 0;
420     }
421     const size_t reply_size = cmd_flags & VK_COMMAND_GENERATE_REPLY_BIT_EXT ? vn_sizeof_vkDestroySampler_reply(device, sampler, pAllocator) : 0;
422 
423     struct vn_cs_encoder *enc = vn_instance_submit_command_init(vn_instance, submit, cmd_data, cmd_size, reply_size);
424     if (cmd_size) {
425         vn_encode_vkDestroySampler(enc, cmd_flags, device, sampler, pAllocator);
426         vn_instance_submit_command(vn_instance, submit);
427         if (cmd_data != local_cmd_data)
428             free(cmd_data);
429     }
430 }
431 
vn_call_vkCreateSampler(struct vn_instance * vn_instance,VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)432 static inline VkResult vn_call_vkCreateSampler(struct vn_instance *vn_instance, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
433 {
434     VN_TRACE_FUNC();
435 
436     struct vn_instance_submit_command submit;
437     vn_submit_vkCreateSampler(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, pCreateInfo, pAllocator, pSampler, &submit);
438     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
439     if (dec) {
440         const VkResult ret = vn_decode_vkCreateSampler_reply(dec, device, pCreateInfo, pAllocator, pSampler);
441         vn_instance_free_command_reply(vn_instance, &submit);
442         return ret;
443     } else {
444         return VK_ERROR_OUT_OF_HOST_MEMORY;
445     }
446 }
447 
vn_async_vkCreateSampler(struct vn_instance * vn_instance,VkDevice device,const VkSamplerCreateInfo * pCreateInfo,const VkAllocationCallbacks * pAllocator,VkSampler * pSampler)448 static inline void vn_async_vkCreateSampler(struct vn_instance *vn_instance, VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
449 {
450     struct vn_instance_submit_command submit;
451     vn_submit_vkCreateSampler(vn_instance, 0, device, pCreateInfo, pAllocator, pSampler, &submit);
452 }
453 
vn_call_vkDestroySampler(struct vn_instance * vn_instance,VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)454 static inline void vn_call_vkDestroySampler(struct vn_instance *vn_instance, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
455 {
456     VN_TRACE_FUNC();
457 
458     struct vn_instance_submit_command submit;
459     vn_submit_vkDestroySampler(vn_instance, VK_COMMAND_GENERATE_REPLY_BIT_EXT, device, sampler, pAllocator, &submit);
460     struct vn_cs_decoder *dec = vn_instance_get_command_reply(vn_instance, &submit);
461     if (dec) {
462         vn_decode_vkDestroySampler_reply(dec, device, sampler, pAllocator);
463         vn_instance_free_command_reply(vn_instance, &submit);
464     }
465 }
466 
vn_async_vkDestroySampler(struct vn_instance * vn_instance,VkDevice device,VkSampler sampler,const VkAllocationCallbacks * pAllocator)467 static inline void vn_async_vkDestroySampler(struct vn_instance *vn_instance, VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
468 {
469     struct vn_instance_submit_command submit;
470     vn_submit_vkDestroySampler(vn_instance, 0, device, sampler, pAllocator, &submit);
471 }
472 
473 #endif /* VN_PROTOCOL_DRIVER_SAMPLER_H */
474